Skip to content

Commit

Permalink
Merge pull request #185 from CliMA/szy21-patch-1
Browse files Browse the repository at this point in the history
Update virtual_dry_static_energy
  • Loading branch information
szy21 authored Jan 22, 2024
2 parents dd73501 + cda74a8 commit 723578d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions 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)
cp_d::FT = TP.cp_d(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_d * (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,8 @@ end
@test all(has_condensate.(q_dry) .== false)

e_tot = total_energy.(param_set, ts, e_kin, e_pot)
_cp_d = FT(TP.cp_d(param_set))
_T_0 = FT(TP.T_0(param_set))
@test all(
specific_enthalpy.(param_set, ts) .≈
e_int .+
Expand All @@ -665,8 +667,7 @@ 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_d .* (virtual_temperature.(param_set, ts) .- _T_0) .+ e_pot,
)

# PhaseEquil
Expand Down

0 comments on commit 723578d

Please sign in to comment.