Model/domain
Khalim Conn-Kowlessar 5b269f23b6 Slice S0380.46: wire β-split into CO2 cascade per SAP 10.2 Appendix M1 §7
The CO2 cascade in calculator.py had no PV credit at all
(environmental_section_from_cert had a stale `pv_credit = 0.0` with
the comment "no PV in any Elmhurst fixture", but that helper isn't
called by `calculate_sap_from_inputs` anyway). The full ASHP+PV
cluster therefore over-counted CO2 by +0.16..+0.28 t/yr — the entire
PV CO2 offset was missing.

Wiring (calculator.py):
  - New fields: `pv_dwelling_co2_factor_kg_per_kwh: Optional[float]`,
    `pv_exported_co2_factor_kg_per_kwh: Optional[float]`.
  - CO2 cascade now subtracts:
      pv_co2_credit = E_PV,dw × dwelling_CO2_factor
                    + E_PV,ex × exported_CO2_factor
    when the split + factors are set. None preserves the legacy
    zero-credit behaviour for synthetic CalculatorInputs constructions.

Wiring (cert_to_inputs.py):
  - New constant: `_PV_EXPORT_FUEL_CODE_TABLE_12 = 60` (SAP 10.2
    Table 12 code 60, "electricity sold to grid, PV") — the EXPORT
    factor key per Appendix M1 §6/§7/§8.
  - The dwelling CO2 factor is the effective monthly Table 12d Σ
    weighted by E_PV,dw,m at code 30 (Standard electricity); the
    exported CO2 factor is the same Σ weighted by E_PV,ex,m at
    code 60 ("Electricity sold to grid, PV"). Both reuse the
    existing `_effective_monthly_co2_factor` helper.

Test impact (CO2 residual cluster, re-pinned in this slice):

  Pre-Slice 46 → Post-Slice 46:
    - 0330 (no PV):                  -0.034 → -0.034   (unchanged ✓)
    - 0350 (PV + 5 kWh battery):     +0.171 → -0.084
    - 0380 (PV + 5 kWh battery):     +0.279 → -0.054
    - 2130 (PV + gas combi):         +0.299 → -0.046
    - 2225 (PV + 5 kWh battery):     +0.263 → -0.071
    - 2636 (PV + 5 kWh battery):     +0.219 → -0.058
    - 3800 (PV + 5 kWh battery):     +0.261 → -0.014
    - 9285 (PV + 5 kWh battery):     +0.157 → -0.098
    - 9418 (PV + 5 kWh battery):     +0.232 → -0.046
    - 9501 (PV, no battery):         +0.202 → -0.047

  Cluster magnitude dropped 3-5× — over-count flipped to slight
  under-count (-0.01..-0.10 vs +0.16..+0.28). The remaining negative
  residual is largely the same E_PV-magnitude bug from Slice 45 (PV
  is over-credited because the cascade thinks E_PV ≈ 3× the worksheet
  value for the 5-kWh-battery cohort). Slice 47 (cost cascade) + Slice
  S0380.48 (E_PV magnitude audit) will close the cluster further.

  Chain tests still <1e-4 — CO2 cascade isn't gated by the chain
  tests' SAP-rating-vs-worksheet assertions.

Test suite: 763 pass + 0 fail. Pyright net-zero per touched file
(calculator.py 0/0; cert_to_inputs.py 34/34; test_golden_fixtures.py 1/1).

Spec citations:
  - SAP 10.2 specification Appendix M1 §7 (p.94) — PV CO2 credit split.
  - SAP 10.2 Table 12d (p.194) code 60 — monthly CO2 factor for
    "electricity sold to grid, PV" (already in `tables/table_12.py`).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 18:42:28 +00:00
..
addresses get rid of comments 2026-05-20 13:21:11 +00:00
sap10_calculator Slice S0380.46: wire β-split into CO2 cascade per SAP 10.2 Appendix M1 §7 2026-05-28 18:42:28 +00:00
sap10_ml Slice S0380.26: RdSAP10 §5.8 dry-lining adjustment on alt walls — closes cert 7700 -0.44 → +5e-5 2026-05-28 10:56:11 +00:00
tasks added postcode splitter rewrite to ddd 2026-05-19 16:35:09 +00:00
postcode.py get rid of comments 2026-05-20 13:21:11 +00:00