Changeset 656 for codes/icosagcm/devel


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

devel/unstructured : some improvement of test cases

Location:
codes/icosagcm/devel/Python/test/py
Files:
3 edited

Legend:

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

    r646 r656  
    5454 
    5555#Lx, nx, llm, thetac, T, Nslice, courant = 2000., 100, 50, 30., 5., 10, 2.8 
    56 Lx, nx, llm, thetac, T, Nslice, courant = 2000., 8, 80, 30, 5., 10, 2.8 
     56Lx, nx, llm, thetac, T, Nslice, courant = 2000., 20, 79, 30, 5., 10, 2.8 
    5757#Lx, nx, llm, thetac, T, Nslice, courant = 3000., 75, 25, -30, 5., 10, 2.8 
    5858 
     
    7272print 'Time step : %d x %g s' % (nt,dt) 
    7373 
     74#caldyn_thermo, caldyn_eta = unst.thermo_theta, unst.eta_mass 
    7475caldyn_thermo, caldyn_eta = unst.thermo_entropy, unst.eta_mass 
    7576#caldyn_thermo, caldyn_eta = unst.thermo_entropy, unst.eta_lag 
     
    9596     
    9697m,S,u,Phi,W=flow0 
     98if caldyn_thermo == unst.thermo_theta: 
     99    s=S/m 
     100    theta = thermo.T0*np.exp(s/thermo.Cpd) 
     101    S=m*theta 
     102    title_format = 'Potential temperature at t=%g s (K)' 
     103else: 
     104    title_format = 'Specific entropy at t=%g s (J/K/kg)' 
     105 
    97106w=mesh.field_mass() 
    98107z=mesh.field_mass() 
     
    114123    ax1.set_ylim((0.,1.)), ax1.set_ylabel('z (km)')         
    115124    plt.colorbar(c,ax=ax1) 
    116     ax1.set_title('Specific entropy at t=%g s (J/K/kg)' % (it*T,)) 
     125    ax1.set_title(title_format % (it*T,)) 
     126 
    117127    #    plt.show() 
    118128     
  • 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.) 
  • codes/icosagcm/devel/Python/test/py/slice_GW_hydro.py

    r646 r656  
    6767        plt.close() 
    6868 
    69 Lx, nx, llm = 3e5, 300, 20 
     69Lx, nx, llm = 3e5, 300, 80 
    7070nqdyn, ny, dx = 1, 1, Lx/nx 
    7171mesh = Mesh(nx,ny,llm,nqdyn,nx*dx,ny*dx,0.) 
Note: See TracChangeset for help on using the changeset viewer.