Revision | 08a73f562b8ef9ea912481f8cc3ed6658967ca6a (tree) |
---|---|
Zeit | 2007-03-07 19:57:33 |
Autor | iselllo |
Commiter | iselllo |
I modified the code Python-codes/postprocess.py by adding some extra
functionalities to read & postprocess the output of the DNS simulations.
@@ -2,13 +2,13 @@ | ||
2 | 2 | from scipy import * |
3 | 3 | import pylab # used to read the .csv file |
4 | 4 | |
5 | -from pylab import * | |
5 | +#from pylab import * | |
6 | 6 | |
7 | 7 | # now I want to try reading some .csv file |
8 | 8 | data = pylab.load("radjet.out") |
9 | 9 | #print "data now is", data |
10 | 10 | |
11 | -hold(False) # so that the plots are NOT superimposed | |
11 | +pylab.hold(False) # so that the plots are NOT superimposed | |
12 | 12 | |
13 | 13 | skip_this=0 |
14 | 14 | if (skip_this !=1): |
@@ -25,15 +25,14 @@ | ||
25 | 25 | |
26 | 26 | |
27 | 27 | x=linspace(0.,1.,len(data[:,0])) |
28 | -print 'the length of data[:,0] is', len(data[:,0]) | |
29 | -print 'the length of x is', len(x) | |
28 | + | |
30 | 29 | |
31 | 30 | |
32 | 31 | rext=5. |
33 | 32 | strr=3.5 # stretching parameter |
34 | 33 | istr_0=tanh(x*strr)/tanh(strr)*rext |
35 | 34 | |
36 | -print 'istr_0 is', istr_0 | |
35 | +#print 'istr_0 is', istr_0 | |
37 | 36 | |
38 | 37 | print 'the length of istr_0 is', len(istr_0) |
39 | 38 |
@@ -47,13 +46,7 @@ | ||
47 | 46 | pylab.savefig('radial_physical_grid_istrr=0') |
48 | 47 | #pylab.show() # uncomment them to plot a distribution |
49 | 48 | |
50 | -#s = file( './field0160.dat','rb' ).read( ) | |
51 | 49 | |
52 | -#newarr = fromstring(s ,Float) | |
53 | - | |
54 | -#print 'newarr is', newarr | |
55 | - | |
56 | -#print 'the dimensions of newarr are', shape(newarr) | |
57 | 50 | |
58 | 51 | data2 = pylab.load("rg2.out") |
59 | 52 |
@@ -65,7 +58,7 @@ | ||
65 | 58 | |
66 | 59 | pylab.plot(seq2,data2[:,0],seq2,data2[:,1],seq2,data2[:,2],seq2,data2[:,3],linewidth=2.0) |
67 | 60 | #hold(True) # now I want to overlap the plots |
68 | -legend(('rc','rm','g2rc','g2rm')) | |
61 | +pylab.legend(('rc','rm','g2rc','g2rm')) | |
69 | 62 | pylab.xlabel('grid point number') |
70 | 63 | pylab.ylabel('physical coordinate') |
71 | 64 | #pylab.title('Radial Grid ISTR=0') |
@@ -89,7 +82,7 @@ | ||
89 | 82 | |
90 | 83 | pylab.plot(seq2,data2[:,0],seq2,data2[:,1],seq2,data2[:,2],linewidth=2.0) |
91 | 84 | #hold(True) # now I want to overlap the plots |
92 | -legend(('x2','yd','rc')) | |
85 | +pylab.legend(('x2','yd','rc')) | |
93 | 86 | pylab.xlabel('grid point number') |
94 | 87 | pylab.ylabel('physical coordinate') |
95 | 88 | #pylab.title('Radial Grid ISTR=0') |
@@ -98,3 +91,103 @@ | ||
98 | 91 | #pylab.plot(seq2,data2[:,2]) |
99 | 92 | #pylab.plot(seq2,data2[:,3]) |
100 | 93 | pylab.savefig('radstrout_plot') |
94 | + | |
95 | + | |
96 | +# now I try reading the binary file | |
97 | + | |
98 | +#s = file( './field0160.dat','rb' ).read( ) | |
99 | + | |
100 | +#newarr = fromstring(s ,Float) | |
101 | + | |
102 | +#print 'newarr is', newarr | |
103 | + | |
104 | +#print 'the dimensions of newarr are', shape(newarr) | |
105 | + | |
106 | +#lenarr=len(newarr) | |
107 | +#print max(newarr) | |
108 | + | |
109 | +pylab.hold(False) | |
110 | + | |
111 | +v_prof = pylab.load("v_prof") | |
112 | + | |
113 | +pylab.plot(data2[:,2],v_prof) | |
114 | +pylab.xlabel('radial distance from axis') | |
115 | +pylab.ylabel('Velocity profile') | |
116 | +pylab.grid(True) | |
117 | +pylab.savefig('velocity_profile') | |
118 | + | |
119 | + | |
120 | + | |
121 | +my_mean=zeros(len(data2[:,0])) | |
122 | + | |
123 | + | |
124 | +pylab.hold(True) # s e t t h e ho ld s t a t e t o be on | |
125 | +for i in range (1,20 ) : # s t a r t a t 1 , end a t 100 | |
126 | + fname = 'vpro%03d'%i # %03d pads t h e i n t e g e r s wi th z e r o s | |
127 | + new_v_prof = pylab.load(fname) | |
128 | + pylab.plot(data2[:,2],new_v_prof,linewidth=1.5) | |
129 | + pylab.xlabel('radial distance from axis') | |
130 | + pylab.ylabel('Velocity profile') | |
131 | + pylab.grid(True) | |
132 | +new_v_prof = pylab.load('vpro001') | |
133 | +pylab.plot(data2[:,2],new_v_prof,linewidth=1.5) | |
134 | +pylab.savefig('velocity_profile_different_times') | |
135 | +#pylab.show() | |
136 | + | |
137 | +pylab.hold(False) | |
138 | + | |
139 | +ini_read=15 | |
140 | +end_read=20 | |
141 | + | |
142 | +#hold(True) # s e t t h e ho ld s t a t e t o be on | |
143 | +for i in range (ini_read,(end_read+1) ) : # s t a r t a t 1 , end a t 100 | |
144 | + #print 'i is', i | |
145 | + fname = 'vpro%03d'%i # %03d pads t h e i n t e g e r s wi th z e r o s | |
146 | + new_v_prof = pylab.load(fname) | |
147 | + my_mean=my_mean+new_v_prof | |
148 | + pylab.plot(data2[:,2],new_v_prof,linewidth=1.5) | |
149 | + pylab.hold(True) | |
150 | + pylab.xlabel('radial distance from axis') | |
151 | + pylab.ylabel('Velocity profile') | |
152 | + pylab.grid(True) | |
153 | + | |
154 | +my_mean=my_mean/(end_read-ini_read+1) | |
155 | +#print 'mymat[] is', mymat[:,1] | |
156 | + | |
157 | +ini_v_prof = pylab.load('vpro001') | |
158 | +pylab.plot(data2[:,2],ini_v_prof,linewidth=1.5) | |
159 | + | |
160 | + | |
161 | + | |
162 | + | |
163 | + | |
164 | + | |
165 | +pylab.legend(('t=150','t=160','t=170','t=180','t=190','t=200','initial profile')) | |
166 | +pylab.savefig('velocity_profile_late_times') | |
167 | +#pylab.show() | |
168 | + | |
169 | +pylab.hold(False) | |
170 | + | |
171 | + | |
172 | +pylab.plot(data2[:,2],my_mean,data2[:,2],ini_v_prof,linewidth=1.5,) | |
173 | +pylab.legend(('average profile at late t','initial profile')) | |
174 | +pylab.savefig('late-average-vs-initial') | |
175 | + | |
176 | +# now I also try plotting the initial profile I would get using an empirical correlation | |
177 | + | |
178 | +def v_appr(r): | |
179 | + return U*(1-r/R)**(1./6.) | |
180 | + | |
181 | +U=my_mean[0] | |
182 | +R=1. | |
183 | +v_emp=map(v_appr,data2[:,2]) | |
184 | +pylab.hold(False) | |
185 | + | |
186 | +pylab.plot(data2[:,2],my_mean,data2[:,2],v_emp,linewidth=1.5,) | |
187 | +pylab.legend(('average profile at late t','empirical_profile')) | |
188 | +pylab.grid(True) | |
189 | +pylab.xlabel('radial distance from axis') | |
190 | +pylab.ylabel('Velocity profile') | |
191 | +pylab.savefig('late-average-vs-empirical') | |
192 | + | |
193 | +print 'So far so good' | |
\ No newline at end of file |