Skip to content

Commit dddde4a

Browse files
authored
Fix and test RoquetIdealizedNonlinearEquationOfState (#574)
Fix and test `RoquetIdealizedNonlinearEquationOfState`
2 parents e15ef87 + e5f4ffa commit dddde4a

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/Oceananigans.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export
3333
FPlane, BetaPlane,
3434

3535
# Buoyancy and equations of state
36-
BuoyancyTracer, SeawaterBuoyancy, LinearEquationOfState,
36+
BuoyancyTracer, SeawaterBuoyancy, LinearEquationOfState, RoquetIdealizedNonlinearEquationOfState,
3737

3838
# Surface waves via Craik-Leibovich equations
3939
SurfaceWaves,

src/buoyancy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const LinearSeawaterBuoyancy = SeawaterBuoyancy{FT, <:LinearEquationOfState} whe
230230
@inline haline_contractionᶜᶜᶠ(i, j, k, grid, eos, C) = @inbounds haline_contraction(ℑzᵃᵃᶠ(i, j, k, grid, C.T), ℑzᵃᵃᶠ(i, j, k, grid, C.S), Dᵃᵃᶠ(i, j, k, grid), eos)
231231

232232
@inline buoyancy_perturbation(i, j, k, grid, b::AbstractBuoyancy{<:AbstractNonlinearEquationOfState}, C) =
233-
- b.gravitational_acceleration * ρ′(i, j, k, grid, b.equation_of_state, C) / b.ρ₀
233+
- b.gravitational_acceleration * ρ′(i, j, k, grid, b.equation_of_state, C) / b.equation_of_state.ρ₀
234234

235235
#####
236236
##### Roquet et al 2015 idealized nonlinear equations of state

test/test_time_stepping.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ function time_stepping_works(arch, FT, Closure)
88
return true # Test that no errors/crashes happen when time stepping.
99
end
1010

11+
function time_stepping_works_with_nonlinear_eos(arch, FT, eos_type)
12+
grid = RegularCartesianGrid(FT; size=(16, 16, 16), length=(1, 2, 3))
13+
14+
eos = RoquetIdealizedNonlinearEquationOfState(eos_type)
15+
b = SeawaterBuoyancy(equation_of_state=eos)
16+
17+
model = Model(architecture=arch, float_type=FT, grid=grid, buoyancy=b)
18+
time_step!(model, 1, 1)
19+
20+
return true # Test that no errors/crashes happen when time stepping.
21+
end
22+
1123
function run_first_AB2_time_step_tests(arch, FT)
1224
add_ones(args...) = 1.0
1325
model = Model(grid=RegularCartesianGrid(FT; size=(16, 16, 16), length=(1, 2, 3)),
@@ -159,6 +171,16 @@ Closures = (ConstantIsotropicDiffusivity, ConstantAnisotropicDiffusivity,
159171
@test time_stepping_works(arch, FT, Closure)
160172
end
161173

174+
@testset "Idealized nonlinear equation of state" begin
175+
for arch in archs, FT in float_types
176+
for eos_type in keys(Oceananigans.optimized_roquet_coeffs)
177+
println(" Testing that time stepping works with " *
178+
"RoquetIdealizedNonlinearEquationOfState [$arch, $FT, $eos_type]")
179+
@test time_stepping_works_with_nonlinear_eos(arch, FT, eos_type)
180+
end
181+
end
182+
end
183+
162184
@testset "2nd-order Adams-Bashforth" begin
163185
println(" Testing 2nd-order Adams-Bashforth...")
164186
for arch in archs, FT in float_types

0 commit comments

Comments
 (0)