mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Pure-function module + 13 unit tests for the photovoltaic onsite/export
split. No cascade wiring yet — Slices S0380.45..47 will wire β into the
PE / CO2 / cost cascades respectively (which currently all over-credit
the exported PV portion at the IMPORT factor).
Module: `domain/sap10_calculator/worksheet/photovoltaic.py`
- `PhotovoltaicSplit` frozen dataclass — monthly β + (E_PV,dw,m,
E_PV,ex,m) with annual-sum properties matching worksheet line
refs (233a) and (233b).
- `pv_beta_coefficients(Cbat)` — three coefficients keyed on battery
capacity (kWh), capped at 15 per §3c:
CPV1 = 1.610 - 0.0973 × Cbat
CPV2 = 0.415 - 0.00776 × Cbat
CPV3 = 0.511 + 0.0866 × Cbat
- `pv_split_monthly(epv, dpv, battery_kwh)` — per §3d-4:
R_PV,m = E_PV,m / D_PV,m
β_m = min(exp(-CPV1 × (R_PV,m × CPV2)^CPV3), D_PV,m / E_PV,m)
E_PV,dw,m = E_PV,m × β_m; E_PV,ex,m = E_PV,m × (1 - β_m)
Edge cases (not in spec but implied by physics):
- E_PV,m = 0 → β = 0; both onsite and exported = 0
- D_PV,m = 0 → cap forces β = 0; all PV exports
Unit-test coverage (13 tests, AAA convention, `abs(diff) <= tol`):
- β coefficient constants at Cbat=0, 5 (ASHP cohort), 15 (cap)
- Cbat>15 clamps to 15; Cbat<0 clamps to 0 (defensive)
- Hand-computed β worked example (no battery): β≈0.4864 at E_PV=100,
D_PV=200 — pinned at 1e-7 against precomputed value AND at 1e-9
against the live formula recomputation (load-bearing math pin)
- Edge cases: E_PV=0 → no split; D_PV=0 → full export
- Battery monotonicity: β increases with Cbat for fixed (E_PV, D_PV)
- Energy conservation: E_PV,dw + E_PV,ex = E_PV per month + annually
- Tuple length validation (raises on != 12 months)
- Return shape pinned to `PhotovoltaicSplit` dataclass contract
Test suite: 750 → 763 pass + 0 fail. Pyright net-zero on new files.
Spec citation: SAP 10.2 specification Appendix M1 §3-4 (p.93-94).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| addresses | ||
| sap10_calculator | ||
| sap10_ml | ||
| tasks | ||
| postcode.py | ||