Skip to content

Commit

Permalink
Update examples and verification experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ramadhan committed Feb 4, 2020
1 parent de97f59 commit 8d3b164
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 22 deletions.
7 changes: 5 additions & 2 deletions examples/eady_turbulence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ output_filename_prefix = string("eady_turb_Nh", Nh, "_Nz", Nz)
# Our use of biharmonic diffusivity means we must instantiate the model grid
# with halos of size `(2, 2, 2)` in `(x, y, z)`.

model = Model( grid = RegularCartesianGrid(size=(Nh, Nh, Nz), halo=(2, 2, 2),
x=(-Lh/2, Lh/2), y=(-Lh/2, Lh/2), z=(-Lz, 0)),
grid = RegularCartesianGrid(size=(Nh, Nh, Nz), halo=(2, 2, 2),
topology=(Periodic, Periodic, Bounded),
x=(-Lh/2, Lh/2), y=(-Lh/2, Lh/2), z=(-Lz, 0))

model = Model( grid = grid,
architecture = CPU(),
coriolis = FPlane(f=f),
buoyancy = BuoyancyTracer(), tracers = :b,
Expand Down
5 changes: 4 additions & 1 deletion examples/internal_wave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ nothing # hide
# use temperature as a buoyancy tracer, and use a small constant viscosity
# and diffusivity to stabilize the model.

grid = RegularCartesianGrid(size=(Nx, 1, Nx), length=(Lx, Lx, Lx),
topology=(Periodic, Singleton, Bounded))

model = Model(
grid = RegularCartesianGrid(size=(Nx, 1, Nx), length=(Lx, Lx, Lx)),
grid = grid,
closure = ConstantIsotropicDiffusivity=1e-6, κ=1e-6),
coriolis = FPlane(f=f),
tracers = :b,
Expand Down
23 changes: 12 additions & 11 deletions examples/langmuir_turbulence.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# # Langmuir turbulence example
#
# This example implements the Langmuir turbulence simulation reported in section
# 4 of McWilliams, J. C. et al., "Langmuir Turbulence in the ocean," Journal of
# 4 of McWilliams, J. C. et al., "Langmuir Turbulence in the ocean," Journal of
# Fluid Mechanics (1997). This example demonstrates:
#
#
# * how to run a simulation with surface wave effects via the Craik-Leibovich
# approximation
#
Expand All @@ -17,7 +17,7 @@ using Oceananigans.SurfaceWaves: UniformStokesDrift
# ## Model parameters
#
# Here we use an anisotropic grid with `Nh` horizontal grid points, `Nz` vertical
# grid points, `Δh` horizontal grid spacing, and `Δz` vertical grid spacing.
# grid points, `Δh` horizontal grid spacing, and `Δz` vertical grid spacing.
# We specify fluxes of buouyancy and momentum that match the specifications in
# McWilliams and Sullivan (1997) via
#
Expand All @@ -39,7 +39,7 @@ using Oceananigans.SurfaceWaves: UniformStokesDrift
f = 1e-4 # [s⁻¹] Coriolis parameter
end_time = 2hour # [s] End time for the simulation

# Surface wave stokes drift profile:
# Surface wave stokes drift profile:
#
# $ uˢ(z) = Uˢ exp(2kˢʷ z) $
#
Expand All @@ -61,7 +61,7 @@ const aˢʷ = 0.8 # [m] Surface wave amplitude
const= aˢʷ^2 * kˢʷ * sqrt(g_Earth * kˢʷ)

## Oceananigans
∂z_uˢ(z, t) = 2kˢʷ ** exp(2kˢʷ * z)
∂z_uˢ(z, t) = 2kˢʷ ** exp(2kˢʷ * z)

# We use the Stokes drift profile for the initial condition
(z) =* exp(2kˢʷ * z)
Expand All @@ -75,19 +75,20 @@ uˢ(z) = Uˢ * exp(2kˢʷ * z)

u_bcs = HorizontallyPeriodicBCs(top = BoundaryCondition(Flux, Qᵘ))

b_bcs = HorizontallyPeriodicBCs(top = BoundaryCondition(Flux, Qᵇ),
b_bcs = HorizontallyPeriodicBCs(top = BoundaryCondition(Flux, Qᵇ),
bottom = BoundaryCondition(Gradient, N²))

# ## Model instantiation
#
# We instantiate a horizontally-periodic `Model` on the CPU with on a `RegularCartesianGrid`,
# using a `FPlane` model for rotation (constant rotation rate), the Anisotropic Minimum
# Dissipation closure to model the effects of unresolved turbulence, and the previously defined
# using a `FPlane` model for rotation (constant rotation rate), the Anisotropic Minimum
# Dissipation closure to model the effects of unresolved turbulence, and the previously defined
# boundary conditions for `u` and `b`.

model = Model(
architecture = CPU(),
grid = RegularCartesianGrid(size=(Nh, Nh, Nz), length=(Δh*Nh, Δh*Nh, Δz*Nz)),
grid = RegularCartesianGrid(size=(Nh, Nh, Nz), length=(Δh*Nh, Δh*Nh, Δz*Nz),
topology=(Periodic, Periodic, Bounded)),
buoyancy = BuoyancyTracer(), tracers = :b,
closure = AnisotropicMinimumDissipation(),
surface_waves = UniformStokesDrift(∂z_uˢ=∂z_uˢ),
Expand All @@ -106,8 +107,8 @@ model = Model(
b₀(x, y, z) =* z + 1e-1 * Ξ(z) ** model.grid.Lz

# Velocity initial condition: note that McWilliams and Sullivan (1997) use a model
# that is formulated in terms of the Eulerian-mean velocity field. Due to this,
# their 'resting' initial condition actually consists of a sheared and
# that is formulated in terms of the Eulerian-mean velocity field. Due to this,
# their 'resting' initial condition actually consists of a sheared and
# unbalanced Lagrangian-mean velocity field uˢ(z). To this we add noise.
u₀(x, y, z) = (z) + sqrt(abs(Qᵘ)) * 1e-1 * Ξ(z)

Expand Down
5 changes: 3 additions & 2 deletions examples/netcdf_ouput_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Nx, Ny, Nz = 16, 16, 16 # No. of grid points in x, y, and z, respectively.
Lx, Ly, Lz = 100, 100, 100 # Length of the domain in x, y, and z, respectively (m).
tf = 5000 # Length of the simulation (s)

model = Model(grid=RegularCartesianGrid(size=(Nx, Ny, Nz), length=(Lx, Ly, Lz)),
closure=ConstantIsotropicDiffusivity())
grid = RegularCartesianGrid(size=(Nx, Ny, Nz), length=(Lx, Ly, Lz),
topology=(Periodic, Periodic, Bounded))
model = Model(grid=grid, closure=ConstantIsotropicDiffusivity())

# Add a cube-shaped warm temperature anomaly that takes up the middle 50%
# of the domain volume.
Expand Down
6 changes: 4 additions & 2 deletions examples/ocean_convection_with_plankton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ nothing # hide
growth_and_decay = SimpleForcing((x, y, z, t) -> exp(z/16))

## Instantiate the model
model = Model(
grid = RegularCartesianGrid(size = (Nz, 1, Nz), length = (Lz, Lz, Lz)),
grid = RegularCartesianGrid(size=(Nz, 1, Nz), length=(Lz, Lz, Lz),
topology=(Periodic, Periodic, Bounded))

model = Model( grid = grid,
closure = ConstantIsotropicDiffusivity=1e-4, κ=1e-4),
coriolis = FPlane(f=1e-4),
tracers = (:b, :plankton),
Expand Down
5 changes: 4 additions & 1 deletion examples/ocean_wind_mixing_and_convection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ nothing # hide
# model.parameters for use in the boundary condition function that calculates the salinity
# flux.

grid = RegularCartesianGrid(size=(Nz, Nz, Nz), length=(Δz*Nz, Δz*Nz, Δz*Nz),
topology=(Periodic, Periodic, Bounded))

model = Model(
architecture = CPU(),
grid = RegularCartesianGrid(size=(Nz, Nz, Nz), length=(Δz*Nz, Δz*Nz, Δz*Nz)),
grid = grid,
coriolis = FPlane(f=f),
buoyancy = SeawaterBuoyancy(equation_of_state=LinearEquationOfState=α, β=β)),
closure = AnisotropicMinimumDissipation(),
Expand Down
3 changes: 2 additions & 1 deletion examples/one_dimensional_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ using Plots, Printf
# `Model` constructor:

model = Model(
grid = RegularCartesianGrid(size = (1, 1, 128), x = (0, 1), y = (0, 1), z = (-0.5, 0.5)),
grid = RegularCartesianGrid(size=(1, 1, 128), x=(0, 1), y=(0, 1), z=(-0.5, 0.5),
topology=(Singleton, Singleton, Bounded)),
closure = ConstantIsotropicDiffusivity= 1.0)
)
nothing # hide
Expand Down
5 changes: 4 additions & 1 deletion examples/two_dimensional_turbulence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ using Oceananigans: Face, Cell
# `Face` and `Cell` represent "locations" on the staggered grid. We instantiate the
# model with a simple isotropic diffusivity.

grid = RegularCartesianGrid(size=(128, 128, 1), length=(2π, 2π, 2π),
topology=(Periodic, Periodic, Singleton))

model = Model(
grid = RegularCartesianGrid(size=(128, 128, 1), length=(2π, 2π, 2π)),
grid = grid,
buoyancy = nothing,
tracers = nothing,
closure = ConstantIsotropicDiffusivity=1e-3, κ=1e-3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ function simulate_stratified_couette_flow(; Nxy, Nz, arch=GPU(), h=1, U_wall=1,
##### Non-dimensional model setup
#####

grid = RegularCartesianGrid(size=(Nxy, Nxy, Nz), length=(4π*h, 2π*h, 2h),
topology=(Periodic, Periodic, Bounded))

model = Model(
architecture = arch,
grid = RegularCartesianGrid(size = (Nxy, Nxy, Nz), length = (4π*h, 2π*h, 2h)),
grid = grid,
buoyancy = SeawaterBuoyancy(equation_of_state=LinearEquationOfState=1.0, β=0.0)),
closure = AnisotropicMinimumDissipation=ν, κ=κ),
boundary_conditions = HorizontallyPeriodicSolutionBCs(u=ubcs, v=vbcs, T=Tbcs),
Expand Down

0 comments on commit 8d3b164

Please sign in to comment.