Skip to content

Conversation

@trontrytel
Copy link
Member

@trontrytel trontrytel commented Nov 14, 2025

Adds a tendency that adjusts negative small cloud and precipitation values towards zero at the expense of water vapor. Switched off by default to prevent it from masking other problems.

@trontrytel trontrytel changed the title wip on moisture fixer Moisture fixer Nov 14, 2025
Copy link
Member

@sajjadazimi sajjadazimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I just left a comment about how we compute qv. We can define a function for computing qv (depending on microphyiscs model) and then apply the fixer on a list of tracers (moisture_species) without checking moisture and microphyiscs models. But feel free to merge as is and leave this to future PRs.

Comment on lines +365 to +367
qᵥ = @. lazy(
specific(Y.c.ρq_tot - Y.c.ρq_liq - Y.c.ρq_ice - Y.c.ρq_rai - Y.c.ρq_sno,
Y.c.ρ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can define a function to return vapor specific humidity as it is used multiple times at different places. This way we don't have to check the microphysics model; we can have a list of tracers and return if the tracer does not exist and fix if it exists.


# NOTE: This will zero out all momentum tendencies in the EDMFX advection test,
if moisture_model isa NonEquilMoistModel &&
microphysics_model isa Microphysics1Moment &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can apply the fixer for both 1M or 2M microphysics models.

Comment on lines +359 to +380
if moisture_model isa NonEquilMoistModel &&
microphysics_model isa Microphysics1Moment &&
p.atmos.water.moisture_fixer
moisture_species = (@name(c.ρq_liq), @name(c.ρq_ice),
@name(c.ρq_rai), @name(c.ρq_sno),
)
qᵥ = @. lazy(
specific(Y.c.ρq_tot - Y.c.ρq_liq - Y.c.ρq_ice - Y.c.ρq_rai - Y.c.ρq_sno,
Y.c.ρ),
)

MatrixFields.unrolled_foreach(
moisture_species,
) do (ρq_name)
ᶜρq = MatrixFields.get_field(Y, ρq_name)
ᶜρqₜ = MatrixFields.get_field(Yₜ, ρq_name)
ᶜq = @. lazy(specific(ᶜρq, Y.c.ρ))
# Increase the grid mean small tracers if negative,
# using mass from grid mean vapor.
@. ᶜρqₜ += Y.c.ρ * moisture_fixer(ᶜq, qᵥ, p.dt)
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to move this to a function under src/parameterized_tendencies/microphysics.

cloud_model::CM = nothing
noneq_cloud_formation_mode::NCFM = nothing
call_cloud_diagnostics_per_stage::CCDPS = nothing
moisture_fixer::MF = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
moisture_fixer::MF = false
moisture_fixer::Bool = false

(I don't think we need an extra type here)

@szy21
Copy link
Member

szy21 commented Nov 15, 2025

Looks good to me, thanks! I just left some minor comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants