Skip to content

Commit

Permalink
try updating to new parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Feb 13, 2024
1 parent cb7302f commit 77e6196
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

[compat]
CLIMAParameters = "0.8.6"
CLIMAParameters = "0.9"
DocStringExtensions = "0.8, 0.9"
ForwardDiff = "0.10"
RootSolvers = "0.3, 0.4"
Expand Down
8 changes: 4 additions & 4 deletions src/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ function Chen2022_vel_coeffs(
ρ::FT,
) where {FT}

(; ρ0, a1, a2, a3, a3_pow, b1, b2, b3, b_ρ, c1, c2, c3) = velo_scheme
(; ρ0, ai, a3_pow, bi, b_ρ, ci) = velo_scheme

q = exp(ρ0 * ρ)
ai = (a1 * q, a2 * q, a3 * q * ρ^a3_pow)
bi = (b1 - b_ρ * ρ, b2 - b_ρ * ρ, b3 - b_ρ * ρ)
ci = (c1, c2, c3)
ai = (a[1] * q, a[2] * q, a[3] * q * ρ^a3_pow)
bi = (b[1] - b_ρ * ρ, b[2] - b_ρ * ρ, b[3] - b_ρ * ρ)
ci = (c[1], c[2], c[3])

# unit conversions
aiu = ai .* 1000 .^ bi
Expand Down
22 changes: 11 additions & 11 deletions src/parameters/Microphysics2M.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ end

function AcnvKK2000(td::CP.AbstractTOMLDict)
name_map = (;
:KK2000_auctoconversion_coeff_A => :A,
:KK2000_auctoconversion_coeff_a => :a,
:KK2000_auctoconversion_coeff_b => :b,
:KK2000_auctoconversion_coeff_c => :c,
:KK2000_autoconversion_coeff_A => :A,
:KK2000_autoconversion_coeff_a => :a,
:KK2000_autoconversion_coeff_b => :b,
:KK2000_autoconversion_coeff_c => :c,
)
parameters = CP.get_parameter_values(td, name_map, "CloudMicrophysics")
FT = CP.float_type(td)
Expand Down Expand Up @@ -115,13 +115,13 @@ end

function AcnvB1994(td::CP.AbstractTOMLDict)
name_map = (;
:B1994_auctoconversion_coeff_C => :C,
:B1994_auctoconversion_coeff_a => :a,
:B1994_auctoconversion_coeff_b => :b,
:B1994_auctoconversion_coeff_c => :c,
:B1994_auctoconversion_coeff_N_0 => :N_0,
:B1994_auctoconversion_coeff_d_low => :d_low,
:B1994_auctoconversion_coeff_d_high => :d_high,
:B1994_autoconversion_coeff_C => :C,
:B1994_autoconversion_coeff_a => :a,
:B1994_autoconversion_coeff_b => :b,
:B1994_autoconversion_coeff_c => :c,
:B1994_autoconversion_coeff_N_0 => :N_0,
:B1994_autoconversion_coeff_d_low => :d_low,
:B1994_autoconversion_coeff_d_high => :d_high,
:threshold_smooth_transition_steepness => :k,
)
parameters = CP.get_parameter_values(td, name_map, "CloudMicrophysics")
Expand Down
73 changes: 24 additions & 49 deletions src/parameters/TerminalVelocity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,49 +143,36 @@ DOI: 10.1016/j.atmosres.2022.106171
$(DocStringExtensions.FIELDS)
"""
struct Chen2022VelTypeSnowIce{FT} <: ParametersType{FT}
As::FT
Bs::FT
Cs::FT
Es::FT
Fs::FT
Gs::FT
As::Array{FT}
Bs::Array{FT}
Cs::Array{FT}
Es::Array{FT}
Fs::Array{FT}
Gs::Array{FT}
"density of cloud ice [kg/m3]"
ρᵢ::FT
end

function Chen2022VelTypeSnowIce(toml_dict::CP.AbstractTOMLDict)
# TODO: These should be array parameters.
name_map = (;
:Chen2022_table_B3_As_coeff_1 => :A1,
:Chen2022_table_B3_As_coeff_2 => :A2,
:Chen2022_table_B3_As_coeff_3 => :A3,
:Chen2022_table_B3_Bs_coeff_1 => :B1,
:Chen2022_table_B3_Bs_coeff_2 => :B2,
:Chen2022_table_B3_Bs_coeff_3 => :B3,
:Chen2022_table_B3_Cs_coeff_1 => :C1,
:Chen2022_table_B3_Cs_coeff_2 => :C2,
:Chen2022_table_B3_Cs_coeff_3 => :C3,
:Chen2022_table_B3_Cs_coeff_4 => :C4,
:Chen2022_table_B3_Es_coeff_1 => :E1,
:Chen2022_table_B3_Es_coeff_2 => :E2,
:Chen2022_table_B3_Es_coeff_3 => :E3,
:Chen2022_table_B3_Fs_coeff_1 => :F1,
:Chen2022_table_B3_Fs_coeff_2 => :F2,
:Chen2022_table_B3_Fs_coeff_3 => :F3,
:Chen2022_table_B3_Gs_coeff_1 => :G1,
:Chen2022_table_B3_Gs_coeff_2 => :G2,
:Chen2022_table_B3_Gs_coeff_3 => :G3,
:Chen2022_table_B3_As => :As,
:Chen2022_table_B3_Bs => :Bs,
:Chen2022_table_B3_Cs => :Cs,
:Chen2022_table_B3_Es => :Es,
:Chen2022_table_B3_Fs => :Fs,
:Chen2022_table_B3_Gs => :Gs,
:density_ice_water => :ρᵢ,
)
p = CP.get_parameter_values(toml_dict, name_map, "CloudMicrophysics")
FT = CP.float_type(toml_dict)
return Chen2022VelTypeSnowIce{FT}(
p.A1 * (log(p.ρᵢ))^2 p.A2 * log(p.ρᵢ) - p.A3,
FT(1) / (p.B1 + p.B2 * log(p.ρᵢ) + p.B3 / sqrt(p.ρᵢ)),
p.C1 + p.C2 * exp(p.C3 * p.ρᵢ) + p.C4 * sqrt(p.ρᵢ),
p.E1 - p.E2 * (log(p.ρᵢ))^2 + p.E3 * sqrt(p.ρᵢ),
-exp(p.F1 - p.F2 * (log(p.ρᵢ))^2 + p.F3 * log(p.ρᵢ)),
FT(1) / (p.G1 + p.G2 / (log(p.ρᵢ)) - p.G3 * log(p.ρᵢ) / p.ρᵢ),
p.As[1] * (log(p.ρᵢ))^2 p.As[2] * log(p.ρᵢ) - p.As[3],
FT(1) / (p.Bs[1] + p.Bs[2] * log(p.ρᵢ) + p.Bs[3] / sqrt(p.ρᵢ)),
p.Cs[1] + p.Cs[2] * exp(p.Cs[3] * p.ρᵢ) + p.Cs[4] * sqrt(p.ρᵢ),
p.Es[1] - p.Es[2] * (log(p.ρᵢ))^2 + p.Es[3] * sqrt(p.ρᵢ),
-exp(p.Fs[1] - p.Fs[2] * (log(p.ρᵢ))^2 + p.Fs[3] * log(p.ρᵢ)),
FT(1) / (p.Gs[1] + p.Gs[2] / (log(p.ρᵢ)) - p.Gs[3] * log(p.ρᵢ) / p.ρᵢ),
p.ρᵢ,
)
end
Expand All @@ -202,17 +189,11 @@ $(DocStringExtensions.FIELDS)
"""
Base.@kwdef struct Chen2022VelTypeRain{FT} <: ParametersType{FT}
ρ0::FT
a1::FT
a2::FT
a3::FT
a::Array{FT}
a3_pow::FT
b1::FT
b2::FT
b3::FT
b::Array{FT}
b_ρ::FT
c1::FT
c2::FT
c3::FT
c::Array{FT}
end

Chen2022VelTypeRain(::Type{FT}) where {FT <: AbstractFloat} =
Expand All @@ -221,17 +202,11 @@ Chen2022VelTypeRain(::Type{FT}) where {FT <: AbstractFloat} =
function Chen2022VelTypeRain(td::CP.AbstractTOMLDict)
name_map = (;
:Chen2022_table_B1_q_coeff => :ρ0,
:Chen2022_table_B1_a1_coeff => :a1,
:Chen2022_table_B1_a2_coeff => :a2,
:Chen2022_table_B1_a3_coeff => :a3,
:Chen2022_table_B1_ai => :a,
:Chen2022_table_B1_a3_pow_coeff => :a3_pow,
:Chen2022_table_B1_b1_coeff => :b1,
:Chen2022_table_B1_b2_coeff => :b2,
:Chen2022_table_B1_b3_coeff => :b3,
:Chen2022_table_B1_bi => :b,
:Chen2022_table_B1_b_rho_coeff => :b_ρ,
:Chen2022_table_B1_c1_coeff => :c1,
:Chen2022_table_B1_c2_coeff => :c2,
:Chen2022_table_B1_c3_coeff => :c3,
:Chen2022_table_B1_ci => :c,
)
parameters = CP.get_parameter_values(td, name_map, "CloudMicrophysics")
FT = CP.float_type(td)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

[compat]
CLIMAParameters = "0.9"
KernelAbstractions = "0.9"

0 comments on commit 77e6196

Please sign in to comment.