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

move surface tendency after precipitation tendency #3159

Merged
merged 1 commit into from
Jun 29, 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
5 changes: 4 additions & 1 deletion src/prognostic_equations/remaining_tendency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ end

NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
viscous_sponge_tendency!(Yₜ, Y, p, t, p.atmos.viscous_sponge)
surface_temp_tendency!(Yₜ, Y, p, t, p.atmos.surface_model)

# Vertical tendencies
rayleigh_sponge_tendency!(Yₜ, Y, p, t, p.atmos.rayleigh_sponge)
Expand Down Expand Up @@ -80,6 +79,10 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
p.atmos.turbconv_model,
)

# NOTE: Precipitation tendencies should be applied before calling this function,
# because precipitation cache is used in this function
surface_temp_tendency!(Yₜ, Y, p, t, p.atmos.surface_model)

# NOTE: All ρa tendencies should be applied before calling this function
pressure_work_tendency!(Yₜ, Y, p, t, p.atmos.turbconv_model)

Expand Down
8 changes: 6 additions & 2 deletions src/solver/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ Return:
"""
function check_conservation(sol)
# energy
energy_total = sum(sol.u[end].c.ρe_tot)
energy_total = sum(sol.u[1].c.ρe_tot)
energy_atmos_change = sum(sol.u[end].c.ρe_tot) - sum(sol.u[1].c.ρe_tot)
p = sol.prob.p
sfc = p.atmos.surface_model
if sfc isa PrognosticSurfaceTemperature
sfc_cρh = sfc.ρ_ocean * sfc.cp_ocean * sfc.depth_ocean
energy_total +=
horizontal_integral_at_boundary(sol.u[end].sfc.T .* sfc_cρh)
horizontal_integral_at_boundary(sol.u[1].sfc.T .* sfc_cρh)
energy_surface_change =
horizontal_integral_at_boundary(
sol.u[end].sfc.T .- sol.u[1].sfc.T,
Expand Down Expand Up @@ -254,6 +254,10 @@ function check_conservation(sol)
sol.u[end].sfc.water .- sol.u[1].sfc.water,
)

mass_conservation =
(sum(sol.u[end].c.ρ) - sum(sol.u[1].c.ρ) + water_surface_change) /
sum(sol.u[1].c.ρ)

water_conservation =
abs(water_atmos_change + water_surface_change) / water_total
end
Expand Down
Loading