mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-22 08:48:38 +00:00
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
"""Map a Landlord-Override glazing value to a glazing Simulation Overlay.
|
|
|
|
A glazing value is one canonical glazing description carrying type + era
|
|
("Double glazing, 2002 or later", "Single glazing", "Triple glazing, 2002 or
|
|
later"). The calculator derives each window's U-value from its SAP10
|
|
`glazing_type` code via the RdSAP Table 24 cascade, so the overlay decomposes
|
|
the value into that code and emits a whole-dwelling `GlazingOverlay` (a landlord
|
|
describes the dwelling's glazing as a whole, with no per-window geometry, so
|
|
`building_part` is ignored). `_fold_glazing` expands it across every window.
|
|
Unresolvable values produce no overlay.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from domain.modelling.simulation import EpcSimulation, GlazingOverlay
|
|
|
|
# Canonical glazing description → SAP10 glazing-type code (the Table 24 /
|
|
# `u_window` cascade enum, `_GLAZING_CODE_TO_UWINDOW` in heat_transmission).
|
|
_GLAZING_CODES: dict[str, int] = {
|
|
"Single glazing": 1,
|
|
"Double glazing, 2002 or later": 2,
|
|
"Double glazing, pre-2002": 3,
|
|
"Triple glazing, pre-2002": 6,
|
|
"Triple glazing, 2002 or later": 9,
|
|
}
|
|
|
|
|
|
def glazing_overlay_for(
|
|
glazing_value: str, building_part: int
|
|
) -> Optional[EpcSimulation]:
|
|
code = _GLAZING_CODES.get(glazing_value)
|
|
if code is None:
|
|
return None
|
|
return EpcSimulation(glazing=GlazingOverlay(glazing_type=code))
|