From 8d3b1647c30cc310ec680a5ba2f6a5169b482012 Mon Sep 17 00:00:00 2001 From: ali-ramadhan Date: Mon, 3 Feb 2020 20:17:42 -0500 Subject: [PATCH] Update examples and verification experiments --- examples/eady_turbulence.jl | 7 ++++-- examples/internal_wave.jl | 5 +++- examples/langmuir_turbulence.jl | 23 ++++++++++--------- examples/netcdf_ouput_example.jl | 5 ++-- examples/ocean_convection_with_plankton.jl | 6 +++-- examples/ocean_wind_mixing_and_convection.jl | 5 +++- examples/one_dimensional_diffusion.jl | 3 ++- examples/two_dimensional_turbulence.jl | 5 +++- .../stratified_couette_flow.jl | 5 +++- 9 files changed, 42 insertions(+), 22 deletions(-) diff --git a/examples/eady_turbulence.jl b/examples/eady_turbulence.jl index 2660fadb5d..ed90827d11 100644 --- a/examples/eady_turbulence.jl +++ b/examples/eady_turbulence.jl @@ -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, diff --git a/examples/internal_wave.jl b/examples/internal_wave.jl index 89980b6ffd..1d45d0b28d 100644 --- a/examples/internal_wave.jl +++ b/examples/internal_wave.jl @@ -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, diff --git a/examples/langmuir_turbulence.jl b/examples/langmuir_turbulence.jl index 17a82433cb..fe5ea79e1b 100644 --- a/examples/langmuir_turbulence.jl +++ b/examples/langmuir_turbulence.jl @@ -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 # @@ -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 # @@ -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) $ # @@ -61,7 +61,7 @@ const aˢʷ = 0.8 # [m] Surface wave amplitude const Uˢ = aˢʷ^2 * kˢʷ * sqrt(g_Earth * kˢʷ) ## Oceananigans -∂z_uˢ(z, t) = 2kˢʷ * Uˢ * exp(2kˢʷ * z) +∂z_uˢ(z, t) = 2kˢʷ * Uˢ * exp(2kˢʷ * z) # We use the Stokes drift profile for the initial condition uˢ(z) = Uˢ * exp(2kˢʷ * z) @@ -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ˢ), @@ -106,8 +107,8 @@ model = Model( b₀(x, y, z) = N² * z + 1e-1 * Ξ(z) * N² * 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) = uˢ(z) + sqrt(abs(Qᵘ)) * 1e-1 * Ξ(z) diff --git a/examples/netcdf_ouput_example.jl b/examples/netcdf_ouput_example.jl index 70f64d96e6..42c23aab46 100644 --- a/examples/netcdf_ouput_example.jl +++ b/examples/netcdf_ouput_example.jl @@ -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. diff --git a/examples/ocean_convection_with_plankton.jl b/examples/ocean_convection_with_plankton.jl index 658282b29d..96b9e6bad8 100644 --- a/examples/ocean_convection_with_plankton.jl +++ b/examples/ocean_convection_with_plankton.jl @@ -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), diff --git a/examples/ocean_wind_mixing_and_convection.jl b/examples/ocean_wind_mixing_and_convection.jl index b768817832..2603ce510d 100644 --- a/examples/ocean_wind_mixing_and_convection.jl +++ b/examples/ocean_wind_mixing_and_convection.jl @@ -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(), diff --git a/examples/one_dimensional_diffusion.jl b/examples/one_dimensional_diffusion.jl index 4f919f42f9..a8df941f6a 100644 --- a/examples/one_dimensional_diffusion.jl +++ b/examples/one_dimensional_diffusion.jl @@ -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 diff --git a/examples/two_dimensional_turbulence.jl b/examples/two_dimensional_turbulence.jl index 833e1478d3..a8b7b58ba4 100644 --- a/examples/two_dimensional_turbulence.jl +++ b/examples/two_dimensional_turbulence.jl @@ -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) diff --git a/verification/stratified_couette_flow/stratified_couette_flow.jl b/verification/stratified_couette_flow/stratified_couette_flow.jl index 7020a9294e..b4ca7aee0f 100644 --- a/verification/stratified_couette_flow/stratified_couette_flow.jl +++ b/verification/stratified_couette_flow/stratified_couette_flow.jl @@ -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),