Skip to content

Conversation

@haakon-e
Copy link
Member

@haakon-e haakon-e commented Jan 13, 2026

This pull request introduces improvements to how scalar nonnegativity is enforced. The main focus is on ensuring that condensate mass variables remain physically valid (non-negative) throughout computations.

Physical Constraints Enforcement:

  • A new function preserve_scalar_nonnegativity! is introduced in dss! (src/prognostic_equations/dss.jl) to explicitly enforce nonnegativity for condensate mass fields (e.g., ρq_liq, ρq_rai, ρq_ice, ρq_sno, ρq_tot). This function clips negative values to zero and applies the limiter, ensuring physically meaningful results for these quantities.
  • The call to preserve_scalar_nonnegativity! is added to the main dss! routine, so nonnegativity is enforced every time dss! runs.

condensate_mass_names = (
@name(ρq_liq), @name(ρq_rai),
@name(ρq_ice), @name(ρq_sno),
@name(ρq_tot),
Copy link
Member

Choose a reason for hiding this comment

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

You don't want to clip q_tot--we'd lose water mass conservation.

Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, it decreases q_tot in other nodal points within the element if it is clipped, so that it conserves water mass within the element.

Copy link
Member

Choose a reason for hiding this comment

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

Why should we mess with q_tot here? Isn't it more natural to deal with this through vertical water borrowing?

Copy link
Member Author

Choose a reason for hiding this comment

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

How is vertical water borrowing more natural than horizontal water borrowing?

That said, I'm fine removing q_tot for now.

Copy link
Member

Choose a reason for hiding this comment

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

There are large gradients in the vertical but not necessarily in the horizontal.

Copy link
Member

Choose a reason for hiding this comment

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

What if q_tot becomes negative because of the horizontal dynamics? Also if there are large gradients in vertical and not necessarily in horizontal, isn't it better to borrow horizontally to not affect those large gradients?

Copy link
Member

Choose a reason for hiding this comment

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

If we adjust q_tot horizontally, we create spurious transport over O(100 km) and change total column water, which controls precipitation. It will lead to precip errors.

If we adjust q_tot vertically, we create spurious transport over O(100 m) and leave total column water unchanged. It is less likely to lead to precip errors.

For condensate, the spurious transport argument over large horizontal distances also applies. But it's generally a less severe problem because condensate << total.

Copy link
Member

Choose a reason for hiding this comment

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

I was also thinking that transporting tracers in the vertical is the worse option than in the horizontal. I agree that distances are larger in the horizontal, but to the first approximation the vertical velocity is zero in the atmosphere. Also the saturation vapor pressure differences are larger in the vertical. So we might end up creating clouds in the vertical due to issues with horizontal transport. Especially since with stretched grid, higher up the spacing is larger than O(100m).

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with whatever works in the end. However, I am worried about creating a pathway that can hide O(1) errors (in q_tot).

Copy link
Member

Choose a reason for hiding this comment

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

Lets test with and without applying those changes to q_tot. I hope there is a way to set up other numerics flags (diffusion/hyperdiffusion, limiters) that will allow us to run without it applied on q_tot

@haakon-e haakon-e force-pushed the he/wip-nonnegativity-element branch from 65de513 to 07969e4 Compare January 13, 2026 23:21
@haakon-e haakon-e force-pushed the he/wip-nonnegativity-element branch from 07969e4 to cbc8faf Compare January 15, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants