Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax to approx in test + remove unnecessary saved output #183

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TwoLayerDirectNumericalShenanigans"
uuid = "40aaee9f-3595-48be-b36c-f1067009652f"
authors = ["Josef Bisits <[email protected]>"]
version = "0.6.3"
version = "0.6.4"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand Down
2 changes: 1 addition & 1 deletion src/TwoLayerDirectNumericalShenanigans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using SeawaterPolynomials: BoussinesqEquationOfState, ρ
using SeawaterPolynomials.TEOS10
using SeawaterPolynomials.SecondOrderSeawaterPolynomials
using SpecialFunctions: erf
using Oceanostics: KineticEnergyDissipationRate, KineticEnergy
using Oceanostics: KineticEnergyDissipationRate, KineticEnergy, PotentialEnergy
using CUDA: allowscalar, CuArray
import Base: show, iterate

Expand Down
15 changes: 3 additions & 12 deletions src/twolayerdns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,28 +294,19 @@ function save_computed_output!(simulation, tldns, save_schedule, save_file, outp
ϵ_maximum = Reduction(maximum!, ϵ, dims = (1, 2, 3))
Eₖ = KineticEnergy(model)
∫Eₖ = Integral(Eₖ)
Eₚ = potential_energy(model)
Eₚ = PotentialEnergy(model)
∫Eₚ = Integral(Eₚ)

# Horizontally integrated vertical temperature flux and vertical temperature gradient
T = model.tracers.T
w′T′ = vertical_tracer_flux(model, T)
∫ₐw′T′ = Integral(w′T′, dims = (1, 2))
∂T∂z = ∂z(T)
∫ₐ∂T∂z = Integral(∂T∂z, dims = (1, 2))

computed_outputs = Dict("σ" => σ, "∫ϵ" => ∫ϵ, "ϵ_maximum" => ϵ_maximum, "∫Eₖ" => ∫Eₖ,
"∫Eₚ" => ∫Eₚ, "∫ₐ∂T∂z" => ∫ₐ∂T∂z, "∫ₐw′T′" => ∫ₐw′T′)
"∫Eₚ" => ∫Eₚ)

oa = Dict(
"σ" => Dict("longname" => "Seawater potential density calculated using TEOS-10 at $(reference_gp_height)dbar",
"units" => "kgm⁻³"),
"ϵ_maximum" => Dict("longname" => "Maximum (in space) TKE dissipation"),
"∫ϵ" => Dict("longname" => "Volume integrated turbulent kintetic energy dissipation"),
"∫Eₖ" => Dict("longname" => "Volume integrated turbulent kinetic energy"),
"∫Eₚ" => Dict("longname" => "Volume integrated potential energy (g∫ᵥρzdV)"),
"∫ₐw′T′" => Dict("longname" => "Horizontally integrated vertical temeprature flux"),
"∫ₐ∂T∂z" => Dict("longname" => "Horizontally integrated vertical temperature gradient")
"∫Eₚ" => Dict("longname" => "Volume integrated potential energy (g∫ᵥρzdV)")
)
simulation.output_writers[:computed_output] =
save_file == :netcdf ? NetCDFOutputWriter(model, computed_outputs;
Expand Down
34 changes: 18 additions & 16 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,36 +172,38 @@ include("output_test.jl")
simulation, td, tldns = run_sim(:netcdf)
NCDataset(simulation.output_writers[:tracers].filepath) do ds
S, T = ds[:S], ds[:T]
@test all(S[:, :, 1:td, :] .== tldns.initial_conditions.S₀ˡ)
@test all(S[:, :, td+1:end, :] .== tldns.initial_conditions.S₀ᵘ)
@test all(T[:, :, 1:td, :] .== tldns.initial_conditions.T₀ˡ)
@test all(T[:, :, td+1:end, :] .== tldns.initial_conditions.T₀ᵘ)
@test all(S[:, :, 1:td, :] . tldns.initial_conditions.S₀ˡ)
@test all(S[:, :, td+1:end, :] . tldns.initial_conditions.S₀ᵘ)
@test all(T[:, :, 1:td, :] . tldns.initial_conditions.T₀ˡ)
@test all(T[:, :, td+1:end, :] . tldns.initial_conditions.T₀ᵘ)
end
NCDataset(simulation.output_writers[:computed_output].filepath) do ds
σ = ds[:σ]
@test all(σ[:, :, 1:td, :] .== SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ˡ,
tldns.initial_conditions.S₀ˡ, 0,
tldns.model.buoyancy.model.equation_of_state))
@test all(σ[:, :, td+1:end, :] .== SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ᵘ,
tldns.initial_conditions.S₀ᵘ, 0,
tldns.model.buoyancy.model.equation_of_state))
@test all(σ[:, :, 1:td, :] .≈
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ˡ,
tldns.initial_conditions.S₀ˡ, 0,
tldns.model.buoyancy.model.equation_of_state))
@test all(σ[:, :, td+1:end, :] .≈
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ᵘ,
tldns.initial_conditions.S₀ᵘ, 0,
tldns.model.buoyancy.model.equation_of_state))
end
end

@testset "jld2" begin
simulation, td, tldns = run_sim(:jld2)
S = FieldTimeSeries(simulation.output_writers[:tracers].filepath, "S")
T = FieldTimeSeries(simulation.output_writers[:tracers].filepath, "T")
@test all(S.data[:, :, 1:td, :] .== tldns.initial_conditions.S₀ˡ)
@test all(S.data[:, :, td+1:end, :] .== tldns.initial_conditions.S₀ᵘ)
@test all(T.data[:, :, 1:td, :] .== tldns.initial_conditions.T₀ˡ)
@test all(T.data[:, :, td+1:end, :] .== tldns.initial_conditions.T₀ᵘ)
@test all(S.data[:, :, 1:td, :] . tldns.initial_conditions.S₀ˡ)
@test all(S.data[:, :, td+1:end, :] . tldns.initial_conditions.S₀ᵘ)
@test all(T.data[:, :, 1:td, :] . tldns.initial_conditions.T₀ˡ)
@test all(T.data[:, :, td+1:end, :] . tldns.initial_conditions.T₀ᵘ)
σ = FieldTimeSeries(simulation.output_writers[:computed_output].filepath, "σ")
@test all(σ.data[:, :, 1:td, :] .==
@test all(σ.data[:, :, 1:td, :] .
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ˡ,
tldns.initial_conditions.S₀ˡ, 0,
tldns.model.buoyancy.model.equation_of_state))
@test all(σ.data[:, :, td+1:end, :] .==
@test all(σ.data[:, :, td+1:end, :] .
SeawaterPolynomials.ρ(tldns.initial_conditions.T₀ᵘ,
tldns.initial_conditions.S₀ᵘ, 0,
tldns.model.buoyancy.model.equation_of_state))
Expand Down
Loading