-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamrmovie.pro
288 lines (239 loc) · 6.04 KB
/
amrmovie.pro
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
pro amrmovie, bx1,bx2,vx1,vx2, rho, prs, t , nlast, nx1,nx2,x1,x2, background,dx1,dx2, hires, plotgrowth, plotgrowthvortex, tag, doannotation
growth=0
nlev=0
cg=0
if (cg eq 1) then begin
cgwindow, xs=1500,ys=1100
;cgWindow
cgSet
endif else begin
if (hires eq 1) then begin
xs=800
window,xs=xs,ys=1.6*xs
endif else begin
window,xs=1000,ys=500
endelse
endelse
;loadct,33
;tvlct, 0,0,0,0
;tvlct, 255,255,255,1
pload,0, /hdf5,level=nlev
help, bx1
initvort= 0.0
initb1= 0.0
initb2= 0.0
;background=1
if ( background eq 1) then begin
initvort=getvortsimple(bx1,bx2,x1,x2,nx1,nx2)
initb1=bx1
initb2=bx2
endif
nstart=1
nend=nlast
nstep=1
pload,0, /hdf5,level=nlev
totalb20=total(bx1^2+bx2^2)
gamma=fltarr(1)
tbx2=fltarr(1)
tbx2(*)=1
totvel1=fltarr(1)
totvel2=fltarr(1)
totprs=fltarr(1)
tnorm=fltarr(1)
for nfile=nstart,nend,nstep do begin
print, nfile
ll=6
zero=''
nts=strcompress(string(nfile),/remove_all)
lnt=strlen(nts)
for j=1,ll-lnt do zero=zero+'0'
fname=tag+zero+nts
pload,nfile, /hdf5, level=nlev
!p.position=0
nx = nx1
nz = nx2
slice= 0
a=total(bx2^2)/totalb20 ; total by^2
b=total(bx1^2)/totalb20 ; total bx^2
qv1=total(vx2^2)/totalb20 ; total by^2
qv2=total(vx1^2)/totalb20 ; total bx^2
gamma=[gamma, a]
tbx2=[tbx2, b]
totvel1=[totvel1, qv1]
totvel2=[totvel2, qv2]
tnorm=[tnorm, t]
print, size(gamma)
print, gamma
vort=getvortsimple(bx1,bx2,x1,x2,nx1,nx2)
var=fltarr(6,nx1,nx2)
rho[0,0]=rho[0,0]+1e-6
var(0,*,*)=alog(prs)
;sndspd=sqrt(1.4*prs/rho)
;var(0,*,*)=sndspd
if ( background eq 1 ) then begin
var(1,*,*)=bx1-initb1
var(2,*,*)=bx2-initb2
tag2="(backgr subtracted)"
endif else begin
var(1,*,*)=bx1
var(2,*,*)=bx2
tag2="(backgr included)"
endelse
var(3,*,*)=vort-initvort
;var(3,*,*)=smooth(vort-initvort, 10,/edge_wrap)
var(4,*,*)=sqrt((bx1^2+bx2^2)/rho)
var(5,*,*)=bx1
str=strarr(6,20)
str(0,*)="prs"
;str(0,*)="sndspd"
str(1,*)="B!DX!N"+tag2
str(2,*)="B!DZ!N"+tag2
str(3,*)="PLUTO AMR current"+tag2
str(4,*)="Alfven speed"
str(5,*)="bx1"
for usingps=0,1 do begin
if ( usingps ) then begin
set_plot,'ps'
device,filename=fname+'.eps',/encapsulated
device, /color
!p.font=0
device, /times
xs=6.
ys=10.
!p.charsize=0.9
cbarchar=0.9
xychar=0.9
legchar=0.9
DEVICE, XSIZE=xs, YSIZE=ys, /INCHES
endif else begin
set_plot,'x'
!p.font=-1
;!p.color=0
;!p.background=255
!p.charsize=1.8
cbarchar=1.8
xychar=1.8
legchar=1.8
;device, set_resolution=[1100,800]
endelse
;window, xs=1100,ys=800
!p.multi=[0,2,1]
if ( plotgrowth eq 1 ) then begin
!p.multi=0
endif
if ( plotgrowthvortex eq 1) then begin
!p.multi=0
endif
!p.multi=[0,1,2]
!x.style=1
!y.style=1
;!p.background=1
xx=x1
yy=x2
;p1 = !P & x1 = !X & y1 = !Y
cgLoadCT, 33, CLIP=[5, 245]
;tvlct, 0,0,0,0
;tvlct, 255,255,255,1
white=1
!p.background=white
!p.color=0
if ( plotgrowthvortex eq 1 ) then begin
for i=3,3 do begin
;r=scale_vector(var(i,*,*),4,255)
r=var(i,*,*)
;contour, r, xx,yy,/nodata, title=str(i), xtitle='x', ytitle='y'
p = [0.08, 0.3, 0.98, 0.95]
;cgIMAGE, r, POSITION=p, /KEEP_ASPECT_RATIO ;, MISSING_INDEX=3 , scale=4, bottom=190, top=254, background='white'
cgimage, r, POSITION=p, /KEEP_ASPECT_RATIO ,background='white', scale=1 ;, /axis, xtitle='x ', ytitle='y'
;cgaxis,0.5,0.1, /xaxis, /normal, xrange=[1,20]
;cgaxis, /xaxis, xRANGE=[0, 100], $
;MINOR=0, MAJOR=3
cgcontour, r, xx,yy,POSITION=p, /NOERASE, XSTYLE=1, $
YSTYLE=1, NLEVELS=10, /nodata, title=str(i)+', t='+string(t,format='(F6.2)'), $
color='white'
imin=min(r)-1e-6
imax=max(r)+1e-6
cgcolorbar, Position=[p[0], p[1]-0.07, p[2], p[1]-0.05], range=[imin,imax], format='(F5.2)', charsize=cbarchar
if (i eq 3 ) then begin
q=25
if (background eq 1) then begin
cv1=congrid(bx1-initb1,q,q)
cv2=congrid(bx2-initb2,q,q)
endif else begin
cv1=congrid(bx1,q,q)
cv2=congrid(bx2,q,q)
endelse
cx=congrid(xx,q)
cy=congrid(yy,q)
cgloadct,0
velovect, cv1,cv2, cx,cy, /noerase,/overplot, position=p , color=255
cgloadct,33
endif
endfor
endif
growth=0
dogrowth=0
if ( max(gamma) ge 0.5 ) then begin
dogrowth=1
endif
; estimate growth rate
tsndcr=1.0/10.0 ; should be kh /10?
;tnorm=t
;tnorm=t/tsndcr
if ( dogrowth ) then begin
nel=n_elements(gamma)
gam2=[0.01, 0.5]
tam2=interpol( tnorm(0:nel-1),gamma, gam2)
print, tam2
print, gam2
growth=(gam2[1]-gam2[0])/(tam2[1]-tam2[0])
growth=(alog10(gam2[1])-alog10(gam2[0]))/(tam2[1]-tam2[0])
endif
if (plotgrowth ne 0) then begin
cgplot, tnorm, alog10(gamma), title='Log (Total B!U2!N!DZ!N)' , xrange=[0.1,24],yrange=[-5,0], xtitle='t / t!D(VK)!N', ytitle='Log Total B!U2!N!DZ!N /B!U2!N!Dt=0!N' , /xlog, psym=-14, Color='black',linestyle=0, background='white'
print, 'tnorm, ', tnorm
cgplot, tnorm, alog10(tbx2), /overplot, PSym=-15, Color='red',linestyle=2
cgplot, tnorm, alog10(totvel1), /overplot,PSym=-16, Color='dodger blue', linestyle=3
cgplot, tnorm, alog10(totvel2), /overplot, PSym=-17, Color='green', linestyle=4
al_legend, ['bz!U2!N','bx!U2!N', 'v1!U2!N','v2!U2!N'], PSym=[-14,-15,-16,-17], $
LineStyle=[0,2,3,4], Color=['black','red','dodger blue','green'], charsize=legchar, /left
if ( dogrowth ) then begin
;oplot,t,exp(growth*t/0.1)*gam2[0]/exp(growth*tam2[0]/0.1)
cgplot, tnorm, growth*(tnorm-tam2[0])+alog10(gam2[0]) , /overplot
cgplot, tam2, alog10(gam2), psym=4, /overplot
endif
endif
talfven=1./max((bx1^2+bx2^2)/rho)
tresis=1/1e-4
tsound=1/max(prs/rho)
aspectratio=max(x2+0.5*dx2[0])/max(x1+0.5*dx1[0])
if ( doannotation eq 1) then begin
xyouts, 0.01,0.01,$
'Tearing Mode Instability, t='+string(t,format='(F5.1)')+ $
', growth rate'+string(growth, format='(F7.4)')+$
', aspect ratio '+string(aspectratio, format='(F7.4)')+$
' , t!DA!N'+string(talfven, format='(F8.4)')+$
' , t!DR!N'+string(tresis, format='(F9.1)')+$
' , t!DS!N'+string(tsound, format='(F7.4)'),$
/normal, charsize=xychar
endif
!p.position=0
!p.multi=0
if ( usingps ) then begin
device,/close
set_plot,'x'
endif else begin
;set_plot,'x'
fname2=fname
im=cgsnapshot(filename=fname2,/nodialog,/jpeg)
endelse
endfor
set_plot,'x'
endfor
f2name='growthratemhd.dat'
OPENW,1,f2name
PRINTF,1, max(x2)/max(x1), growth,FORMAT='(F9.6 , F9.6)'
CLOSE,1
print, totalb20
PRINT, max(x2)/max(x1), ' growth ', growth
end