Ignore:
Timestamp:
12/30/17 01:06:26 (7 years ago)
Author:
dubos
Message:

devel/unstructured : some improvement of test cases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/Python/test/py/slice_GW_NH.py

    r646 r656  
    1616    caldyn_thermo = unst.thermo_entropy 
    1717    g = mesh.dx/metric.dx_g0 
    18     caldyn = unst.Caldyn_NH(caldyn_thermo,caldyn_eta, mesh,thermo,BC,g) 
     18 
     19    dt = courant*.5*dx/np.sqrt(gas0.c2.max()) 
     20    nt=int(T/dt)+1 
     21    dt=T/nt 
     22    print 'nt,dt,dx', nt,dt,dx 
    1923 
    2024    Sik = m0ik*gas0.s 
     
    3034    flow0=(m0ik,S0ik,u0,Phi0_il,0*Phi0_il) 
    3135 
    32     dt = courant*.5*dx/np.sqrt(gas0.c2.max()) 
    33     nt=int(T/dt)+1 
    34     dt=T/nt 
    35     print 'nt,dt,dx', nt,dt,dx 
    36     scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt, a32=0.7) 
    37     #scheme = time_step.ARK3(caldyn.bwd_fast_slow, dt) 
     36    if False: # time stepping in Python 
     37        caldyn = unst.Caldyn_NH(caldyn_thermo,caldyn_eta, mesh,thermo,BC,g) 
     38        scheme = time_step.ARK2(caldyn.bwd_fast_slow, dt, a32=0.7) 
     39        #scheme = time_step.ARK3(caldyn.bwd_fast_slow, dt) 
     40        def next_flow(m,S,u,Phi,W): 
     41            m,S,u,Phi,W = scheme.advance((m,S,u,Phi,W),nt) 
     42            return m,S,u,Phi,W 
     43    else: # time stepping in Fortran 
     44        scheme = time_step.ARK2(None, dt, a32=0.7) 
     45        caldyn_step = unst.caldyn_step_NH(mesh,scheme,nt,  
     46                                          caldyn_thermo,caldyn_eta,thermo,BC,g) 
     47        def next_flow(m,S,u,Phi,W): 
     48            caldyn_step.mass[:,:], caldyn_step.theta_rhodz[:,:], caldyn_step.u[:,:] = m,S,u 
     49            caldyn_step.geopot[:,:], caldyn_step.W[:,:] = Phi,W 
     50            caldyn_step.next() 
     51            return (caldyn_step.mass.copy(), caldyn_step.theta_rhodz.copy(), caldyn_step.u.copy(), 
     52                    caldyn_step.geopot.copy(), caldyn_step.W.copy()) 
    3853 
    39 #    nt=1 # FIXME 
    40     flow=flow0 
     54    m,S,u,Phi,W=flow0 
     55 
    4156    for i in range(12): 
    4257        time1=time.time() 
    43         flow = scheme.advance(flow,nt) 
     58        m,S,u,Phi,W = next_flow(m,S,u,Phi,W) 
    4459        time2=time.time() 
    4560        print 'ms per time step : ', 1000*(time2-time1)/nt 
    4661 
    47         m,S,u,Phi,W = flow 
    4862        w=.5*(W[:,0:llm]+W[:,1:llm+1])/m 
    49         junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 
     63#        junk,fast,slow = caldyn.bwd_fast_slow(flow, 0.) 
    5064#        zz=caldyn.geopot[:,0:llm]/metric.g0/1000 
    5165        zz=Phi[:,0:llm]/metric.g0/1000 
     
    5973            plt.colorbar() 
    6074 
    61         plt.figure(figsize=(12,3)) 
    62         ucomp = mesh.ucomp(u) 
    63         plt.pcolor(xx,zz,caldyn.pk) 
    64         plt_axes() 
    65         plt.title("T(t = %f s)" % ((i+1)*dt*nt)) 
    66         plt.savefig('fig_slice_GW_NH/T%02d.png'%i) 
    67         plt.close() 
    68  
     75#        plt.figure(figsize=(12,3)) 
     76#        ucomp = mesh.ucomp(u) 
     77#        plt.pcolor(xx,zz,caldyn.pk) 
     78#        plt_axes() 
     79#        plt.title("T(t = %f s)" % ((i+1)*dt*nt)) 
     80#        plt.savefig('fig_slice_GW_NH/T%02d.png'%i) 
     81#        plt.close() 
     82# 
    6983        plt.figure(figsize=(12,3)) 
    7084        ucomp = mesh.ucomp(u) 
     
    91105 
    92106#Lx, nx, llm = 3e5, 100, 1e4, 30 
    93 Lx, nx, ztop, llm = 2e5, 400, 3e4, 60 
     107Lx, nx, ztop, llm = 3e5, 300, 3e4, 80 
    94108nqdyn, ny, dx = 1, 1, Lx/nx 
    95109mesh = Mesh(nx,ny,llm,nqdyn,nx*dx,ny*dx,0.) 
Note: See TracChangeset for help on using the changeset viewer.