P5.5: SapResult.intermediate exposes useful_space_heating_kwh_per_yr

§9 / Table 9c step 10 output keyed by worksheet name on `intermediate`.
Mirrors the top-level `space_heating_kwh_per_yr` field so spec sweep
slices refer to the worksheet name regardless of field renames.

135 SAP tests pass.
This commit is contained in:
Khalim Conn-Kowlessar 2026-05-19 10:22:53 +00:00
parent 80845b0919
commit 44b1d0d923
2 changed files with 18 additions and 0 deletions

View file

@ -351,6 +351,7 @@ def calculate_sap_from_inputs(inputs: CalculatorInputs) -> SapResult:
"time_constant_h": tau_h,
"internal_gains_annual_avg_w": sum(e.internal_gains_w for e in monthly) / 12.0,
"mean_internal_temp_annual_avg_c": sum(e.internal_temp_c for e in monthly) / 12.0,
"useful_space_heating_kwh_per_yr": space_heating_kwh,
}
return SapResult(

View file

@ -212,6 +212,23 @@ def test_calculate_exposes_hlc_hlp_and_annual_averages() -> None:
)
def test_calculate_exposes_useful_space_heating_kwh() -> None:
# Arrange — P5 trace mode: useful space heating kWh/yr (§9 / Table 9c
# step 10) surfaces on `intermediate` keyed by worksheet name. Mirrors
# `space_heating_kwh_per_yr` on the top-level result so spec sweep
# slices can refer to the worksheet name regardless of `SapResult`
# field renames.
inputs = _baseline_inputs()
# Act
result = calculate_sap_from_inputs(inputs)
# Assert
assert result.intermediate["useful_space_heating_kwh_per_yr"] == pytest.approx(
result.space_heating_kwh_per_yr, rel=1e-9
)
def test_higher_main_heating_efficiency_reduces_fuel_use() -> None:
# Arrange — Direction check: doubling the boiler efficiency must halve
# the main-heating fuel kWh, holding everything else constant.