Changeset 642 for codes/icosagcm/devel/Python/test
- Timestamp:
- 12/19/17 15:26:51 (7 years ago)
- Location:
- codes/icosagcm/devel/Python/test
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/Python/test/fig_RSW2_MPAS_W02
-
Property
svn:ignore
set to
*.png
-
Property
svn:ignore
set to
-
codes/icosagcm/devel/Python/test/py/NH_3D_bubble.py
r632 r642 53 53 return thermo, mesh, params, (mass_ik,Sik,ujk,Phi_il,Wil), gas 54 54 55 Lx, nx, llm, thetac, T, Nslice, courant = 2000., 100, 50, 30., 5., 10, 2.856 #Lx, nx, llm, thetac, T, Nslice, courant = 2000., 50, 25, 1., 50., 10, 2.855 #Lx, nx, llm, thetac, T, Nslice, courant = 2000., 100, 50, 30., 5., 10, 2.8 56 Lx, nx, llm, thetac, T, Nslice, courant = 2000., 50, 25, 30, 5., 10, 2.8 57 57 #Lx, nx, llm, thetac, T, Nslice, courant = 3000., 75, 25, -30, 5., 10, 2.8 58 58 … … 61 61 thermo, mesh, params, flow0, gas0 = thermal_bubble_3D(Lx,nx,Ly,ny,llm, thetac=thetac) 62 62 63 caldyn_thermo, caldyn_eta = unst.thermo_entropy, unst.eta_mass64 caldyn = unst.Caldyn_NH(caldyn_thermo,caldyn_eta, mesh,params,thermo,params,params.g)65 66 63 # compute hybrid coefs from initial distribution of mass 67 64 mass_bl,mass_dak,mass_dbk = meshes.compute_hybrid_coefs(flow0[0]) 68 65 unst.ker.dynamico_init_hybrid(mass_bl,mass_dak,mass_dbk) 69 print mass_dbk70 66 71 67 dz = flow0[3].max()/(params.g*llm) … … 74 70 nt = int(math.ceil(T/dt)) 75 71 dt = T/nt 76 print 'Time step : % g s' % dt72 print 'Time step : %d x %g s' % (nt,dt) 77 73 78 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt) 74 caldyn_thermo, caldyn_eta = unst.thermo_entropy, unst.eta_mass 75 #caldyn_thermo, caldyn_eta = unst.thermo_entropy, unst.eta_lag 79 76 80 flow=flow0 77 if False: # time stepping in Python 78 caldyn = unst.Caldyn_NH(caldyn_thermo,caldyn_eta, mesh,thermo,params,params.g) 79 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt) 80 def next_flow(m,S,u,Phi,W): 81 # junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 82 return scheme.advance((m,S,u,Phi,W),nt) 83 84 else: # time stepping in Fortran 85 scheme = time_step.ARK2(None, dt) 86 caldyn_step = unst.caldyn_step_NH(mesh,scheme,nt, caldyn_thermo,caldyn_eta, 87 thermo,params,params.g) 88 def next_flow(m,S,u,Phi,W): 89 # junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 90 caldyn_step.mass[:,:,:], caldyn_step.theta_rhodz[:,:,:], caldyn_step.u[:,:,:] = m,S,u 91 caldyn_step.geopot[:,:,:], caldyn_step.W[:,:,:] = Phi,W 92 caldyn_step.next() 93 return (caldyn_step.mass.copy(), caldyn_step.theta_rhodz.copy(), caldyn_step.u.copy(), 94 caldyn_step.geopot.copy(), caldyn_step.W.copy()) 95 96 m,S,u,Phi,W=flow0 81 97 w=mesh.field_mass() 82 98 z=mesh.field_mass() 99 83 100 for it in range(Nslice): 84 junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 85 m,S,u,Phi,W = flow 86 s=S/m ; # s=.5*(s+abs(s)) 101 s=S/m ; s=.5*(s+abs(s)) 87 102 for l in range(llm): 88 103 w[:,:,l]=.5*params.g*(W[:,:,l+1]+W[:,:,l])/m[:,:,l] … … 92 107 jj=ny/2 93 108 xx,zz,ss,ww = mesh.xx[:,jj,:]/1000., z[:,jj,:]/1000., s[:,jj,:], w[:,jj,:] 109 110 f, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(12,4)) 94 111 95 f, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(12,4))96 97 112 c=ax1.contourf(xx,zz,ss,20) 98 113 ax1.set_xlim((-.5,.5)), ax1.set_xlabel('x (km)') … … 100 115 plt.colorbar(c,ax=ax1) 101 116 ax1.set_title('Specific entropy at t=%g s (J/K/kg)' % (it*T,)) 102 # plt.show()117 # plt.show() 103 118 104 # plt.figure(figsize=(12,5))119 # plt.figure(figsize=(12,5)) 105 120 c=ax2.contourf(xx,zz,ww,20) 106 121 ax2.set_xlim((-.5,.5)), ax2.set_xlabel('x (km)') … … 108 123 plt.colorbar(c,ax=ax2) 109 124 ax2.set_title('Vertical velocity at t=%g s (m/s)' % (it*T,)) 110 # plt.tight_layout()111 # plt.show()125 # plt.tight_layout() 126 # plt.show() 112 127 plt.savefig('fig_NH_3D_bubble/%02d.png'%it) 113 128 114 129 time1, elapsed1 =time.time(), unst.getvar('elapsed') 115 flow = scheme.advance(flow,nt)130 m,S,u,Phi,W = next_flow(m,S,u,Phi,W) 116 131 time2, elapsed2 =time.time(), unst.getvar('elapsed') 117 132 factor = 1000./(4*nt) -
codes/icosagcm/devel/Python/test/py/RSW2_MPAS_W02.py
r641 r642 38 38 #scheme = time_step.RKn_simple(1,caldyn.bwd_fast_slow, dt) # forward Euler scheme 39 39 print dt, scheme.csjl, scheme.cfjl 40 step = unst.Caldyn_step(mesh,scheme) 41 step.setup_TRSW() 40 step = unst.caldyn_step_TRSW(mesh,scheme,nt) 42 41 43 42 u0 = Omega*radius/12. # cf Williamson (1991), p.13 … … 63 62 for i in range(20): 64 63 if True: 65 for j in range(nt): 66 step.next() 64 step.next() 67 65 gh,u = step.mass, step.u 68 66 print i, gh.shape, gh.min(), gh.max(), u.min(), u.max() -
codes/icosagcm/devel/Python/test/py/slice_GW_hydro.py
r631 r642 15 15 caldyn_thermo = unst.thermo_entropy 16 16 g = mesh.dx/metric.dx_g0 17 caldyn = unst.Caldyn_HPE(caldyn_thermo,caldyn_eta, mesh,metric,thermo,BC,g)18 17 19 18 Sik = m0ik*gas0.s … … 25 24 S0ik = m0ik*gas0.s 26 25 27 u0=mesh.field_u() 26 u0=mesh.field_u() 28 27 u0[:,range(0,2*nx,2),:] = 100.*mesh.dx # Doppler shift 100 m/s 29 28 flow0=(m0ik,S0ik,u0) … … 35 34 dt=T/nt 36 35 print 'nt,dt,dx', nt,dt,dx 37 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt, a32=0.7)38 #scheme = time_step.ARK3(caldyn.bwd_fast_slow, dt)39 36 40 flow=flow0 37 m,S,u=flow0 38 39 if False: # time stepping in Python 40 caldyn = unst.Caldyn_HPE(caldyn_thermo,caldyn_eta, mesh,thermo,BC,g) 41 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt, a32=0.7) 42 #scheme = time_step.ARK3(caldyn.bwd_fast_slow, dt) 43 def next_flow(m,S,u): 44 m,S,u = scheme.advance((m,S,u),nt) 45 return m,S,u,caldyn.geopot 46 else: # time stepping in Fortran 47 scheme = time_step.ARK2(None, dt, a32=0.7) 48 caldyn_step = unst.caldyn_step_HPE(mesh,scheme,nt, caldyn_thermo,caldyn_eta,thermo,BC,g) 49 def next_flow(m,S,u): 50 caldyn_step.mass[:,:], caldyn_step.theta_rhodz[:,:], caldyn_step.u[:,:] = m,S,u 51 caldyn_step.next() 52 return caldyn_step.mass, caldyn_step.theta_rhodz, caldyn_step.u, caldyn_step.geopot 53 41 54 for i in range(10): 42 55 time1=time.time() 43 flow = scheme.advance(flow,nt)56 m,S,u,geopot = next_flow(m,S,u) 44 57 time2=time.time() 45 m,S,u = flow 46 print 'ms per time step : ', 1000*(time2-time1)/nt 47 print 'ptop, model top (m) :', unst.getvar('ptop'), caldyn.geopot.max()/unst.getvar('g') 48 junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 49 zz=caldyn.geopot[:,0:llm]/metric.g0/1000 58 print 'ms per time step : ', 1000*(time2-time1)/nt, 1000*unst.getvar('elapsed')/(nt*(i+1)) 59 print 'ptop, model top (m) :', unst.getvar('ptop'), geopot.max()/unst.getvar('g') 60 # junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 61 zz=geopot[:,0:llm]/metric.g0/1000 50 62 plt.figure(figsize=(12,3)) 51 63 ucomp = mesh.ucomp(u)
Note: See TracChangeset
for help on using the changeset viewer.