mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
§7 slice 5: delete legacy mean_internal_temperature_c + unused imports
Removes:
- mean_internal_temperature_c (legacy single-η whole-dwelling fn)
- _zone_mean_temperature_c (only used by the deleted fn)
- calculator.py imports of mean_internal_temperature_c + utilisation_factor
(both unused since slice 4 removed the η-iteration loop)
- 2 obsolete tests asserting legacy single-η behaviour (coverage
subsumed by the §7 ALL_FIXTURES parametrised e2e at slice 3)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
8ec9da4742
commit
a7f39685a0
3 changed files with 0 additions and 140 deletions
|
|
@ -41,7 +41,6 @@ if TYPE_CHECKING:
|
|||
from datatypes.epc.domain.epc_property_data import EpcPropertyData
|
||||
from domain.sap.worksheet.dimensions import Dimensions
|
||||
from domain.sap.worksheet.heat_transmission import HeatTransmission
|
||||
from domain.sap.worksheet.mean_internal_temperature import mean_internal_temperature_c
|
||||
from domain.sap.worksheet.rating import (
|
||||
ECF_LOG_THRESHOLD,
|
||||
ENERGY_COST_DEFLATOR,
|
||||
|
|
@ -51,7 +50,6 @@ from domain.sap.worksheet.rating import (
|
|||
sap_rating_integer,
|
||||
)
|
||||
from domain.sap.worksheet.space_heating import monthly_heat_requirement_kwh
|
||||
from domain.sap.worksheet.utilisation_factor import utilisation_factor
|
||||
|
||||
|
||||
_DAYS_IN_MONTH: Final[tuple[int, ...]] = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
|
||||
|
|
|
|||
|
|
@ -91,81 +91,6 @@ _ELSEWHERE_OFF_HOURS_TYPE_12: Final[tuple[float, float]] = (7.0, 8.0)
|
|||
_ELSEWHERE_OFF_HOURS_TYPE_3: Final[tuple[float, float]] = (9.0, 8.0)
|
||||
|
||||
|
||||
def _zone_mean_temperature_c(
|
||||
*,
|
||||
heating_temperature_c: float,
|
||||
off_hours_first: float,
|
||||
off_hours_second: float,
|
||||
external_temp_c: float,
|
||||
responsiveness: float,
|
||||
total_gains_w: float,
|
||||
heat_transfer_coefficient_w_per_k: float,
|
||||
utilisation_factor: float,
|
||||
time_constant_h: float,
|
||||
) -> float:
|
||||
"""Mean temperature for one heating zone = T_h − u1 − u2."""
|
||||
common = dict(
|
||||
heating_temperature_c=heating_temperature_c,
|
||||
external_temperature_c=external_temp_c,
|
||||
responsiveness=responsiveness,
|
||||
total_gains_w=total_gains_w,
|
||||
heat_transfer_coefficient_w_per_k=heat_transfer_coefficient_w_per_k,
|
||||
utilisation_factor=utilisation_factor,
|
||||
time_constant_h=time_constant_h,
|
||||
)
|
||||
u1 = off_period_temperature_reduction_c(off_period_hours=off_hours_first, **common)
|
||||
u2 = off_period_temperature_reduction_c(off_period_hours=off_hours_second, **common)
|
||||
return heating_temperature_c - u1 - u2
|
||||
|
||||
|
||||
def mean_internal_temperature_c(
|
||||
*,
|
||||
external_temp_c: float,
|
||||
heat_transfer_coefficient_w_per_k: float,
|
||||
total_gains_w: float,
|
||||
utilisation_factor: float,
|
||||
time_constant_h: float,
|
||||
heat_loss_parameter: float,
|
||||
living_area_fraction: float,
|
||||
control_type: int,
|
||||
responsiveness: float,
|
||||
control_temperature_adjustment_c: float = 0.0,
|
||||
) -> float:
|
||||
"""SAP 10.3 Table 9c steps 1-8 — whole-dwelling mean internal temperature
|
||||
for the month. Blends living-area + rest-of-dwelling zone means by the
|
||||
living-area fraction, then applies the Table 4e control-type temperature
|
||||
adjustment."""
|
||||
t_h2 = elsewhere_heating_temperature_c(
|
||||
heat_loss_parameter=heat_loss_parameter,
|
||||
control_type=control_type,
|
||||
)
|
||||
elsewhere_off_hours = (
|
||||
_ELSEWHERE_OFF_HOURS_TYPE_3 if control_type == 3 else _ELSEWHERE_OFF_HOURS_TYPE_12
|
||||
)
|
||||
common = dict(
|
||||
external_temp_c=external_temp_c,
|
||||
responsiveness=responsiveness,
|
||||
total_gains_w=total_gains_w,
|
||||
heat_transfer_coefficient_w_per_k=heat_transfer_coefficient_w_per_k,
|
||||
utilisation_factor=utilisation_factor,
|
||||
time_constant_h=time_constant_h,
|
||||
)
|
||||
t_1 = _zone_mean_temperature_c(
|
||||
heating_temperature_c=_T_H1_C,
|
||||
off_hours_first=_LIVING_AREA_OFF_HOURS[0],
|
||||
off_hours_second=_LIVING_AREA_OFF_HOURS[1],
|
||||
**common,
|
||||
)
|
||||
t_2 = _zone_mean_temperature_c(
|
||||
heating_temperature_c=t_h2,
|
||||
off_hours_first=elsewhere_off_hours[0],
|
||||
off_hours_second=elsewhere_off_hours[1],
|
||||
**common,
|
||||
)
|
||||
t_internal = living_area_fraction * t_1 + (1.0 - living_area_fraction) * t_2
|
||||
return t_internal + control_temperature_adjustment_c
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MeanInternalTemperatureResult:
|
||||
"""SAP 10.2 §7 worksheet line refs (85)..(94).
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from domain.sap.climate.appendix_u import external_temperature_c
|
|||
from domain.sap.worksheet.mean_internal_temperature import (
|
||||
MeanInternalTemperatureResult,
|
||||
elsewhere_heating_temperature_c,
|
||||
mean_internal_temperature_c,
|
||||
mean_internal_temperature_monthly,
|
||||
off_period_temperature_reduction_c,
|
||||
)
|
||||
|
|
@ -297,65 +296,3 @@ def test_long_off_period_temperature_reduction_uses_linear_branch() -> None:
|
|||
assert result == pytest.approx(8.02, abs=0.05)
|
||||
|
||||
|
||||
def test_mean_internal_temperature_blends_living_and_elsewhere_by_la_fraction() -> None:
|
||||
# Arrange — Hand-computed worked example following Table 9c steps 1-7.
|
||||
# Inputs: HLP=2 (control type 2 -> T_h2 = 19.333), τ=50h, R=1.0,
|
||||
# f_LA=0.3, T_e=5, G=200 W, H=200 W/K, η=0.9.
|
||||
# Standard living-area off-hours (7, 8). With T_sc = 5.9 °C:
|
||||
# Living (T_h=21): u1=0.934, u2=1.220, T_1 = 21 − 0.934 − 1.220 = 18.846
|
||||
# Elsewhere (T_h=19.333): u1=0.831, u2=1.085, T_2 = 19.333 − 1.916 = 17.417
|
||||
# T_int = 0.3 × 18.846 + 0.7 × 17.417 ≈ 17.846 °C.
|
||||
|
||||
# Act
|
||||
result = mean_internal_temperature_c(
|
||||
external_temp_c=5.0,
|
||||
heat_transfer_coefficient_w_per_k=200.0,
|
||||
total_gains_w=200.0,
|
||||
utilisation_factor=0.9,
|
||||
time_constant_h=50.0,
|
||||
heat_loss_parameter=2.0,
|
||||
living_area_fraction=0.3,
|
||||
control_type=2,
|
||||
responsiveness=1.0,
|
||||
)
|
||||
|
||||
# Assert
|
||||
assert result == pytest.approx(17.85, abs=0.05)
|
||||
|
||||
|
||||
def test_control_type_3_uses_longer_first_off_period_for_elsewhere_zone() -> None:
|
||||
# Arrange — Table 9 footnote (b): control type 3 (time + temperature
|
||||
# zone control) shifts the first off-period in the rest-of-dwelling zone
|
||||
# from 7 h to 9 h. The longer off-period drops T_2 further, so a
|
||||
# control-3 dwelling has a slightly lower mean internal temperature than
|
||||
# the same dwelling under control-2 — even though T_h2 formula is
|
||||
# identical between the two.
|
||||
|
||||
# Act
|
||||
control_2 = mean_internal_temperature_c(
|
||||
external_temp_c=5.0,
|
||||
heat_transfer_coefficient_w_per_k=200.0,
|
||||
total_gains_w=200.0,
|
||||
utilisation_factor=0.9,
|
||||
time_constant_h=50.0,
|
||||
heat_loss_parameter=2.0,
|
||||
living_area_fraction=0.3,
|
||||
control_type=2,
|
||||
responsiveness=1.0,
|
||||
)
|
||||
control_3 = mean_internal_temperature_c(
|
||||
external_temp_c=5.0,
|
||||
heat_transfer_coefficient_w_per_k=200.0,
|
||||
total_gains_w=200.0,
|
||||
utilisation_factor=0.9,
|
||||
time_constant_h=50.0,
|
||||
heat_loss_parameter=2.0,
|
||||
living_area_fraction=0.3,
|
||||
control_type=3,
|
||||
responsiveness=1.0,
|
||||
)
|
||||
|
||||
# Assert — Same T_h2 formula but longer first off-period for elsewhere
|
||||
# zone in control type 3 means a slightly lower mean.
|
||||
assert control_3 < control_2
|
||||
assert (control_2 - control_3) == pytest.approx(0.25, abs=0.2)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue