Skip to content

Perparticle sstp deposition#481

Open
pdziekan wants to merge 17 commits into
igfuw:masterfrom
pdziekan:perparticle_sstp_deposition
Open

Perparticle sstp deposition#481
pdziekan wants to merge 17 commits into
igfuw:masterfrom
pdziekan:perparticle_sstp_deposition

Conversation

@pdziekan

Copy link
Copy Markdown
Contributor

No description provided.

@pdziekan pdziekan marked this pull request as ready for review July 8, 2026 14:29
Copilot AI review requested due to automatic review settings July 8, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 extends the Lagrangian microphysics “sstp” (substepping) machinery to support depositional growth alongside condensation, and refactors the implementation into a unified condensation_deposition module that can run per-cell or per-particle logic.

Changes:

  • Introduces a new runtime option opts.depo and routes deposition through the same step path as condensation (step_cond()).
  • Refactors condensation/deposition code into src/impl/condensation_deposition/**, adding per-particle deposition support and new helper kernels.
  • Updates ice mass bookkeeping to separate per-particle vs per-cell temporary buffers (*_percell_gp) and aligns RH_i calculation with the selected RH formula enum.

Reviewed changes

Copilot reviewed 27 out of 37 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/particles.tpp Switches includes from legacy condensation layout to new condensation_deposition module; adds new per-particle deposition helpers.
src/particles_step.ipp Adds opts.depo gating, integrates deposition into the condensation step pipeline (per-particle and per-cell paths).
src/impl/particles_impl.ipp Extends impl API (new methods and new temp buffers) to support deposition and combined per-particle logic.
src/impl/initialization/particles_impl_init_sanity_check.ipp Adjusts ice-related sanity checks/comments; current turb_cond + ice restriction remains.
src/impl/ice/particles_impl_ice_dep.ipp Removes old deposition implementation (moved/refactored into new module).
src/impl/housekeeping/particles_impl_hskpng_Tpr.ipp Updates RH_i computation to accept Tetens enum values (mapped internally to CC for ice).
src/impl/condensation/perparticle/perparticle_nomixing_adaptive_sstp_cond.ipp Removes old per-particle adaptive condensation implementation (replaced by new combined file).
src/impl/condensation/perparticle/cond_perparticle_advance_rw2.ipp Removes old condensation-only perparticle advance (replaced by size-advance abstraction).
src/impl/condensation/perparticle/apply_perparticle_drw3_to_perparticle_rv_and_th.ipp Removes old condensation-only drv/dth application (replaced by combined liquid/ice handler).
src/impl/condensation_deposition/perparticle/set_perparticle_drwX_to_minus_rwX.ipp New helper to initialize per-particle liquid delta accumulators.
src/impl/condensation_deposition/perparticle/set_perparticle_d_ice_mass_to_minus_ice_mass.ipp New helper to initialize per-particle ice mass delta accumulators.
src/impl/condensation_deposition/perparticle/release_arrays_for_perparticle_sstp.ipp Releases only the temp arrays required for enabled processes (cond/depo).
src/impl/condensation_deposition/perparticle/perparticle_nomixing_adaptive_sstp_cond.ipp New combined adaptive per-particle substepping for condensation and deposition.
src/impl/condensation_deposition/perparticle/perparticle_advance_size.ipp New wrapper selecting RH and advancing either liquid (rw2) or ice (ice_a/ice_c).
src/impl/condensation_deposition/perparticle/perparticle_advance_hlpr.ipp Generalizes the old perparticle_advance_rw2 into an ice-templated helper.
src/impl/condensation_deposition/perparticle/init_perparticle_sstp.ipp Initializes per-particle substepping state for new particles when exact SSTP is enabled.
src/impl/condensation_deposition/perparticle/calculate_noncond_perparticle_sstp_delta.ipp Computes the non-condensation state deltas used during substeps.
src/impl/condensation_deposition/perparticle/calc_perparticle_T.ipp Extracts per-particle temperature computation into a standalone routine.
src/impl/condensation_deposition/perparticle/apply_perparticle_drw3_or_d_ice_mass_to_perparticle_rv_and_th.ipp Applies per-particle liquid/ice phase-change deltas consistently into rv/th.
src/impl/condensation_deposition/perparticle/apply_perparticle_cond_change_to_percell_rv_and_th.ipp Consolidates post-substep state reconciliation (mixing vs non-mixing mode).
src/impl/condensation_deposition/perparticle/apply_noncond_perparticle_sstp_delta.ipp Applies per-substep fractions of the non-condensation deltas.
src/impl/condensation_deposition/perparticle/add_perparticle_rwX_to_drwX.ipp Accumulates per-particle liquid changes across substeps (optionally storing rw3).
src/impl/condensation_deposition/perparticle/add_perparticle_ice_mass_to_d_ice_mass.ipp Accumulates per-particle ice-mass changes across substeps (optionally storing ice mass).
src/impl/condensation_deposition/perparticle/acquire_arrays_for_perparticle_sstp.ipp Allocates only the temp arrays required for enabled processes (cond/depo).
src/impl/condensation_deposition/percell/sstp_percell_step.ipp New per-cell substep scalar state stepping for rv/th/rhod.
src/impl/condensation_deposition/percell/particles_impl_depo.ipp New per-cell deposition kernel with optional SGS supersaturation handling.
src/impl/condensation_deposition/percell/particles_impl_cond.ipp New per-cell condensation kernel (refactored from old location).
src/impl/condensation_deposition/common/sstp_save.ipp New shared SSTP state snapshot helper (per-particle vs per-cell behavior).
src/impl/condensation_deposition/common/particles_impl_depo_common.ipp Adds depositional growth math helpers and advance_ice_ac functor.
src/impl/condensation_deposition/common/particles_impl_cond_common.ipp Refactors condensation common utilities; adjusts advance functor behavior for ice particles.
src/impl/condensation_deposition/common/cond_depo_common.ipp New shared utilities (massdiff2drv, rw2->rwX) used by both cond and depo.
src/impl/condensation_deposition/common/apply_perparticle_sgs_supersat.ipp New helper advancing SGS supersaturation per substep.
src/impl/common/save_liq_ice_content_before_change.ipp Switches ice change storage to d_ice_mass_percell_gp.
src/impl/common/particles_impl_update_th_rv.ipp Updates to use d_ice_mass_percell_gp throughout rv/th updates and guard cleanup.
src/impl/common/calc_liq_ice_content_change.ipp Updates to use d_ice_mass_percell_gp for ice content change accumulation.
include/libcloudph++/lgrngn/opts.hpp Adds new runtime toggle depo with default false.
include/libcloudph++/lgrngn/opts_init.hpp Clarifies RH formula behavior for ice when using Tetens enum values.

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

Comment thread src/impl/initialization/particles_impl_init_sanity_check.ipp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 27 out of 37 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

src/impl/condensation_deposition/perparticle/perparticle_nomixing_adaptive_sstp_cond.ipp:218

  • The liquid convergence condition uses abs(drw2 < ...), which takes abs() of a boolean and effectively turns the second part of the condition into a constant 0/1. This breaks adaptive substepping selection and can lead to incorrect or unstable time stepping decisions.
    src/impl/condensation_deposition/perparticle/perparticle_nomixing_adaptive_sstp_cond.ipp:233
  • The ice convergence check compares da_dt_rel to the epsilon threshold twice and never checks dc_dt_rel against epsilon. This can accept non-converged changes in the c-axis (or reject converged ones) and leads to inconsistent adaptive substep counts for ice.

Comment thread src/particles_step.ipp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants