Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Feb 15, 2024
1 parent ff72717 commit ffdd7fb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 40 deletions.
2 changes: 1 addition & 1 deletion ext/EmulatorModelsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function AA.N_activated_per_mode(
:initial_pressure => p,
)
X = DF.DataFrame([merge(reduce(merge, per_mode_data), additional_data)])
max(FT(0), min(FT(1), MLJ.predict(scheme.machine, X)[1])) *
max(FT(0), min(FT(1), MLJ.predict(ml.machine, X)[1])) *
ad.Modes[i].N
end
end
Expand Down
20 changes: 4 additions & 16 deletions src/AerosolActivation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export mean_hygroscopicity_parameter,
total_M_activated

"""
coeff_of_curvature(ap, T)
- `ap` - a struct with aerosol activation parameters
Expand Down Expand Up @@ -151,16 +150,6 @@ function max_supersaturation(
p_vs::FT = TD.saturation_vapor_pressure(tps, T, TD.Liquid())
G::FT = CO.G_func(aip, tps, T, TD.Liquid()) / ap.ρ_w

# TODO - add a test with the overwritten params
# New values of parameters obtained through calibration.
# TODO: Do we want to swap them for defaults in CLIMAParameters?
#f1 = 0.26583888195264627
#f2 = 2.3851515425961853
#g1 = 0.779519468021862
#g2 = 0.10571967167118024
#p1 = 1.6523365679298359
#p2 = 0.7578626397779737

# eq 11, 12 in Razzak et al 1998
# but following eq 10 from Rogers 1975
α::FT = L * ap.g * ϵ / R_m / cp_m / T^2 - ap.g / R_m / T
Expand All @@ -176,14 +165,13 @@ function max_supersaturation(

mode_i = ad.Modes[i]

f::FT = ap.f1 * exp(ap.f2 * (log(mode_i.stdev))^2)
g::FT = ap.g1 + ap.g2 * log(mode_i.stdev)
η::FT =
* w / G)^FT(3 / 2) / (FT(2 * pi) * ap.ρ_w * γ * mode_i.N)
f::FT = 0.5 * exp(2.5 * (log(mode_i.stdev))^2)
g::FT = 1 + 0.25 * log(mode_i.stdev)
η::FT =* w / G)^FT(3 / 2) / (FT(2 * pi) * ap.ρ_w * γ * mode_i.N)

tmp +=
1 / (Sm[i])^2 *
(f */ η)^ap.p1 + g * (Sm[i]^2 /+ 3 * ζ))^ap.p2)
(f */ η)^FT(3 / 2) + g * (Sm[i]^2 /+ 3 * ζ))^FT(3 / 4))
end

return FT(1) / sqrt(tmp)
Expand Down
12 changes: 0 additions & 12 deletions src/parameters/AerosolActivation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ Base.@kwdef struct AerosolActivationParameters{FT} <: ParametersType{FT}
σ::FT
"gravitational_acceleration [m/s2]"
g::FT
"scaling coefficient in Abdul-Razzak and Ghan 2000 [-]"
f1::FT
"scaling coefficient in Abdul-Razzak and Ghan 2000 [-]"
f2::FT
"scaling coefficient in Abdul-Razzak and Ghan 2000 [-]"
g1::FT
"scaling coefficient in Abdul-Razzak and Ghan 2000 [-]"
g2::FT
"power of (zeta / eta) in Abdul-Razzak and Ghan 2000 [-]"
p1::FT
"power of (S_m^2 / (zeta + 3 * eta)) in Abdul-Razzak and Ghan 2000 [-]"
p2::FT
end

AerosolActivationParameters(::Type{FT}) where {FT <: AbstractFloat} =
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
CloudMicrophysics = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

Expand Down
14 changes: 4 additions & 10 deletions test/aerosol_activation_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ function test_aerosol_activation(FT)
aip = CMP.AirProperties(FT)
ap = CMP.AerosolActivationParameters(FT)

#ARG2000 = CMT.ARG2000Type()

# Atmospheric conditions
T = FT(294) # air temperature K
p = FT(1e5) # air pressure Pa
Expand Down Expand Up @@ -246,16 +244,12 @@ function test_aerosol_activation(FT)
N_act_frac_κ[it] =
AA.N_activated_per_mode(ap, AD_κ, aip, tps, T, p, w, q)[1] /
N_1_paper
#@info("1 ", N_act_frac_B[it], N_act_obs[it])
#@info("2 ", N_act_frac_κ[it], N_act_obs[it])
# TODO - i think this has to do with using different parameters in ARG
TT.@test isapprox(N_act_frac_B[it], N_act_obs[it], rtol = 0.45)# TODO rtol 0.05
TT.@test isapprox(N_act_frac_κ[it], N_act_obs[it], rtol = 0.45)# TODO rtol 0.1
it += 1
end
#TODO
#TT.@test all(isapprox(N_act_frac_B, N_act_obs, rtol = 0.05))
#TT.@test all(isapprox(N_act_frac_κ, N_act_obs, rtol = 0.1))

TT.@test all(isapprox(N_act_frac_B, N_act_obs, rtol = 0.05))
TT.@test all(isapprox(N_act_frac_κ, N_act_obs, rtol = 0.1))

end
end

Expand Down

0 comments on commit ffdd7fb

Please sign in to comment.