|
| 1 | +using Test |
| 2 | +using Breeze |
| 3 | +using Oceananigans |
| 4 | + |
| 5 | +@testset "Pressure solver matches NonhydrostaticModel with ρᵣ == 1 [$FT]" for FT in (Float32, Float64) |
| 6 | + Nx = Ny = Nz = 32 |
| 7 | + z = 0:(1/Nz):1 |
| 8 | + grid = RectilinearGrid(FT; size=(Nx, Ny, Nz), x=(0, 1), y=(0, 1), z) |
| 9 | + thermodynamics = ThermodynamicConstants(FT) |
| 10 | + reference_constants = ReferenceStateConstants(FT; base_pressure=101325, potential_temperature=288) |
| 11 | + |
| 12 | + formulation = AnelasticFormulation(grid, reference_constants, thermodynamics) |
| 13 | + parent(formulation.reference_density) .= 1 |
| 14 | + |
| 15 | + anelastic = AtmosphereModel(grid; thermodynamics=thermodynamics, formulation) |
| 16 | + boussinesq = NonhydrostaticModel(; grid) |
| 17 | + |
| 18 | + uᵢ = rand(size(grid)...) |
| 19 | + vᵢ = rand(size(grid)...) |
| 20 | + wᵢ = rand(size(grid)...) |
| 21 | + |
| 22 | + set!(anelastic, ρu=uᵢ, ρv=vᵢ, ρw=wᵢ) |
| 23 | + set!(boussinesq, u=uᵢ, v=vᵢ, w=wᵢ) |
| 24 | + |
| 25 | + ρu = anelastic.momentum.ρu |
| 26 | + ρv = anelastic.momentum.ρv |
| 27 | + ρw = anelastic.momentum.ρw |
| 28 | + δᵃ = Field(∂x(ρu) + ∂y(ρv) + ∂z(ρw)) |
| 29 | + |
| 30 | + u = boussinesq.velocities.u |
| 31 | + v = boussinesq.velocities.v |
| 32 | + w = boussinesq.velocities.w |
| 33 | + δᵇ = Field(∂x(u) + ∂y(v) + ∂z(w)) |
| 34 | + |
| 35 | + boussinesq_solver = boussinesq.pressure_solver |
| 36 | + anelastic_solver = anelastic.pressure_solver |
| 37 | + @test anelastic_solver.batched_tridiagonal_solver.a == boussinesq_solver.batched_tridiagonal_solver.a |
| 38 | + @test anelastic_solver.batched_tridiagonal_solver.b == boussinesq_solver.batched_tridiagonal_solver.b |
| 39 | + @test anelastic_solver.batched_tridiagonal_solver.c == boussinesq_solver.batched_tridiagonal_solver.c |
| 40 | + @test anelastic_solver.source_term == boussinesq_solver.source_term |
| 41 | + |
| 42 | + @test maximum(abs, δᵃ) < prod(size(grid)) * eps(FT) |
| 43 | + @test maximum(abs, δᵇ) < prod(size(grid)) * eps(FT) |
| 44 | + @test anelastic.nonhydrostatic_pressure == boussinesq.pressures.pNHS |
| 45 | +end |
0 commit comments