Skip to content

Commit

Permalink
Update virtual_dry_static_energy
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Jan 22, 2024
1 parent dd73501 commit 168c8e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2915,9 +2915,10 @@ function virtual_dry_static_energy(
ts::ThermodynamicState{FT},
e_pot::FT,
) where {FT <: Real}
T_0::FT = TP.T_0(param_set)
T_virt = virtual_temperature(param_set, ts)
_cp_m = cp_m(param_set, ts)
return _cp_m * T_virt + e_pot
return _cp_m * (T_virt - T_0) + e_pot
end

"""
Expand Down
5 changes: 3 additions & 2 deletions test/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ end
@test all(has_condensate.(q_dry) .== false)

e_tot = total_energy.(param_set, ts, e_kin, e_pot)
_T_0 = FT(TP.T_0(param_set))
@test all(
specific_enthalpy.(param_set, ts) .≈
e_int .+
Expand All @@ -665,8 +666,8 @@ end
)
@test all(
virtual_dry_static_energy.(param_set, ts, e_pot) .≈
cp_m.(param_set, ts) .* virtual_temperature.(param_set, ts) .+
e_pot,
cp_m.(param_set, ts) .*
(virtual_temperature.(param_set, ts) .- _T_0) .+ e_pot,
)

# PhaseEquil
Expand Down

0 comments on commit 168c8e7

Please sign in to comment.