Skip to content

Move parameters out 1M options types into Microphysics1MParams #767

Open
nefrathenrici wants to merge 2 commits into
mainfrom
ne/params
Open

Move parameters out 1M options types into Microphysics1MParams #767
nefrathenrici wants to merge 2 commits into
mainfrom
ne/params

Conversation

@nefrathenrici

@nefrathenrici nefrathenrici commented Jul 21, 2026

Copy link
Copy Markdown
Member

Changes

  • Made the 1M option types singletons.
  • Moved 1M options parameters to new field process_params in Microphysics1MParams. process_params_for(option, toml_dict) reads the parameter values for each selected process.
  • The 1M tendency functions now read values from mp.process_params.<slot> instead of off the option struct. Dropped the now-unused opt argument names.
  • Separated two condensation/deposition timescale kernels out (_conv_q_vap_to_q_lcl_const, _conv_q_vap_to_q_icl_const) so the 2M scheme can reuse them. Temperature-dependent ice stays inlined.
  • Added defaults to Microphysics1MOptions.

Some benchmark tests fail on the 1.12 runner, I would like to increase the time limit since there is no type-stability change.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.05556% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.86%. Comparing base (284c88a) to head (dd98d51).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #767      +/-   ##
==========================================
- Coverage   92.92%   92.86%   -0.06%     
==========================================
  Files          56       56              
  Lines        2896     2889       -7     
==========================================
- Hits         2691     2683       -8     
- Misses        205      206       +1     
Components Coverage Δ
src 93.66% <93.05%> (-0.06%) ⬇️
ext 69.47% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haakon-e haakon-e left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. some minor inline comments attached.

The biggest piece that it would be useful if this PR documented (at least in the PR description) is why this change is desired. Some motivation is provided in #766 which appear to primarily point to ergonomics:

[currently,] you can't choose a process without a full parameter set, complicating the atmosphere model interface downstream.

If I understood some offline conversations correctly, this change could also be beneficial for performance. It would be useful to spell that out (and test it) in this PR too.

Comment thread docs/bibliography.bib
year = {2016}
}

@Article{KnopfAlpert2013,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why remove this? is it unused?

rain_snow_accretion = process_params_for(o.rain_snow_accretion, td),
)

# ═══════════════════════════════════════════════════════════════════

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I personally think it's fine to skip deprecation.

Comment on lines 79 to +80
options::OPT
process_params::PPR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

small nit: I think it would be more intuitive if the naming between options and process_params was uniform. That is, name both either:

  • options, option_params
  • processes, process_params

I have a slight preference towards the latter, but bike shedding like this can also wait until another day.


# Fields
- `options::OPT`: Microphysics1MOptions — process configuration (carries process-specific parameters)
- `options::OPT`: Microphysics1MOptions — process selection (no parameters)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- `options::OPT`: Microphysics1MOptions — process selection (no parameters)
- `options::OPT`: Microphysics1MOptions — process selection

# Fields
- `options::OPT`: Microphysics1MOptions — process configuration (carries process-specific parameters)
- `options::OPT`: Microphysics1MOptions — process selection (no parameters)
- `process_params::PPR`: per-process parameter data matching `options` (or `nothing` for parameter-free/disabled processes)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what does

nothing for [...] disabled processes

mean?

Comment on lines +42 to +46
Process selection (which variant of each process runs) lives in `options`. The
parameter values each selected variant needs (relaxation timescales,
autoconversion thresholds, collision efficiencies) live in `process_params`,
whose fields mirror `options`. Shared parameters (particle size distributions,
air properties, terminal velocities) are stored directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps an example would help make this a bit clearer? The language is a bit dense and abstract right now, I think, for something that shouldn't be that hard to grasp.

Comment thread src/MicrophysicsNonEq.jl
Comment on lines +113 to +117
_conv_q_vap_to_q_lcl_const(
mp.process_params.cloud_liquid_formation.τ_relax, tps, micro, thermo)

# Kernel for `conv_q_vap_to_q_lcl`with a constant relaxation timescale `τ`.
@inline function _conv_q_vap_to_q_lcl_const(τ, tps::TDI.PS, micro, thermo)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we have inner _-functions for this and _conv_q_vap_to_q_icl_const?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants