Skip to content

Microphysics architecture: remaining refactoring TODOs #4285

@tapios

Description

@tapios

There is significant architectural debt in the microphysics integration. This issue tracks remaining cleanup work, roughly ordered by priority.

  • Remove call_cloud_diagnostics_per_stage option: Treat as always true. The per-stage path is the only physically correct one; carrying two code paths adds complexity for no benefit. (The computational expense reasons are no longer a concern.)
  • We are supporting the following models:
    • equilibrium + 0M
    • non-equilibrium + 1M
    • non-equilibrium + 2M + P3
      We should remove the separate moisture_model and microphysics_model choices, since they are never separate.
  • Consolidate microphysics cache into a single file: Currently, microphysics tendencies and terminal velocities are computed in three separate files:
    • precipitation_precomputed_quantities.jl (grid-mean / quadrature path)
    • diagnostic_edmf_precomputed_quantities.jl (diagnostic EDMF environment)
    • prognostic_edmf_precomputed_quantities.jl (prognostic EDMF environment)
      Move all microphysics cache computations (tendencies + terminal velocities) into a single microphysics_cache.jl, dispatching on turbconv model type. This eliminates cross-file duplication and makes the microphysics boundary explicit.
  • Remove duplicate cache allocations for tendency results: ᶜmp_tendency (a NamedTuple field) and the individual tendency fields (ᶜSqₗᵐ, ᶜSqᵢᵐ, ᶜSqᵣᵐ, ᶜSqₛᵐ etc.) store the same data. Use ᶜmp_tendency directly downstream and remove individual fields.
  • Remove wrapping of parameter structs such as (cmc,), cmc.activation,) to make them tuples; this won't be necessary with CloudMicrophysics.jl v0.15.5, which makes all those structs broadcastable
  • Rename tendency fields for readability: Replace subscript/superscript Unicode names with readable ASCII:
    | Current | Proposed |
    |---------|----------|
    | ᶜSqₗᵐ | ᶜdqlcl_dt |
    | ᶜSqᵢᵐ | ᶜdqicl_dt |
    | ᶜSqᵣᵐ | ᶜdqrai_dt |
    | ᶜSqₛᵐ | ᶜdqsno_dt |
  • Harmonize variable names: We use ᶜq_tot_safe for clipped q_tot, but q_liq_rai, q_ice_sno are also clipped.
  • Make microphysics tendencies implicit: Add an approximate Jacobian with only diagonal elements for the condensate species (targeting the fastest timescales, e.g., condensation/evaporation). This would improve stability. (Use implicit_microphysics toggle to enable option.)
  • Remove remaining two uses of PhaseEquil in utility functions and tests, so Thermodynamics API use is entirely functional.
  • Evaluate terminal velocities lazily: Terminal velocities (ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ) are pointwise functions of local state. Move them out of the cache and evaluate lazily to reduce memory footprint and cache pressure.
  • Move toward a functional microphysics API: Reduce reliance on mutating cache writes and if/type-based dispatch in favor of:
    • Pure functions that return results (like apply_1m_tendency_limits)
    • Method dispatch on microphysics scheme types
    • Composable helpers over monolithic set_*! functions
      This reduces code duplication across EDMF variants and simplifies testing.
  • Extend SGS quadrature to 2-moment microphysics: Currently, microphysics_tendencies_quadrature_2m only supports GridMeanSGS. Full bivariate quadrature integration (as implemented for 1M) should be extended to 2M schemes.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions