Skip to content

Commit

Permalink
Merge branch 'main' into gb/fix
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel authored Oct 9, 2024
2 parents a16fcb8 + c0fd779 commit 20f6c9c
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 223 deletions.
248 changes: 121 additions & 127 deletions docs/src/IceNucleationParcel0D.md

Large diffs are not rendered by default.

23 changes: 9 additions & 14 deletions parcel/Example_AerosolActivation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ IC = [Sₗ, p₀, T₀, qᵥ, qₗ, qᵢ, Nₐ, Nₗ, Nᵢ, ln_INPC]
# Simulation parameters passed into ODE solver
w = FT(1.2) # updraft speed
const_dt = FT(1) # model timestep
t_max = FT(100) # total time
t_max = FT(35) # total time
aerosol = CMP.Sulfate(FT)

condensation_growth = "Condensation"
Expand All @@ -64,20 +64,15 @@ params = parcel_params{FT}(
sol = run_parcel(IC, FT(0), t_max, params)

# Plot results
fig = MK.Figure(size = (1000, 800), fontsize = 20)
ax1 = MK.Axis(fig[1, 1], ylabel = "Liquid Saturation [-]")
ax2 = MK.Axis(fig[1, 2], xlabel = "Time [s]", ylabel = "Temperature [K]")
ax3 = MK.Axis(fig[2, 1], ylabel = "N_aero [m^-3]", xlabel = "Time [s]")
ax4 = MK.Axis(fig[2, 2], ylabel = "N_liq [m^-3]", xlabel = "Time [s]")
ax5 = MK.Axis(fig[3, 1], ylabel = "q_vap [g/kg]", xlabel = "Time [s]")
ax6 = MK.Axis(fig[3, 2], ylabel = "q_liq [g/kg]", xlabel = "Time [s]")
fig = MK.Figure(size = (800, 300), fontsize = 20)
ax1 = MK.Axis(fig[1, 1], ylabel = "Liquid Saturation [-]", xlabel = "Time [s]")
ax2 = MK.Axis(fig[1, 2], ylabel = "N [m^-3]", xlabel = "Time [s]")

MK.lines!(ax1, sol.t, (sol[1, :])) # liq saturation
MK.lines!(ax2, sol.t, sol[3, :]) # temperature
MK.lines!(ax3, sol.t, sol[7, :]) # N_aero
MK.lines!(ax4, sol.t, sol[8, :]) # N_liq
MK.lines!(ax5, sol.t, sol[4, :] .* 1e3) # q_vap
MK.lines!(ax6, sol.t, sol[5, :] .* 1e3) # q_liq
MK.lines!(ax1, sol.t, (sol[1, :]), linewidth = 2)
MK.lines!(ax2, sol.t, sol[7, :], label = "N_aero", linewidth = 2, color = :red)
MK.lines!(ax2, sol.t, sol[8, :], label = "N_liq", linewidth = 2, color = :blue)

MK.axislegend(ax2, framevisible = false, labelsize = 16, position = :rc)

MK.save("Parcel_Aerosol_Activation.svg", fig)
nothing
17 changes: 6 additions & 11 deletions parcel/Example_Deposition_Nucleation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ deposition_growth = "Deposition"
size_distribution = "Monodisperse"

# Plotting
fig = MK.Figure(size = (800, 600))
ax1 = MK.Axis(fig[1, 1], ylabel = "Ice Saturation [-]")
ax2 = MK.Axis(fig[1, 2], ylabel = "Temperature [K]")
ax3 = MK.Axis(fig[2, 1], ylabel = "q_ice [g/kg]", xlabel = "time")
ax4 = MK.Axis(fig[2, 2], ylabel = "N_ice [m^-3]", xlabel = "time")
fig = MK.Figure(size = (800, 300))
ax1 = MK.Axis(fig[1, 1], ylabel = "Ice Saturation [-]", xlabel = "time")
ax2 = MK.Axis(fig[1, 2], ylabel = "N_ice [m^-3]", xlabel = "time")

for deposition in deposition_modes
if deposition == "MohlerRate"
Expand Down Expand Up @@ -79,9 +77,7 @@ for deposition in deposition_modes
S_i.(tps, sol[3, :], sol[1, :]),
label = aero_label,
)
MK.lines!(ax2, sol.t, sol[3, :]) # temperature
MK.lines!(ax3, sol.t, sol[6, :] * 1e3) # q_ice
MK.lines!(ax4, sol.t, sol[9, :]) # N_ice
MK.lines!(ax2, sol.t, sol[9, :]) # N_ice
end

elseif deposition == "ABDINM"
Expand Down Expand Up @@ -113,9 +109,7 @@ for deposition in deposition_modes
label = aero_label,
linestyle = :dash,
)
MK.lines!(ax2, sol.t, sol[3, :], linestyle = :dash) # temperature
MK.lines!(ax3, sol.t, sol[6, :] * 1e3, linestyle = :dash) # q_ice
MK.lines!(ax4, sol.t, sol[9, :], linestyle = :dash) # N_ice
MK.lines!(ax2, sol.t, sol[9, :], linestyle = :dash) # N_ice
end
end
end
Expand All @@ -130,3 +124,4 @@ MK.axislegend(
)

MK.save("deposition_nucleation.svg", fig)
nothing
59 changes: 20 additions & 39 deletions parcel/Example_Jensen_et_al_2022.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,25 @@ Jensen_t_ICNC = [0.217, 42.69, 50.02, 54.41, 58.97, 65.316, 72.477, 82.08, 92.65
Jensen_ICNC = [0, 0, 0.282, 0.789, 1.804, 4.1165, 7.218, 12.12, 16.35, 16.8, 16.97, 17.086]
#! format: on

fig = MK.Figure(size = (1000, 1000))
ax1 = MK.Axis(fig[1, 1], ylabel = "Saturation")
ax2 = MK.Axis(fig[3, 1], xlabel = "Time [s]", ylabel = "Temperature [K]")
ax3 = MK.Axis(fig[2, 1], ylabel = "q_vap [g/kg]")
ax4 = MK.Axis(fig[2, 2], xlabel = "Time [s]", ylabel = "q_liq [g/kg]")
ax5 = MK.Axis(fig[1, 2], ylabel = "ICNC [cm^-3]")
ax6 = MK.Axis(fig[3, 2], ylabel = "q_ice [g/kg]")

MK.ylims!(ax2, 188.5, 190)
MK.xlims!(ax2, -5, 150)
MK.xlims!(ax3, -5, 150)
MK.xlims!(ax4, -5, 150)
fig = MK.Figure(size = (800, 300), fontsize = 20)
ax1 = MK.Axis(fig[1, 1], ylabel = "Saturation", xlabel = "Time [s]")
ax2 = MK.Axis(fig[1, 2], ylabel = "ICNC [cm^-3]", xlabel = "Time [s]")

MK.lines!(
ax1,
Jensen_t_sat,
Jensen_sat,
label = "Jensen et al 2022",
color = :green,
linewidth = 2,
)
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",
linewidth = 2,
)

params = parcel_params{FT}(
Expand All @@ -113,37 +99,32 @@ MK.lines!(
S_i.(tps, sol[3, :], (sol[1, :])),
label = "ice",
color = :blue,
linewidth = 2,
)
MK.lines!(ax1, sol.t, (sol[1, :]), label = "liquid", color = :red) # liq saturation
MK.lines!(ax2, sol.t, sol[3, :], label = "CM.jl") # temperature
MK.lines!(ax3, sol.t, sol[4, :] * 1e3) # q_vap
MK.lines!(ax4, sol.t, sol[5, :] * 1e3) # q_liq
MK.lines!(ax5, sol.t, sol[9, :] * 1e-6, label = "CM.jl") # ICNC
MK.lines!(ax6, sol.t, sol[6, :] * 1e3) # q_ice
MK.lines!(
ax1,
sol.t,
(sol[1, :]),
label = "liquid",
color = :red,
linewidth = 2,
) # liq saturation
MK.lines!(ax2, sol.t, sol[9, :] * 1e-6, label = "CM.jl", linewidth = 2) # ICNC

MK.axislegend(
ax1,
framevisible = false,
labelsize = 12,
orientation = :horizontal,
nbanks = 2,
position = :lc,
)
MK.axislegend(
ax5,
framevisible = false,
labelsize = 12,
orientation = :horizontal,
nbanks = 2,
labelsize = 16,
orientation = :vertical,
position = :lc,
)
MK.axislegend(
ax2,
framevisible = false,
labelsize = 12,
orientation = :horizontal,
nbanks = 2,
labelsize = 16,
orientation = :vertical,
position = :lc,
)

MK.save("Jensen_et_al_2022.svg", fig)
nothing
26 changes: 11 additions & 15 deletions parcel/Example_Liquid_only.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,15 @@ Rogers_time_supersat = [0.0645, 0.511, 0.883, 1.4, 2.07, 2.72, 3.24, 3.89, 4.53,
Rogers_supersat = [0.0268, 0.255, 0.393, 0.546, 0.707, 0.805, 0.863, 0.905, 0.938, 0.971, 0.978, 0.963, 0.910, 0.885]
Rogers_time_radius = [0.561, 2, 3.99, 10.7, 14.9, 19.9]
Rogers_radius = [8.0, 8.08, 8.26, 8.91, 9.26, 9.68]
#! format: on

# Setup the plots
fig = MK.Figure(size = (800, 600))
ax1 = MK.Axis(fig[1, 1], ylabel = "Supersaturation [%]")
ax2 = MK.Axis(fig[3, 1], xlabel = "Time [s]", ylabel = "Temperature [K]")
ax3 = MK.Axis(fig[2, 1], ylabel = "q_vap [g/kg]")
ax4 = MK.Axis(fig[2, 2], xlabel = "Time [s]", ylabel = "q_liq [g/kg]")
ax5 = MK.Axis(fig[1, 2], ylabel = "radius [μm]")
MK.lines!(ax1, Rogers_time_supersat, Rogers_supersat, label = "Rogers_1975")
MK.lines!(ax5, Rogers_time_radius, Rogers_radius)
fig = MK.Figure(size = (800, 300))
ax1 = MK.Axis(fig[1, 1], xlabel = "Time [s]", ylabel = "Supersaturation [%]")
ax2 = MK.Axis(fig[1, 2], xlabel = "Time [s]", ylabel = "radius [μm]")
ax3 = MK.Axis(fig[1, 3], xlabel = "Time [s]", ylabel = "q_liq [g/kg]")
MK.lines!(ax1, Rogers_time_supersat, Rogers_supersat, label = "Rogers_1975", color = :red)
MK.lines!(ax2, Rogers_time_radius, Rogers_radius, color = :red)
#! format: on

for DSD in liq_size_distribution_list
local params = parcel_params{FT}(
Expand All @@ -74,9 +72,7 @@ for DSD in liq_size_distribution_list

# Plot results
MK.lines!(ax1, sol.t, (sol[1, :] .- 1) * 100.0, label = DSD)
MK.lines!(ax2, sol.t, sol[3, :])
MK.lines!(ax3, sol.t, sol[4, :] * 1e3)
MK.lines!(ax4, sol.t, sol[5, :] * 1e3)
MK.lines!(ax3, sol.t, sol[5, :] * 1e3)

sol_Nₗ = sol[8, :]
sol_Nᵢ = sol[9, :]
Expand All @@ -96,16 +92,16 @@ for DSD in liq_size_distribution_list
for it in range(1, length(sol_T))
r[it] = moms[it].r
end
MK.lines!(ax5, sol.t, r * 1e6)
MK.lines!(ax2, sol.t, r * 1e6)
end

MK.axislegend(
ax1,
framevisible = false,
labelsize = 12,
orientation = :horizontal,
nbanks = 2,
orientation = :vertical,
position = :rb,
)

MK.save("liquid_only_parcel.svg", fig)
nothing
25 changes: 9 additions & 16 deletions parcel/Example_P3_ice_nuc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Nₗ = FT(2000)
Nᵢ = FT(0)
rₗ = FT(1.25e-6)
p₀ = FT(20000)
qᵥ = FT(8.3e-4)
qᵥ = FT(5e-4)
qₗ = FT(Nₗ * 4 / 3 * π * rₗ^3 * wps.ρw / 1.2)
qᵢ = FT(0)
ln_INPC = FT(0)
Expand All @@ -37,21 +37,15 @@ deposition_growth = "Deposition"
size_distribution = "Monodisperse"

# Plotting
fig = MK.Figure(size = (900, 600))
ax1 = MK.Axis(fig[1, 1], ylabel = "Ice Saturation [-]")
ax2 = MK.Axis(fig[1, 2], ylabel = "ICNC [cm^-3]")
ax7 = MK.Axis(fig[1, 3], ylabel = "Temperature [K]")
ax3 = MK.Axis(fig[2, 1], ylabel = "Ice Saturation [-]")
ax4 = MK.Axis(fig[2, 2], ylabel = "ICNC [cm^-3]")
ax8 = MK.Axis(fig[2, 3], ylabel = "Temperature [K]")
ax5 = MK.Axis(fig[3, 1], ylabel = "Ice Saturation [-]", xlabel = "Time [s]")
ax6 = MK.Axis(fig[3, 2], ylabel = "ICNC [cm^-3]", xlabel = "Time [s]")
ax9 = MK.Axis(fig[3, 3], ylabel = "Temperature [K]", xlabel = "Time [s]")
fig = MK.Figure(size = (1000, 350), fontsize = 20)
ax1 = MK.Axis(fig[1, 1], ylabel = "ICNC [cm^-3]", xlabel = "Time [s]")
ax2 = MK.Axis(fig[1, 2], ylabel = "ICNC [cm^-3]", xlabel = "Time [s]")
ax3 = MK.Axis(fig[1, 3], ylabel = "ICNC [cm^-3]", xlabel = "Time [s]")

ice_nucleation_modes_list = ["P3_dep", "P3_het", "P3_hom"]
T₀_list = [FT(235), FT(235), FT(233.2)]
color = [:blue, :red, :orange]
ax_row = [[ax1, ax2, ax7], [ax3, ax4, ax8], [ax5, ax6, ax9]]
ax_list = [ax1, ax2, ax3]

for it in [1, 2, 3]
mode = ice_nucleation_modes_list[it]
Expand Down Expand Up @@ -94,12 +88,11 @@ for it in [1, 2, 3]
# solve ODE
local sol = run_parcel(IC, FT(0), t_max, params)

MK.lines!(ax_row[it][1], sol.t, S_i.(tps, sol[3, :], (sol[1, :])), label = mode, color = color[it]) # saturation
MK.lines!(ax_row[it][2], sol.t, sol[9, :] * 1e-6, color = color[it]) # ICNC
MK.lines!(ax_row[it][3], sol.t, sol[3, :], color = color[it]) # Temperature
MK.axislegend(ax_row[it][1], framevisible = false, labelsize = 12, orientation = :horizontal, position = :rt)
MK.lines!(ax_list[it], sol.t, sol[9, :] * 1e-6, label = mode, color = color[it]) # saturation
MK.axislegend(ax_list[it], framevisible = false, labelsize = 12, orientation = :horizontal, position = :rb)

#! format: on
end

MK.save("P3_ice_nuc.svg", fig)
nothing
1 change: 1 addition & 0 deletions parcel/Example_Tully_et_al_2023.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,4 @@ function Tully_et_al_2023(FT)
MK.save("cirrus_box.svg", fig)
end
Tully_et_al_2023(Float32)
nothing
2 changes: 1 addition & 1 deletion test/performance_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function benchmark_test(FT)
bench_press(CMI_hom.homogeneous_J_linear, (ip.homogeneous, Delta_a_w), 230)

# non-equilibrium
bench_press(CMN.τ_relax, (liquid,), 10)
bench_press(CMN.τ_relax, (liquid,), 15)
bench_press(
CMN.conv_q_vap_to_q_liq_ice,
(
Expand Down

0 comments on commit 20f6c9c

Please sign in to comment.