Skip to content

Commit aff39c5

Browse files
authored
Merge pull request #267 from CliMA/zs/remove_ft
Remove dispatch on FT
2 parents b04481c + 9ea22e2 commit aff39c5

15 files changed

+352
-452
lines changed

src/Thermodynamics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ include("printing.jl")
6767
@inline print_warning() = false
6868

6969
# Default phase partition for dry air
70-
@inline q_pt_0(::Type{FT}) where {FT} = PhasePartition(FT(0), FT(0), FT(0))
70+
@inline q_pt_0(::APS{FT}) where {FT} = PhasePartition(FT(0), FT(0), FT(0))
7171

7272
@inline solution_type() = RS.CompactSolution()
7373
include("DataCollection.jl")

src/air_dry_adiabatic.jl

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ for an isentropic process: `p = p₀ * (1 - Φ/(θ * cₚ))^(cₚ/R)`, where `p
2626
"""
2727
@inline function air_pressure_given_θ(
2828
param_set::APS,
29-
θ::FT,
30-
Φ::FT,
29+
θ,
30+
Φ,
3131
::DryAdiabaticProcess,
32-
) where {FT <: Real}
32+
)
3333
p0 = TP.p_ref_theta(param_set)
3434
_R_d = TP.R_d(param_set)
3535
_cp_d = TP.cp_d(param_set)
@@ -49,15 +49,9 @@ The pressure is computed using the isentropic relation: `p = p∞ * (T/T∞)^(1/
4949
where `κ = R/cₚ` is the ratio of the gas constant to the isobaric specific heat capacity
5050
of dry air.
5151
"""
52-
@inline function air_pressure(
53-
param_set::APS,
54-
T::FT,
55-
T∞::FT,
56-
p∞::FT,
57-
::DryAdiabaticProcess,
58-
) where {FT <: Real}
52+
@inline function air_pressure(param_set::APS, T, T∞, p∞, ::DryAdiabaticProcess)
5953
_kappa_d = TP.kappa_d(param_set)
60-
return p∞ * (T / T∞)^(FT(1) / _kappa_d)
54+
return p∞ * (T / T∞)^(1 / _kappa_d)
6155
end
6256

6357
"""
@@ -72,12 +66,7 @@ The temperature is computed using the definition of the dry potential temperatur
7266
`T = θ * (p/p₀)^(R/cₚ)`, where `p₀` is the reference pressure, `R` is the gas constant of dry air,
7367
and `cₚ` is the isobaric specific heat capacity of dry air.
7468
"""
75-
@inline function air_temperature(
76-
param_set::APS,
77-
p::FT,
78-
θ::FT,
79-
::DryAdiabaticProcess,
80-
) where {FT <: Real}
69+
@inline function air_temperature(param_set::APS, p, θ, ::DryAdiabaticProcess)
8170
_R_d = TP.R_d(param_set)
8271
_cp_d = TP.cp_d(param_set)
8372
p0 = TP.p_ref_theta(param_set)

src/air_energies.jl

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ When `q` is not provided, the results are for dry air.
3131
"""
3232
@inline function internal_energy(
3333
param_set::APS,
34-
T::FT,
35-
q::PhasePartition{FT} = q_pt_0(FT),
36-
) where {FT <: Real}
34+
T,
35+
q::PhasePartition = q_pt_0(param_set),
36+
)
3737
q_vap = vapor_specific_humidity(q)
3838
q_dry = 1 - q.tot
3939

@@ -53,7 +53,7 @@ The dry air internal energy, given
5353
- `param_set` an `AbstractParameterSet`, see the [`Thermodynamics`](@ref) for more details
5454
- `T` temperature
5555
"""
56-
@inline function internal_energy_dry(param_set::APS, T::FT) where {FT <: Real}
56+
@inline function internal_energy_dry(param_set::APS, T)
5757
T_0 = TP.T_0(param_set)
5858
cv_d = TP.cv_d(param_set)
5959
R_d = TP.R_d(param_set)
@@ -68,7 +68,7 @@ The water vapor internal energy, given
6868
- `param_set` an `AbstractParameterSet`, see the [`Thermodynamics`](@ref) for more details
6969
- `T` temperature
7070
"""
71-
@inline function internal_energy_vapor(param_set::APS, T::FT) where {FT <: Real}
71+
@inline function internal_energy_vapor(param_set::APS, T)
7272
T_0 = TP.T_0(param_set)
7373
cv_v = TP.cv_v(param_set)
7474
e_int_v0 = TP.e_int_v0(param_set)
@@ -84,10 +84,7 @@ The liquid water internal energy, given
8484
- `param_set` an `AbstractParameterSet`, see the [`Thermodynamics`](@ref) for more details
8585
- `T` temperature
8686
"""
87-
@inline function internal_energy_liquid(
88-
param_set::APS,
89-
T::FT,
90-
) where {FT <: Real}
87+
@inline function internal_energy_liquid(param_set::APS, T)
9188
T_0 = TP.T_0(param_set)
9289
cv_l = TP.cv_l(param_set)
9390

@@ -102,7 +99,7 @@ The ice internal energy, given
10299
- `param_set` an `AbstractParameterSet`, see the [`Thermodynamics`](@ref) for more details
103100
- `T` temperature
104101
"""
105-
@inline function internal_energy_ice(param_set::APS, T::FT) where {FT <: Real}
102+
@inline function internal_energy_ice(param_set::APS, T)
106103
T_0 = TP.T_0(param_set)
107104
cv_i = TP.cv_i(param_set)
108105
e_int_i0 = TP.e_int_i0(param_set)
@@ -125,18 +122,18 @@ given
125122
"""
126123
@inline function internal_energy_sat(
127124
param_set::APS,
128-
T::FT,
129-
ρ::FT,
130-
q_tot::FT,
125+
T,
126+
ρ,
127+
q_tot,
131128
::Type{phase_type},
132-
q_pt::PhasePartition{FT} = PhasePartition_equil(
129+
q_pt::PhasePartition = PhasePartition_equil(
133130
param_set,
134131
T,
135132
ρ,
136133
q_tot,
137134
phase_type,
138135
),
139-
) where {FT <: Real, phase_type <: ThermodynamicState}
136+
) where {phase_type <: ThermodynamicState}
140137
return internal_energy(param_set, T, q_pt)
141138
end
142139
@inline internal_energy_sat(param_set, T, ρ, q_tot, phase_type) =
@@ -160,11 +157,11 @@ When `q` is not provided, the results are for dry air.
160157
"""
161158
@inline function total_energy(
162159
param_set::APS,
163-
e_kin::FT,
164-
e_pot::FT,
165-
T::FT,
166-
q::PhasePartition{FT} = q_pt_0(FT),
167-
) where {FT <: Real}
160+
e_kin,
161+
e_pot,
162+
T,
163+
q::PhasePartition = q_pt_0(param_set),
164+
)
168165
return internal_energy(param_set, T, q) + e_pot + e_kin
169166
end
170167

@@ -180,7 +177,7 @@ The specific enthalpy, given
180177
181178
This method is deprecated and will be removed in a future release.
182179
"""
183-
@inline function specific_enthalpy(e_int::FT, R_m::FT, T::FT) where {FT <: Real}
180+
@inline function specific_enthalpy(e_int, R_m, T)
184181
return e_int + R_m * T
185182
end
186183

@@ -200,9 +197,9 @@ When `q` is not provided, the results are for dry air.
200197
"""
201198
@inline function specific_enthalpy(
202199
param_set::APS,
203-
T::FT,
204-
q::PhasePartition{FT} = q_pt_0(FT),
205-
) where {FT <: Real}
200+
T,
201+
q::PhasePartition = q_pt_0(param_set),
202+
)
206203
R_m = gas_constant_air(param_set, q)
207204
e_int = internal_energy(param_set, T, q)
208205
return e_int + R_m * T
@@ -222,11 +219,11 @@ and total specific humidity, given
222219
"""
223220
@inline function specific_enthalpy_sat(
224221
param_set::APS,
225-
T::FT,
226-
ρ::FT,
227-
q_tot::FT,
222+
T,
223+
ρ,
224+
q_tot,
228225
::Type{phase_type},
229-
) where {FT <: Real, phase_type <: ThermodynamicState}
226+
) where {phase_type <: ThermodynamicState}
230227
return specific_enthalpy(
231228
param_set,
232229
T,
@@ -302,10 +299,10 @@ When `q` is not provided, the results are for dry air.
302299
"""
303300
@inline function total_specific_enthalpy(
304301
param_set::APS,
305-
e_tot::FT,
306-
T::FT,
307-
q::PhasePartition{FT} = q_pt_0(FT),
308-
) where {FT <: Real}
302+
e_tot,
303+
T,
304+
q::PhasePartition = q_pt_0(param_set),
305+
)
309306
R_m = gas_constant_air(param_set, q)
310307
return e_tot + R_m * T
311308
end
@@ -320,10 +317,6 @@ The total specific enthalpy, given
320317
- `R_m` [`gas_constant_air`](@ref)
321318
- `T` air temperature
322319
"""
323-
@inline function total_specific_enthalpy(
324-
e_tot::FT,
325-
R_m::FT,
326-
T::FT,
327-
) where {FT <: Real}
320+
@inline function total_specific_enthalpy(e_tot, R_m, T)
328321
return e_tot + R_m * T
329322
end

src/air_entropies.jl

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ The specific entropy, given
1515
1616
The specific entropy is computed from equations (29)-(33) of [Pressel2015](@cite).
1717
"""
18-
@inline function specific_entropy(
19-
param_set::APS,
20-
p::FT,
21-
T::FT,
22-
q::PhasePartition{FT},
23-
) where {FT <: Real}
18+
@inline function specific_entropy(param_set::APS, p, T, q::PhasePartition)
2419
L_v = latent_heat_vapor(param_set, T)
2520
L_s = latent_heat_sublim(param_set, T)
2621
s_d = specific_entropy_dry(param_set, p, T, q)
@@ -39,11 +34,11 @@ The dry air specific entropy, given
3934
- `q` phase partition
4035
"""
4136
@inline function specific_entropy_dry(
42-
param_set::APS,
43-
p::FT,
44-
T::FT,
45-
q::PhasePartition{FT},
46-
) where {FT <: Real}
37+
param_set::APS{FT},
38+
p,
39+
T,
40+
q::PhasePartition,
41+
) where {FT}
4742
T_ref = TP.entropy_reference_temperature(param_set)
4843
p_ref = TP.MSLP(param_set)
4944
s_d_ref = TP.entropy_dry_air(param_set)
@@ -64,11 +59,11 @@ The specific entropy of water vapor, given
6459
- `q` phase partition
6560
"""
6661
@inline function specific_entropy_vapor(
67-
param_set::APS,
68-
p::FT,
69-
T::FT,
70-
q::PhasePartition{FT},
71-
) where {FT <: Real}
62+
param_set::APS{FT},
63+
p,
64+
T,
65+
q::PhasePartition,
66+
) where {FT}
7267
T_ref = TP.entropy_reference_temperature(param_set)
7368
p_ref = TP.MSLP(param_set)
7469
s_v_ref = TP.entropy_water_vapor(param_set)

0 commit comments

Comments
 (0)