Skip to content

Commit f84a95c

Browse files
committed
Adds a moisture fixer tendency for small moisture tracers
1 parent a1a9948 commit f84a95c

File tree

7 files changed

+52
-3
lines changed

7 files changed

+52
-3
lines changed

config/default_configs/default_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ c_amd:
172172
smagorinsky_lilly:
173173
help: "Smagorinsky-Lilly diffusive closure [`nothing` (default), `UVW`, `UV`, `W`, `UV_W_decoupled`]"
174174
value: ~
175+
moisture_fixer:
176+
help: "A flag to switch on a grid mean tendency that moves mass from vapor to adjust small negative tracer values [false (default), true]"
177+
value: false
175178
bubble:
176179
help: "Enable bubble correction for more accurate surface areas"
177180
value: false

config/model_configs/baroclinic_wave_nonequil_conservation_source.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FLOAT_TYPE: "Float32"
22
initial_condition: "MoistBaroclinicWave"
33
t_end: "5days"
44
moist: "nonequil"
5+
moisture_fixer: true
56
surface_setup: DefaultMoninObukhov
67
prognostic_surface: "SlabOceanSST"
78
rad: "clearsky"

docs/src/microphysics.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ The magnitude of diffusion acting on precipitation tracers can be scaled using t
140140
`tracer_vertical_diffusion_factor`.
141141
There is no such scaling applied when using the Smagorinsky-Lilly or AMD models.
142142

143+
### Moisture Fixer
144+
145+
The moisture fixer is an optional grid-mean tendency correction that can be enabled for
146+
nonequilibrium moisture models with 1-moment microphysics.
147+
When enabled (via the `moisture_fixer` configuration option), the fixer adjusts small negative
148+
tracer values by transferring mass from water vapor to the affected microphysics tracers
149+
(cloud liquid, cloud ice, rain, and snow).
150+
This provides an additional safeguard against numerical errors that may produce negative tracer values,
151+
complementing the limiters and diffusion schemes described above.
152+
The fixer operates on the grid-mean tendencies and conserves total water mass.
153+
143154
## Aerosol Activation for 2-Moment Microphysics
144155

145156
Aerosol activation uses functions from the [CloudMicrophysics.jl](https://github.com/CliMA/CloudMicrophysics.jl) library, based on the Abdul-Razzak and Ghan (ARG) parameterization. ARG predicts the number of activated cloud droplets assuming a parcel of clear air rising adiabatically. This formulation is traditionally applied only at cloud base, where the maximum supersaturation typically occurs.

src/parameterized_tendencies/microphysics/microphysics_wrappers.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ function limit(q, dt, n::Int)
2929
return q / FT(dt) / n
3030
end
3131

32+
function moisture_fixer(q, qᵥ, dt)
33+
FT = eltype(q)
34+
return triangle_inequality_limiter(
35+
-min(FT(0), q / dt),
36+
limit(qᵥ, dt, 5),
37+
FT(0),
38+
)
39+
end
40+
3241
"""
3342
cloud_sources(cm_params, thp, qₜ, qₗ, qᵢ, qᵣ, qₛ, ρ, Tₐ, dt)
3443

src/prognostic_equations/remaining_tendency.jl

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ state vector `Y`.
77
This function follows a sequence:
88
1. Prepares hyperdiffusion tendencies for tracers (stored in `Yₜ_lim`).
99
2. Prepares hyperdiffusion tendencies for other state variables (e.g., momentum, energy, stored in `Yₜ`).
10-
3. If Direct Stiffness Summation (DSS) is required and hyperdiffusion is active, performs DSS on the
10+
3. If Direct Stiffness Summation (DSS) is required and hyperdiffusion is active, performs DSS on the
1111
prepared hyperdiffusion tendencies.
1212
4. Applies the (potentially DSSed) hyperdiffusion tendencies to `Yₜ_lim` and `Yₜ`.
1313
@@ -356,7 +356,30 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
356356
horizontal_amd_tendency!(Yₜ, Y, p, t, amd)
357357
vertical_amd_tendency!(Yₜ, Y, p, t, amd)
358358

359-
# NOTE: This will zero out all momentum tendencies in the EDMFX advection test,
359+
if moisture_model isa NonEquilMoistModel &&
360+
microphysics_model isa Microphysics1Moment &&
361+
p.atmos.water.moisture_fixer
362+
moisture_species = (@name(c.ρq_liq), @name(c.ρq_ice),
363+
@name(c.ρq_rai), @name(c.ρq_sno),
364+
)
365+
qᵥ = @. lazy(
366+
specific(Y.c.ρq_tot - Y.c.ρq_liq - Y.c.ρq_ice - Y.c.ρq_rai - Y.c.ρq_sno,
367+
Y.c.ρ),
368+
)
369+
370+
MatrixFields.unrolled_foreach(
371+
moisture_species,
372+
) do (ρq_name)
373+
ᶜρq = MatrixFields.get_field(Y, ρq_name)
374+
ᶜρqₜ = MatrixFields.get_field(Yₜ, ρq_name)
375+
ᶜq = @. lazy(specific(ᶜρq, Y.c.ρ))
376+
# Increase the grid mean small tracers if negative,
377+
# using mass from grid mean vapor.
378+
@. ᶜρqₜ += Y.c.ρ * moisture_fixer(ᶜq, qᵥ, p.dt)
379+
end
380+
end
381+
382+
# NOTE: This will zero out all momentum tendencies in the EDMFX advection test,
360383
# where velocities do not evolve
361384
# DO NOT add additional velocity tendencies after this function
362385
zero_velocity_tendency!(Yₜ, Y, p, t)

src/solver/type_getters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function get_atmos(config::AtmosConfig, params)
122122
noneq_cloud_formation_mode = implicit_noneq_cloud_formation ?
123123
Implicit() : Explicit(),
124124
call_cloud_diagnostics_per_stage,
125+
moisture_fixer = parsed_args["moisture_fixer"],
125126

126127
# SCMSetup - Single-Column Model components
127128
subsidence = get_subsidence_model(parsed_args, radiation_mode, FT),

src/solver/types.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,13 @@ end
604604
605605
Groups moisture-related models and types.
606606
"""
607-
Base.@kwdef struct AtmosWater{MM, PM, CM, NCFM, CCDPS}
607+
Base.@kwdef struct AtmosWater{MM, PM, CM, NCFM, CCDPS, MF}
608608
moisture_model::MM = nothing
609609
microphysics_model::PM = nothing
610610
cloud_model::CM = nothing
611611
noneq_cloud_formation_mode::NCFM = nothing
612612
call_cloud_diagnostics_per_stage::CCDPS = nothing
613+
moisture_fixer::MF = false
613614
end
614615

615616
"""

0 commit comments

Comments
 (0)