Model/tests/domain/test_building_geometry.py
Khalim Conn-Kowlessar 4c10405071 feat(modelling): floor Recommendation Generator + ground-floor-area geometry
recommend_floor_insulation(epc, products) detects an uninsulated ground floor
(SapBuildingPart.floor_insulation_thickness blank/zero) and its construction
from floor_construction_type — 'Suspended timber' -> suspended_floor_insulation,
'Solid' -> solid_floor_insulation — emitting the matching single Option (a
floor is one construction, like a cavity wall) with the overlay
(floor_insulation_thickness = 100 mm) and a priced Cost (ground-floor area x
the Product's fully-loaded unit cost + contingency).

- building_geometry.ground_floor_area(epc, identifier): the lowest floor's
  (floor == 0) area. Pinned 14.85 m^2 on 000490 MAIN.
- BuildingPartOverlay gains floor_insulation_thickness (generic Applicator
  writes it unchanged). suspended (0.20) / solid (0.26) floor contingencies.

Progress on #1159 (generator + geometry); end-to-end + Elmhurst pin pending
the orchestrator (#1157) and parser. Four behaviour tests (suspended / solid
/ none / cost) + geometry pin. pyright strict clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 09:12:29 +00:00

50 lines
1.5 KiB
Python

"""Behaviour of shared building geometry derived from EpcPropertyData —
reusable outside the SAP calculator (e.g. for Modelling cost quantities)."""
from datatypes.epc.domain.epc_property_data import BuildingPartIdentifier
from domain.building_geometry import (
gross_heat_loss_wall_area,
ground_floor_area,
roof_area,
)
from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import (
build_epc,
)
def test_gross_heat_loss_wall_area_sums_perimeter_times_height_per_storey() -> None:
# Arrange
# 000490 MAIN: floor 0 (perimeter 7.42 m x height 2.95 m) + floor 1
# (7.42 m x 3.24 m) = 21.889 + 24.0408 = 45.93 m^2. Party walls are
# excluded by construction (heat-loss perimeter, not total perimeter).
epc = build_epc()
# Act
area: float = gross_heat_loss_wall_area(epc, BuildingPartIdentifier.MAIN)
# Assert
assert abs(area - 45.93) <= 0.01
def test_roof_area_is_the_parts_greatest_floor_area() -> None:
# Arrange
# RdSAP10 §3.8: roof area is the greatest of the floor areas on each
# level. 000490 MAIN has two floors of 14.85 m^2, so the roof is 14.85.
epc = build_epc()
# Act
area: float = roof_area(epc, BuildingPartIdentifier.MAIN)
# Assert
assert abs(area - 14.85) <= 0.01
def test_ground_floor_area_is_the_lowest_floors_area() -> None:
# Arrange — 000490 MAIN floor 0 total area is 14.85 m^2
epc = build_epc()
# Act
area: float = ground_floor_area(epc, BuildingPartIdentifier.MAIN)
# Assert
assert abs(area - 14.85) <= 0.01