Changeset 747 for codes/icosagcm/devel/Python/test
- Timestamp:
- 10/05/18 13:42:49 (6 years ago)
- Location:
- codes/icosagcm/devel/Python/test/py
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/Python/test/py/DCMIP2008c5.py
r687 r747 136 136 plt.savefig('fig_DCMIP2008c5/Ai.png'); plt.close() 137 137 138 139 if False: # time stepping in Python 138 if False: # time stepping in Python => set precision to np_num 140 139 caldyn = unst.Caldyn_HPE(caldyn_thermo,caldyn_eta, mesh,thermo,params,params.g) 141 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt, a32=0.7)140 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt, precision=unst.np_num, a32=0.7) 142 141 def next_flow(m,S,u): 143 142 m,S,u = scheme.advance((m,S,u),nt) … … 179 178 z, vol = mesh.field_mass(), mesh.field_mass() 180 179 m,S,u,Phi,W = flow0 180 181 print 'types of m,S,u :', m.dtype, S.dtype, u.dtype 182 181 183 caldyn_step.geopot[:,0]=Phi[:,0] 182 184 plots(0) -
codes/icosagcm/devel/Python/test/py/NH_3D_bubble.py
r656 r747 4 4 from dynamico import DCMIP 5 5 from dynamico import meshes 6 from dynamico import precision as prec 6 7 from dynamico.meshes import Cartesian_mesh as Mesh 7 8 import math as math … … 51 52 params.rho_bot = 1e6/gas_bot.v 52 53 53 return thermo, mesh, params, (mass_ik,Sik,ujk,Phi_il,Wil), gas54 return thermo, mesh, params, prec.asnum([mass_ik,Sik,ujk,Phi_il,Wil]), gas 54 55 55 56 #Lx, nx, llm, thetac, T, Nslice, courant = 2000., 100, 50, 30., 5., 10, 2.8 … … 63 64 # compute hybrid coefs from initial distribution of mass 64 65 mass_bl,mass_dak,mass_dbk = meshes.compute_hybrid_coefs(flow0[0]) 66 print 'Type of mass_bl, mass_dak, mass_dbk : ', [x.dtype for x in mass_bl, mass_dak, mass_dbk] 65 67 unst.ker.dynamico_init_hybrid(mass_bl,mass_dak,mass_dbk) 66 68 -
codes/icosagcm/devel/Python/test/py/RSW_2D.py
r632 r747 18 18 19 19 x1,x2,yy = mesh.xx[:,:,0]-1., mesh.xx[:,:,0]+1., mesh.yy[:,:,0] 20 h0 = 1+0.1*(np.exp(-2.*(x1*x1+yy*yy))+ 20 h0, u0 = mesh.field_mass(), mesh.field_u() # flow initally at rest 21 h0[:] = 1+0.1*(np.exp(-2.*(x1*x1+yy*yy))+ 21 22 np.exp(-2.*(x2*x2+yy*yy))) 22 u0 = mesh.field_u() # flow initally at rest23 23 flow0=(h0,u0) 24 24 … … 32 32 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt) 33 33 34 print 'types : yy, u0, h0, u0', yy.dtype, u0.dtype, h0.dtype, u0.dtype 35 34 36 flow=flow0 35 37 for i in range(10): 36 38 h,u=flow 39 print 'types : h,u', h.dtype, u.dtype 37 40 caldyn.bwd_fast_slow(flow, 0.) 38 41 plt.figure(); plt.pcolor(mesh.x,mesh.y,caldyn.qv) … … 48 51 unst.elapsed=0. 49 52 flow = scheme.advance(flow,N) 53 h,u=flow 54 print 'types : h,u', h.dtype, u.dtype 50 55 # flops 51 56 # mass flux : 1add+1mul per edge => 4 -
codes/icosagcm/devel/Python/test/py/RSW_2D_mesh.py
r719 r747 45 45 dx,dy=Lx/nx,Ly/ny 46 46 47 filename, llm, nqdyn, g, f, radius = 'cart128.nc', 1, 1, 1., 1., 1.47 filename, llm, nqdyn, g, f, radius = 'cart128.nc', 1, 1, 1., 1., None 48 48 unst.setvar('g',g) 49 49 … … 64 64 65 65 x1,x2,yy = xx-1., xx+1., yy 66 u0 = mesh.field_u() # flow initally at rest 66 67 h0 = 1+0.1*(np.exp(-2.*(x1*x1+yy*yy))+ 67 68 np.exp(-2.*(x2*x2+yy*yy))) 68 u0 = mesh.field_u() # flow initally at rest 69 flow0=(h0,u0) 69 flow0=meshes.asnum([h0,u0]) 70 70 71 71 #print('h0 : ', h0[1234]-1.) … … 79 79 dt=T/N 80 80 print N,dt,Lx/nx 81 scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt) 81 #scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt, precision=unst.np_num) 82 scheme = time_step.RK4(caldyn.bwd_fast_slow, dt, precision=unst.np_num) 82 83 83 84 flow=flow0 … … 90 91 for i in range(10): 91 92 h,u=flow 92 flow, fast, slow = caldyn.bwd_fast_slow(flow, 0.)93 flow, fast, slow = caldyn.bwd_fast_slow(flow, unst.zero_num) 93 94 junk, du_fast = fast 94 95 dh, du_slow = slow … … 102 103 plt.figure(); plt.pcolor(x,y,reshape(caldyn.qv)) 103 104 plt.colorbar(); plt.title('potential vorticity') 104 plt.savefig('fig_RSW_2D_mesh/%02d.png'%i) 105 plt.savefig('fig_RSW_2D_mesh/%03d.png'%i) 106 plt.close() 105 107 # plt.figure(); plt.pcolor(mesh.x,mesh.y,h) 106 108 # plt.colorbar(); plt.title('h') … … 112 114 unst.elapsed=0. 113 115 flow = scheme.advance(flow,N) 116 # flow = scheme.advance(flow,5) 114 117 # flops 115 118 # mass flux : 1add+1mul per edge => 4 -
codes/icosagcm/devel/Python/test/py/RSW_MPAS_W02.py
r680 r747 1 1 print 'Loading DYNAMICO modules ...' 2 2 from dynamico import unstructured as unst 3 from dynamico.precision import asnum 3 4 from dynamico.meshes import MPAS_Format, Unstructured_Mesh 4 5 from dynamico import time_step … … 34 35 dt = T/nt 35 36 #scheme = time_step.RKn_simple(1,caldyn.bwd_fast_slow, dt) 36 scheme = time_step.RK4(caldyn.bwd_fast_slow, dt )37 scheme = time_step.RK4(caldyn.bwd_fast_slow, dt, precision=unst.np_num) 37 38 38 39 print dx, dt, dt*c0/dx … … 61 62 fu_perp = mesh.ucov2D(0.*ulon,2*Omega*np.sin(mesh.lat_e)*ulon) 62 63 63 flow = (Phi0,mesh.ucov2D(ulon,0.*ulon)) 64 flow = asnum([Phi0, mesh.ucov2D(ulon,0.*ulon)]) 65 print 'type of Phi0,u0 : ', flow[0].dtype, flow[1].dtype 66 64 67 for i in range(N): 65 68 h,u=flow -
codes/icosagcm/devel/Python/test/py/bubble.py
r631 r747 1 import math as math2 import numpy as np3 import matplotlib.pyplot as plt4 import matplotlib.animation as manimation5 6 1 from dynamico.meshes import Cartesian_mesh as Mesh 7 2 import dynamico.dyn as dyn … … 10 5 import dynamico.advect as advect 11 6 from dynamico import unstructured as unst 7 8 import math as math 9 import numpy as np 10 import matplotlib.pyplot as plt 11 import matplotlib.animation as manimation 12 12 13 13 14 def reldiff(a,b): -
codes/icosagcm/devel/Python/test/py/slice_GW_NH.py
r666 r747 29 29 30 30 u0=mesh.field_u() 31 u0[ :,range(0,2*nx,2),:] = u*mesh.dx # Doppler shift by u31 u0[range(0,2*nx,2),:] = u*mesh.dx # Doppler shift by u 32 32 flow0=(m0ik,S0ik,u0,Phi0_il,0*Phi0_il) 33 33 … … 81 81 plt.figure(figsize=(12,3)) 82 82 ucomp = mesh.ucomp(u) 83 plt.pcolor(xx,zz,ucomp[ 0,:,:]/dx)83 plt.pcolor(xx,zz,ucomp[:,:]/dx) 84 84 plt_axes() 85 85 plt.title("u(t = %f s)" % ((i+1)*dt*nt)) -
codes/icosagcm/devel/Python/test/py/slice_GW_hydro.py
r656 r747 23 23 24 24 u0=mesh.field_u() 25 u0[ :,range(0,2*nx,2),:] = 100.*mesh.dx # Doppler shift 100 m/s25 u0[range(0,2*nx,2),:] = 100.*mesh.dx # Doppler shift 100 m/s 26 26 flow0=(m0ik,S0ik,u0) 27 27 … … 60 60 plt.figure(figsize=(12,3)) 61 61 ucomp = mesh.ucomp(u) 62 plt.pcolor(xx,zz,ucomp[ 0,:,:]/dx)62 plt.pcolor(xx,zz,ucomp[:,:]/dx) 63 63 plt.ylim(0,10.) 64 64 plt.colorbar()
Note: See TracChangeset
for help on using the changeset viewer.