-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathplotMartinez2DBump.py
More file actions
executable file
·142 lines (124 loc) · 4.42 KB
/
Copy pathplotMartinez2DBump.py
File metadata and controls
executable file
·142 lines (124 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys, math, os
from os import path
from numpy import *
from pylab import *
import matplotlib.pyplot as plt
import os,glob,subprocess
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib import rc
# reading arguments
n = len(sys.argv)
if n<1:
print "Need <TARGET>"
sys.exit(-1)
target = sys.argv[1]
hSample = 10
def main(target, hSample):
dirNameList = glob.glob(target + "*")
dirNameList.sort()
print "\nPlotting the following cases:"
print dirNameList
h = 60 # Martinez case
dirNameLegend = range(len(dirNameList))
for i, dirName in enumerate(dirNameList):
# finding the most converged run.
setName = glob.glob(dirName + '/sets/*')
lastRun = range(len(setName))
for num in range(len(setName)):
lastRun[num] = int(setName[num][setName[num].rfind("/")+1:])
m = max(lastRun)
p = lastRun.index(m)
# output to screen of convergence data
if not(m % 10):
print dirName + " did not converge, after " + str(m) + " iterations the error is TODO"
else:
print dirName + " converged after " + str(m) + " iterations"
# x line
data_h = genfromtxt(setName[p] + '/line_h_U.xy',delimiter=' ')
x, Ux_h, Uy_h = data_h[:,0], data_h[:,1], data_h[:,2]
# y line
data_y = genfromtxt(setName[p] + '/line_y_U.xy',delimiter=' ')
y, Ux_y, Uy_y = data_y[:,0], data_y[:,1], data_y[:,2]
y = y-h # normalizing data to height of hill-top above ground
# inlet
data_inlet = genfromtxt(setName[p] + '/line_inlet_U.xy',delimiter=' ')
y_inlet, Ux_inlet, Uy_inlet = data_inlet[:,0], data_inlet[:,1], data_inlet[:,2]
# calculating S_x
Ux_inlet_hSample = interp(hSample,y_inlet,Ux_inlet)
Sx = (Ux_h - Ux_inlet_hSample)/Ux_inlet_hSample
# calculating S_y
Sy = (Ux_y - interp(y,y_inlet,Ux_inlet))/interp(y,y_inlet,Ux_inlet)
# calculating normolized TKE_x
data_h_k = genfromtxt(setName[p] + '/line_h_epsilon_k_nut_p.xy',delimiter=' ')
k = data_h_k[:,2]
TKEn = k/(Ux_inlet_hSample**2)
# plotting sample lines and acceleration numbers
import Martinez2DBump
X,Y = Martinez2DBump.main(3000,100)
fig0 = figure(0)
plt.plot(X,Y,'k',X,Y+10,'k-.',[-1500,-1500],[0,300],'r-.',[0,0],[60,360],'b-.')
plt.legend(['hill shape','10 meter above terrain','inlet','maximum height'])
# quiver
arrowNum = 40
xq_inlet, xq_top = -1500 + 0*linspace(0,1,arrowNum), 0*linspace(0,1,arrowNum)
yq_inlet = yq_top = linspace(0,200,arrowNum)
uq_inlet, uq_top = interp(yq_inlet,y_inlet,Ux_inlet), interp(yq_top,y,Ux_y)
vq = xq_inlet*0
Q = quiver(xq_inlet, yq_inlet, uq_inlet, vq, angles='xy',scale=200,color='r')
Q = quiver(xq_top, 60+ yq_top, uq_top, vq, angles='xy',scale=100,color='b')
qk = quiverkey(Q, -1400, 550, 10, r'$10 \frac{m}{s}$', coordinates='data',
fontproperties={'weight': 'bold'})
plt.axis([-1600,400,0,600])
fig0.set_facecolor('w')
""
# plotting S_x
fig1 = figure(1)
plt.plot(x,Sx,'.k')
plt.grid(which='major')
plt.grid(which='minor')
plt.hold(True)
plt.title('Sx for h = ' + str(hSample) + ' meters' )
plt.ylabel('Sx')
fig1.set_facecolor('w')
# adding Martinez results
data_Martinez = genfromtxt('Martinez_Figure21a.csv',delimiter=',')
x_Martinez, Sx_Martinez = data_Martinez[:,0], data_Martinez[:,1]
plt.plot(x_Martinez,Sx_Martinez,'ro')
plt.legend(['OF2.1','Martinez'])
fig1.set_facecolor('w')
# plotting TKE_x
fig2 = figure(2)
plt.plot(x,TKEn,'.')
plt.grid(which='major')
plt.grid(which='minor')
plt.hold(True)
plt.title('TKEn for h = ' + str(hSample) + ' meters' )
plt.ylabel('TKEn')
plt.xlabel('Horizontal coordinate [m]')
fig2.set_facecolor('w')
# adding Martinez results
data_M = genfromtxt('Martinez_Figure21b.csv')
x_Martinez, TKE_Martinez = data_M[:,0], data_M[:,1]
plt.plot(x_Martinez,TKE_Martinez,'ro')
plt.legend(['OF2.1','Martinez'])
fig1.set_facecolor('w')
# plotting S_y
fig3 = figure(3)
plt.semilogy(Sy,y,'.')
plt.grid(which='major')
plt.grid(which='minor')
plt.hold(True)
plt.title('Sy above hill center' )
plt.xlabel('Sy')
plt.ylabel('Vertical coordinate [m]')
# adding Martinez results
data_M = genfromtxt('Martinez_Figure21c.csv')
y_Martinez, Ux_y_Martinez = data_M[:,0], data_M[:,1]
plt.semilogy(y_Martinez,Ux_y_Martinez,'ro')
plt.legend(['OF2.1','Martinez'])
fig3.set_facecolor('w')
plt.show()
if __name__ == '__main__':
main(target, hSample)