(0.105.1) Add density and gravity_wave_speed to PerturbationAdvection#5314
Merged
(0.105.1) Add density and gravity_wave_speed to PerturbationAdvection#5314
Conversation
Extends PerturbationAdvection with two optional features needed for models with density-weighted prognostic variables (e.g., anelastic models): 1. `density` field: when provided, converts density-weighted fields (ρψ) to intensive fields (ψ) before radiation and back after. This fixes the dimensional inconsistency when applying PerturbationAdvection directly to prognostic variables like ρu, ρθ, ρq. 2. `gravity_wave_speed`: additional phase speed added to the advective velocity, following Klemp & Wilhelmson (1978). Useful for momentum fields where gravity waves propagate faster than the mean flow. Both default to `nothing` and `0` respectively, so this is fully backward compatible — existing code using PerturbationAdvection is unaffected. Also adds _fill_*_halo! methods for Center-located fields, enabling PerturbationAdvection to be used on scalar fields (tracers, ρθ, etc.) in addition to Face-located velocity/momentum fields. Motivated by NumericalEarth/Breeze.jl#494 which currently maintains a separate PerturbationMomentumAdvection scheme with ~270 lines of duplicated radiation logic. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
…call sites Add a 2-positional-arg constructor for backward compatibility after the struct gained gravity_wave_speed and density fields. Update tests and validation scripts to use keyword arguments. Rename test_CGSolver to test_cgsolver to conform with naming conventions. Co-Authored-By: Claude Opus 4.6 <[email protected]>
glwagner
commented
Feb 20, 2026
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Member
Author
|
i think tests will pass but CI is being flaky now |
glwagner
commented
Feb 24, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5314 +/- ##
==========================================
+ Coverage 68.94% 73.45% +4.51%
==========================================
Files 398 398
Lines 21793 22574 +781
==========================================
+ Hits 15025 16582 +1557
+ Misses 6768 5992 -776
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jagoosw
approved these changes
Feb 24, 2026
| end | ||
|
|
||
| # Backward compatibility: support old 2-positional-arg constructor | ||
| PerturbationAdvection(inflow_timescale::Number, outflow_timescale::Number) = |
Collaborator
There was a problem hiding this comment.
I'm not sure this type annotation is necessary
Member
Author
There was a problem hiding this comment.
agree, its just the 2 arguments that are needed
glwagner
commented
Feb 24, 2026
tomchor
reviewed
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends
PerturbationAdvectionwith two optional keyword arguments for models with density-weighted prognostic variables (e.g., anelastic atmospheric models):density: when provided, converts density-weighted fields (ρψ) to intensive fields (ψ) before radiation and back after. Fixes the dimensional inconsistency when applyingPerturbationAdvectiondirectly to prognostic variables like ρu, ρθ, ρq.gravity_wave_speed: additional phase speed added to the advective velocity, following Klemp & Wilhelmson (1978). Useful for momentum fields where gravity waves propagate faster than the mean flow.Both default to
nothingand0respectively, so this is fully backward compatible.Also adds
_fill_*_halo!methods forCenter-located fields, enablingPerturbationAdvectionto be used on scalar fields (tracers, ρθ, etc.) in addition toFace-located velocity/momentum fields.Motivation
This is motivated by NumericalEarth/Breeze.jl#494, which would otherwise have to maintain a separate
PerturbationMomentumAdvectionscheme with ~270 lines of duplicated radiation logic. With this upstream change, Breeze can usePerturbationAdvectiondirectly and delete the duplicate code.Test plan
PerturbationAdvectionAPI is unchanged (new kwargs have defaults)🤖 Generated with Claude Code