Skip to content

City ADST: a stated diversion share is what is diverted (no rejects) - #115

Merged
HughRunyan merged 3 commits into
am-waste-flowfrom
adst-diverted-means-diverted
Oct 30, 2026
Merged

HughRunyan merged 3 commits into
am-waste-flowfrom
adst-diverted-means-diverted

Conversation

@HughRunyan

@HughRunyan HughRunyan commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

User story

As an advanced DST user, I want a diversion share to mean what actually happens, so that "compost 10% of our waste" composts 10%, and every number I type or read refers to the same thing.

What changes

advanced_dst_city._diverted_masses stops applying reject and yield rates. Before:

  • composting lost 10–19% of what it was sent, by material, in two stacked cuts (non_compostable_not_targeted, then unprocessable);
  • recycling kept only each material's yield;
  • combustion lost 10%.

All of that went back to the landfills. So a city told to compost 10% composted about 8.7%, and the landfills received the rest on top of their stated shares. Anaerobic digestion already kept everything.

Now every pathway keeps everything it is sent. _diverted_masses returns one DivsDF. The separate gross figure was there to catch over-diversion before rejects. It is now the same thing, so over_diversion measures the residual directly.

Effect. A city of 1 Mt a year with no gas capture, in 2040:

Diversion Landfilled before Landfilled after Methane
compost 10% 913,039 t 900,000 t −2.3%
compost 10% + recycling 10% 827,326 t 800,000 t −4.8%
compost 30% + recycling 15% 610,547 t 550,000 t −16.7%

Unchanged:

  • The city DST, the site tool, the cities table and Climate TRACE all keep City's rates. city_params.py is untouched.
  • A burning facility (combusts) in the advanced DST still buries combustion_reject_rate. That is a separate rate, which main already set to 0 in Waste sent to incineration stops producing methane #100; it arrives here with the next merge of main into am-waste-flow. Zeroing it on this branch now would make an incinerator's Sites-tab intake read 0 t, because the mass flow reports what a site buries rather than what it takes in.

Why

Hugh's call, 2026-10-28: rejects are minor, and they made every share a user states mean something smaller than what they typed. Removing them also clears two earlier problems:

  • In the 2026-08-31 reject audit, composting's rejects were essentially the whole reason digestion looked 29% cleaner than composting.
  • A site loaded with its WasteMAP record ended up 5–6% above that record (RMI/WasteMAP#917).

Acceptance criteria

  • A stated compost, recycling or digestion share is exactly the mass diverted.
  • Landfilled plus diverted still equals what is generated, less prevention.
  • The city DST's City paths are unchanged.
  • The changelog states the effect.

Testing

  • pytest -m "not integration": 659 passed.
  • test_diverted_is_the_whole_requested_share replaces the test that required rejects. test_recycling_and_digestion_keep_everything_they_are_sent covers the other pathways.
  • WasteMAP's side is RMI/WasteMAP#921, which pins this branch; its ADST, incineration and decisions tests pass against it.

Definition of Done

Acceptance criteria met · tests and checks pass · changelog updated · reviewed and merged (merge commit).

🤖 Generated with Claude Code

HughRunyan and others added 2 commits October 28, 2026 19:26
Composting, recycling and combustion no longer return rejects to the
landfills in the city-level advanced DST, so a stated share is what is
diverted. The city DST, site tool and Climate TRACE keep City's rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HughRunyan HughRunyan added enhancement New feature or request model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs labels Oct 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The mass-flow tests omit combustion diversion, leaving a regression to the old 10% combustion loss untested.

1 open issue
What changed in this PR

This PR makes city-level advanced DST diversion shares equal the mass actually diverted, without changing the legacy City paths or facility reject handling.

Changes:

  • Removes pathway reject and yield reductions and simplifies residual validation.
  • Updates mass-flow tests and routing helpers for the single diversion result.
  • Documents the resulting landfill and methane reductions.
File Description
tests/​test_adst_city_mass_flow.py Checks full requested diversion shares and mass balance.
tests/​test_adst_city_diversion_routing.py Adapts the helper to the single DivsDF return value.
SWEET_python/​advanced_dst_city.py Removes pathway losses and simplifies residual calculations.
changelog/​2026-10.md Records model-output changes and unchanged behavior.

Review effort: Balanced

Comment on lines +229 to +251
def test_recycling_and_digestion_keep_everything_they_are_sent():
"""The no-reject rule holds for every pathway, recycling's per-material yields
included, not only for compost."""
request = _request(
[_landfill()],
(1.0,),
diversion={
"recycling": {y: 0.15 for y in YEARS},
"anaerobic": {y: 0.05 for y in YEARS},
},
food_prevention=0.5,
)
flow = run_advanced_dst_city(request, with_mass_flow=True)["mass_flow"]["scenario"]
net_generated = float(
flow["generated"].loc[AFTER].sum() - flow["prevented"].loc[AFTER].sum()
)

assert float(flow["diverted"]["recycling"].loc[AFTER].sum()) == pytest.approx(
0.15 * net_generated
)
assert float(flow["diverted"]["anaerobic"].loc[AFTER].sum()) == pytest.approx(
0.05 * net_generated
)
@HughRunyan
HughRunyan marked this pull request as ready for review October 29, 2026 23:46
@HughRunyan
HughRunyan merged commit 900336e into am-waste-flow Oct 30, 2026
3 checks passed
@HughRunyan
HughRunyan deleted the adst-diverted-means-diverted branch October 30, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants