-
Notifications
You must be signed in to change notification settings - Fork 7
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
Interpolated inital conditions #60
Changes from 8 commits
99ec13e
fad2080
b8c915e
f94d25e
f6eece4
b2af7c1
3eab9e7
fe2e521
29a61d4
9d90b08
f10b9f1
9f22cfd
02112d1
59a39cf
8f39ee1
9f29882
9790836
aa7c2d8
be3bff8
351debc
75dbdf7
a2aff1a
fc59ff8
c3d145b
0a04d6a
7caf635
a611a27
0f9ec22
aae87fd
90ec6f8
7a81f63
84ae45d
1923c2d
6822280
a81496e
7c52982
333a15b
2ca7a89
a4f7e1d
a4a7185
cb1c451
9ab3093
abf3b25
48109ca
9ce454b
60393b9
6efc275
3844970
dbb7256
1cfe3f9
cf2beaa
4cc11de
67ba1e7
8f7e2ea
3234942
6f08f78
dc1303b
353992b
a9fe0a5
fd4aaf0
6bb9422
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using GLMakie | ||
using Oceananigans | ||
using Oceananigans: architecture | ||
using Oceananigans.Utils: prettytime | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is exported I think? |
||
using ClimaOcean.Bathymetry: regrid_bathymetry | ||
using ClimaOcean.ECCO2: ecco2_field, ecco2_center_mask | ||
using ClimaOcean.VerticalGrids: stretched_vertical_faces, PowerLawStretching | ||
using ClimaOcean.InitialConditions: three_dimensional_regrid!, adjust_tracers! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we start exporting all the things we need so we don't have to have these big |
||
using Oceananigans.TurbulenceClosures.CATKEVerticalDiffusivities: CATKEVerticalDiffusivity | ||
using Oceananigans.Coriolis: ActiveCellEnstrophyConserving | ||
|
||
##### | ||
##### Regional Mediterranean grid | ||
##### | ||
|
||
function regrid_ecco_tracers_to_grid(grid) | ||
Tecco = ecco2_field(:temperature) | ||
Secco = ecco2_field(:salinity) | ||
|
||
ecco_tracers = (; Tecco, Secco) | ||
|
||
# Make sure all values are extended properly before regridding | ||
adjust_tracers!(ecco_tracers; mask = ecco2_center_mask(architecture(grid))) | ||
|
||
T = CenterField(grid) | ||
S = CenterField(grid) | ||
|
||
three_dimensional_regrid!(T, Tecco) | ||
three_dimensional_regrid!(S, Secco) | ||
|
||
return T, S | ||
end | ||
|
||
# A stretched vertical grid with a Δz of 1.5 meters in the first 50 meters | ||
z = stretched_vertical_faces(minimum_depth = 5000, | ||
surface_layer_Δz = 1.75, | ||
stretching = PowerLawStretching(1.070), | ||
surface_layer_height = 50) | ||
|
||
Nx = 20 * 42 # 1 / 20th of a degree | ||
Ny = 20 * 15 # 1 / 20th of a degree | ||
Nz = length(z) - 1 | ||
|
||
grid = LatitudeLongitudeGrid(GPU(); | ||
size = (Nx, Ny, Nz), | ||
latitude = (30, 45), | ||
longitude = (0, 42), | ||
z, | ||
halo = (7, 7, 7)) | ||
|
||
h = regrid_bathymetry(grid, height_above_water=1) | ||
|
||
grid = ImmersedBoundaryGrid(grid, GridFittedBottom(h)) | ||
|
||
T, S = regrid_ecco_tracers_to_grid(grid) | ||
|
||
mask_immersed_field!(T) | ||
mask_immersed_field!(S) | ||
|
||
# fig = Figure() | ||
# ax = Axis(fig[1, 1]) | ||
# heatmap!(ax, interior(T, :, :, Nz), colorrange = (10, 20), colormap = :thermal) | ||
# ax = Axis(fig[1, 2]) | ||
# heatmap!(ax, interior(S, :, :, Nz), colorrange = (35, 40), colormap = :haline) | ||
|
||
# Correct oceananigans | ||
import Oceananigans.Advection: nothing_to_default | ||
|
||
nothing_to_default(user_value; default) = isnothing(user_value) ? default : user_value | ||
|
||
# Construct the model and run it, will it run or we have to diffuse? | ||
model = HydrostaticFreeSurfaceModel(; grid, | ||
momentum_advection = WENOVectorInvariant(), | ||
tracer_advection = WENO(grid; order = 7), | ||
free_surface = SplitExplicitFreeSurface(; cfl = 0.75, grid), | ||
closure = CATKEVerticalDiffusivity(), | ||
buoyancy = SeawaterBuoyancy(), | ||
tracers = (:T, :S, :e), | ||
coriolis = HydrostaticSphericalCoriolis(scheme = ActiveCellEnstrophyConserving())) | ||
|
||
set!(model, T = T, S = S) | ||
|
||
# Probably we'll need to diffuse? Probably not let's see now | ||
|
||
simulation = Simulation(model, Δt = 20, stop_time = 2days) | ||
|
||
function progress(sim) | ||
u, v, w = sim.model.velocities | ||
T, S = sim.model.tracers | ||
|
||
@info @sprintf("Time: %s, Iteration %d, Δt %s, max(vel): (%.2e, %.2e, %.2e), max(T, S): %.2f, %.2f\n", | ||
prettytime(sim.model.clock.time), | ||
sim.model.clock.iteration, | ||
prettytime(sim.Δt), | ||
maximum(abs, u), maximum(abs, v), maximum(abs, w), | ||
maximum(abs, T), maximum(abs, S)) | ||
end | ||
|
||
simulation.callbacks[:progress] = Callback(progress, IterationInterval(100)) | ||
|
||
# warm up! | ||
run!(simulation) | ||
|
||
simulation.stop_time = 10*365days | ||
|
||
wizard = TimeStepWizard(; cfl = 0.2, max_Δt = 2minutes, max_change = 1.1) | ||
|
||
simulation.callbacks = Callback(wizard, IterationInterval(10)) | ||
|
||
simulation.output_writers[:surface_fields] = JLD2OutputWriter(model, merge(model.velocities, model.tracers); | ||
indices = (:, :, Nz), | ||
schedule = TimeInterval(1day), | ||
overwrite_existing = true, | ||
filename = "med_surface_field") | ||
|
||
run!(simulation) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to figure out how to get rid of this so users don' thave to worry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed