Skip to content

Declare each species' phase and read it instead of the X-name rule - #1096

Merged
ctdegroot merged 3 commits into
mainfrom
species-phase
Dec 4, 2026
Merged

ctdegroot merged 3 commits into
mainfrom
species-phase

Conversation

@ctdegroot

@ctdegroot ctdegroot commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Closes #957. This adds the last item that issue listed.

Summary

A model file can now give each species phase: soluble | particulate | gas. The compiled model resolves the phases once into model.species_phases. An undeclared species falls back to the old name rule (X... particulate, S_gas_... gas, otherwise soluble), which now lives only in aquakin/core/phases.py.

Every shipped and example model declares its species' phases. The code that used to guess from the X prefix now reads the declared phase:

  • solids_species / lumped_tss_weights (the clarifiers' settling and TSS species, used by build_bsm1 and build_a2o);
  • the biofilm's default soluble mask (BiofilmReactor, IFASUnit);
  • the measures' gas-phase states (_gas_phase), a fourth name guess found along the way;
  • the editor's settling-species suggestions. The editor cannot import aquakin, so model_info now sends each species' phase.

Things a reviewer should know

  • No numbers change. Every declared phase equals what the name rule gave (checked across all 24 shipped and example models), and every consumer treats "not particulate" as soluble, as before.
  • The name fallback is kept for user models that do not declare phases, so existing model files load and behave as before.
  • The solids_species error wording changed: it now says the model "has no particulate species" instead of referring to X-prefixed names.
  • Test edited: tests/ui/test_forms.py::test_settling_species_follow_the_units_model now passes species records carrying a phase, because suggest_species reads phases rather than names. The expected values are unchanged. It adds a soluble XSOL species, which the old name rule would have settled.
  • The BSM1 and BSM2 example flowsheets' recorded model sha256 values are refreshed, because the model files changed.
  • docs/model_format.md is now exactly at its 645-line ceiling.
  • Touches aquakin/models/*, so this needs full-ci.

Testing

  • tests/unit + tests/ui, fast tier: 3240 passed.
  • Integration tests for the consumers (test_a2o, test_biofilm, test_biofilm_variant, test_bsm1, test_bsm1_asmn_n2o, test_golden_numbers, test_ifas, test_plant_measures, test_plant_spec, test_primary_clarifier), not slow: 202 passed, 1 skipped.
  • Docs pages touched (Sybil): passed. sphinx-build -W: clean.
  • ruff, scripts/check_types.py and pyright: clean. check_test_integrity.py: no test weakened.
  • New tests/unit/test_species_phase.py uses a hand-built model whose declared phases disagree with the names. Four of its tests failed with the consumers switched back to the name rule.
  • Not run locally: the slow and validation tiers. full-ci covers them.

Patch coverage

python scripts/patch_coverage.py: 100.00% of 28 changed lines.


Generated by Claude Code

Model files may give each species `phase: soluble | particulate | gas`.
The compiled model resolves it once into `species_phases`, falling back
to the name rule (X... particulate, S_gas_... gas, otherwise soluble) for
an undeclared species; that rule now lives only in `core/phases.py`.

Every shipped and example model declares its phases, each equal to what
the name rule gave, so no number changes. The clarifier's settling and
TSS species, the biofilm's soluble mask, the measures' gas-phase states
and the editor's settling suggestions read the declared phase.

Part of #957.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ctdegroot ctdegroot added the full-ci Run the full slow+validation suite on this PR (opt-in pre-merge check) label Dec 4, 2026 — with Claude
Merging main put rows_for one line over the function-size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ctdegroot
ctdegroot added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit 5b7d14d Dec 4, 2026
54 checks passed
@ctdegroot
ctdegroot deleted the species-phase branch December 4, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the full slow+validation suite on this PR (opt-in pre-merge check)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check models for reactions that balance but run backwards (sign invariants over the state space)

2 participants