Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Merge #608
Browse files Browse the repository at this point in the history
608: Add quadratic term to air temperature Taylor expansion r=charleskawczynski a=charleskawczynski

This adds the quadratic term in the Taylor expansion for temperature in `air_temperature_from_liquid_ice_pottemp `. The previous version (with only the linear term, but not quadratic) fails the test that has been added (and is passing with the quadratic term).

Closes #567

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
  • Loading branch information
bors[bot] and charleskawczynski authored Jan 9, 2020
2 parents c6421dc + 8e09c6d commit 40a8a35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Common/MoistThermodynamics/MoistThermodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -927,9 +927,14 @@ and, optionally,
function air_temperature_from_liquid_ice_pottemp(θ_liq_ice::FT, ρ::FT,
q::PhasePartition{FT}=q_pt_0(FT)) where {FT<:Real}

cv = cv_m(q)
cvm = cv_m(q)
cpm = cp_m(q)
R_m = gas_constant_air(q)
return θ_liq_ice **R_m*θ_liq_ice/FT(MSLP))^(R_m/cv) + latent_heat_liq_ice(q)/cv
κ = 1 - cvm/cpm
T_u =*R_m*θ_liq_ice/FT(MSLP))^(R_m/cvm)*θ_liq_ice
T_1 = latent_heat_liq_ice(q)/cvm
T_2 = -κ/(2*T_u)*(latent_heat_liq_ice(q)/cvm)^2
return T_u + T_1 + T_2
end

"""
Expand Down
2 changes: 2 additions & 0 deletions test/Common/MoistThermodynamics/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ end

# Accurate but expensive `LiquidIcePotTempSHumNonEquil` constructor (Non-linear temperature from θ_liq_ice)
T_non_linear = air_temperature_from_liquid_ice_pottemp_non_linear.(θ_liq_ice, ρ, FT(1e-3), 10, q_pt)
T_expansion = air_temperature_from_liquid_ice_pottemp.(θ_liq_ice, ρ, q_pt)
@test all(isapprox.(T_non_linear, T_expansion, rtol=rtol))
e_int_ = internal_energy.(T_non_linear, q_pt)
ts = PhaseNonEquil.(e_int_, ρ, q_pt)
@test all(T_non_linear .≈ air_temperature.(ts))
Expand Down

0 comments on commit 40a8a35

Please sign in to comment.