fixed missing boiler_upgrade pps option

This commit is contained in:
Khalim Conn-Kowlessar 2025-08-27 19:20:45 +01:00
parent 3e4f33dfa3
commit e391b6c7c6

View file

@ -521,6 +521,7 @@ class Funding:
current_wall_uvalue: float = None,
is_partial: bool = False,
existing_li_thickness: float = None,
has_no_system: bool = False,
):
"""
Calculate the partial project ABS score for a single measure.
@ -700,6 +701,33 @@ class Funding:
# If we don't have a pre heating system, we assume the measure is not applicable
return 0
if measure_type == "boiler_upgrade":
# We don't have funding for a gas to gas boiler upgrade unless it's first time central heating
if pre_heating_system == "Condensing Gas Boiler":
return 0
if has_no_system:
pps = filtered_pps_matrix[
(filtered_pps_matrix["Pre_Main_Heating_Source"] == pre_heating_system) &
(filtered_pps_matrix["Post_Main_Heating_Source"] == "Condensing Gas Boiler") &
(filtered_pps_matrix["Measure_Type"] == "B_First_Time_CH")
]
else:
pps = filtered_pps_matrix[
(filtered_pps_matrix["Pre_Main_Heating_Source"] == pre_heating_system) &
(filtered_pps_matrix["Post_Main_Heating_Source"] == "Condensing Gas Boiler") &
(filtered_pps_matrix["Measure_Type"] == "B_Upgrade_preHCs")
]
# No funding for EPC C or above
if self.starting_sap_band in ["Low_C", "High_C", "Low_B", "High_B", "Low_A", "High_A"] and pps.empty:
return 0
if pps.shape[0] != 1:
raise ValueError("something went wrong, more than one pps for boiler upgrade")
return pps.squeeze()["Cost Savings"]
raise ValueError(f"Invalid measure type for partial project ABS calculation: {measure_type}")
# -----------------------
@ -1131,6 +1159,8 @@ class Funding:
pre_heating_system = self._map_to_pre_main_heating(mainheating, main_fuel, mainheat_energy_eff)
has_no_system = mainheating["has_no_system_present"]
measure_type = measure["measure_type"]
pps = self.calculate_partial_project_abs(
@ -1139,7 +1169,8 @@ class Funding:
is_partial=is_partial,
existing_li_thickness=existing_li_thickness,
filtered_pps_matrix=filtered_pps_matrix,
pre_heating_system=pre_heating_system
pre_heating_system=pre_heating_system,
has_no_system=has_no_system
)
innovation_uplift = pps * measure["innovation_rate"]