Skip to content

Commit

Permalink
move surface tendency after precipitation tendency
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Jun 29, 2024
1 parent ba8e013 commit d08e21c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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

0 comments on commit d08e21c

Please sign in to comment.