Skip to content

Commit

Permalink
Merge pull request #320 from CliMA/aj/update_to_CLIMAParameters9
Browse files Browse the repository at this point in the history
Update to CLIMAParameters v0.9 and Thermodynamics v0.12
  • Loading branch information
trontrytel authored Feb 14, 2024
2 parents cb7302f + af49482 commit 11fd264
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 65 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CloudMicrophysics"
uuid = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
authors = ["Climate Modeling Alliance"]
version = "0.15.2"
version = "0.16.0"

[deps]
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
Expand All @@ -12,10 +12,10 @@ 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"
SpecialFunctions = "1, 2"
Thermodynamics = "0.11"
Thermodynamics = "0.12"
julia = "1.6"
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[compat]
CLIMAParameters = "0.8"
CLIMAParameters = "0.9"
Documenter = "1.1"
DocumenterCitations = "1.2"
2 changes: 1 addition & 1 deletion parcel/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

[compat]
CLIMAParameters = "0.8"
CLIMAParameters = "0.9"
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, a, a3_pow, b, b_ρ, c) = 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
67 changes: 22 additions & 45 deletions src/parameters/TerminalVelocity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,36 +156,23 @@ 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[2] * (log(p.ρᵢ))^2 p.As[3] * log(p.ρᵢ) + p.As[1],
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 @@ -200,19 +187,13 @@ DOI: 10.1016/j.atmosres.2022.106171
# Fields
$(DocStringExtensions.FIELDS)
"""
Base.@kwdef struct Chen2022VelTypeRain{FT} <: ParametersType{FT}
Base.@kwdef struct Chen2022VelTypeRain{FT, N} <: ParametersType{FT}
ρ0::FT
a1::FT
a2::FT
a3::FT
a::NTuple{N, FT}
a3_pow::FT
b1::FT
b2::FT
b3::FT
b::NTuple{N, FT}
b_ρ::FT
c1::FT
c2::FT
c3::FT
c::NTuple{N, FT}
end

Chen2022VelTypeRain(::Type{FT}) where {FT <: AbstractFloat} =
Expand All @@ -221,21 +202,17 @@ 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")
# hack!
parameters = map(p -> p isa Vector ? Tuple(p) : p, parameters)
FT = CP.float_type(td)
return Chen2022VelTypeRain{FT}(; parameters...)
return Chen2022VelTypeRain{FT, 3}(; parameters...)
end

"""
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"
1 change: 1 addition & 0 deletions test/aerosol_activation_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Test as TT

import CLIMAParameters
import CloudMicrophysics as CM
import Thermodynamics as TD

Expand Down
1 change: 1 addition & 0 deletions test/common_functions_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Test as TT

import CLIMAParameters
import Thermodynamics as TD
import CloudMicrophysics as CM
import CloudMicrophysics.Common as CO
Expand Down
1 change: 1 addition & 0 deletions test/microphysics0M_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Test as TT

import CLIMAParameters
import Thermodynamics as TD

import CloudMicrophysics.Parameters as CMP
Expand Down
1 change: 1 addition & 0 deletions test/microphysics_noneq_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Test as TT

import CLIMAParameters
import Thermodynamics as TD

import CloudMicrophysics.Parameters as CMP
Expand Down
1 change: 1 addition & 0 deletions test/p3_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Test as TT
import CLIMAParameters
import CloudMicrophysics as CM
import CloudMicrophysics.P3Scheme as P3
import CloudMicrophysics.Parameters as CMP
Expand Down
1 change: 1 addition & 0 deletions test/performance_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Test as TT
import BenchmarkTools as BT

import CLIMAParameters
import Thermodynamics as TD

import CloudMicrophysics.Common as CO
Expand Down

2 comments on commit 11fd264

@trontrytel
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/100824

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.16.0 -m "<description of version>" 11fd26480e493b2aa4f0b3c84f74890114f8982f
git push origin v0.16.0

Please sign in to comment.