mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
92 lines
4 KiB
Python
92 lines
4 KiB
Python
import numpy as np
|
|
from recommendations.Costs import Costs
|
|
|
|
|
|
class SolarPvRecommendations:
|
|
# Approximate area of the solar panels
|
|
SOLAR_PANEL_AREA = 1.6
|
|
# Wattage per panel - this is based on the average wattage of a solar panel being between 250w and 420w
|
|
SOLAR_PANEL_WATTAGE = 250
|
|
|
|
def __init__(self, property_instance):
|
|
"""
|
|
:param property_instance: Instance of the Property class, for the home associated to property_id
|
|
"""
|
|
|
|
self.property = property_instance
|
|
self.costs = Costs(self.property)
|
|
|
|
self.recommendation = []
|
|
|
|
def recommend(self, phase):
|
|
"""
|
|
We check if a property is potentially suitable for solar PV based on the following criteria:
|
|
- The property is a house or bungalow
|
|
- The property has a flat or pitched roof
|
|
- The property does not have existing solar pv
|
|
:return:
|
|
"""
|
|
|
|
is_valid_property_type = self.property.data["property-type"] in ["House", "Bungalow"]
|
|
is_valid_roof_type = (
|
|
self.property.roof["is_flat"] or self.property.roof["is_pitched"] or self.property.roof["is_roof_room"]
|
|
)
|
|
# If there is no existing solar PV, the photo-supply field will be None or a missing value
|
|
has_no_existing_solar_pv = self.property.data["photo-supply"] in [
|
|
None, 0, self.property.DATA_ANOMALY_MATCHES
|
|
]
|
|
|
|
if not is_valid_property_type or not is_valid_roof_type or not has_no_existing_solar_pv:
|
|
return
|
|
|
|
# For the solar recommendations, we produce the following scenarios:
|
|
# 1) Solar panels only, we present a high, medium and low coverage
|
|
# 2) With and without battery
|
|
roof_coverage_scenarios = [
|
|
self.property.solar_pv_percentage - 0.1, self.property.solar_pv_percentage,
|
|
self.property.solar_pv_percentage + 0.1
|
|
]
|
|
# We make sure we haven't gone too low or high
|
|
roof_coverage_scenarios = [v for v in roof_coverage_scenarios if 0 <= v <= 1]
|
|
battery_scenarios = [False, True]
|
|
|
|
# I now produce the cross product of the scenarios
|
|
scenarios = [(roof, battery) for roof in roof_coverage_scenarios for battery in battery_scenarios]
|
|
|
|
for roof_coverage, has_battery in scenarios:
|
|
# We now have a property which is potentially suitable for solar PV
|
|
solar_pv_roof_area = self.property.get_solar_pv_roof_area(roof_coverage)
|
|
|
|
number_solar_panels = np.floor(solar_pv_roof_area / self.SOLAR_PANEL_AREA)
|
|
solar_panel_wattage = number_solar_panels * self.SOLAR_PANEL_WATTAGE
|
|
|
|
roof_coverage_percent = round(roof_coverage * 100)
|
|
|
|
# Given the wattage, we estimate the cost of the solar PV system. This is based on the MCS database
|
|
# of solar PV installations
|
|
cost_result = self.costs.solar_pv(wattage=solar_panel_wattage, has_battery=has_battery)
|
|
|
|
kw = np.floor(solar_panel_wattage / 100) / 10
|
|
|
|
if has_battery:
|
|
description = (f"Install a {kw} kilowatt-peak (kWp) solar photovoltaic (PV) panel system on "
|
|
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)}% the roof.")
|
|
|
|
self.recommendation.append(
|
|
{
|
|
"phase": phase,
|
|
"parts": [],
|
|
"type": "solar_pv",
|
|
"description": description,
|
|
"starting_u_value": None,
|
|
"new_u_value": None,
|
|
"sap_points": None,
|
|
**cost_result,
|
|
# This is required for simulating the SAP impact. solar_pv_percentage is between 0 & 1 so we scale
|
|
# back up here
|
|
"photo_supply": 100 * roof_coverage
|
|
}
|
|
)
|