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

Replace AbstractFloat with Real #194

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ext/CreateParametersExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module CreateParametersExt
import Thermodynamics.Parameters.ThermodynamicsParameters
import CLIMAParameters as CP

ThermodynamicsParameters(::Type{FT}) where {FT <: AbstractFloat} =
ThermodynamicsParameters(::Type{FT}) where {FT <: Real} =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not remove the restriction altogether? You can test that parameter structs are built with the right type in ClimaAtmos, it may not help much to enforce this here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think it makes sense to have a parameter struct with Ints.

Copy link
Member

@glwagner glwagner Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure only some types make sense, it's just you save yourself having to predict them in advance which might save you from having to write PRs like this (or eliminate the slowdown that happens when code doesn't work because of a wrong assumption like this, requiring source code update). Overrestriction of types is typical, so just trying to spread the good word...

ThermodynamicsParameters(CP.create_toml_dict(FT))

function ThermodynamicsParameters(toml_dict::CP.AbstractTOMLDict)
Expand Down
2 changes: 1 addition & 1 deletion src/TemperatureProfiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract type TemperatureProfile{FT} end

"""
IsothermalProfile(param_set, T_virt)
IsothermalProfile(param_set, ::Type{FT<:AbstractFloat})
IsothermalProfile(param_set, ::Type{FT<:Real})

A uniform virtual temperature profile, which is implemented
as a special case of [`DecayingTemperatureProfile`](@ref).
Expand Down
6 changes: 3 additions & 3 deletions src/isentropic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The air pressure for an isentropic process, where
θ::FT,
Φ::FT,
::DryAdiabaticProcess,
) where {FT <: AbstractFloat}
) 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)
Expand All @@ -50,7 +50,7 @@ The air pressure for an isentropic process, where
T∞::FT,
p∞::FT,
::DryAdiabaticProcess,
) where {FT <: AbstractFloat}
) where {FT <: Real}
_kappa_d::FT = TP.kappa_d(param_set)
return p∞ * (T / T∞)^(FT(1) / _kappa_d)
end
Expand All @@ -69,7 +69,7 @@ The air temperature for an isentropic process, where
p::FT,
θ::FT,
::DryAdiabaticProcess,
) where {FT <: AbstractFloat}
) 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)
Expand Down
4 changes: 2 additions & 2 deletions src/relations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@ The dry potential temperature, given a thermodynamic state `ts`.
ρ::FT,
RH::FT,
::Type{phase_type},
) where {FT <: AbstractFloat, phase_type <: ThermodynamicState}
) where {FT <: Real, phase_type <: ThermodynamicState}
q_tot = RH * q_vap_saturation(param_set, T, ρ, phase_type)
q_pt = PhasePartition_equil(param_set, T, ρ, q_tot, phase_type)
return virtual_temperature(param_set, T, q_pt)
Expand All @@ -2366,7 +2366,7 @@ The air temperature and `q_tot` where
::Type{phase_type},
maxiter::Int = 100,
tol::RS.AbstractTolerance = RS.ResidualTolerance{FT}(sqrt(eps(FT))),
) where {FT <: AbstractFloat, phase_type <: ThermodynamicState}
) where {FT <: Real, phase_type <: ThermodynamicState}

_T_min::FT = TP.T_min(param_set)
_T_max = T_virt
Expand Down
Loading