Map Not-Defined glazing code to a valid type for windowless 18.0 certs 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-11 11:55:46 +00:00
parent 0008c33ea9
commit fb14f03873
2 changed files with 19 additions and 4 deletions

View file

@ -3009,6 +3009,12 @@ def _synthesise_20_0_0_sap_windows(schema: RdSapSchema20_0_0) -> List[SapWindow]
]
# ADR-0028: multiple_glazing_type "ND" (Not Defined, 69/1000 18.0 certs) has no
# cascade mapping — treat as the DG-modal default (cascade code 2 → daylight g_L
# 0.80, matching the calculator's `_G_LIGHT_DEFAULT` for unknown glazing).
_RDSAP18_ND_GLAZING_TYPE: int = 2
def _synthesise_18_0_sap_windows(schema: RdSapSchema18_0) -> List[SapWindow]:
"""ADR-0028 Reduced-Field Synthesis of `sap_windows` for an 18.0 cert.
@ -3025,15 +3031,22 @@ def _synthesise_18_0_sap_windows(schema: RdSapSchema18_0) -> List[SapWindow]:
_RDSAP20_GLAZING_RATIO * float(schema.total_floor_area) * band_multiplier
)
per_window_area = total_area / len(_RDSAP20_SYNTH_ORIENTATIONS)
# ADR-0028: 18.0 glazed_type codes 1-8 are identical to 20.0.0's (verified
# against epc_codes.csv), so reuse the verified cascade for integer codes;
# the "ND" string falls back to the DG-modal default.
mgt = schema.multiple_glazing_type
glazing_type = (
_api_cascade_glazing_type(mgt)
if isinstance(mgt, int)
else _RDSAP18_ND_GLAZING_TYPE
)
return [
SapWindow(
frame_material=None,
glazing_gap=0,
orientation=orientation,
window_type=0,
# ADR-0028: 18.0 glazed_type codes 1-8+ND are identical to 20.0.0's
# (verified against epc_codes.csv), so reuse the verified cascade.
glazing_type=_api_cascade_glazing_type(schema.multiple_glazing_type),
glazing_type=glazing_type,
window_width=per_window_area,
window_height=1.0,
draught_proofed=False,

View file

@ -241,7 +241,9 @@ class RdSapSchema18_0:
energy_rating_current: int
lighting_cost_current: CostAmount
main_heating_controls: List[EnergyElement]
multiple_glazing_type: int
# ADR-0028: lodged as an int code (1-7) or the string "ND" (Not Defined,
# 69/1000) — widen so both parse; the synthesis maps "ND" to a default.
multiple_glazing_type: Union[int, str]
open_fireplaces_count: int
has_hot_water_cylinder: str
heating_cost_potential: CostAmount