Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
amylu00 committed Jan 23, 2024
1 parent cfaf1e0 commit 618e2a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
10 changes: 6 additions & 4 deletions parcel/Jensen_et_al_2022.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ R_d = TD.Parameters.R_d(tps)

# Saturation conversion equations
ξ(T) =
TD.saturation_vapor_pressure(tps, T, TD.Liquid()) /
TD.saturation_vapor_pressure(tps, T, TD.Ice())
TD.saturation_vapor_pressure(tps, T, TD.Liquid()) /
TD.saturation_vapor_pressure(tps, T, TD.Ice())
s_i(T, s_liq) = @. s_liq * ξ(T) # saturation ratio

# Initial conditions
Expand All @@ -45,8 +45,8 @@ qₗ = Nₗ * 4 / 3 * π * r₀^3 * ρₗ / 1.2
qᵢ = FT(0)
q = TD.PhasePartition(qᵥ + qₗ + qᵢ, qₗ, qᵢ)
R_a = TD.gas_constant_air(tps, q)
e = qᵥ * p₀ * R_v / R_a
sₗ = e / eₛ
e = qᵥ * p₀ * R_v / R_a
sₗ = e / eₛ

## Moisture dependent initial conditions
ts = TD.PhaseNonEquil_pTq(tps, p₀, T₀, q)
Expand Down Expand Up @@ -90,6 +90,7 @@ MK.xlims!(ax2, -5, 150)
MK.xlims!(ax3, -5, 150)
MK.xlims!(ax4, -5, 150)

#! format: off
MK.lines!(ax1, Jensen_t_sat, Jensen_sat, label = "Jensen et al 2022", color = :green)
MK.lines!(ax2, Jensen_t_T, Jensen_T, color = :green, label = "Jensen et al 2022")
MK.lines!(ax5, Jensen_t_ICNC, Jensen_ICNC, color = :green, label = "Jensen et al 2022")
Expand Down Expand Up @@ -149,6 +150,7 @@ for droplet_size_distribution in droplet_size_distribution_list
nbanks = 2,
position = :lc,
)
#! format: on
end

MK.save("Jensen_et_al_2022.svg", fig)
31 changes: 10 additions & 21 deletions parcel/parcel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ function parcel_model(dY, Y, p, t)
N_aer = Y[7] # number concentration of interstitial aerosol
N_liq = Y[8] # number concentration of existing water droplets
N_ice = Y[9] # number concentration of activated ice crystals
x_sulph = Y[10] # percent mass sulphuric acid


x_sulph = Y[10] # percent mass sulphuric acid

# Constants
R_v = TD.Parameters.R_v(tps)
Expand All @@ -57,7 +55,7 @@ function parcel_model(dY, Y, p, t)
e_sl = TD.saturation_vapor_pressure(tps, T, TD.Liquid())
ξ = e_sl / e_si
s_i = ξ * s_liq

# Constants and variables that depend on the moisture content
R_a = TD.gas_constant_air(tps, q)
cp_a = TD.cp_m(tps, q)
Expand All @@ -75,8 +73,6 @@ function parcel_model(dY, Y, p, t)
a5 = L_vap * L_fus / R_v / cp_a / (T^2)

# TODO - we should zero out all tendencies and augemnt them
# TODO - add immersion, homogeneous, ...
#dN_act_dt_homogeneous = FT(0)

dN_act_dt_depo = FT(0)
dqi_dt_new_depo = FT(0)
Expand Down Expand Up @@ -149,7 +145,7 @@ function parcel_model(dY, Y, p, t)
dN_aer_dt = -dN_act_dt_depo
dN_liq_dt = -dN_act_dt_immersion - dN_act_dt_hom
end

# Growth
dqi_dt_depo = FT(0)
if "Deposition" in growth_modes && N_ice > 0
Expand Down Expand Up @@ -204,7 +200,6 @@ function parcel_model(dY, Y, p, t)
# from vap-ice transitions
dq_ice_dt_iv = dqi_dt_new_depo + dqi_dt_depo
end


# Update the tendecies
dq_vap_dt = -dq_ice_dt_iv - dq_liq_dt_lv
Expand Down Expand Up @@ -269,7 +264,7 @@ The named tuple p should contain:
- droplet_size_distribution - a vector with assumed droplet size distribution. Possible options: ("Monodisperse", "Gamma")
"""
function run_parcel(IC, t_0, t_end, p)

#! format: off
FT = eltype(IC)
(; const_dt, ice_nucleation_modes, growth_modes, droplet_size_distribution) = p

Expand All @@ -288,9 +283,7 @@ function run_parcel(IC, t_0, t_end, p)
print("\n")
print("Growth modes: ")
if "Condensation" in growth_modes
print(
"Condensation on liquid droplets",
)
print("Condensation on liquid droplets",)
end
if "Condensation_DSD" in growth_modes
print("Condensation on liquid droplets")
Expand All @@ -301,22 +294,18 @@ function run_parcel(IC, t_0, t_end, p)
print("\n")
print("Size distribution modes: ")
if "Monodisperse" in droplet_size_distribution
print(
"Monodisperse size distribution",
)
print("Monodisperse size distribution")
end
if "Gamma" in droplet_size_distribution
print(
"Gamma size distribution",
)
print("Gamma size distribution")
end
if "Lognormal" in droplet_size_distribution
print(
"Lognormal size distribution",
)
print("Lognormal size distribution")
end
println(" ")

#! format: on

problem = ODE.ODEProblem(parcel_model, IC, (FT(t_0), FT(t_end)), p)
sol = ODE.solve(
problem,
Expand Down
4 changes: 2 additions & 2 deletions src/IceNucleation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ Parameterization based on Koop 2000, DOI: 10.1038/35020537.
"""
function homogeneous_J(ip::CMP.Koop2000, Δa_w::FT) where {FT}

#@assert Δa_w > ip.Δa_w_min
#@assert Δa_w < ip.Δa_w_max
@assert Δa_w > ip.Δa_w_min
@assert Δa_w < ip.Δa_w_max
if Δa_w < ip.Δa_w_min
Δa_w = ip.Δa_w_min

Check warning on line 91 in src/IceNucleation.jl

View check run for this annotation

Codecov / codecov/patch

src/IceNucleation.jl#L91

Added line #L91 was not covered by tests
elseif Δa_w > ip.Δa_w_max
Expand Down

0 comments on commit 618e2a6

Please sign in to comment.