-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add condensation dynamic and simple test cases (#138)
* Add Condensation module * Add unit tests * Add simple condensation examples * Add new examples to tests and buildkite * CliMA Formatter * Fix example and update version # * Small changes, e.g. don't compute negative moments * Get rid of array partition; update version number * Increment subversion * rm stray .x * Remove array partition * Update plotting helper
- Loading branch information
1 parent
b136abd
commit bdac538
Showing
12 changed files
with
165 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
multi-moment bulk microphysics implementation of condensation/evaporation | ||
Includes only a single variations that involves analytical integration | ||
""" | ||
module Condensation | ||
|
||
using Cloudy | ||
using Cloudy.ParticleDistributions | ||
|
||
export get_cond_evap | ||
|
||
|
||
""" | ||
get_cond_evap(s::FT, par::NamedTuple) | ||
's' - supersaturation | ||
`par` - ODE parameters, a NamedTuple containing a list of ParticleDistributions and the condensation coefficient ξ | ||
Returns the rate of change of all prognostic moments due to condensation and evaporation (without ventilation effects) | ||
based on the equation dg(x) / dt = -3ξs d/dx(x^{1/3} g(x)) | ||
""" | ||
function get_cond_evap(s::FT, par::NamedTuple) where {FT <: Real} | ||
ξ = par.ξ | ||
n_dist = length(par.pdists) | ||
NProgMoms = [nparams(dist) for dist in par.pdists] | ||
|
||
# build diagnostic moments | ||
mom = zeros(FT, sum(NProgMoms)) | ||
for i in 1:n_dist | ||
for j in 2:NProgMoms[i] | ||
ind = get_dist_moment_ind(NProgMoms, i, j) | ||
mom[ind] = moment(par.pdists[i], FT(j - 1 - 2 / 3)) | ||
end | ||
end | ||
|
||
# calculate condensation/evaporation flux for prognostic moments | ||
cond_evap_int = zeros(FT, sum(NProgMoms)) | ||
for i in 1:n_dist | ||
for j in 2:NProgMoms[i] | ||
ind = get_dist_moment_ind(NProgMoms, i, j) | ||
cond_evap_int[ind] = 3 * FT(ξ) * s * (j - 1) * mom[ind] | ||
end | ||
end | ||
|
||
return cond_evap_int | ||
end | ||
|
||
end #module Condensation.jl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"Box model with a single gamma mode" | ||
|
||
using DifferentialEquations | ||
|
||
include("../utils/box_model_helpers.jl") | ||
include("../utils/plotting_helpers.jl") | ||
|
||
FT = Float64 | ||
|
||
# Initial condition | ||
moments_init = [100.0, 10.0, 10.0, 10.0, 20.0] | ||
dist_init = [ | ||
ExponentialPrimitiveParticleDistribution(FT(100), FT(0.1)), # 100/cm^3; 10^5 µm^3 | ||
GammaPrimitiveParticleDistribution(FT(10), FT(1), FT(1)), # 10/cm^3; 10^6 µm^3; k=1 | ||
] | ||
|
||
# Solver | ||
s = 0.05 | ||
ξ = 1e-2 | ||
tspan = (FT(0), FT(120)) | ||
rhs!(dm, m, par, t) = rhs_condensation!(dm, m, par, s) | ||
NProgMoms = [nparams(dist) for dist in dist_init] | ||
ODE_parameters = (; ξ = ξ, pdists = dist_init, NProgMoms = NProgMoms, dt = FT(10)) | ||
prob = ODEProblem(rhs!, moments_init, tspan, ODE_parameters) | ||
sol = solve(prob, SSPRK33(), dt = ODE_parameters.dt) | ||
|
||
plot_params!(sol, ODE_parameters; file_name = "condensation_expgam_params.pdf") | ||
plot_moments!(sol, ODE_parameters; file_name = "condensation_expgam_moments.pdf") | ||
plot_spectra!(sol, ODE_parameters; file_name = "condensation_expgam_spectra.pdf", logxrange = (-3, 6)) | ||
print_box_results!(sol, ODE_parameters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"Box model with a single gamma mode" | ||
|
||
using DifferentialEquations | ||
|
||
include("../utils/box_model_helpers.jl") | ||
include("../utils/plotting_helpers.jl") | ||
|
||
FT = Float64 | ||
|
||
# Initial condition | ||
moments_init = [100.0, 10.0, 2.0] | ||
dist_init = [GammaPrimitiveParticleDistribution(FT(100), FT(0.1), FT(1))] | ||
|
||
# Solver | ||
s = 0.05 | ||
ξ = 1e-2 | ||
tspan = (FT(0), FT(120)) | ||
NProgMoms = [nparams(dist) for dist in dist_init] | ||
rhs!(dm, m, par, t) = rhs_condensation!(dm, m, par, s) | ||
ODE_parameters = (; ξ = ξ, pdists = dist_init, NProgMoms = NProgMoms, dt = FT(10)) | ||
prob = ODEProblem(rhs!, moments_init, tspan, ODE_parameters) | ||
sol = solve(prob, SSPRK33(), dt = ODE_parameters.dt) | ||
|
||
plot_params!(sol, ODE_parameters; file_name = "condensation_single_gamma_params.pdf") | ||
plot_moments!(sol, ODE_parameters; file_name = "condensation_single_gamma_moments.pdf") | ||
plot_spectra!(sol, ODE_parameters; file_name = "condensation_single_gamma_spectra.pdf", logxrange = (-3, 6)) | ||
print_box_results!(sol, ODE_parameters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters