示例#1
0
param.freq_plot = 10
a = 0.2
param.cax = [-a, a]
param.plot_interactive = False
param.colorscheme = 'symmetric'
param.generate_mp4 = False

# physics
param.beta = 0.
param.Rd = 10.  # 2*grid.dx
param.forcing = False
param.noslip = False
param.diffusion = False

grid = Grid(param)
param.Kdiff = 0.1e-3 * grid.dx

f2d = Fluid2d(param, grid)
model = f2d.model

xr, yr = grid.xr, grid.yr
vor = model.var.get('pv')


def vortex(param, grid, x0, y0, sigma, vortex_type, ratio=1):

    xr, yr = grid.xr, grid.yr
    # ratio controls the ellipticity, ratio=1 is a disc
    x = np.sqrt((xr - param.Lx * x0)**2 + (yr - param.Ly * y0)**2 * ratio**2)

    y = x.copy() * 0.
示例#2
0
param.cmap = 'RdYlBu_r'  # 'Spectral'
# change the color scale if you change the magnitude of the  vorticity
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
示例#3
0
param.beta=1.  # beta parameter (for QG model only)
param.Rd=1.    # Rossby deformation radius (for QG only)
param.gravity=1. # for Boussinesq model
param.forcing = True  # activate the forcing
param.forcing_module='forcing_dbl_gyre' #python module name where the forcing is defined
param.noslip = False # active the no-slip boundary condition (causes energy dissipation)
param.diffusion=False # activate a diffusion on tracer.
param.additional_tracer=['tracer'] # you may add an additional passive
                                   # tracer, by simply adding this
                                   # line. Example in inverse_cascade.py


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,
示例#4
0
param.colorscheme = 'imposed'
param.cax = [-0.2, 2.2]
param.plot_interactive = True
# param.plotting_module='plotting_adv'

# physics
param.diffusion = False


# ********* PARAMETERS CONTROLLING THE FLOW AND THE TRACER ********
flow_config = 0  # controls the flow
tracer_config = 0  # controls the tracer


grid = Grid(param)
param.Kdiff = 1e-3*grid.dx

# put obstacles: uncomment below
# grid.msk[-60:-40,40:60]=0
# grid.msk[:64,64]=0

f2d = Fluid2d(param, grid)
model = f2d.model


def vortex(x0, y0, sigma):
    x = np.sqrt((xr-param.Lx*x0)**2+(yr-param.Ly*y0)**2)
    y = 2-2./(1+np.exp(-x/sigma))
    #y = cos(x/sigma*pi/2)
    # y[x>sigma]=0.
    return y
示例#5
0
param.timestepping = 'RK3_SSP'

param.plot_var = 'tracer'
param.var_to_save = ['tracer']
param.list_diag = ['mean', 'rms']
param.freq_his = 10
param.freq_diag = 1
param.freq_plot = 1
param.colorscheme = 'minmax'
param.cax = [-1.2, 1.2]
param.plot_interactive = True
param.adaptable_dt = True
param.dt = .1
param.dtmax = 1e4
param.diffusion = True
param.Kdiff = 0.

grid = Grid(param)

# grid.msk[-60:-40,40:60]=0
# grid.msk[:64,64]=0

f2d = Fluid2d(param, grid)
model = f2d.model

xr, yr = grid.xr, grid.yr
# 1/ set the stream function
sigma = 2 * param.Lx
state = model.var.get('tracer')
state[:] = 1.  # body rotation
state[:] = state[:] * grid.msk
示例#6
0
if grid.j0==param.npy-1:
    msk = grid.msk.copy()*0
    msk[-nh:-1,:]=1
    idx = where(msk==1)
    grid.island.add(idx,psi0)

# tell the code to deactivate the no-slip along the outer walls
if grid.j0==0:
    grid.msknoslip[:nh,:]=1
if grid.j0==param.npy-1:
    grid.msknoslip[-nh:,:]=1



param.Kdiff=20e-3*grid.dx # regular street, with Heun and up3
param.Kdiff=10e-3*grid.dx # regular street, single vortices only
param.Kdiff=5e-3*grid.dx 
param.Kdiff=0 # start to send dipolewith up5, RK3, no dissipation, all good too


f2d = Fluid2d(param,grid)
model = f2d.model

xr,yr = grid.xr,grid.yr
vor = model.var.get('vorticity')

# add noise to trigger the instability
noise = random.normal(size=shape(yr))*grid.msk
grid.fill_halo(noise)
noise -= grid.domain_integration(noise)*grid.msk/grid.area
示例#7
0
prandtl = 1.

deltab = 600  # this is directly the Rayleigh number is L=visco=diffus=1

param.deltab = deltab  # make it known to param

L = param.Ly
visco = .002 * grid.dy
diffus = visco / prandtl

# Rayleigh number is
Ra = deltab * L**3 / (visco * diffus)
print('Rayleigh number is %4.1f' % Ra)

param.Kdiff = {}
param.Kdiff['vorticity'] = visco
param.Kdiff['buoyancy'] = diffus  # param.Kdiff['vorticity'] / prandtl

# time step is imposed by the diffusivity
# param.dt = 0.25*grid.dx**2 / max(visco, diffus)
# param.dtmax = param.dt
# print('dt = %f' % param.dt)

f2d = Fluid2d(param, grid)
model = f2d.model

xr, yr = grid.xr, grid.yr

buoy = model.var.get('buoyancy')
# add noise to trigger the instability
示例#8
0
    grid.island.add(idx, psi0 * .5)

if grid.j0 == param.npy - 1:
    msk = grid.msk.copy() * 0
    msk[-nh:-1, :] = 1
    idx = np.where(msk == 1)
    grid.island.add(idx, -psi0 * .5)

# tell the code to deactivate the no-slip along the outer walls
if grid.j0 == 0:
    grid.msknoslip[:nh, :] = 1

if grid.j0 == param.npy - 1:
    grid.msknoslip[-nh:, :] = 1

param.Kdiff = 20e-3 * grid.dx  # regular street, with Heun and up3
param.Kdiff = 5e-3 * grid.dx  # regular street, single vortices only

f2d = Fluid2d(param, grid)
model = f2d.model

xr, yr = grid.xr, grid.yr
vor = model.var.get('vorticity')

# add noise to trigger the instability
noise = np.random.normal(size=np.shape(yr)) * grid.msk
grid.fill_halo(noise)
noise -= grid.domain_integration(noise) * grid.msk / grid.area

vor += 1e-1 * noise * grid.msk
示例#9
0
param.freq_plot = 10
a = 0.5
param.cax = [-a, a]
param.plot_interactive = True
param.colorscheme = 'imposed'
param.generate_mp4 = True

# physics
param.beta = 1.
param.Rd = 1.  # 2*grid.dx
param.forcing = True
param.noslip = False
param.diffusion = False

grid = Grid(param)
param.Kdiff = 0.5e-4 * grid.dx

# add an island
# grid.msk[28:32,34:38]=0
# grid.finalize_msk()

f2d = Fluid2d(param, grid)
model = f2d.model

# set the forcing
model.forc = Forcing(param, grid)

xr, yr = grid.xr, grid.yr
vor = model.var.get('pv')

# set an initial tracer field
示例#10
0
param.plot_interactive = True
#param.plotting_module='plotting_rayleigh'
param.freq_plot = 10
param.colorscheme = 'imposed'
param.cax = [-.6, .6]

# physics
param.gravity = 1.
param.forcing = False
param.diffusion = False
param.noslip = False
param.enforce_momentum = False

grid = Grid(param)

param.Kdiff = 2e-3 * grid.dx

f2d = Fluid2d(param, grid)
model = f2d.model

xr, yr = grid.xr, grid.yr
buoy = model.var.get('buoyancy')


def sigmoid(x, delta):
    return 1 / (1 + exp(-(x - 0.5) / delta))


def stratif():
    sigma = 3 * grid.dx  # width of the interface
    b = sigmoid(yr / param.Ly, sigma / param.Lx)
示例#11
0
param.freq_plot = 10
param.plot_interactive = True
param.plot_psi = True
param.plot_var = 'vorticity'
param.cax = np.array([-2, 2.]) * 5
param.colorscheme = 'imposed'
param.generate_mp4 = True

# physics
param.noslip = False
param.diffusion = False
param.additional_tracer = ['tracer']

grid = Grid(param)

param.Kdiff = 5e-2 * grid.dx

xr, yr = grid.xr, grid.yr

# it's time to modify the mask and add obstacles  if you wish, 0 is land

msk_config = 'none'  # the other possibility is 'T-wall' or 'bay'

if msk_config == 'bay':
    x0, y0, radius = 0.5, 0.35, 0.2
    y1 = 0.5
    msk2 = ap.vortex(xr, yr, param.Lx, param.Ly, x0, y0, radius, 'step')

    grid.msk[yr < y1] = 0
    grid.msk += np.asarray(msk2, dtype=int)
    grid.msk[grid.msk < 0] = 0
示例#12
0
# physics
param.forcing = False
param.noslip = False
param.diffusion = False
param.forcing = False
param.generate_mp4 = True

param.gravity = 1.
param.f0 = 0.1
param.additional_tracer = ['tracer']

nh = param.nh

grid = Grid(param)

param.Kdiff = 5e-1 * grid.dx**2

f2d = Fluid2d(param, grid)
model = f2d.model

xr, yr = grid.xr, grid.yr
vor = model.var.get('vorticity')
buoy = model.var.get('buoyancy')
V = model.var.get('V')
qE = model.var.get('qE')
trac = model.var.get('tracer')

sigma = 0.2
delta = .2
V0 = .2  # jet speed
示例#13
0
param.plot_interactive = True
param.plot_var = 'vorticity'
param.plot_psi = False
param.cax = [-1.1, 1.1]
param.colorscheme = 'imposed'
param.generate_mp4 = True

# physics
param.forcing = False
param.noslip = False
param.diffusion = False
param.additional_tracer = ['tracer']
param.diag_fluxes = True

grid = Grid(param)
param.Kdiff = 2e-4*grid.dx

# it's time to modify the mask and add obstacles  if you wish, 0 is land
# grid.msk[:55,35]=0
# grid.msk[:,:4]=0
# grid.finalize_msk()

f2d = Fluid2d(param, grid)
model = f2d.model

xr, yr = grid.xr, grid.yr
vor = model.var.get('vorticity')


def vortex(x0, y0, sigma):
    x = np.sqrt((xr-param.Lx*x0)**2+(yr-param.Ly*y0)**2)