Repository navigation
Add a waste phase to SBRUnit - #1095
Merged
Merged
Conversation
An SBRPhase with waste=True draws waste_flow out of a waste port, at the bottom-of-tank concentration the settling model reports: the mixed liquor when mixed, the settled blanket after a settle. InterfaceSettling gives the mass-consistent blanket, capped by a new max_thickening (default 3); LayeredSettling wastes its bottom layer. The waste port and waste_flow exist only when a phase wastes, so existing SBRs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # aquakin/plant/sbr.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #334
Summary
SBRUnitcan waste sludge, which is how an SBR sets its sludge age; without it the solids the clarified decant leaves behind build up cycle after cycle.SBRPhase(waste=True)draws the newwaste_flowsetting (a plant parameter,"<unit>.waste_flow") out of awasteport (waste_port), at the bottom-of-tank concentration the settling model reports. The tank keeps the rest, so mass is conserved whatever the model reports.SettlingModelgains an abstractwaste_multiplier:InterfaceSettling: the blanket below the clarified zone. Withcthe clarified share of the depth holding particulates at(1 - c)of the bulk, the blanket holds them at(1 - c + c²)/(1 - c)of the bulk, capped by a newmax_thickening(default 3, must be ≥ 1). It is the bulk when mixed (c = 0), and the cap keeps a fully clarified tank finite.LayeredSettling: the bottom layer's ratio.waste_flow, and awaste_flowwithout a waste phase is refused. The port and the parameter exist only when a phase wastes, so existing SBRs, their parameter vectors and their spec files are unchanged.when: {setting: waste_flow}. The unit requires the two together, so the port rules agree with the built unit without a new kind ofwhencondition (none that reads a record's field), and the editor needed no change.docs/custom_flowsheets.mdand a line indocs/plant_files.md/ thespec.pydocstring. Also a changelog fragment and thewhenline in.claude/rules/plant-spec.md.Things a reviewer should know
InterfaceSettlingandmax_thickening = 3were the owner's choice. The alternatives were wasting the mixed liquor only, or an uncapped blanket.SBRPhaseor anInterfaceSettling, so I addedwaste/"waste": Falseandmax_thickening/3.0to them. No assertion was loosened:tests/unit/test_plant_catalog.py: the phases' field list,InterfaceSettling's argument list, and the written phase and settling dicts.tests/integration/test_plant_spec.py: the written phase,_INTERFACE, and the defaults used to shorten a spec.tests/ui/test_forms.py: the phase table's fields, values and blank row.make_small_sbr_plant(intests/conftest.py) takesphases=, so the waste tests reuse the small decay-model SBR.Testing
tests/integration/test_sbr.py):waste_flowin the waste phase only, at the capped-blanket ratio for the particulate and the bulk for the soluble;sbr.wasteamong the outlets;jax.gradof the held solids with respect towaste_flowmatches a central finite difference (rel=1e-5) and is negative.c·decant + (1 − c)·waste = 1;c = 1, with a finite zero gradient;LayeredSettling's bottom layer;max_thickening < 1.check_unitfor a wasting SBR.pytest tests/unit tests/integration tests/ui -m "not validation and not slow" -n 4: 5800 passed, 1 failed. The failure,test_plant_identifiability.py::test_rank_forward_and_reverse_agree, is a one-CSTR test that passes alone; it is tracked in test_rank_forward_and_reverse_agree fails intermittently under xdist #1094.main: the SBR, catalogue, spec, form and repository-check tests (381 passed) and ruff.scripts/check_types.pypasses. The doc examples pass (pytest docs/custom_flowsheets.md docs/plant_files.md: 33 passed, 2 skipped). The strict docs build (sphinx-build -W, offline) is clean.slow/validationtiers and the browser tests.Patch coverage
python scripts/patch_coverage.py: 100.00% of 50 changed lines.Found on the way, not changed here
test_rank_forward_and_reverse_agreefailed once under xdist.Generated by Claude Code