Skip to content

Commit c79685e

Browse files
authored
Merge pull request #39 from jagoosw/jsw/add-biogeochemistry-interface
Adds biogeochemistry interface + fix example to work out of the box
2 parents a0e0fc0 + 06f3c7e commit c79685e

5 files changed

+26
-11
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "ClimaOcean"
22
uuid = "0376089a-ecfe-4b0e-a64f-9c555d74d754"
33
license = "MIT"
44
authors = ["Climate Modeling Alliance and contributors"]
5-
version = "0.1.0"
5+
version = "0.1.2"
66

77
[deps]
88
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

examples/one_degree_near_global_simulation.jl

+11-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ using Oceananigans.Models.HydrostaticFreeSurfaceModels: VerticalVorticityField
88
using Oceananigans.TurbulenceClosures.CATKEVerticalDiffusivities:
99
MixingLength, TurbulentKineticEnergyEquation, CATKEVerticalDiffusivity
1010

11-
using ParameterEstimocean.Parameters: closure_with_parameters
11+
#using ParameterEstimocean.Parameters: closure_with_parameters
1212
using JLD2
1313

14+
const years = 365days
15+
16+
architecuture = GPU()
17+
1418
#####
1519
##### Boundary layer turbulence closure options
1620
#####
1721

1822
# "Ri-based" --- uses calibrated defaults in Oceananigans
1923
ri_based = RiBasedVerticalDiffusivity()
20-
24+
#=
2125
# CATKE with calibrated parameters loaded from file
2226
neutral_default_mixing_length_parameters = (Cᵇu = Inf, Cᵇc = Inf, Cᵇe = Inf,
2327
Cˢu = Inf, Cˢc = Inf, Cˢe = Inf,
@@ -36,8 +40,9 @@ catke_parameters = load(catke_parameters_filename, "mean") # load ensemble mean
3640
3741
catke = closure_with_parameters(neutral_catke, catke_parameters)
3842
43+
=#
3944
# Choose closure
40-
boundary_layer_turbulence_closure = catke
45+
boundary_layer_turbulence_closure = ri_based#catke
4146

4247
@show boundary_layer_turbulence_closure
4348

@@ -49,7 +54,8 @@ start_time = 345days
4954
stop_time = start_time + 2years
5055
with_isopycnal_skew_symmetric_diffusivity = true
5156

52-
simulation = one_degree_near_global_simulation(; start_time, stop_time,
57+
simulation = one_degree_near_global_simulation(architecure;
58+
start_time, stop_time,
5359
with_isopycnal_skew_symmetric_diffusivity,
5460
boundary_layer_turbulence_closure,
5561
isopycnal_κ_skew = 900.0,
@@ -63,7 +69,7 @@ slices_save_interval = 2day
6369
fields_save_interval = 10days
6470
Nx, Ny, Nz = size(simulation.model.grid)
6571

66-
dir = "/storage1/greg"
72+
dir = "."
6773
closure_name = typeof(boundary_layer_turbulence_closure).name.wrapper
6874
output_prefix = "near_global_$(Nx)_$(Ny)_$(Nz)_$closure_name"
6975
with_isopycnal_skew_symmetric_diffusivity || (output_prefix *= "_no_gm")

src/NearGlobalSimulations/NearGlobalSimulations.jl

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ function leith_viscosity(formulation; C_vort = 3.0, C_div = 3.0)
144144
parameters = (; Cζ, Cδ))
145145
end
146146

147+
NoBiogeochemistry(args...; kwargs...) = nothing
148+
147149
include("one_degree_global_simulation.jl")
148150
include("quarter_degree_global_simulation.jl")
149151

src/NearGlobalSimulations/one_degree_global_simulation.jl

+8-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ function one_degree_near_global_simulation(architecture = GPU();
3131
initial_conditions = datadep"near_global_one_degree/initial_conditions_month_01_360_150_48.jld2",
3232
bathymetry_path = datadep"near_global_one_degree/bathymetry_lat_lon_360_150.jld2",
3333
surface_boundary_conditions_path = datadep"near_global_one_degree/surface_boundary_conditions_12_months_360_150.jld2",
34+
biogeochemistry = NoBiogeochemistry,
35+
biogeochemistry_kwargs = (),
36+
progress_callback = false,
3437
)
3538

3639
size == (360, 150, 48) || throw(ArgumentError("Only size = (360, 150, 48) is supported."))
@@ -104,7 +107,7 @@ function one_degree_near_global_simulation(architecture = GPU();
104107

105108
vitd = VerticallyImplicitTimeDiscretization()
106109

107-
horizontal_κ = (T=0, S=0, e=horizontal_tke_diffusivity)
110+
horizontal_κ = merge(NamedTuple{tracers}([0 for tracer in tracers]), (e = horizontal_tke_diffusivity, ))
108111
horizontal_diffusivity = HorizontalScalarDiffusivity=horizontal_viscosity, κ=horizontal_κ)
109112
vertical_viscosity = VerticalScalarDiffusivity(vitd, ν=νz, κ=background_vertical_diffusivity)
110113

@@ -186,7 +189,7 @@ function one_degree_near_global_simulation(architecture = GPU();
186189

187190
equation_of_state = TEOS10EquationOfState(; reference_density)
188191
buoyancy = SeawaterBuoyancy(; equation_of_state)
189-
coriolis = HydrostaticSphericalCoriolis(scheme = ActiveCellEnstrophyConservingScheme())
192+
coriolis = HydrostaticSphericalCoriolis()
190193
free_surface = ImplicitFreeSurface()
191194

192195
@info "Building a model..."; start=time_ns()
@@ -195,7 +198,8 @@ function one_degree_near_global_simulation(architecture = GPU();
195198
momentum_advection = VectorInvariant(),
196199
tracer_advection = WENO(underlying_grid),
197200
closure = closures,
198-
boundary_conditions = (u=u_bcs, v=v_bcs, T=T_bcs, S=S_bcs))
201+
boundary_conditions = (u=u_bcs, v=v_bcs, T=T_bcs, S=S_bcs),
202+
biogeochemistry = biogeochemistry(; grid, biogeochemistry_kwargs...))
199203

200204
@info "... built $model."
201205
@info "Model building time: " * prettytime(1e-9 * (time_ns() - start))
@@ -237,7 +241,7 @@ function one_degree_near_global_simulation(architecture = GPU();
237241
return nothing
238242
end
239243

240-
simulation.callbacks[:progress] = Callback(progress, IterationInterval(10))
244+
progress_callback && (simulation.callbacks[:progress] = Callback(progress, IterationInterval(10)))
241245

242246
return simulation
243247
end

src/NearGlobalSimulations/quarter_degree_global_simulation.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ function quarter_degree_near_global_simulation(architecture = GPU();
3030
salt_surface_boundary_conditions_path = datadep"near_global_quarter_degree/salt-1440x600-latitude-75.jld2",
3131
u_stress_surface_boundary_conditions_path = datadep"near_global_quarter_degree/tau_x-1440x600-latitude-75.jld2",
3232
v_stress_surface_boundary_conditions_path = datadep"near_global_quarter_degree/tau_y-1440x600-latitude-75.jld2",
33+
biogeochemistry = NoBiogeochemistry,
34+
biogeochemistry_kwargs = ()
3335
)
3436

3537
bathymetry_file = jldopen(bathymetry_path)
@@ -164,7 +166,8 @@ function quarter_degree_near_global_simulation(architecture = GPU();
164166
vertical_scheme = WENO()),
165167
closure = closures,
166168
boundary_conditions = (u=u_bcs, v=v_bcs, T=T_bcs, S=S_bcs),
167-
tracer_advection = WENO(underlying_grid))
169+
tracer_advection = WENO(underlying_grid),
170+
biogeochemistry = biogeochemistry(; grid, biogeochemistry_kwargs...))
168171

169172
@info "... built $model."
170173
@info "Model building time: " * prettytime(1e-9 * (time_ns() - start))

0 commit comments

Comments
 (0)