Model/backend/documents_parser
Khalim Conn-Kowlessar cc70e55917 Slice S0380.114: pump gain via Table 5a Note a) (SAP 10.2 p.177)
SAP 10.2 Table 5a (PDF p.177) verbatim:

  "Central heating pump in heated space, 2013 or later: 3 W"

  Note a): "Where there are two main heating systems serving
  different parts of the dwelling, assume each has its own
  circulation pump and therefore include two figures from this
  table. ... Set to zero in summer months. **Not applicable for
  electric heat pumps from database.** Where two main systems serve
  the same space a single pump is assumed."

The Note a) "not applicable for electric heat pumps" rule zeros the
pump GAIN only for HP-category systems themselves. Where a cert
lodges a non-HP main system alongside an HP, the non-HP system's
circulation pump still operates and dissipates 3/7/10 W into the
dwelling as an internal gain.

Pre-slice the cascade conflated TWO different spec rules:

  Table 4f (ELECTRICITY)  — HP pump electricity is in the COP, so
                             worksheet line 230b = 0 for HP certs.
  Table 5a (GAIN)         — HP-from-database pump gain is omitted
                             ONLY for that HP system, not for any
                             non-HP system in the same cert.

`_main_heating_category_from_cert(epc)` returned `details[0].
main_heating_category` and the caller zeroed pump_w whenever that
was category 4. This dropped the 3 W gain for any cert whose first
main system was an HP — even when system 2 was a non-HP boiler with
its own pump.

Cert 000565 lodges TWO main systems:
  [0] HP        (category 4)  pump_age "2013 or later"
  [1] Gas boiler (category 2)  pump_age None

Per spec the system [1] gas boiler's pump contributes 3 W (post-2013
date from [0]'s lodgement). Worksheet (70) confirms:

  Pumps, fans  3.0 3.0 3.0 3.0 3.0 0.0 0.0 0.0 0.0 3.0 3.0 3.0  (70)

Pre-slice cascade returned 0 every month, missing 24 W·months of
winter internal gains. Downstream: +10 kWh space heating, +£0.71
fuel cost, +0.90 kg CO2, -0.008 continuous SAP.

Cert 0380 (cohort-1 ASHP, HP-only):
  [0] HP (category 4)  pump_age unknown
  (no [1])

Worksheet (70) = 0 every month. Cascade post-slice: every main
system is HP → pump_w = 0 ✓ unchanged.

Fix:

`domain/sap10_calculator/worksheet/internal_gains.py`:
- Replace `_main_heating_category_from_cert` + the {4} set-membership
  check with `_all_main_systems_are_heat_pumps(epc)`. Returns True
  iff every lodged `main_heating_details[i].main_heating_category`
  equals 4. Pump gain is zeroed only in that case.
- Existing `_pump_date_category_from_cert` (reads [0]'s pump_age)
  unchanged — Elmhurst lodges the dwelling's pump_age on detail[0]
  regardless of which system the pump serves.

Cohort safety: all 6 cohort certs have a single main system (gas
boiler, category 2) → `all_main_systems_are_heat_pumps` returns
False → pump_w applies, same as the prior `else` branch. Cert 0380
(ASHP) has a single HP main → True → pump_w = 0, unchanged.

Cert 000565 cascade snapshot (HEAD 59de805e → this):
  (70)m pumps_fans gain   [0]*12  → [3,3,3,3,3,0,0,0,0,3,3,3] ✓ EXACT
  sap_score (int)             29 ✓ EXACT (preserved)
  sap_score_continuous   28.5007 → 28.508742  (Δ -0.0080 → +0.000042)
                                  **← essentially exact at 4.2e-5**
  ecf                     5.3876 →  5.386823  (Δ +0.0010 → +0.0002)
  total_fuel_cost_gbp    4680.97 → 4680.2515  (Δ +0.71 → -0.008)
  co2_kg_per_yr          6448.53 → 6447.6161  (Δ +0.90 → -0.010)
  space_heating_kwh     59018.52 → 59008.2363 (Δ +10.17 → -0.114)
  main_heating_fuel     34716.78 → 34710.7272 (Δ +5.98 → -0.067)

**Cert 000565 continuous SAP now exact at 1e-4 tolerance.** Every
intermediate (66-73, 83-84, 93-98, fuel/cost/CO2) closes the
worksheet at ≤1e-3 relative error.

Pyright net-zero (17 → 17 errors across touched files).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-30 19:46:46 +00:00
..
handler address JTK review comments 2026-04-20 15:11:17 +00:00
tests Slice S0380.114: pump gain via Table 5a Note a) (SAP 10.2 p.177) 2026-05-30 19:46:46 +00:00
__init__.py Map to RdSapSiteNotes from site notes JSON 🟥 2026-04-16 13:54:03 +00:00
db_writer.py include updating epc_property_data to pashub to ara workflow 2026-04-29 09:55:14 +00:00
elmhurst_extractor.py Slice S0380.102: Wire MEV decentralised cascade into pumps_fans (SAP 10.2 §2.6.4 + Table 4f line 230a) 2026-05-30 15:45:55 +00:00
extractor.py Handle wall thickness "Unmeasurable" 🟩 2026-04-30 16:41:16 +00:00
local_runner.py update local runner to work for elmhurst 2026-04-24 14:01:36 +00:00
parser.py load ecmk site notes to db 2026-04-29 11:20:47 +00:00
pdf.py update local runner to work for elmhurst 2026-04-24 14:01:36 +00:00