Skip to content

Commit 209d82f

Browse files
Change the one-degree example top vertical resolution from ~50m to ~8m (#591)
* change the top vertical resolution to ~8m * 6min * debug * debug * day -> days * Update one_degree_simulation.jl * tests * bugfix + smaller dt * works now? * simplify * bring back all examples * reclaim CUDA memory after each literated example --------- Co-authored-by: Simone Silvestri <[email protected]>
1 parent 2d367ec commit 209d82f

File tree

2 files changed

+21
-28
lines changed

2 files changed

+21
-28
lines changed

docs/make.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using
22
ClimaOcean,
3+
CUDA,
34
Documenter,
45
DocumenterCitations,
56
Literate
@@ -27,6 +28,8 @@ for file in to_be_literated
2728
withenv("JULIA_DEBUG" => "Literate") do
2829
Literate.markdown(filepath, OUTPUT_DIR; flavor = Literate.DocumenterFlavor(), execute = true)
2930
end
31+
GC.gc()
32+
CUDA.reclaim()
3033
end
3134

3235
#####

examples/one_degree_simulation.jl

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ using CUDA
2424
arch = GPU()
2525
Nx = 360
2626
Ny = 180
27-
Nz = 40
27+
Nz = 50
28+
29+
depth = 5000meters
30+
z = ExponentialCoordinate(Nz, -depth, 0; scale = depth/4)
2831

29-
depth = 4000meters
30-
z = ExponentialCoordinate(Nz, -depth, 0; scale = 0.85*depth)
31-
z = Oceananigans.Grids.MutableVerticalDiscretization(z)
3232
underlying_grid = TripolarGrid(arch; size = (Nx, Ny, Nz), halo = (5, 5, 4), z)
3333

3434
# Next, we build bathymetry on this grid, using interpolation passes to smooth the bathymetry.
@@ -49,29 +49,29 @@ grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height);
4949
#
5050
# We include a Gent-McWilliams isopycnal diffusivity as a parameterization for the mesoscale
5151
# eddy fluxes. For vertical mixing at the upper-ocean boundary layer we include the CATKE
52-
# parameterization. We also include some explicit horizontal diffusivity.
52+
# parameterization.
5353

54-
eddy_closure = Oceananigans.TurbulenceClosures.IsopycnalSkewSymmetricDiffusivity(κ_skew=2e3, κ_symmetric=2e3)
54+
eddy_closure = Oceananigans.TurbulenceClosures.IsopycnalSkewSymmetricDiffusivity(κ_skew=1e3, κ_symmetric=1e3)
5555
vertical_mixing = ClimaOcean.OceanSimulations.default_ocean_closure()
56-
horizontal_viscosity = HorizontalScalarDiffusivity=4000)
5756

5857
# ### Ocean simulation
5958
# Now we bring everything together to construct the ocean simulation.
60-
# We use a split-explicit timestepping with 70 substeps for the barotropic
61-
# mode.
59+
# We use a split-explicit timestepping with 70 substeps for the barotropic mode.
6260

6361
free_surface = SplitExplicitFreeSurface(grid; substeps=70)
6462
momentum_advection = WENOVectorInvariant(order=5)
6563
tracer_advection = WENO(order=5)
6664

6765
ocean = ocean_simulation(grid; momentum_advection, tracer_advection, free_surface,
68-
closure=(eddy_closure, horizontal_viscosity, vertical_mixing))
66+
timestepper = :SplitRungeKutta3,
67+
closure=(eddy_closure, vertical_mixing))
6968

7069
@info "We've built an ocean simulation with model:"
7170
@show ocean.model
7271

7372
# ### Sea Ice simulation
74-
# We also need to build a sea ice simulation. We use the default configuration:
73+
#
74+
# We also build a sea ice simulation. We use the default configuration:
7575
# EVP rheology and a zero-layer thermodynamic model that advances thickness
7676
# and concentration.
7777

@@ -84,8 +84,8 @@ sea_ice = sea_ice_simulation(grid, ocean; advection=tracer_advection)
8484
date = DateTime(1993, 1, 1)
8585
dataset = ECCO4Monthly()
8686
ecco_temperature = Metadatum(:temperature; date, dataset)
87-
ecco_salinity = Metadatum(:salinity; date, dataset)
88-
ecco_sea_ice_thickness = Metadatum(:sea_ice_thickness; date, dataset)
87+
ecco_salinity = Metadatum(:salinity; date, dataset)
88+
ecco_sea_ice_thickness = Metadatum(:sea_ice_thickness; date, dataset)
8989
ecco_sea_ice_concentration = Metadatum(:sea_ice_concentration; date, dataset)
9090

9191
set!(ocean.model, T=ecco_temperature, S=ecco_salinity)
@@ -103,12 +103,10 @@ atmosphere = JRA55PrescribedAtmosphere(arch; backend=JRA55NetCDFBackend(80),
103103
# Now we are ready to build the coupled ocean--sea ice model and bring everything
104104
# together into a `simulation`.
105105

106-
# We use a relatively short time step initially and only run for a few days to
107-
# avoid numerical instabilities from the initial "shock" of the adjustment of the
108-
# flow fields.
106+
# With Runge-Kutta 3rd order time-stepping we can safely use a timestep of 20 minutes.
109107

110108
coupled_model = OceanSeaIceModel(ocean, sea_ice; atmosphere, radiation)
111-
simulation = Simulation(coupled_model; Δt=8minutes, stop_time=20days)
109+
simulation = Simulation(coupled_model; Δt=20minutes, stop_time=365days)
112110

113111
# ### A progress messenger
114112
#
@@ -141,7 +139,7 @@ function progress(sim)
141139
end
142140

143141
# And add it as a callback to the simulation.
144-
add_callback!(simulation, progress, IterationInterval(1000))
142+
add_callback!(simulation, progress, TimeInterval(5days))
145143

146144
# ### Output
147145
#
@@ -157,27 +155,19 @@ sea_ice_outputs = merge((h = sea_ice.model.ice_thickness,
157155
sea_ice.model.velocities)
158156

159157
ocean.output_writers[:surface] = JLD2Writer(ocean.model, ocean_outputs;
160-
schedule = TimeInterval(5days),
158+
schedule = TimeInterval(1days),
161159
filename = "ocean_one_degree_surface_fields",
162160
indices = (:, :, grid.Nz),
163161
overwrite_existing = true)
164162

165163
sea_ice.output_writers[:surface] = JLD2Writer(ocean.model, sea_ice_outputs;
166-
schedule = TimeInterval(5days),
164+
schedule = TimeInterval(1days),
167165
filename = "sea_ice_one_degree_surface_fields",
168166
overwrite_existing = true)
169167

170168
# ### Ready to run
171169

172170
# We are ready to press the big red button and run the simulation.
173-
174-
# After we run for a short time (here we set up the simulation with `stop_time = 20days`),
175-
# we increase the timestep and run for longer.
176-
177-
run!(simulation)
178-
179-
simulation.Δt = 30minutes
180-
simulation.stop_time = 365days
181171
run!(simulation)
182172

183173
# ### A movie

0 commit comments

Comments
 (0)