From 884f5582224a0866b1c1193110e8ae06380f1e8a Mon Sep 17 00:00:00 2001 From: jbisits Date: Wed, 17 Jul 2024 10:18:19 +1000 Subject: [PATCH 1/2] Relax to approx in test + remove unnecessary saved output --- src/TwoLayerDirectNumericalShenanigans.jl | 2 +- src/twolayerdns.jl | 15 ++-------- test/runtests.jl | 34 ++++++++++++----------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/TwoLayerDirectNumericalShenanigans.jl b/src/TwoLayerDirectNumericalShenanigans.jl index 972402e..5767aa0 100644 --- a/src/TwoLayerDirectNumericalShenanigans.jl +++ b/src/TwoLayerDirectNumericalShenanigans.jl @@ -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 diff --git a/src/twolayerdns.jl b/src/twolayerdns.jl index ec7ef26..a74b965 100644 --- a/src/twolayerdns.jl +++ b/src/twolayerdns.jl @@ -294,18 +294,11 @@ 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", @@ -313,9 +306,7 @@ function save_computed_output!(simulation, tldns, save_schedule, save_file, outp "ϵ_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; diff --git a/test/runtests.jl b/test/runtests.jl index 1d52f37..9fd6c42 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -172,19 +172,21 @@ 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 @@ -192,16 +194,16 @@ include("output_test.jl") 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)) From dbe7eb2a44eefcf88a0b52f28be31d3482af6fc6 Mon Sep 17 00:00:00 2001 From: jbisits Date: Wed, 17 Jul 2024 10:31:48 +1000 Subject: [PATCH 2/2] up version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1b44609..2e849a8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TwoLayerDirectNumericalShenanigans" uuid = "40aaee9f-3595-48be-b36c-f1067009652f" authors = ["Josef Bisits "] -version = "0.6.3" +version = "0.6.4" [deps] CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"