From 17be8452f9540f0839e5a7dd00a35ab7af4bf2e8 Mon Sep 17 00:00:00 2001 From: Navid Constantinou Date: Fri, 18 Dec 2020 13:04:24 +1100 Subject: [PATCH] tests now cover everything --- test/runtests.jl | 6 ++++++ test/test_singlelayerqg.jl | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index b583f4df..e605d8db 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -77,6 +77,12 @@ for dev in devices @test test_1layerqg_deterministicforcing_enstrophybudget(dev) @test test_1layerqg_stochasticforcing_enstrophybudget(dev) @test SingleLayerQG.nothingfunction() == nothing + @test_throws ErrorException("not implemented for finite deformation radius") test_1layerqg_energy_dissipation(dev; deformation_radius=2.23) + @test_throws ErrorException("not implemented for finite deformation radius") test_1layerqg_enstrophy_dissipation(dev; deformation_radius=2.23) + @test_throws ErrorException("not implemented for finite deformation radius") test_1layerqg_energy_work(dev; deformation_radius=2.23) + @test_throws ErrorException("not implemented for finite deformation radius") test_1layerqg_enstrophy_work(dev; deformation_radius=2.23) + @test_throws ErrorException("not implemented for finite deformation radius") test_1layerqg_energy_drag(dev; deformation_radius=2.23) + @test_throws ErrorException("not implemented for finite deformation radius") test_1layerqg_enstrophy_drag(dev; deformation_radius=2.23) end @testset "BarotropicQGQL" begin diff --git a/test/test_singlelayerqg.jl b/test/test_singlelayerqg.jl index 0e563b86..03e1e0d7 100644 --- a/test/test_singlelayerqg.jl +++ b/test/test_singlelayerqg.jl @@ -334,7 +334,7 @@ function test_1layerqg_energyenstrophy_BarotropicQG(dev::Device=CPU()) energyq₀ = SingleLayerQG.energy(prob) enstrophyq₀ = SingleLayerQG.enstrophy(prob) - return isapprox(energyq₀, energy_calc, rtol=rtol_singlelayerqg) && isapprox(enstrophyq₀, enstrophy_calc, rtol=rtol_singlelayerqg) && + return isapprox(energyq₀, energy_calc, rtol=rtol_singlelayerqg) && isapprox(enstrophyq₀, enstrophy_calc, rtol=rtol_singlelayerqg) && SingleLayerQG.potential_energy(prob)==0 && SingleLayerQG.addforcing!(prob.timestepper.N, sol, clock.t, clock, vars, params, grid) == nothing end @@ -406,3 +406,39 @@ function test_streamfunctionfrompv(dev; deformation_radius=1.23) return (prob_barotropicQG.vars.ψ ≈ ψ && prob_equivalentbarotropicQG.vars.ψ ≈ ψ) end + +function test_1layerqg_energy_dissipation(dev; deformation_radius=2.23) + prob = SingleLayerQG.Problem(dev; nx=16, deformation_radius=deformation_radius) + SingleLayerQG.energy_dissipation(prob) + return nothing +end + +function test_1layerqg_enstrophy_dissipation(dev; deformation_radius=2.23) + prob = SingleLayerQG.Problem(dev; nx=16, deformation_radius=deformation_radius) + SingleLayerQG.enstrophy_dissipation(prob) + return nothing +end + +function test_1layerqg_energy_work(dev; deformation_radius=2.23) + prob = SingleLayerQG.Problem(dev; nx=16, deformation_radius=deformation_radius) + SingleLayerQG.energy_work(prob) + return nothing +end + +function test_1layerqg_enstrophy_work(dev; deformation_radius=2.23) + prob = SingleLayerQG.Problem(dev; nx=16, deformation_radius=deformation_radius) + SingleLayerQG.enstrophy_work(prob) + return nothing +end + +function test_1layerqg_energy_drag(dev; deformation_radius=2.23) + prob = SingleLayerQG.Problem(dev; nx=16, deformation_radius=deformation_radius) + SingleLayerQG.energy_drag(prob) + return nothing +end + +function test_1layerqg_enstrophy_drag(dev; deformation_radius=2.23) + prob = SingleLayerQG.Problem(dev; nx=16, deformation_radius=deformation_radius) + SingleLayerQG.enstrophy_drag(prob) + return nothing +end \ No newline at end of file