Skip to content

Commit 7149ef1

Browse files
committed
add more comments
1 parent a4713cf commit 7149ef1

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/initial_conditions/initial_conditions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ function (initial_condition::PrecipitatingColumn)(params)
12241224
thermo_state = ts,
12251225
velocity = Geometry.UVVector(u(z), v(z)),
12261226
turbconv_state = nothing,
1227-
precip_state = PrecipState2M(;
1227+
precip_state = PrecipStateMassNum(;
12281228
n_liq = nₗ(z),
12291229
n_rai = nᵣ(z),
12301230
q_rai = qᵣ(z),

src/initial_conditions/local_state.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,22 @@ struct NoPrecipState{FT} <: PrecipState{FT} end
104104
"""
105105
PrecipState2M(; q_rai, q_sno)
106106
107-
Stores the values of `n_liq`, `n_rai`, `q_rai` and `q_sno`for the `precip_model`.
108-
If no values are provided, they are set to zero.
107+
108+
Stores the values of `n_liq`, `n_rai`, `q_rai`, and `q_sno` for the `precip_model`.
109+
This struct includes both mass and number densities and can be used for initializing
110+
precipitation states in both one-moment and two-moment microphysics schemes.
111+
In one-moment schemes, the number densities (`n_liq`, `n_rai`) are ignored.
112+
If no values are provided, all fields are initialized to zero.
109113
"""
110-
struct PrecipState2M{FT} <: PrecipState{FT}
114+
struct PrecipStateMassNum{FT} <: PrecipState{FT}
111115
n_liq::FT
112116
n_rai::FT
113117
q_rai::FT
114118
q_sno::FT
115119
end
116-
PrecipState2M(;
120+
PrecipStateMassNum(;
117121
n_liq = 0,
118122
n_rai = 0,
119123
q_rai = 0,
120124
q_sno = 0,
121-
) = PrecipState2M{typeof(q_rai)}(n_liq, n_rai, q_rai, q_sno)
125+
) = PrecipStateMassNum{typeof(q_rai)}(n_liq, n_rai, q_rai, q_sno)

src/parameterized_tendencies/microphysics/microphysics_wrappers.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,14 @@ end
370370
- Sᵖ, S₂ᵖ - temporary containters to help compute precipitation source terms
371371
- Snₗᵖ, Snᵣᵖ, Sqₗᵖ, Sqᵣᵖ - cached storage for precipitation source terms
372372
- ρ - air density
373-
- nₗ, nᵣ - cloud liquid and rain number concentration per mass
373+
- nₗ, nᵣ - cloud liquid and rain number concentration per mass [1 / kg of moist air]
374374
- qₗ, qᵣ - cloud liquid and rain specific humidity
375375
- ts - thermodynamic state (see td package for details)
376376
- dt - model time step
377377
- thp, mp - structs with thermodynamic and microphysics parameters
378378
379379
Computes precipitation number and mass sources due to warm precipitation processes based on the 2-moment
380-
Seifert and Beheng (2006) scheme.
380+
[Seifert and Beheng (2006) scheme](https://clima.github.io/CloudMicrophysics.jl/dev/Microphysics2M/).
381381
"""
382382
function compute_warm_precipitation_sources_2M!(
383383
Sᵖ,
@@ -413,7 +413,7 @@ function compute_warm_precipitation_sources_2M!(
413413
ρ,
414414
ρ * nₗ,
415415
).dq_rai_dt,
416-
limit(qₗ, dt, 5),
416+
limit(qₗ, dt, 5), # cap rate to at most 20% of qₗ per timestep to ensure stability
417417
)
418418
@. Sqₗᵖ -= Sᵖ
419419
@. Sqᵣᵖ += Sᵖ
@@ -430,14 +430,17 @@ function compute_warm_precipitation_sources_2M!(
430430
).dN_liq_dt / ρ,
431431
limit(nₗ, dt, 10),
432432
)
433+
# triangle_inequality_limiter assumes positive rates and limits.
434+
# Here the physical rate is negative (a sink), so we negate it before passing,
435+
# and negate the result again to preserve the original sign.
433436
@. S₂ᵖ =
434437
-triangle_inequality_limiter(
435438
-CM2.liquid_self_collection(mp.sb.acnv, mp.sb.pdf_c, qₗ, ρ, Sᵖ) / ρ,
436439
limit(nₗ / ρ, dt, 5),
437440
)
438441
@. Snₗᵖ += Sᵖ
439442
@. Snₗᵖ += S₂ᵖ
440-
@. Snᵣᵖ -= 0.5 * Sᵖ
443+
@. Snᵣᵖ -= 0.5 * Sᵖ # each raindrop forms from two cloud particles → factor 0.5
441444

442445
# rain self-collection and breakup
443446
@. Sᵖ =

0 commit comments

Comments
 (0)