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

Use ifelse in liquid_fraction, plus a comment about condensate probability #178

Merged
merged 1 commit into from
Feb 5, 2024
Merged
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
37 changes: 21 additions & 16 deletions src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1320,22 +1320,27 @@ is a function that is 1 above `T_freeze` and goes to zero below `T_icenuc`.
T::FT,
::Type{phase_type},
q::PhasePartition{FT} = q_pt_0(FT),
) where {FT <: Real, phase_type <: ThermodynamicState}
_T_freeze::FT = TP.T_freeze(param_set)
_T_icenuc::FT = TP.T_icenuc(param_set)

if T > _T_freeze
return FT(1)
elseif T > _T_icenuc
_pow_icenuc::FT = TP.pow_icenuc(param_set)
if _pow_icenuc == 1
return (T - _T_icenuc) / (_T_freeze - _T_icenuc)
else
return ((T - _T_icenuc) / (_T_freeze - _T_icenuc))^_pow_icenuc
end
else
return FT(0)
end
) where {FT, phase_type <: ThermodynamicState}

Tᶠ = TP.T_freeze(param_set) # freezing temperature
Tⁿ = TP.T_icenuc(param_set) # temperature of homogeneous ice nucleation
α = TP.pow_icenuc(param_set) # power law partial ice nucleation parameter

# Model for cloud water condensate probabilty when temperature is below
# freezing (all liquid condensate), but above the temperature of homogeneous
# ice nucleation (all ice condensate). In it's simplest form, this is simply
# a number that varies between 0 and 1. For example, see figure 6 in
# Hu et al., https://doi.org/10.1029/2009JD012384, JGR (2010).
λᵖ = ((T - Tⁿ) / (Tᶠ - Tⁿ))^α
charleskawczynski marked this conversation as resolved.
Show resolved Hide resolved

above_freezing = T > Tᶠ
supercooled_liquid = (T ≤ Tᶠ) & (T > Tⁿ)

return ifelse(
above_freezing,
one(FT),
ifelse(supercooled_liquid, λᵖ, zero(FT)),
)
end

@inline function liquid_fraction(
Expand Down
Loading