Skip to content

Commit f4441f3

Browse files
authored
Merge pull request #183 from jbisits/joey-fixtest
Relax to approx in test + remove unnecessary saved output
2 parents 3b54557 + dbe7eb2 commit f4441f3

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TwoLayerDirectNumericalShenanigans"
22
uuid = "40aaee9f-3595-48be-b36c-f1067009652f"
33
authors = ["Josef Bisits <[email protected]>"]
4-
version = "0.6.3"
4+
version = "0.6.4"
55

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

src/TwoLayerDirectNumericalShenanigans.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using SeawaterPolynomials: BoussinesqEquationOfState, ρ
77
using SeawaterPolynomials.TEOS10
88
using SeawaterPolynomials.SecondOrderSeawaterPolynomials
99
using SpecialFunctions: erf
10-
using Oceanostics: KineticEnergyDissipationRate, KineticEnergy
10+
using Oceanostics: KineticEnergyDissipationRate, KineticEnergy, PotentialEnergy
1111
using CUDA: allowscalar, CuArray
1212
import Base: show, iterate
1313

src/twolayerdns.jl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,28 +294,19 @@ function save_computed_output!(simulation, tldns, save_schedule, save_file, outp
294294
ϵ_maximum = Reduction(maximum!, ϵ, dims = (1, 2, 3))
295295
Eₖ = KineticEnergy(model)
296296
∫Eₖ = Integral(Eₖ)
297-
Eₚ = potential_energy(model)
297+
Eₚ = PotentialEnergy(model)
298298
∫Eₚ = Integral(Eₚ)
299299

300-
# Horizontally integrated vertical temperature flux and vertical temperature gradient
301-
T = model.tracers.T
302-
w′T′ = vertical_tracer_flux(model, T)
303-
∫ₐw′T′ = Integral(w′T′, dims = (1, 2))
304-
∂T∂z = ∂z(T)
305-
∫ₐ∂T∂z = Integral(∂T∂z, dims = (1, 2))
306-
307300
computed_outputs = Dict("σ" => σ, "∫ϵ" => ∫ϵ, "ϵ_maximum" => ϵ_maximum, "∫Eₖ" => ∫Eₖ,
308-
"∫Eₚ" => ∫Eₚ, "∫ₐ∂T∂z" => ∫ₐ∂T∂z, "∫ₐw′T′" => ∫ₐw′T′)
301+
"∫Eₚ" => ∫Eₚ)
309302

310303
oa = Dict(
311304
"σ" => Dict("longname" => "Seawater potential density calculated using TEOS-10 at $(reference_gp_height)dbar",
312305
"units" => "kgm⁻³"),
313306
"ϵ_maximum" => Dict("longname" => "Maximum (in space) TKE dissipation"),
314307
"∫ϵ" => Dict("longname" => "Volume integrated turbulent kintetic energy dissipation"),
315308
"∫Eₖ" => Dict("longname" => "Volume integrated turbulent kinetic energy"),
316-
"∫Eₚ" => Dict("longname" => "Volume integrated potential energy (g∫ᵥρzdV)"),
317-
"∫ₐw′T′" => Dict("longname" => "Horizontally integrated vertical temeprature flux"),
318-
"∫ₐ∂T∂z" => Dict("longname" => "Horizontally integrated vertical temperature gradient")
309+
"∫Eₚ" => Dict("longname" => "Volume integrated potential energy (g∫ᵥρzdV)")
319310
)
320311
simulation.output_writers[:computed_output] =
321312
save_file == :netcdf ? NetCDFOutputWriter(model, computed_outputs;

test/runtests.jl

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,36 +172,38 @@ include("output_test.jl")
172172
simulation, td, tldns = run_sim(:netcdf)
173173
NCDataset(simulation.output_writers[:tracers].filepath) do ds
174174
S, T = ds[:S], ds[:T]
175-
@test all(S[:, :, 1:td, :] .== tldns.initial_conditions.S₀ˡ)
176-
@test all(S[:, :, td+1:end, :] .== tldns.initial_conditions.S₀ᵘ)
177-
@test all(T[:, :, 1:td, :] .== tldns.initial_conditions.T₀ˡ)
178-
@test all(T[:, :, td+1:end, :] .== tldns.initial_conditions.T₀ᵘ)
175+
@test all(S[:, :, 1:td, :] . tldns.initial_conditions.S₀ˡ)
176+
@test all(S[:, :, td+1:end, :] . tldns.initial_conditions.S₀ᵘ)
177+
@test all(T[:, :, 1:td, :] . tldns.initial_conditions.T₀ˡ)
178+
@test all(T[:, :, td+1:end, :] . tldns.initial_conditions.T₀ᵘ)
179179
end
180180
NCDataset(simulation.output_writers[:computed_output].filepath) do ds
181181
σ = ds[]
182-
@test all(σ[:, :, 1:td, :] .== SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ˡ,
183-
tldns.initial_conditions.S₀ˡ, 0,
184-
tldns.model.buoyancy.model.equation_of_state))
185-
@test all(σ[:, :, td+1:end, :] .== SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ᵘ,
186-
tldns.initial_conditions.S₀ᵘ, 0,
187-
tldns.model.buoyancy.model.equation_of_state))
182+
@test all(σ[:, :, 1:td, :] .≈
183+
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ˡ,
184+
tldns.initial_conditions.S₀ˡ, 0,
185+
tldns.model.buoyancy.model.equation_of_state))
186+
@test all(σ[:, :, td+1:end, :] .≈
187+
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ᵘ,
188+
tldns.initial_conditions.S₀ᵘ, 0,
189+
tldns.model.buoyancy.model.equation_of_state))
188190
end
189191
end
190192

191193
@testset "jld2" begin
192194
simulation, td, tldns = run_sim(:jld2)
193195
S = FieldTimeSeries(simulation.output_writers[:tracers].filepath, "S")
194196
T = FieldTimeSeries(simulation.output_writers[:tracers].filepath, "T")
195-
@test all(S.data[:, :, 1:td, :] .== tldns.initial_conditions.S₀ˡ)
196-
@test all(S.data[:, :, td+1:end, :] .== tldns.initial_conditions.S₀ᵘ)
197-
@test all(T.data[:, :, 1:td, :] .== tldns.initial_conditions.T₀ˡ)
198-
@test all(T.data[:, :, td+1:end, :] .== tldns.initial_conditions.T₀ᵘ)
197+
@test all(S.data[:, :, 1:td, :] . tldns.initial_conditions.S₀ˡ)
198+
@test all(S.data[:, :, td+1:end, :] . tldns.initial_conditions.S₀ᵘ)
199+
@test all(T.data[:, :, 1:td, :] . tldns.initial_conditions.T₀ˡ)
200+
@test all(T.data[:, :, td+1:end, :] . tldns.initial_conditions.T₀ᵘ)
199201
σ = FieldTimeSeries(simulation.output_writers[:computed_output].filepath, "σ")
200-
@test all.data[:, :, 1:td, :] .==
202+
@test all.data[:, :, 1:td, :] .
201203
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ˡ,
202204
tldns.initial_conditions.S₀ˡ, 0,
203205
tldns.model.buoyancy.model.equation_of_state))
204-
@test all.data[:, :, td+1:end, :] .==
206+
@test all.data[:, :, td+1:end, :] .
205207
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ᵘ,
206208
tldns.initial_conditions.S₀ᵘ, 0,
207209
tldns.model.buoyancy.model.equation_of_state))

0 commit comments

Comments
 (0)