diff --git a/packages/domain/src/domain/sap/worksheet/heat_transmission.py b/packages/domain/src/domain/sap/worksheet/heat_transmission.py index 43d6bef1..06abcde3 100644 --- a/packages/domain/src/domain/sap/worksheet/heat_transmission.py +++ b/packages/domain/src/domain/sap/worksheet/heat_transmission.py @@ -420,29 +420,32 @@ def heat_transmission_from_cert( for surf in rir.detailed_surfaces: kind = surf.kind area = surf.area_m2 - rr_detailed_area += area + # Only (26)-(30) elements contribute to the external area + # aggregate (LINE_31) — gable_wall sits on (32) alongside + # the regular party walls, so its area is bookkept under + # `party` and excluded from `rr_detailed_area`. if kind == "slope": + rr_detailed_area += area roof += area * u_rr_slope( country=country, age_band=rir.construction_age_band, insulation_thickness_mm=surf.insulation_thickness_mm, insulation_type=surf.insulation_type, ) elif kind == "flat_ceiling": + rr_detailed_area += area roof += area * u_rr_flat_ceiling( country=country, age_band=rir.construction_age_band, insulation_thickness_mm=surf.insulation_thickness_mm, insulation_type=surf.insulation_type, ) elif kind == "stud_wall": + rr_detailed_area += area roof += area * u_rr_stud_wall( country=country, age_band=rir.construction_age_band, insulation_thickness_mm=surf.insulation_thickness_mm, insulation_type=surf.insulation_type, ) elif kind == "gable_wall": - # Treated as party-style at U=0.25 per Table 4. Lines - # 196-197 of the U985 worksheet for 000477 confirm - # this — RR gable walls land under (32) with U=0.25. party += 0.25 * area floor += uf * floor_area_total party += upw * party_area diff --git a/packages/domain/src/domain/sap/worksheet/tests/_elmhurst_worksheet_000477.py b/packages/domain/src/domain/sap/worksheet/tests/_elmhurst_worksheet_000477.py index fc3d1290..7666ebd3 100644 --- a/packages/domain/src/domain/sap/worksheet/tests/_elmhurst_worksheet_000477.py +++ b/packages/domain/src/domain/sap/worksheet/tests/_elmhurst_worksheet_000477.py @@ -85,11 +85,11 @@ def build_epc() -> EpcPropertyData: ), SapRoomInRoofSurface( kind="slope", area_m2=5.71, - insulation_thickness_mm=0, insulation_type="mineral_wool", + insulation_thickness_mm=0, ), SapRoomInRoofSurface( kind="slope", area_m2=7.02, - insulation_thickness_mm=0, insulation_type="mineral_wool", + insulation_thickness_mm=0, ), SapRoomInRoofSurface(kind="gable_wall", area_m2=7.55), SapRoomInRoofSurface(kind="gable_wall", area_m2=7.55), @@ -106,7 +106,12 @@ def build_epc() -> EpcPropertyData: sap_building_parts=[main], habitable_rooms_count=4, heated_rooms_count=4, - door_count=1, # U985 line 42: single "Doors uninsulated" entry @ 3.70 + # 000477 line 42 lodges total door area 3.70 m² = 2 × _DEFAULT_DOOR_ + # AREA_M2 (1.85). Worksheet vocabulary calls it one "Doors + # uninsulated 1" entry but the area resolves to 2 physical doors + # (front + back, typical mid-terrace). U=3.0 (Table 26 age B + # uninsulated) × 3.70 m² = 11.10 W/K matches LINE_26 exactly. + door_count=2, percent_draughtproofed=100, low_energy_fixed_lighting_bulbs_count=SECTION_5_BULB_COUNT_LEL, sap_windows=list(SECTION_6_VERTICAL_WINDOWS), diff --git a/packages/domain/src/domain/sap/worksheet/tests/test_heat_transmission.py b/packages/domain/src/domain/sap/worksheet/tests/test_heat_transmission.py index 2aa26947..732e51d2 100644 --- a/packages/domain/src/domain/sap/worksheet/tests/test_heat_transmission.py +++ b/packages/domain/src/domain/sap/worksheet/tests/test_heat_transmission.py @@ -1530,3 +1530,78 @@ def test_room_in_roof_detailed_per_surface_lodgement_routes_each_to_correct_line assert result.roof_w_per_k == pytest.approx(expected_roof, abs=0.001) assert result.party_walls_w_per_k == pytest.approx(expected_party, abs=0.001) assert result.walls_w_per_k == pytest.approx(expected_walls, abs=0.001) + + +def test_room_in_roof_detailed_gable_wall_excluded_from_line_31_external_area() -> None: + """LINE_31 = Σ(26)-(30) net areas — the external-elements aggregate + that drives (36) thermal-bridging. Per the U985 worksheet, RR gable + walls sit on line (32) alongside party walls (Table 4 "as common + wall"), so their area must NOT contribute to LINE_31. Pre-fix the + detailed-RR loop summed every surface (including gable_wall) into + the external-area accumulator, overcounting LINE_31 by the gable + area and inflating (36) bridging by `y × A_gable`. + + Synthetic dwelling (mirrors the routing test above; LINE_31 is + now the assertion): + - 1 storey × 40 m², 24 m perim, 2.5 m height → gross_wall 60, + net_wall 60 (no openings). + - Roof = ground_floor − RR_floor = 40 − 10 = 30 m². + - Ground floor = 40 m². + - RR detailed surfaces: slope 10 + stud_wall 5 + flat_ceiling 8 + (on (30)) + gable_wall 7 (on (32)). + + Expected LINE_31 = net_wall 60 + roof 30 + floor 40 + windows 0 + + doors 0 + rr_external(slope+stud+flat) 23 + = 153 m². Pre-fix this would have been 153 + 7 + = 160 m² (gable double-counted). + """ + # Arrange + main = make_building_part( + identifier=BuildingPartIdentifier.MAIN, + construction_age_band="B", + wall_construction=4, + wall_insulation_type=4, + party_wall_construction=1, + roof_construction=4, + floor_dimensions=[ + make_floor_dimension( + total_floor_area_m2=40.0, room_height_m=2.5, + heat_loss_perimeter_m=24.0, party_wall_length_m=0.0, floor=0, + ), + ], + sap_room_in_roof=SapRoomInRoof( + floor_area=10.0, construction_age_band="B", + detailed_surfaces=[ + SapRoomInRoofSurface( + kind="slope", area_m2=10.0, + insulation_thickness_mm=100, insulation_type="mineral_wool", + ), + SapRoomInRoofSurface( + kind="stud_wall", area_m2=5.0, + insulation_thickness_mm=100, insulation_type="mineral_wool", + ), + SapRoomInRoofSurface( + kind="flat_ceiling", area_m2=8.0, + insulation_thickness_mm=200, insulation_type="mineral_wool", + ), + SapRoomInRoofSurface(kind="gable_wall", area_m2=7.0), + ], + ), + ) + epc = make_minimal_sap10_epc( + total_floor_area_m2=50.0, + habitable_rooms_count=3, + country_code="ENG", + sap_building_parts=[main], + ) + + # Act + result = heat_transmission_from_cert( + epc, window_total_area_m2=0.0, window_avg_u_value=None, door_count=0, + ) + + # Assert + expected_line_31 = 60.0 + 30.0 + 40.0 + 0.0 + 0.0 + (10.0 + 5.0 + 8.0) + assert result.total_external_element_area_m2 == pytest.approx( + expected_line_31, abs=0.001 + )