Skip to content

Commit ebf8597

Browse files
glwagnernavidcy
andauthored
Add to some of the text and fix progress for one degree simulation (#533)
* Update one_degree_simulation.jl * Update one_degree_simulation.jl * Update one_degree_simulation.jl * Update one_degree_simulation.jl --------- Co-authored-by: Navid C. Constantinou <[email protected]>
1 parent 03a4986 commit ebf8597

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

examples/one_degree_simulation.jl

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
# # One-degree global ocean simulation
22
#
33
# This example configures a global ocean--sea ice simulation at 1ᵒ horizontal resolution with
4-
# realistic bathymetry, few closures. The simulation is forced by JRA55 atmospheric reanalysis
5-
# and initialized by temperature and salinity from ECCO2 state estimate.
4+
# realistic bathymetry and a few closures including the "Gent-McWilliams" `IsopycnalSkewSymmetricDiffusivity`.
5+
# The simulation is forced by JRA55 atmospheric reanalysis
6+
# and initialized by temperature and salinity from the ECCO state estimate.
67
#
7-
# For this example, we need Oceananigans, ClimaOcean, and
8-
# CairoMakie to visualize the simulation. Also we need CFTime and Dates for date handling.
8+
# For this example, we need Oceananigans, ClimaOcean, Dates, and
9+
# CairoMakie to visualize the simulation.
910

1011
using ClimaOcean
1112
using ClimaOcean.ECCO
1213
using Oceananigans
1314
using Oceananigans.Units
1415
using Dates
1516
using Printf
16-
using ClimaOcean.ECCO: download_dataset
17-
18-
# ### Download necessary files to run the code
19-
20-
# ### ECCO files
21-
22-
start_date = DateTime(1993, 1, 1)
23-
stop_date = DateTime(1993, 12, 1)
24-
dates = range(start_date, step=Month(1), stop=stop_date)
25-
ecco_temperature = Metadata(:temperature; dates, dataset=ECCO4Monthly())
26-
ecco_salinity = Metadata(:salinity; dates, dataset=ECCO4Monthly())
2717

2818
# ### Grid and Bathymetry
2919

20+
# We start by constructing an underlying TripolarGrid at ~1 degree resolution,
21+
3022
arch = GPU()
3123
Nx = 360
3224
Ny = 180
@@ -35,21 +27,30 @@ Nz = 40
3527
z = exponential_z_faces(; Nz, depth=4000, h=34)
3628
underlying_grid = TripolarGrid(arch; size = (Nx, Ny, Nz), halo = (5, 5, 4), z)
3729

38-
## 75 interpolation passes smooth the bathymetry near Florida so that the Gulf Stream is able to flow:
30+
# Next, we build bathymetry on this grid, using interpolation passes to smooth the bathymetry.
31+
# With 2 major basins, we keep the Mediterranean (though we need to manually open the Gibraltar
32+
# Strait to connect it to the Atlantic):
33+
3934
bottom_height = regrid_bathymetry(underlying_grid;
4035
minimum_depth = 10,
4136
interpolation_passes = 10,
4237
major_basins = 2)
4338

44-
# For this bathymetry at this horizontal resolution we need to manually open the Gibraltar strait.
45-
grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height); active_cells_map=true)
39+
# We then incorporate the bathymetry into an ImmersedBoundaryGrid,
4640

47-
@info "We've built a grid:"
48-
@show grid
41+
grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height);
42+
active_cells_map=true)
4943

5044
# ### Restoring
5145
#
52-
# We include temperature and salinity surface restoring to ECCO data thoughout the water column.
46+
# We include temperature and salinity surface restoring to ECCO data from 1993 thoughout the water column.
47+
48+
start_date = DateTime(1993, 1, 1)
49+
stop_date = DateTime(1993, 12, 1)
50+
dates = range(start_date, step=Month(1), stop=stop_date)
51+
ecco_temperature = Metadata(:temperature; dates, dataset=ECCO4Monthly())
52+
ecco_salinity = Metadata(:salinity; dates, dataset=ECCO4Monthly())
53+
5354
restoring_rate = 1 / 3days
5455
mask = LinearlyTaperedPolarMask(southern=(-80, -70), northern=(70, 90), z=(z[1], 0))
5556

@@ -64,9 +65,8 @@ forcing = (T=FT, S=FS)
6465
# parameterization. We also include some explicit horizontal diffusivity.
6566

6667
eddy_closure = Oceananigans.TurbulenceClosures.IsopycnalSkewSymmetricDiffusivity(κ_skew=2e3, κ_symmetric=2e3)
67-
vertical_mixing = Oceananigans.TurbulenceClosures.CATKEVerticalDiffusivity(minimum_tke=1e-6)
6868
horizontal_viscosity = HorizontalScalarDiffusivity=4000)
69-
closure = (eddy_closure, horizontal_viscosity, vertical_mixing)
69+
vertical_mixing = Oceananigans.TurbulenceClosures.CATKEVerticalDiffusivity(minimum_tke=1e-6)
7070

7171
# ### Ocean simulation
7272
# Now we bring everything together to construct the ocean simulation.
@@ -77,7 +77,8 @@ free_surface = SplitExplicitFreeSurface(grid; substeps=70)
7777
momentum_advection = WENOVectorInvariant(order=5)
7878
tracer_advection = WENO(order=5)
7979

80-
ocean = ocean_simulation(grid; momentum_advection, tracer_advection, closure, forcing, free_surface)
80+
ocean = ocean_simulation(grid; momentum_advection, tracer_advection, forcing, free_surface,
81+
closure=(eddy_closure, horizontal_viscosity, vertical_mixing))
8182

8283
@info "We've built an ocean simulation with model:"
8384
@show ocean.model
@@ -118,17 +119,16 @@ function progress(sim)
118119
T = ocean.model.tracers.T
119120
e = ocean.model.tracers.e
120121
Tmin, Tmax = minimum(T), maximum(T)
121-
emin, emax = minimum(e), maximum(e)
122+
emax = maximum(e)
122123
umax = (maximum(abs, u), maximum(abs, v), maximum(abs, w))
123124

124-
125125
step_time = 1e-9 * (time_ns() - wall_time[])
126126

127-
msg1 = @sprintf("time: %s, iteration: %d, Δt: %s, ", prettytime(sim), iteration(sim), prettytime(sim.Δt))
128-
msg2 = @sprintf("max|u|: (%.2e, %.2e, %.2e) m s⁻¹, ", umax...)
129-
msg3 = @sprintf("extrema(T): (%.2f, %.2f) ᵒC, ", Tmin, Tmax)
130-
msg4 = @sprintf("extrema(e): (%.2f, %.2f) m² s⁻², ", emin, emax)
131-
msg5 = @sprintf("wall time: %s \n", prettytime(step_time))
127+
msg1 = @sprintf("Time: %s, iter: %d", prettytime(sim), iteration(sim))
128+
msg2 = @sprintf(", max|u|: (%.1e, %.1e, %.1e) m s⁻¹, ", umax...)
129+
msg3 = @sprintf(", extrema(T): (%.1f, %.1f) ᵒC, ", Tmin, Tmax)
130+
msg4 = @sprintf(", maximum(e): %.2f m² s⁻², ", emax)
131+
msg5 = @sprintf(", wall time: %s \n", prettytime(step_time))
132132

133133
@info msg1 * msg2 * msg3 * msg4 * msg5
134134

@@ -138,7 +138,7 @@ function progress(sim)
138138
end
139139

140140
# And add it as a callback to the simulation.
141-
add_callback!(simulation, progress, IterationInterval(100))
141+
add_callback!(simulation, progress, IterationInterval(1000))
142142

143143
# ### Output
144144
#

0 commit comments

Comments
 (0)