param.cax = np.array([-1, 1]) * .25 param.colorscheme = 'imposed' param.generate_mp4 = True # physics param.forcing = False param.noslip = False param.diffusion = False # # add a passive tracer param.additional_tracer = ['tracer'] grid = Grid(param) param.Kdiff = 5e-4 * grid.dx f2d = Fluid2d(param, grid) model = f2d.model xr, yr = grid.xr, grid.yr vor = model.var.get('vorticity') trac = model.var.get('tracer') # set an initial small scale random vorticity field (white noise) np.random.seed(42) def set_x_and_k(n, L): k = ((n // 2 + np.arange(n)) % n) - n // 2 return (np.arange(n) + 0.5) * L / n, 2 * np.pi * k / L
grid = Grid(param) # define the grid coordinates grid.xr, grid.yr and # the mask, grid.msk. You may modify the mask just below param.Kdiff=0.5e-4*grid.dx # diffusion coefficient (same for all # tracers), there is a possibility to # assign a different value for each tracer, # see the experiment rayleigh_benard.py # watch out, Kdiff should be adjusted when # the resolution is changed f2d = Fluid2d(param,grid) # define everything model = f2d.model xr,yr = grid.xr,grid.yr vor = model.var.get('pv') # way to access the 2D array of a variable, # vor is 2 array # set an initial tracer field vor[:] = 1e-2*random.normal(size=shape(vor))*grid.msk y=vor[:]*1. model.ope.fill_halo(y) # each variable is surrounded with a halo. Halo # width is param.nh=3 grid points. The halo is # used in the periodic case (xchannel, # ychannel, perio) and when the model is used with MPI vor[:]=y