Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antarctic slope current example #8

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Changes from 8 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
02b697c
Set up grid with immersed boundary condition for ASC model, starting …
jlk9 Jul 5, 2023
3f7b23a
Adding sponge layers and coriolis, updated equations of state to be h…
jlk9 Jul 5, 2023
375b630
Added both sponge layers and relaxation forcings, and diffusivities a…
jlk9 Jul 5, 2023
2e28ce6
Created simulation run
jlk9 Jul 6, 2023
952b796
Fixed simulation time scale, set to run on GPU
jlk9 Jul 6, 2023
17da147
Printing out simulation
Jul 7, 2023
2c2cfea
Adding storage of output
jlk9 Jul 7, 2023
f7ae29f
Minor edits
Jul 7, 2023
8e27b2a
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
528c194
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
9656960
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
ba3f10a
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
1518f01
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
9eeebf2
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
fed4167
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
9fb7d9f
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
432b51f
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
5ae2bb0
Update examples/antarctic_slope_current_model.jl
jlk9 Jul 10, 2023
c7ee0f7
Adding some modules for new changes
jlk9 Jul 10, 2023
9035fcd
Created low-resolution model run that generates movie of model variab…
jlk9 Jul 13, 2023
8a216e8
Modified script for 5 day run
jlk9 Jul 14, 2023
90bb0f4
Added wind stress as a surface boundary condition
jlk9 Jul 19, 2023
9a26cb1
Added zonal average cross-section visualization
jlk9 Jul 21, 2023
788e573
Running with larger step size
jlk9 Jul 26, 2023
9836e44
Using smaller vertical stratification
jlk9 Jul 27, 2023
bb40c83
Minor edit
jlk9 Jul 27, 2023
c70a2ff
Minor edit
jlk9 Jul 27, 2023
820941e
Minor edit
jlk9 Jul 27, 2023
1650072
Running more tests
jlk9 Jul 28, 2023
0b43b1e
Trying hi-res model with custom beta plane
jlk9 Aug 2, 2023
3e25a6a
Testing different runs
jlk9 Aug 15, 2023
380708d
Added wind stress and relaxation sponge layers
jlk9 Aug 21, 2023
12a133e
Added speed data and plots
jlk9 Aug 23, 2023
cf94e3e
minor adds
jlk9 Aug 23, 2023
31d1748
Fixed boundary condition implementation
jlk9 Aug 24, 2023
aaf894c
Changed filename
jlk9 Aug 24, 2023
5cec281
Can now run full workflow remotely
Oct 20, 2023
72c7b05
Merge branch 'main' into asc_model_example
Oct 20, 2023
35181a6
Trying relaxation on boundaries again
jlk9 Oct 20, 2023
cc71c6f
Removed relaxation forcing
Oct 23, 2023
8fe96d1
Add sea ice package
Oct 31, 2023
9d590d8
Adding architecture field to SlabIceModel
jlk9 Oct 31, 2023
fc13b51
Cleaning up architecture field
jlk9 Oct 31, 2023
a15fc56
Still fixing grid architecture field
jlk9 Oct 31, 2023
e59a723
Adding architecture field to ice_ocean_model struct
jlk9 Oct 31, 2023
2b1196e
Add AbstractArchitecture
jlk9 Oct 31, 2023
1c5790f
Set up model run with ice
jlk9 Nov 1, 2023
10c77ff
Updated ice-ocean model, added architecture functions to SlabSeaIceMo…
jlk9 Nov 8, 2023
4d6be26
Added architecture functions to OceanIceModel
jlk9 Nov 8, 2023
64aa547
Fixed vorticity plot, added heat flux computations back in
jlk9 Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions examples/antarctic_slope_current_model.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@

#using CairoMakie
using Oceananigans
using Oceananigans.Units: minute, minutes, hour
using SeawaterPolynomials.TEOS10

# This file sets up a model that resembles the Antarctic Slope Current (ASC) model in the
# 2022 paper by Ian Eisenman

arch = GPU()

g_Earth = 9.80665
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be simpler to keep the defaults rather than change this. I made a comment though if we want to manually set this


Lx = 400000
Ly = 450000
Lz = 4000

Nx = 400
Ny = 450
Nz = 70 # TODO: modify spacing if needed, 10 m at surface, 100m at seafloor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we start with a smaller resolution? It'd be nice to test this on our laptops first


sponge_width = 20000
#=
#
# Setting up the grid and bathymetry:
#
# Using a linear slope that approximates the min and max spacings in the paper:
init_adjustment = (0.5*(100-10)/(Nz-1)) + (10 - (100-10)/(Nz-1))
linear_slope(k) = (0.5*(100-10)/(Nz-1))*(k)^2 + (10 - (100-10)/(Nz-1))*(k) - init_adjustment

spacing_adjustment = Lz / linear_slope(Nz+1)
linear_slope_z_faces(k) = -spacing_adjustment * linear_slope(k)
# Can reverse this to get grid from -4000 to 0 later
=#
refinement = 20.0 # controls spacing near surface (higher means finer spaced), 12.0
stretching = 3 # controls rate of stretching at bottom, 3

# Normalized height ranging from 0 to 1
h(k) = (k - 1) / Nz

# Linear near-surface generator
ζ₀(k) = 1 + (h(k) - 1) / refinement

# Bottom-intensified stretching function
Σ(k) = (1 - exp(-stretching * h(k))) / (1 - exp(-stretching))

# Generating function
z_faces(k) = Lz * (ζ₀(k) * Σ(k) - 1)

underlying_grid = RectilinearGrid(arch,
size = (Nx, Ny, Nz),
topology = (Periodic, Bounded, Bounded),
x = (-Lx/2, Lx/2),
y = (0, Ly),
z = z_faces)

println(underlying_grid)

# We want the underwater slope to provide a depth of 500 m at y = 0 and the full 4 km by y =200. It follows
# a hyperbolic tangent curve with its center at y ~= 150 at a depth of ~ -4000 + (4000 - 500)/2 = -2250 m
underwater_slope(x, y) = -1750tanh(0.00004*(y - 150000)) - 2250
# TODO: add 50km troughs to the slope, dependent on x and y. Use appendix C to add detail here

grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(underwater_slope))

println(grid)

# TODO: add underwater slope at y = 0 with troughs

#
# Creating the Hydrostatic model:
#

# Forcings:
u_forcing(x, y, z, t) = exp(z) * cos(x) * sin(t) # Not actual forcing, just example

# TODO: need to use forcings to enact the sponge layers. Their support is within 20000 m
# of the N/S boundaries, they impose a cross-slope buoyancy gradient, and the relaxation
# tiem scales decrease linearly with distance from the interior termination of the sponge layers

# We'll use Relaxation() to impose a sponge layer forcing on velocity, temperature, and salinity
damping_rate = 1 / 43200 # Relaxation time scale in seconds, need to make this decrease linearly toward outermost boundary
south_mask = GaussianMask{:y}(center=0, width=sponge_width)
north_mask = GaussianMask{:y}(center=Ly, width=sponge_width)
south_sponge_layer = Relaxation(; rate=damping_rate, mask=south_mask)
north_sponge_layer = Relaxation(; rate=damping_rate, mask=north_mask)
sponge_layers = (south_sponge_layer, north_sponge_layer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try running without the sponge layer to start

# TODO: compose north_mask and south_mask together into one sponge layer, OR compose north/south sponge layers


# Boundary Conditions:
no_slip_bc = ValueBoundaryCondition(0.0)
free_slip_bc = FluxBoundaryCondition(nothing)

free_slip_surface_bcs = FieldBoundaryConditions(no_slip_bc, top=FluxBoundaryCondition(nothing))
no_slip_field_bcs = FieldBoundaryConditions(no_slip_bc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to impose no slip conditions here (even if it was used in the original Si and Stewart). We just need the momentum fluxes for u and v at the surface to start. We can also add bottom drag for u and v but this is a detail we can get to later


# Buoyancy Equations of State - we want high order polynomials, so we'll use TEOS-10
eos = TEOS10EquationOfState()

# Coriolis Effect, using basic f-plane with precribed reference Coriolis parameter
coriolis = FPlane(f=-1.3e14)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps insert the reference latitude here? Eg something like

coriolis = FPlane(latitude=-60)


# Diffusivities as part of closure
# TODO: make sure this works for biharmonic diffusivities as the horizontal,
horizontal_closure = HorizontalScalarDiffusivity(ν=0.1, κ=0.1)
vertical_closure = VerticalScalarDiffusivity(ν=3e-4, κ=1e-5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need biharmonic or a background diffusivity if we use WENO + CATKE, so we can eliminate these


# Assuming no particles or biogeochemistry
model = HydrostaticFreeSurfaceModel(; grid,
clock = Clock{eltype(grid)}(0, 0, 1),
momentum_advection = CenteredSecondOrder(),
tracer_advection = CenteredSecondOrder(),
buoyancy = SeawaterBuoyancy(equation_of_state=eos),
coriolis = coriolis,
free_surface = ImplicitFreeSurface(gravitational_acceleration=g_Earth),
forcing = (u=sponge_layers, v=sponge_layers, w=sponge_layers, T=sponge_layers, S=sponge_layers), # NamedTuple()
closure = (horizontal_closure, vertical_closure),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can rely entirely on WENO for horizontal dissipation. The only closure we need is for vertical mixing.

boundary_conditions = (u=free_slip_surface_bcs, v=free_slip_surface_bcs, w=no_slip_field_bcs), # NamedTuple(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note we can't set boundary conditions on w in a hydrostatic model.

tracers = (:T, :S),
velocities = nothing,
pressure = nothing,
diffusivity_fields = nothing,
#auxiliary_fields = nothing, # NamedTuple(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the unused kwargs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
velocities = nothing,
pressure = nothing,
diffusivity_fields = nothing,
#auxiliary_fields = nothing, # NamedTuple(),

)

println(model)

println("u boundary conditions:")
println(model.velocities.u.boundary_conditions)
println("v boundary conditions:")
println(model.velocities.v.boundary_conditions)
println("w boundary conditions:")
println(model.velocities.w.boundary_conditions)

#
# Now create a simulation and run the model
#
simulation = Simulation(model; Δt=100.0, stop_time=600minutes)

# Create a NamedTuple

filename = "asc_model_run"

simulation.output_writers[:slices] =
JLD2OutputWriter(model, merge(model.velocities, model.tracers),
filename = filename * ".jld2",
indices = (:, grid.Ny/2, :),
schedule = TimeInterval(1minute),
overwrite_existing = true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most interesting output will be a slice at the surface, eg using

indices = (:, :, grid.Nz)

so make sure to always output that


run!(simulation)

println(simulation)