From b63822c3f9276f931a92f690a38e848db9cd6c39 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sun, 17 Aug 2025 17:57:33 +0100 Subject: [PATCH] updated ventilation --- recommendations/VentilationRecommendations.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/recommendations/VentilationRecommendations.py b/recommendations/VentilationRecommendations.py index c2208914..c0ccd891 100644 --- a/recommendations/VentilationRecommendations.py +++ b/recommendations/VentilationRecommendations.py @@ -39,26 +39,29 @@ class VentilationRecommendations(Definitions): # We recommend installing 2 units n_units = 2 - part = self.materials.copy() + parts = self.materials.copy() already_installed = "cavity_wall_insulation" in self.property.already_installed - estimated_cost = n_units * part[0]["total_cost"] if not already_installed else 0 + # TODO: We now have multiple ventilation options - we default to selecting the cheapest option + part = min(parts, key=lambda x: x['total_cost']) + + estimated_cost = n_units * part["total_cost"] if not already_installed else 0 labour_hours = 4 * n_units if not already_installed else 0 labour_days = 4 * n_units / 8.0 if not already_installed else 0 - part[0]["total"] = estimated_cost - part[0]["quantity"] = n_units - part[0]["quantity_unit"] = "part" + part["total"] = estimated_cost + part["quantity"] = n_units + part["quantity_unit"] = "part" # We recommend installing two mechanical ventilation systems self.recommendation = [ { "phase": phase, - "parts": part, - "type": part[0]["type"], + "parts": [part], + "type": part["type"], "measure_type": "mechanical_ventilation", - "description": f"Install {n_units} {part[0]['description']} units", + "description": f"Install {n_units} {part['description']} units", "starting_u_value": None, "new_u_value": None, "already_installed": already_installed, @@ -76,7 +79,8 @@ class VentilationRecommendations(Definitions): }, "description_simulation": { "mechanical-ventilation": "mechanical, extract only" - } + }, + "innovation_rate": part["innovation_rate"], } ]