Skip to content

Add sedimentation latent heat tendency ρe and ρθ for 1M and 2M#591

Draft
kaiyuan-cheng wants to merge 15 commits into
mainfrom
kyc/vt
Draft

Add sedimentation latent heat tendency ρe and ρθ for 1M and 2M#591
kaiyuan-cheng wants to merge 15 commits into
mainfrom
kyc/vt

Conversation

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator

@kaiyuan-cheng kaiyuan-cheng commented Mar 30, 2026

This PR addresses an issue where sedimentation was unable to modulate the liquid-ice potential temperature. We are encountering the same challenge previously discussed regarding the advection of total water and moist density: no consistent way to advect moisture-coupled thermodynamic quantities alongside falling hydrometeors.

To at least address the missing influence of sedimentation on the liquid-ice potential temperature, we implemented a 1st-order upwind scheme to compute the energy flux due to sedimentation. We recognize that this approach is not fully consistent with the mass flux.

close #364 and supersede #383

Copilot AI review requested due to automatic review settings March 30, 2026 20:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds precipitation-sedimentation latent heat flux divergence tendencies so that falling hydrometeors can modulate thermodynamic prognostics (ρe and ρθ), addressing missing sedimentation impact on liquid-ice potential temperature (issue #364).

Changes:

  • Implemented a 1st-order upwind latent-heat sedimentation flux and its vertical divergence as grid_microphysical_tendency for Val(:ρe) and Val(:ρθ).
  • Applied the new tendencies to both 1M (rain; optional snow path) and 2M (cloud liquid + rain) schemes.
  • Added required operator/thermodynamics imports for flux-divergence computation and Exner scaling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
ext/BreezeCloudMicrophysicsExt/two_moment_microphysics.jl Adds sedimentation latent-heat flux divergence tendencies for 2M thermodynamics (ρe, ρθ).
ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl Adds sedimentation latent-heat flux divergence tendencies for 1M thermodynamics (ρe, ρθ).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ext/BreezeCloudMicrophysicsExt/two_moment_microphysics.jl Outdated
Comment thread ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl Outdated
Comment thread ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl Outdated
Comment thread ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl Outdated
Comment thread ext/BreezeCloudMicrophysicsExt/two_moment_microphysics.jl Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 94.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ezeCloudMicrophysicsExt/two_moment_microphysics.jl 83.33% 5 Missing ⚠️
src/Utils/product_of_arrays.jl 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@glwagner
Copy link
Copy Markdown
Member

Is this correct? shouldn't this manifest as an advection term, dz(\rho w^r \theta^li)? I don't think its correct that the latent heat appears.

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

The latent heat term should be correct here. The term dz(\rho w^r \theta^li) would mean rain advects the whole θ_li (including the contribution from other hydrometeors).

@glwagner
Copy link
Copy Markdown
Member

The latent heat term should be correct here. The term dz(\rho w^r \theta^li) would mean rain advects the whole θ_li (including the contribution from other hydrometeors).

Yes, and this is correct right?θ_li is materially conserved and via thermal equilibrium each component (dry air, vapor, rain, etc) has the same θ_li.

@glwagner
Copy link
Copy Markdown
Member

My thought is that it would be somewhat similar to the equation for moist entropy (eq 3.5) here: https://journals.ametsoc.org/view/journals/atsc/58/15/1520-0469_2001_058_2073_adatff_2.0.co_2.xml.

However I can't find a reference for what equation liquid-ice potential temperature obeys in the presence of precipitation. @kaiyuan-cheng can you indicate what principle you are using to derive the conservation equation for \theta_li?

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

kaiyuan-cheng commented Mar 31, 2026

@glwagner Here is what I think. The idea is to diagnose `θˡⁱ given the change in hydrometeor. Start from the diagnostic definition of θ_li at constant T:

θˡⁱ = (T - (ℒˡᵣ qˡ + ℒⁱᵣ qⁱ) / cᵖᵐ) / Π

Differentiate it by applying the chain rule, and setting dT = 0 (assuming sedimentation moves liquid water mass without exchanging sensible heat with the air), we get

∂θˡⁱ/∂t = -(ℒˡᵣ/(cᵖᵐ Π)) × ∂qˡ/∂t

@glwagner
Copy link
Copy Markdown
Member

glwagner commented Mar 31, 2026

and setting dT = 0

Do you mean T / Π? I think what this neglects is the change in T / Π due to phase change. In other words, your derivation is assuming that T / Π is conserved when it is not.

In fact, this non-conservation motivates the definition of θˡⁱ. In the absence of phase change it is equal to θ = T / Π, which is conserved. But it is also conserved in the presence of phase change.

Actually θˡⁱ is a linearized form of the exact conserved quantity for vanishing condensate, eg note the exponential form in Tripoli and Cotton 1981.

Note that θˡⁱ is a form of entropy. There are some approximations in TC81 as well, so I think there is yet a more exact "conserved entropy".

Tripoli and Cotton take care to mention that θˡⁱ is not conserved in the presence of precipitation. However, because precipitation is for us part of the working fluid, we can simply define θˡⁱ for precipitating species as well as non-precipitating components. We then sum them all together, and we obtain an equation for θˡⁱ which includes the fractional contribution of sedimentation to the θˡⁱ tendency.

Still trying to understand this, but I know that in other models precipitating species may be "removed" from the working fluid. In that case provided the energetics are accurate when precipitation is formed, we don't have to worry about where the rain goes afterwards.

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

kaiyuan-cheng commented Mar 31, 2026

and setting dT = 0

Do you mean T / Π? I think what this neglects is the change in T / Π due to phase change. In other words, your derivation is assuming that T / Π is conserved when it is not.

In fact, this non-conservation motivates the definition of θˡⁱ. In the absence of phase change it is equal to θ = T / Π, which is conserved. But it is also conserved in the presence of phase change.

Actually θˡⁱ is a linearized form of the exact conserved quantity for vanishing condensate, eg note the exponential form in Tripoli and Cotton 1981.

Note that θˡⁱ is a form of entropy. There are some approximations in TC81 as well, so I think there is yet a more exact "conserved entropy".

Tripoli and Cotton take care to mention that θˡⁱ is not conserved in the presence of precipitation. However, because precipitation is for us part of the working fluid, we can simply define θˡⁱ for precipitating species as well as non-precipitating components. We then sum them all together, and we obtain an equation for θˡⁱ which includes the fractional contribution of sedimentation to the θˡⁱ tendency.

Still trying to understand this, but I know that in other models precipitating species may be "removed" from the working fluid. In that case provided the energetics are accurate when precipitation is formed, we don't have to worry about where the rain goes afterwards.

By dT = 0, I meant that no sensible heat exchange associated with the hydrometeor movement, e.g., a falling raindrop does not transport "temperature" downwards. (This is acceptable, particularly in the context of θˡⁱ, because the latent heat effects are significantly larger.) Even a falling raindrop does not transport temperature, it can still change θˡⁱ locally due to mass changes scale by latent heat. This is distinct from the local conservation of θˡⁱ, where total water remains constant and only phase changes occur.

@glwagner
Copy link
Copy Markdown
Member

glwagner commented Mar 31, 2026

I think the rain does transport temperature? Also dT is not zero because of adiabatic pressure effects.

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

kaiyuan-cheng commented Mar 31, 2026

I think the rain does transport temperature? Also dT is not zero because of adiabatic pressure effects.

Strictly speaking, yes. It does transport temperature. However, I would argue that dT is negligible, given that the hydrometeor mass fraction is small and that the effect of sensible heat is much smaller than its latent heat effect. The primary goal of this PR is to account for the impact of mass exchange on θˡⁱ.

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

On second thought, I think we should consider adiabatic pressure effects in the sensible exchange. Let me revise the code.

@glwagner
Copy link
Copy Markdown
Member

See equation 18 here: https://rams.atmos.colostate.edu/cotton/vita/22.pdf

Comment thread ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl Outdated
Comment thread ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl Outdated
Copy link
Copy Markdown
Member

@glwagner glwagner left a comment

Choose a reason for hiding this comment

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

I think we should consider using the specified advection scheme for sedimentation

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

Sure, for consistency, we should use the same scheme as the mass flux. I’m not sure what the cleanest implementation would be.

@glwagner
Copy link
Copy Markdown
Member

glwagner commented Mar 31, 2026

Sure, for consistency, we should use the same scheme as the mass flux. I’m not sure what the cleanest implementation would be.

I believe you need to compute the effective total velocity for each component. This is already done for scalar_tendency, eg:

Uᵖ = microphysical_velocities(microphysics, microphysical_fields, name)
Uᵗ = sum_of_velocities(velocities, Uᵖ)
ρ_field = dynamics_density(dynamics)
@inbounds ρ = ρ_field[i, j, k]
@inbounds qᵛᵉ = specific_prognostic_moisture[i, j, k]
closure_buoyancy = AtmosphereModelBuoyancy(dynamics, formulation, constants)
# Compute moisture fractions first
q = grid_moisture_fractions(i, j, k, grid, microphysics, ρ, qᵛᵉ, microphysical_fields)
𝒰 = diagnose_thermodynamic_state(i, j, k, grid, formulation, dynamics, q)
return ( - div_ρUc(i, j, k, grid, advection, ρ_field, Uᵗ, c)

We may need to have the sedimentation velocity interface we explored a while ago:

#458

that PR is now stale, but I believe we can use its essential ideas. The key now is that we "only" need extra terms for the thermodynamic variable. We no longer need extra terms for total water.

Note, another change we have not yet made is to prognose dry density rather than total density (to avoid the need for sedimentation terms).

kaiyuan-cheng and others added 5 commits April 1, 2026 01:02
…de by local cᵖᵐΠ for ρθ

Two physics/numerics fixes to the sedimentation tendency for thermodynamic variables:

1. The ρθ formulation previously put 1/(cᵖᵐ Π) inside the flux divergence
   (evaluated at the upwind cell). The correct form computes the enthalpy flux
   divergence (same as ρe) then divides by LOCAL cᵖᵐ Π. This eliminates a
   systematic O(Δz) bias and makes ρθ and ρe formulations physically consistent.

2. Sedimentation mass reconstruction now uses Oceananigans' configured advection
   scheme (_advective_tracer_flux_z) instead of manual 1st-order upwinding,
   matching the scheme used for mass transport of ρqʳ/ρqᶜˡ.

Removes the Θˡ/Θⁱ diagnostic fields and sedimentation_theta_flux_z functions
(no longer needed). Adds advection parameter to grid_microphysical_tendency
interface so sedimentation fluxes can use the configured scheme.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
numterra-bot[bot]

This comment was marked as resolved.

Comment thread ext/BreezeCloudMicrophysicsExt/BreezeCloudMicrophysicsExt.jl Outdated
Copy link
Copy Markdown
Member

@glwagner glwagner left a comment

Choose a reason for hiding this comment

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

comment

@giordano
Copy link
Copy Markdown
Member

giordano commented Apr 2, 2026

│ WARNING: Method definition sedimentation_mass_flux_z(Any, Any, Any, Any, Any, Any, Any, Any, Any) in module BreezeCloudMicrophysicsExt at /Users/runner/work/Breeze.jl/Breeze.jl/ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl:855 overwritten at /Users/runner/work/Breeze.jl/Breeze.jl/ext/BreezeCloudMicrophysicsExt/two_moment_microphysics.jl:586.
│ ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.

Both one_moment and two_moment files defined sedimentation_mass_flux_z
with 9 untyped arguments, causing a precompilation error. Renamed the
two-moment version to two_moment_sedimentation_mass_flux_z.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

│ WARNING: Method definition sedimentation_mass_flux_z(Any, Any, Any, Any, Any, Any, Any, Any, Any) in module BreezeCloudMicrophysicsExt at /Users/runner/work/Breeze.jl/Breeze.jl/ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl:855 overwritten at /Users/runner/work/Breeze.jl/Breeze.jl/ext/BreezeCloudMicrophysicsExt/two_moment_microphysics.jl:586.
│ ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.

Good catch! Thanks!

@glwagner
Copy link
Copy Markdown
Member

glwagner commented Apr 2, 2026

should we tackle #458 first before merging this PR?

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator Author

kaiyuan-cheng commented Apr 2, 2026

should we tackle #458 first before merging this PR?

The implementation in this PR is clean: it modifies the temperature for each falling species. #458 might be more advantageous when the number of falling hydrometers is large, but I think we should prioritize filling the physics gaps first.

@glwagner
Copy link
Copy Markdown
Member

glwagner commented Apr 2, 2026

Does it mean that this PR's code has to be refactored in the future?

@kaiyuan-cheng kaiyuan-cheng marked this pull request as draft April 2, 2026 20:10
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.

Microphysics sedimentation does not change total water or liquid-ice potential temperature at the lowest level

4 participants