Attachment 'rayleigh.py'

Download

   1 import sys; sys.path.append('../py_src')
   2 from numpy import *
   3 from pyOM_gui import pyOM_gui as pyOM
   4 
   5 fac = 1.0
   6 mix = 2.5e-3
   7 
   8 class rayleigh(pyOM):
   9     
  10    def set_parameter(self):
  11      """set main parameter
  12      """
  13      M=self.fortran.main_module   
  14      M.nx=int(2*32*fac)
  15      M.nz=int(20*fac)
  16      M.ny=1
  17      M.dt_tracer=0.25/fac
  18      M.dt_mom   =0.25/fac
  19      
  20      M.enable_conserve_energy = 0
  21      M.coord_degree           = 0
  22      M.enable_cyclic_x        = 1
  23      M.enable_hydrostatic     = 0
  24      
  25      M.eq_of_state_type       = 1 
  26      M.enable_tempsalt_sources = 1
  27 
  28      M.congr_epsilon = 1e-6
  29      M.congr_max_iterations = 5000
  30      M.congr_epsilon_non_hydro=   1e-6
  31      M.congr_max_itts_non_hydro = 5000    
  32 
  33      M.enable_explicit_vert_friction = 1
  34      M.kappam_0 = mix/fac**2
  35      M.enable_hor_friction = 1
  36      M.a_h = mix/fac**2
  37 
  38      M.enable_superbee_advection = 1
  39      #M.kappah_0 = mix/fac**2
  40      #M.enable_hor_diffusion = 1
  41      #M.k_h = mix/fac**2
  42      
  43      M.runlen =  86400.0
  44      return
  45 
  46    
  47    def set_grid(self):
  48      M=self.fortran.main_module   
  49      M.dxt[:]=0.5/fac 
  50      M.dyt[:]=0.5/fac 
  51      M.dzt[:]=0.5/fac 
  52      return
  53    
  54    def set_initial_conditions(self):
  55      """ setup all initial conditions
  56      """
  57      M=self.fortran.main_module   
  58      for i in range(M.is_pe,M.ie_pe+1): 
  59          ii = self.if2py(i)
  60          M.temp[ii,:,:,:] = 0.05*sin(M.xt[ii]/(20*M.dxt[2])*pi) 
  61      for k in [0,1,2]:     M.temp[:,:,:,k] = M.temp[:,:,:,k]*M.maskt
  62      return
  63  
  64    def set_forcing(self):
  65      """ setup all forcing
  66          surface and bottom boundary conditions
  67          might be variable in time, called every time step
  68      """
  69      M=self.fortran.main_module   
  70      M.temp_source[:,:,-1] = -175/4185.5 /M.dzt[-1]
  71      M.temp_source[:,:,0 ] =  175/4185.5 /M.dzt[0]
  72      return
  73 
  74 
  75    def make_plot(self):
  76      """ diagnose the model variables, could be replaced by other version
  77      """
  78      M=self.fortran.main_module         # fortran module with model variables
  79      self.figure.clf()
  80      ax=self.figure.add_subplot(211)
  81      a=where( M.maskt[2:-2,2,:] >0, M.temp[2:-2,2,:,M.tau-1], NaN)
  82      co=ax.contourf(M.xt[2:-2],M.zt,a.transpose(),arange(-2.5,2.5,0.25))
  83      self.figure.colorbar(co)
  84      ax.quiver(M.xt[2:-2:2],M.zt[::2],M.u[2:-2:2,2,::2,M.tau-1].transpose(),M.w[2:-2:2,2,::2,M.tau-1].transpose() )
  85      ax.set_title('temperature')
  86      ax.set_xlabel('x [m]')
  87      ax.set_ylabel('z [m]')
  88      ax.axis('tight')
  89      return
  90 
  91 if __name__ == "__main__": rayleigh().run(5.0)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2014-09-13 14:20:24, 2.5 KB) [[attachment:rayleigh.py]]
  • [get | view] (2014-09-13 14:47:16, 127.8 KB) [[attachment:snapshot1.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.