From 132bf98eeb8791aa015313078a179f32f560c478 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 16 Feb 2024 15:18:09 +0000 Subject: [PATCH] small tweaks to fill missing data in ventilation recs and percentage in solar description --- backend/app/plan/router.py | 2 +- recommendations/Costs.py | 8 ++++---- recommendations/Recommendations.py | 8 +++----- recommendations/SolarPvRecommendations.py | 4 ++-- recommendations/VentilationRecommendations.py | 4 ++++ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 3b010d12..28dcaa68 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -220,7 +220,7 @@ async def trigger_plan(body: PlanTriggerRequest): selected_recommendations = {r["id"] for r in solution} - # If wall ventilation is selected, we also include mechanical ventilation as a best practice measure + # If wall insulation is selected, we also include mechanical ventilation as a best practice measure if any(x in [r["type"] for r in solution] for x in [ "internal_wall_insulation", "external_wall_insulation", "cavity_wall_insulation" ]): diff --git a/recommendations/Costs.py b/recommendations/Costs.py index dd1f1a21..6ea17dce 100644 --- a/recommendations/Costs.py +++ b/recommendations/Costs.py @@ -860,12 +860,12 @@ class Costs: kw = wattage / 1000 total_cost = kw * regional_cost - subtotal_before_vat = total_cost / (1 + self.VAT_RATE) - if has_battery: # The battery cost is based on the £3500 quote, recieved from installers - subtotal_before_vat += BATTERY_COST - + total_cost += BATTERY_COST + + subtotal_before_vat = total_cost / (1 + self.VAT_RATE) + vat = total_cost - subtotal_before_vat # Labour hours are based on estimates from online research but an average team seems to consist of 3 people diff --git a/recommendations/Recommendations.py b/recommendations/Recommendations.py index 7bdfbdea..d1eec41b 100644 --- a/recommendations/Recommendations.py +++ b/recommendations/Recommendations.py @@ -215,8 +215,6 @@ class Recommendations: heat_phase_impact = property_heat_predictions.groupby("phase")["predictions"].median().reset_index() carbon_phase_impact = property_carbon_predictions.groupby("phase")["predictions"].median().reset_index() - ## TODO: NEW - # The heat demand change is the difference between the starting heat demand and the value at the final phase expected_heat_demand = property_instance.floor_area * ( heat_phase_impact[heat_phase_impact["phase"] == max(heat_phase_impact["phase"])]["predictions"].values[0] @@ -305,13 +303,13 @@ class Recommendations: rec["heat_demand"] / predicted_heat_demand_change ) # We make sure this is NOT below 0 - rec["adjusted_heat_demand"] = max(0, rec["heat_demand"]) + rec["adjusted_heat_demand"] = max(0, rec["adjusted_heat_demand"]) # Depending on the property's tarriff, we calculate the amount of energy savings this measure will bring if property_instance.energy_source == "electricity": - rec["energy_cost_savings"] = AnnualBillSavings.estimate_electric(rec["heat_demand"]) + rec["energy_cost_savings"] = AnnualBillSavings.estimate_electric(rec["adjusted_heat_demand"]) elif property_instance.energy_source == "electricity_and_gas": - rec["energy_cost_savings"] = AnnualBillSavings.estimate(rec["heat_demand"]) + rec["energy_cost_savings"] = AnnualBillSavings.estimate(rec["adjusted_heat_demand"]) else: raise ValueError("Invalid value for energy source") diff --git a/recommendations/SolarPvRecommendations.py b/recommendations/SolarPvRecommendations.py index 5fae09b3..3a89b213 100644 --- a/recommendations/SolarPvRecommendations.py +++ b/recommendations/SolarPvRecommendations.py @@ -70,10 +70,10 @@ class SolarPvRecommendations: if has_battery: description = (f"Install a {kw} kilowatt-peak (kWp) solar photovoltaic (PV) panel system on " - f"{round(roof_coverage_percent * 100)}% the roof, with a battery storage system.") + f"{round(roof_coverage_percent)}% the roof, with a battery storage system.") else: description = (f"Install a {kw} kilowatt-peak (kWp) solar photovoltaic (PV) p" - f"anel system on {round(roof_coverage_percent * 100)}% the roof.") + f"anel system on {round(roof_coverage_percent)}% the roof.") self.recommendation.append( { diff --git a/recommendations/VentilationRecommendations.py b/recommendations/VentilationRecommendations.py index 19aad0e1..1657b759 100644 --- a/recommendations/VentilationRecommendations.py +++ b/recommendations/VentilationRecommendations.py @@ -66,6 +66,10 @@ class VentilationRecommendations(Definitions): "starting_u_value": None, "new_u_value": None, "sap_points": 0, + "heat_demand": 0, + "adjusted_heat_demand": 0, + "co2_equivalent_savings": 0, + "energy_cost_savings": 0, "total": estimated_cost, # We use a very simple and rough estimate of 4 hours per unit "labour_hours": 4 * n_units,