Skip to content

Commit eb298da

Browse files
authored
Merge pull request #4105 from CliMA/aj/fixer_tendency
Moisture fixer
2 parents f7b702b + 8b263bf commit eb298da

File tree

9 files changed

+71
-2
lines changed

9 files changed

+71
-2
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/ClimaAtmos.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ include(
115115
"microphysics_wrappers.jl",
116116
),
117117
)
118+
include(
119+
joinpath(
120+
"parameterized_tendencies", "microphysics", "moisture_fixer.jl"),
121+
)
118122
include(
119123
joinpath("prognostic_equations", "vertical_diffusion_boundary_layer.jl"),
120124
)

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
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import ClimaCore.MatrixFields as MF
2+
import CloudMicrophysics.ThermodynamicsInterface as TDI
3+
4+
moisture_fixer_tendency!(Yₜ, Y, p, t, _, _) = nothing
5+
6+
function moisture_fixer_tendency!(
7+
Yₜ,
8+
Y,
9+
p,
10+
t,
11+
::NonEquilMoistModel,
12+
::Union{Microphysics1Moment, Microphysics2Moment},
13+
)
14+
if p.atmos.water.moisture_fixer
15+
moisture_species = (
16+
MF.@name(c.ρq_liq), MF.@name(c.ρq_ice),
17+
MF.@name(c.ρq_rai), MF.@name(c.ρq_sno),
18+
)
19+
qᵥ = @. lazy(
20+
specific(
21+
TDI.q_vap(Y.c.ρq_tot, Y.c.ρq_liq, Y.c.ρq_ice, Y.c.ρq_rai, Y.c.ρq_sno),
22+
Y.c.ρ,
23+
),
24+
)
25+
26+
MF.unrolled_foreach(moisture_species) do (ρq_name)
27+
ᶜρq = MF.get_field(Y, ρq_name)
28+
ᶜρqₜ = MF.get_field(Yₜ, ρq_name)
29+
ᶜq = @. lazy(specific(ᶜρq, Y.c.ρ))
30+
# Increase the grid mean small tracers if negative,
31+
# using mass from grid mean vapor.
32+
@. ᶜρqₜ += Y.c.ρ * moisture_fixer(ᶜq, qᵥ, p.dt)
33+
end
34+
end
35+
end

src/prognostic_equations/remaining_tendency.jl

Lines changed: 6 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,11 @@ 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+
# Optional tendency to bring negative small tracers back from negative
360+
# at the cost of water vapor.
361+
moisture_fixer_tendency!(Yₜ, Y, p, t, moisture_model, microphysics_model)
362+
363+
# NOTE: This will zero out all momentum tendencies in the EDMFX advection test,
360364
# where velocities do not evolve
361365
# DO NOT add additional velocity tendencies after this function
362366
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ Base.@kwdef struct AtmosWater{MM, PM, CM, NCFM, CCDPS}
610610
cloud_model::CM = nothing
611611
noneq_cloud_formation_mode::NCFM = nothing
612612
call_cloud_diagnostics_per_stage::CCDPS = nothing
613+
moisture_fixer::Bool = false
613614
end
614615

615616
"""

0 commit comments

Comments
 (0)