mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
refactoring walls
This commit is contained in:
parent
77b5c87fbe
commit
9adb03530e
4 changed files with 56 additions and 31 deletions
|
|
@ -135,10 +135,18 @@ def handler():
|
|||
)
|
||||
df["property-type"].unique()
|
||||
|
||||
from model_data.recommendations.WallRecommendations import WallRecommendations
|
||||
self = WallRecommendations(property_instance=input_properties[2], uvalue_estimates=uvalue_estimates)
|
||||
input_properties[2].walls
|
||||
self.recommend()
|
||||
df = pd.DataFrame(self.recommendations[0]["parts"])
|
||||
recommendations = pd.DataFrame(self.recommendations)
|
||||
|
||||
from model_data.recommendations.FloorRecommendations import FloorRecommendations
|
||||
self = FloorRecommendations(property_instance=input_properties[4], uvalue_estimates=uvalue_estimates)
|
||||
self.recommendations
|
||||
self.recommend()
|
||||
self.recommendations
|
||||
|
||||
# We need to deduce a U-value for "Good" energy effieciency
|
||||
|
||||
|
|
|
|||
|
|
@ -333,7 +333,12 @@ class FloorRecommendations(BaseUtility):
|
|||
lowest_selected_u_value = update_lowest_selected_u_value(lowest_selected_u_value, new_u_value)
|
||||
|
||||
self.recommendations.append(
|
||||
get_recommended_part(part, depth, new_u_value)
|
||||
{
|
||||
"parts": [
|
||||
get_recommended_part(part, depth),
|
||||
],
|
||||
"new_u_value": new_u_value,
|
||||
}
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -293,23 +293,10 @@ class WallRecommendations(BaseUtility):
|
|||
|
||||
raise NotImplementedError("Not implemented yet")
|
||||
|
||||
def find_insulation(self, u_value):
|
||||
"""
|
||||
This function contains the logic for finding potential insulation measures for a property, depending
|
||||
on the parts available and whether the property can have external wall insulation installed
|
||||
:return:
|
||||
"""
|
||||
|
||||
ewi_parts = [
|
||||
part for part in wall_parts if part["type"] == "external_wall_insulation"
|
||||
] if self.ewi_valid else []
|
||||
|
||||
iwi_parts = [part for part in wall_parts if part["type"] == "internal_wall_insulation"]
|
||||
|
||||
# Recommend external and internal wall insulation separately
|
||||
|
||||
def _find_insulation(self, parts, u_value):
|
||||
lowest_selected_u_value = None
|
||||
for part in ewi_parts + iwi_parts:
|
||||
recommendations = []
|
||||
for part in parts:
|
||||
|
||||
for depth in part["depths"]:
|
||||
part_u_value = r_value_per_mm_to_u_value(depth, part["r_value_per_mm"])
|
||||
|
|
@ -324,7 +311,7 @@ class WallRecommendations(BaseUtility):
|
|||
# further into the diminishing returns threshold and can shouldn't be
|
||||
|
||||
if is_diminishing_returns(
|
||||
self.recommendations, new_u_value, lowest_selected_u_value, self.DIMINISHING_RETURNS_U_VALUE
|
||||
recommendations, new_u_value, lowest_selected_u_value, self.DIMINISHING_RETURNS_U_VALUE
|
||||
):
|
||||
continue
|
||||
|
||||
|
|
@ -332,9 +319,35 @@ class WallRecommendations(BaseUtility):
|
|||
if new_u_value <= self.BUILDING_REGULATIONS_PART_L_MAX_U_VALUE:
|
||||
lowest_selected_u_value = update_lowest_selected_u_value(lowest_selected_u_value, new_u_value)
|
||||
|
||||
self.recommendations.append(
|
||||
get_recommended_part(part, depth, new_u_value)
|
||||
)
|
||||
recommendations.append({
|
||||
"parts": [get_recommended_part(part, depth)],
|
||||
"new_u_value": new_u_value,
|
||||
})
|
||||
|
||||
return recommendations
|
||||
|
||||
def find_insulation(self, u_value):
|
||||
"""
|
||||
This function contains the logic for finding potential insulation measures for a property, depending
|
||||
on the parts available and whether the property can have external wall insulation installed
|
||||
:return:
|
||||
"""
|
||||
|
||||
ewi_parts = [
|
||||
part for part in wall_parts if part["type"] == "external_wall_insulation"
|
||||
] if self.ewi_valid else []
|
||||
|
||||
iwi_parts = [part for part in wall_parts if part["type"] == "internal_wall_insulation"]
|
||||
|
||||
# Recommend external and internal wall insulation separately
|
||||
# Since external and internal wall insulation are sufficiently different,
|
||||
# we separate the logic for for recommending them, therefore we don't
|
||||
# consider diminishing returns between the two
|
||||
|
||||
ewi_recommendations = self._find_insulation(ewi_parts, u_value)
|
||||
iwi_recommendations = self._find_insulation(iwi_parts, u_value)
|
||||
|
||||
self.recommendations += ewi_recommendations + iwi_recommendations
|
||||
|
||||
# We also can recommend both internal and external wall insulation together
|
||||
# By looping through ewi first, if there is nothing there, that ensures not combinations are tested
|
||||
|
|
@ -358,11 +371,13 @@ class WallRecommendations(BaseUtility):
|
|||
if combined_new_u_value - self.U_VALUE_ERROR <= self.BUILDING_REGULATIONS_PART_L_MAX_U_VALUE:
|
||||
# Here you might want to define a way to add both recommendations together.
|
||||
# For now, I'm adding them as separate items in the list
|
||||
|
||||
recommendation = [
|
||||
get_recommended_part(ewi_part, ewi_depth, combined_new_u_value),
|
||||
get_recommended_part(iwi_part, iwi_depth, combined_new_u_value)
|
||||
]
|
||||
recommendation = {
|
||||
"parts": [
|
||||
get_recommended_part(ewi_part, ewi_depth),
|
||||
get_recommended_part(iwi_part, iwi_depth)
|
||||
],
|
||||
"new_u_value": combined_new_u_value,
|
||||
}
|
||||
self.recommendations.append(recommendation)
|
||||
|
||||
self.prune_diminishing_recommendations()
|
||||
|
|
|
|||
|
|
@ -99,17 +99,14 @@ def update_lowest_selected_u_value(lowest_selected_u_value, new_u_value):
|
|||
return lowest_selected_u_value
|
||||
|
||||
|
||||
def get_recommended_part(part, selected_depth, new_u_value):
|
||||
def get_recommended_part(part, selected_depth):
|
||||
"""
|
||||
Utility function to return a recommended part with the selected depth.
|
||||
:param part:
|
||||
:param selected_depth:
|
||||
:param new_u_value:
|
||||
:return:
|
||||
"""
|
||||
recommended_part = deepcopy(part)
|
||||
recommended_part["depths"] = [selected_depth]
|
||||
|
||||
return {
|
||||
**recommended_part, "new_u_value": new_u_value,
|
||||
}
|
||||
return recommended_part
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue