Skip to content

Commit

Permalink
Merge pull request #195 from CliMA/ck/rm_type_casting
Browse files Browse the repository at this point in the history
Remove type casting of parameters
  • Loading branch information
charleskawczynski authored Feb 13, 2024
2 parents fa610f8 + 53b65cd commit 5d3b8e0
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 144 deletions.
14 changes: 7 additions & 7 deletions src/TemperatureProfiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ to be greater than or equal to `profile.T_min_ref`.
"""
function (profile::DryAdiabaticProfile)(param_set::APS, z::FT) where {FT}

R_d::FT = TP.R_d(param_set)
cp_d::FT = TP.cp_d(param_set)
grav::FT = TP.grav(param_set)
MSLP::FT = TP.MSLP(param_set)
R_d = TP.R_d(param_set)
cp_d = TP.cp_d(param_set)
grav = TP.grav(param_set)
MSLP = TP.MSLP(param_set)

# Temperature
Γ = grav / cp_d
Expand Down Expand Up @@ -127,9 +127,9 @@ end


function (profile::DecayingTemperatureProfile)(param_set::APS, z::FT) where {FT}
R_d::FT = TP.R_d(param_set)
grav::FT = TP.grav(param_set)
MSLP::FT = TP.MSLP(param_set)
R_d = TP.R_d(param_set)
grav = TP.grav(param_set)
MSLP = TP.MSLP(param_set)

# Scale height for surface temperature
H_sfc = R_d * profile.T_virt_surf / grav
Expand Down
8 changes: 4 additions & 4 deletions src/TestedProfiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ function PhaseDryProfiles(param_set::APS, ::Type{ArrayType}) where {ArrayType}
shared_profiles(param_set, z_range, relative_sat, T_surface, T_min)
T = T_virt
FT = eltype(T)
R_d::FT = TP.R_d(param_set)
grav::FT = TP.grav(param_set)
R_d = TP.R_d(param_set)
grav = TP.grav(param_set)
ρ = p ./ (R_d .* T)

# Additional variables
Expand Down Expand Up @@ -235,8 +235,8 @@ function PhaseEquilProfiles(param_set::APS, ::Type{ArrayType}) where {ArrayType}
T = T_virt

FT = eltype(T)
R_d::FT = TP.R_d(param_set)
grav::FT = TP.grav(param_set)
R_d = TP.R_d(param_set)
grav = TP.grav(param_set)
# Compute total specific humidity from temperature, pressure
# and relative saturation, and partition the saturation excess
# according to temperature.
Expand Down
26 changes: 13 additions & 13 deletions src/config_numerical_method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.NewtonsMethod, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
T_init = if T_guess isa Nothing
max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor
else
Expand All @@ -73,7 +73,7 @@ end
::Type{phase_type},
T_guess::FT,
) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
T_init = if T_guess isa Nothing
max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor
else
Expand All @@ -91,7 +91,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice
T_2 = air_temperature(param_set, e_int, q_pt)
T_1 = max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor
Expand All @@ -108,7 +108,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.RegulaFalsiMethod, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice
T_2 = air_temperature(param_set, e_int, q_pt)
T_1 = max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor
Expand Down Expand Up @@ -166,7 +166,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
T_init = if T_guess isa Nothing
max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor
else
Expand All @@ -184,7 +184,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice
T_2 = air_temperature(param_set, e_int, q_pt)
T_1 = max(T_min, air_temperature(param_set, e_int, PhasePartition(q_tot))) # Assume all vapor
Expand All @@ -205,7 +205,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
T_init = if T_guess isa Nothing # Assume all vapor
max(
T_min,
Expand All @@ -226,7 +226,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice
T_2 = air_temperature_from_enthalpy(param_set, h, q_pt)
T_1 = max(
Expand All @@ -246,7 +246,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.RegulaFalsiMethod, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
q_pt = PhasePartition(q_tot, FT(0), q_tot) # Assume all ice
T_2 = air_temperature_from_enthalpy(param_set, h, q_pt)
T_1 = max(
Expand All @@ -270,8 +270,8 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.RegulaFalsiMethod, phase_type <: PhaseEquil}
_T_min::FT = TP.T_min(param_set)
_T_max::FT = TP.T_max(param_set)
_T_min = TP.T_min(param_set)
_T_max = TP.T_max(param_set)
@inline air_temp(q) = air_temperature_given_pθq(param_set, p, θ_liq_ice, q)
T_1 = max(_T_min, air_temp(PhasePartition(q_tot))) # Assume all vapor
T_2 = T_1 + 10
Expand All @@ -288,7 +288,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.SecantMethod, phase_type <: PhaseEquil}
_T_min::FT = TP.T_min(param_set)
_T_min = TP.T_min(param_set)
@inline air_temp(q) = air_temperature_given_pθq(param_set, p, θ_liq_ice, q)
T_1 = max(_T_min, air_temp(PhasePartition(q_tot))) # Assume all vapor
T_2 = air_temp(PhasePartition(q_tot, FT(0), q_tot)) # Assume all ice
Expand All @@ -305,7 +305,7 @@ end
::Type{phase_type},
T_guess::Union{FT, Nothing},
) where {FT, NM <: RS.NewtonsMethodAD, phase_type <: PhaseEquil}
T_min::FT = TP.T_min(param_set)
T_min = TP.T_min(param_set)
@inline air_temp(q) = air_temperature_given_pθq(param_set, p, θ_liq_ice, q)
T_init = if T_guess isa Nothing
max(T_min, air_temp(PhasePartition(q_tot))) # Assume all vapor
Expand Down
14 changes: 7 additions & 7 deletions src/isentropic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ The air pressure for an isentropic process, where
Φ::FT,
::DryAdiabaticProcess,
) where {FT <: Real}
p0::FT = TP.p_ref_theta(param_set)
_R_d::FT = TP.R_d(param_set)
_cp_d::FT = TP.cp_d(param_set)
p0 = TP.p_ref_theta(param_set)
_R_d = TP.R_d(param_set)
_cp_d = TP.cp_d(param_set)
return p0 * (1 - Φ /* _cp_d))^(_cp_d / _R_d)
end

Expand All @@ -51,7 +51,7 @@ The air pressure for an isentropic process, where
p∞::FT,
::DryAdiabaticProcess,
) where {FT <: Real}
_kappa_d::FT = TP.kappa_d(param_set)
_kappa_d = TP.kappa_d(param_set)
return p∞ * (T / T∞)^(FT(1) / _kappa_d)
end

Expand All @@ -70,8 +70,8 @@ The air temperature for an isentropic process, where
θ::FT,
::DryAdiabaticProcess,
) where {FT <: Real}
_R_d::FT = TP.R_d(param_set)
_cp_d::FT = TP.cp_d(param_set)
p0::FT = TP.p_ref_theta(param_set)
_R_d = TP.R_d(param_set)
_cp_d = TP.cp_d(param_set)
p0 = TP.p_ref_theta(param_set)
return (p / p0)^(_R_d / _cp_d) * θ
end
Loading

0 comments on commit 5d3b8e0

Please sign in to comment.