Model/recommendations/HeatingRecommender.py
2024-02-19 18:37:50 +00:00

91 lines
3.8 KiB
Python

from recommendations.Costs import Costs
from recommendations.recommendation_utils import check_simulation_difference
from backend.Property import Property
from etl.epc_clean.epc_attributes.MainheatAttributes import MainHeatAttributes
class HeatingRecommender:
def __init__(self, property_instance: Property):
self.property = property_instance
self.costs = Costs(self.property)
self.recommendations = []
def recommend(self, phase=0):
# This first iteration of the recommender will provide very basic recommendation
# We recommend heating controls based on the main heating system
if self.property.main_heating["clean_description"] == "Room heaters, electric":
self.recommend_room_heaters_electric(phase=phase)
return
@staticmethod
def check_simulation_difference(old_config, new_config):
"""
Given two dictionaries, that describe the heating control configurations, this method will compare the two
and pick out the differences. These differences will be things that have been added and things that have been
removed. This will be used to determine how we should be updating the configuration in the simulation
:return:
"""
differences = {key + "_ending": new_config[key] for key in new_config if old_config[key] != new_config[key]}
return differences
def recommend_room_heaters_electric(self, phase):
"""
If the home has Room heaters, electric, we start by identifying potential heating controls that could
be upgraded, that would provide a practical impact. This will be the least invasive improvement.
We can then consider the heating system itself
:return:
"""
if self.property.data["mainheat-energy-eff"] in ["Poor", "Very Poor"]:
# Re recommend two possible upgrades:
# 1) Installation of more efficient electic room heaters
# 2) Installation of electric storage heaters
room_heater_recommendation = {
"phase": phase,
"parts": [
# TODO
],
"type": "heating",
"description": "Upgrade electric room heaters to more electric radiators",
"starting_u_value": None,
"new_u_value": None,
"sap_points": None,
**self.costs.electric_room_heaters(number_heated_rooms=self.property.data["number-heated-rooms"]),
"simulation_config": {"mainheat_energy_eff_ending": "Average"}
}
ending_config = MainHeatAttributes("Electric storage heaters, radiators").process()
simulation_config = check_simulation_difference(
new_config=ending_config, old_config=self.property.main_heating
)
# This upgrade will only take the heating system to average energy efficiency
simulation_config["mainheatc_energy_eff_ending"] = "Good"
electric_storage_heaters_recommendation = {
"phase": phase,
"parts": [
# TODO
],
"type": "heating",
"description": "Install electric storage heaters",
"starting_u_value": None,
"new_u_value": None,
"sap_points": None,
**self.costs.electric_storage_heaters(number_heated_rooms=self.property.data["number-heated-rooms"]),
"simulation_config": {
"TODO" # TODO
"mainheat_energy_eff_ending": "Average"
}
}
self.recommendations.extend(
[room_heater_recommendation, electric_storage_heaters_recommendation]
)
# We don't implement any other recommendations right now
return