diff --git a/domain/sap10_calculator/rdsap/cert_to_inputs.py b/domain/sap10_calculator/rdsap/cert_to_inputs.py index ae4862a2..dccec930 100644 --- a/domain/sap10_calculator/rdsap/cert_to_inputs.py +++ b/domain/sap10_calculator/rdsap/cert_to_inputs.py @@ -512,12 +512,26 @@ SAP_10_2_SPEC_PRICES: Final[PriceTable] = RDSAP_10_TABLE_32_PRICES # Type 3: time-and-temperature zone control (separate living-zone # schedule via plumbing/electrical arrangement or PCDB device). _CONTROL_TYPE_BY_CODE: Final[dict[int, int]] = { + # Group 1 — BOILER SYSTEMS WITH RADIATORS OR UNDERFLOOR HEATING 2101: 1, 2102: 1, 2103: 1, 2104: 1, 2105: 2, 2106: 2, 2107: 2, 2108: 2, 2109: 2, 2110: 3, 2111: 2, # TRVs and bypass — Table 4e row "2 0" 2112: 3, 2113: 2, # Room thermostat and TRVs — Table 4e row "2 0" + # Group 2 — HEAT PUMPS WITH RADIATORS OR UNDERFLOOR HEATING + # (SAP 10.2 Table 4e PDF p.172-173). Pre-S0380.87 this group was + # missing entirely; HP control codes fell through to the default + # `return 2`, silently dropping control-type-3 zone control on cert + # 000565 (main_heating_control=2207). Mis-classifying 2207 as type + # 2 swapped elsewhere off-hours from (9, 8) → (7, 8), raising + # MIT_elsewhere by ~+0.5 °C and driving the ~+4500 kWh SH over- + # count surfaced after S0380.86 closed the BP main-wall gap. + 2201: 1, 2202: 1, 2203: 1, 2204: 1, + 2205: 2, 2206: 2, + 2207: 3, # Time + temp zone control by plumbing/electrical (§9.4.14) + 2208: 3, # Time + temp zone control by PCDB device (§9.4.14) + 2209: 2, 2210: 2, } diff --git a/domain/sap10_calculator/rdsap/tests/test_cert_to_inputs.py b/domain/sap10_calculator/rdsap/tests/test_cert_to_inputs.py index d7dd235c..469cf164 100644 --- a/domain/sap10_calculator/rdsap/tests/test_cert_to_inputs.py +++ b/domain/sap10_calculator/rdsap/tests/test_cert_to_inputs.py @@ -806,6 +806,67 @@ def test_main_heating_control_code_maps_to_sap_control_type() -> None: assert type_2_via_2113.control_type == 2 +def test_heat_pump_control_code_2207_maps_to_sap_control_type_3_per_table_4e_group_2() -> None: + # Arrange — SAP 10.2 Table 4e GROUP 2 (PDF p.172-173, "HEAT PUMPS + # WITH RADIATORS OR UNDERFLOOR HEATING"): + # + # 2207 = Time and temperature zone control by arrangement of + # plumbing and electrical services (see 9.4.14) → type 3 + # 2208 = Time and temperature zone control by device in PCDB + # (see 9.4.14) → type 3 + # + # Pre-S0380.87 `_CONTROL_TYPE_BY_CODE` contained only Group 1 BOILER + # codes (21XX); all Group 2 HP codes (22XX) fell through to the + # default `return 2`. Cert 000565 lodges `main_heating_control=2207` + # on its HP main and was silently routed to type 2 instead of type 3. + # + # The downstream effect: type 2 → 3 swaps elsewhere off-hours from + # (7, 8) → (9, 8) per Table 9 — the elsewhere zone is heated for + # fewer hours/day, so MIT_elsewhere drops by ~0.5 °C (winter) + + # 0.04 °C (summer). On cert 000565 this drives SH demand down by + # ~+4500 kWh — bulk of the structural SH over-count surfaced after + # the BP-main-wall fixes (S0380.84/.85/.86) exposed the channel. + + def _epc_with_hp_control(code: int): + return make_minimal_sap10_epc( + total_floor_area_m2=_TYPICAL_TFA_M2, + habitable_rooms_count=4, + region_code="1", + sap_building_parts=[make_building_part( + floor_dimensions=[make_floor_dimension(total_floor_area_m2=90.0, floor=0)], + )], + sap_heating=make_sap_heating( + main_heating_details=[ + MainHeatingDetail( + has_fghrs=False, main_fuel_type=30, heat_emitter_type=1, + emitter_temperature=1, main_heating_control=code, + main_heating_category=4, sap_main_heating_code=224, + ), + ], + ), + ) + + # Act + type_1_via_2201 = cert_to_inputs(_epc_with_hp_control(2201)) + type_1_via_2204 = cert_to_inputs(_epc_with_hp_control(2204)) + type_2_via_2205 = cert_to_inputs(_epc_with_hp_control(2205)) + type_2_via_2206 = cert_to_inputs(_epc_with_hp_control(2206)) + type_2_via_2209 = cert_to_inputs(_epc_with_hp_control(2209)) + type_2_via_2210 = cert_to_inputs(_epc_with_hp_control(2210)) + type_3_via_2207 = cert_to_inputs(_epc_with_hp_control(2207)) + type_3_via_2208 = cert_to_inputs(_epc_with_hp_control(2208)) + + # Assert — Table 4e GROUP 2 per-code control types + assert type_1_via_2201.control_type == 1 + assert type_1_via_2204.control_type == 1 + assert type_2_via_2205.control_type == 2 + assert type_2_via_2206.control_type == 2 + assert type_2_via_2209.control_type == 2 + assert type_2_via_2210.control_type == 2 + assert type_3_via_2207.control_type == 3 + assert type_3_via_2208.control_type == 3 + + def test_off_peak_meter_routes_electric_costs_to_low_rate() -> None: # Arrange — RdSAP 10 §12 page 62: Dual meter + storage heater (SAP # code 402) → Rule 2 → 7-hour tariff. Electric SH and electric HW