Skip to content

sedimentation_velocity interface + effective liquid/ice velocities#614

Open
kaiyuan-cheng wants to merge 22 commits into
mainfrom
kyc/sedimentation2
Open

sedimentation_velocity interface + effective liquid/ice velocities#614
kaiyuan-cheng wants to merge 22 commits into
mainfrom
kyc/sedimentation2

Conversation

@kaiyuan-cheng
Copy link
Copy Markdown
Collaborator

Summary

  • Introduce sedimentation_speed interface (positive magnitude) replacing microphysical_velocities as the primary interface for microphysics schemes
  • Add water_phase for liquid/ice phase classification of mass tracers
  • Add NegatedField wrapper and generic microphysical_velocities that calls sedimentation_speed
  • Precompute effective sedimentation velocities 𝕎ᴸ (total liquid) and 𝕎ᴵ (total ice) on AtmosphereModel.effective_sedimentation_velocities
  • Change sign convention: terminal velocity fields (, wᶜˡ, etc.) now store positive magnitudes

Overhauls #458 — computes effective velocities for total liquid and total ice separately instead of total moisture.

Test plan

  • 1M microphysics tests pass (90/90)
  • 2M microphysics tests pass (82/82)
  • Full CI

🤖 Generated with Claude Code

Introduce a `sedimentation_speed` interface (positive magnitude) replacing
`microphysical_velocities` as the primary interface for microphysics schemes.
Add `water_phase` for liquid/ice classification, `NegatedField` wrapper, and
precomputed effective sedimentation velocities (𝕎ᴸ, 𝕎ᴵ) on AtmosphereModel.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kaiyuan-cheng kaiyuan-cheng marked this pull request as ready for review April 7, 2026 02:43
Copilot AI review requested due to automatic review settings April 7, 2026 02:43
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

This PR refactors the microphysics sedimentation interface to use a new sedimentation_speed API (positive magnitudes) while keeping microphysical_velocities as a generic wrapper, and adds model-level precomputed effective sedimentation velocities for total liquid and total ice.

Changes:

  • Introduces sedimentation_speed + water_phase interfaces and a NegatedField wrapper to produce advection-ready vertical velocities with the correct sign convention.
  • Adds model.effective_sedimentation_velocities (ρqᴸ, ρqᴵ) and updates it each update_state! via a kernel computing mass-weighted phase-aggregate sedimentation velocities.
  • Updates CloudMicrophysics extensions, docs, and tests for the new sign convention (terminal/sedimentation speed fields are now stored as positive magnitudes).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/cloud_microphysics_2M.jl Updates tests for positive sedimentation magnitudes; adds interface checks for sedimentation_speed/water_phase and presence of effective velocities.
test/cloud_microphysics_1M.jl Same as 2M: updates sign expectations and adds new interface/effective-velocity assertions.
src/Microphysics/saturation_adjustment.jl Switches scheme hook from microphysical_velocities to sedimentation_speed (returns nothing).
src/Microphysics/dcmip2016_kessler.jl Switches to sedimentation_speed (returns nothing) and updates related comments.
src/AtmosphereModels/update_atmosphere_model_state.jl Updates update_state! to refresh effective_sedimentation_velocities each step.
src/AtmosphereModels/microphysics_interface.jl Adds the new interface, NegatedField, generic microphysical_velocities wrapper, and effective-velocity materialization/update kernel.
src/AtmosphereModels/AtmosphereModels.jl Exports the new interface symbols and imports grid location types used by effective velocity allocation.
src/AtmosphereModels/atmosphere_model.jl Adds effective_sedimentation_velocities field to AtmosphereModel and initializes it during construction.
ext/BreezeCloudMicrophysicsExt/zero_moment_microphysics.jl Updates extension to implement sedimentation_speed(...)=nothing.
ext/BreezeCloudMicrophysicsExt/two_moment_microphysics.jl Converts terminal-velocity storage to positive magnitudes and implements sedimentation_speed + water_phase.
ext/BreezeCloudMicrophysicsExt/two_moment_helpers.jl Updates surface precipitation flux sign to use positive magnitude .
ext/BreezeCloudMicrophysicsExt/one_moment_microphysics.jl Converts terminal-velocity storage to positive magnitudes and implements sedimentation_speed + water_phase; renames bottom-BC helper.
ext/BreezeCloudMicrophysicsExt/one_moment_helpers.jl Updates surface precipitation flux sign to use positive magnitude .
ext/BreezeCloudMicrophysicsExt/BreezeCloudMicrophysicsExt.jl Removes now-unused ZeroField import.
docs/src/developer/microphysics/overview.md Documents the new sedimentation_speed/water_phase interfaces and effective bulk velocities.
docs/src/appendix/notation.md Adds notation entries for effective liquid/ice sedimentation velocities.

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

Comment thread src/AtmosphereModels/microphysics_interface.jl
Comment thread src/AtmosphereModels/microphysics_interface.jl
Comment thread docs/src/appendix/notation.md Outdated
Comment thread test/cloud_microphysics_1M.jl
Comment thread test/cloud_microphysics_2M.jl
Comment thread ext/BreezeCloudMicrophysicsExt/one_moment_helpers.jl Outdated
Comment thread ext/BreezeCloudMicrophysicsExt/two_moment_helpers.jl Outdated
Comment thread docs/src/appendix/notation.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 80.76923% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Advection.jl 30.00% 21 Missing ⚠️
src/AtmosphereModels/microphysics_interface.jl 85.48% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

kaiyuan-cheng and others added 4 commits April 7, 2026 21:12
…idation

- Add generic sedimentation_speed fallback for non-sedimenting schemes
- Fix interface comments to match actual API signatures and return types
- Fix notation sign convention description (stored values are negative)
- Rename terminal_velocity field to sedimentation_speed in surface precip kernels
- Add numerical validation of mass-weighted averaging in 1M and 2M tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread docs/src/developer/microphysics/overview.md Outdated
Comment thread ext/BreezeCloudMicrophysicsExt/one_moment_helpers.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.

quick comment --- this looks pretty good, but there is a notation confusion. (u, v, w) are the velocity components, so w^r is the vertical velocity of rain if I understand what we want. We need a different symbol for "speed", which we choose \mathbb{W}. Can we clear this up?

The other minor but conceptually important comment is that "moisture" is not always "water". This is the idea of ThermodynamicConstants which allow the properties of the moist species to be changed; eg for simulations of atmospheres of other planets.

@kaiyuan-cheng kaiyuan-cheng changed the title sedimentation_speed interface + effective liquid/ice velocities sedimentation_velocity interface + effective liquid/ice velocities Apr 15, 2026
kaiyuan-cheng and others added 8 commits April 15, 2026 14:52
Compute the surface precipitation flux using the same advection scheme
face flux that div_ρUc uses during time stepping, rather than a simple
pointwise product at cell center. This ensures numerical consistency
between the diagnosed flux and the actual mass leaving the domain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generic surface flux used _advective_tracer_flux_z, which does not
apply the bounds-limiting coefficient θ that bounded_tracer_flux_divergence_z
uses during time stepping. This dispatch replicates the bottom-face flux
logic with the same θ-limiting, ensuring numerical consistency for
BoundsPreservingWENO advection schemes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace unresolvable @ref for div_ρUc (no docstring) with plain inline
code, and replace broken @extref for KernelFunctionOperation with a
direct URL to the Oceananigans docs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/Advection.jl Outdated
@kaiyuan-cheng kaiyuan-cheng requested a review from glwagner April 22, 2026 00:05
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.

3 participants