Model/domain/sap10_calculator/worksheet
Khalim Conn-Kowlessar 5344bc8920 Slice S0380.44: SAP 10.2 Appendix M1 §3-4 PV β-factor calculator (no wiring)
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>
2026-05-28 18:11:56 +00:00
..
tests Slice S0380.44: SAP 10.2 Appendix M1 §3-4 PV β-factor calculator (no wiring) 2026-05-28 18:11:56 +00:00
__init__.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
dimensions.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
energy_requirements.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
fabric_energy_efficiency.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
fuel_cost.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
heat_transmission.py Slice S0380.42: Decimal HALF_UP per-window areas per RdSAP10 §15 — closes cert 1536 2026-05-28 17:11:39 +00:00
internal_gains.py Slice S0380.42: Decimal HALF_UP per-window areas per RdSAP10 §15 — closes cert 1536 2026-05-28 17:11:39 +00:00
mean_internal_temperature.py Slice 102f-prep.5: Wire N3.5 extended-heating MIT cascade (HP-gated) 2026-05-27 13:47:49 +00:00
photovoltaic.py Slice S0380.44: SAP 10.2 Appendix M1 §3-4 PV β-factor calculator (no wiring) 2026-05-28 18:11:56 +00:00
rating.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
solar_gains.py Slice S0380.42: Decimal HALF_UP per-window areas per RdSAP10 §15 — closes cert 1536 2026-05-28 17:11:39 +00:00
space_cooling.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
space_heating.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
utilisation_factor.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
ventilation.py refactor: lift-and-shift packages/domain/src/domain/sap → domain/sap10_calculator 2026-05-26 12:22:37 +00:00
water_heating.py Slice S0380.21: Table 3a row 1 (no keep-hot) + row 4 dispatch — closes 9 cohort-2 RAISES 2026-05-28 08:56:01 +00:00