mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Allow system built walls to have iwi and ewi
This commit is contained in:
parent
f326de6ea0
commit
8b078da71e
5 changed files with 35 additions and 63 deletions
2
.idea/Model.iml
generated
2
.idea/Model.iml
generated
|
|
@ -7,7 +7,7 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/open_uprn" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/recommendations" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (model_data)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (backend)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyNamespacePackagesService">
|
||||
|
|
|
|||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (model_data)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (backend)" project-jdk-type="Python SDK" />
|
||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -122,6 +122,12 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
# import pickle
|
||||
# with open("input_properties.pickle", "rb") as f:
|
||||
# input_properties = pickle.load(f)
|
||||
#
|
||||
# with open("cleaned.pickle", "rb") as f:
|
||||
# cleaned = pickle.load(f)
|
||||
#
|
||||
# with open("materials_by_type.pickle", "wb") as f:
|
||||
# materials_by_type = pickle.load(f)
|
||||
|
||||
recommendations = {}
|
||||
recommendations_scoring_data = []
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class WallRecommendations(Definitions):
|
|||
|
||||
self.estimated_u_value = u_value
|
||||
|
||||
if self.property.walls["is_solid_brick"]:
|
||||
if self.property.walls["is_solid_brick"] | self.property.walls["is_system_built"]:
|
||||
|
||||
if u_value >= self.BUILDING_REGULATIONS_PART_L_MAX_U_VALUE:
|
||||
self.find_insulation(u_value)
|
||||
|
|
@ -128,9 +128,7 @@ class WallRecommendations(Definitions):
|
|||
|
||||
return
|
||||
|
||||
logger.error("Not implemented yet")
|
||||
return
|
||||
# NotImplementedError("Not implemented yet")
|
||||
raise NotImplementedError("Not implemented yet")
|
||||
|
||||
def find_cavity_insulation(self, u_value, insulation_thickness):
|
||||
"""
|
||||
|
|
@ -273,63 +271,6 @@ class WallRecommendations(Definitions):
|
|||
|
||||
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
|
||||
for ewi_part in ewi_parts:
|
||||
for iwi_part in iwi_parts:
|
||||
for (ewi_depth, ewi_cost_per_unit), (iwi_depth, iwi_cost_per_unit) in itertools.product(
|
||||
zip(ewi_part["depths"], ewi_part["cost"]),
|
||||
zip(iwi_part["depths"], iwi_part["cost"])
|
||||
):
|
||||
ewi_part_u_value = r_value_per_mm_to_u_value(ewi_depth, ewi_part["r_value_per_mm"])
|
||||
iwi_part_u_value = r_value_per_mm_to_u_value(iwi_depth, iwi_part["r_value_per_mm"])
|
||||
|
||||
# First calculate the new U-value after applying external wall insulation
|
||||
_, ewi_new_u_value = calculate_u_value_uplift(u_value, ewi_part_u_value)
|
||||
# Then calculate the new U-value after applying internal wall insulation
|
||||
_, combined_new_u_value = calculate_u_value_uplift(ewi_new_u_value, iwi_part_u_value)
|
||||
combined_new_u_value = round(combined_new_u_value, 2)
|
||||
|
||||
if combined_new_u_value < self.DIMINISHING_RETURNS_U_VALUE:
|
||||
# We don't recommend an overkill solution
|
||||
continue
|
||||
|
||||
# Check if the combined new U-value meets the requirement
|
||||
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
|
||||
ewi_esimtated_cost = ewi_cost_per_unit * self.property.insulation_wall_area
|
||||
iwi_esimtated_cost = iwi_cost_per_unit * self.property.insulation_wall_area
|
||||
|
||||
recommendation = {
|
||||
"parts": [
|
||||
get_recommended_part(
|
||||
part=ewi_part,
|
||||
selected_depth=ewi_depth,
|
||||
quantity=self.property.insulation_wall_area,
|
||||
quantity_unit=QuantityUnits.m2.value,
|
||||
selected_total_cost=ewi_esimtated_cost
|
||||
),
|
||||
get_recommended_part(
|
||||
part=iwi_part,
|
||||
selected_depth=iwi_depth,
|
||||
quantity=self.property.insulation_wall_area,
|
||||
quantity_unit=QuantityUnits.m2.value,
|
||||
selected_total_cost=iwi_esimtated_cost
|
||||
)
|
||||
],
|
||||
"type": "wall_insulation",
|
||||
"description": (
|
||||
"Install " + self._make_description(ewi_part, ewi_depth) + " and " +
|
||||
self._make_description(iwi_part, iwi_depth)
|
||||
),
|
||||
"starting_u_value": u_value,
|
||||
"new_u_value": combined_new_u_value,
|
||||
"sap_points": None,
|
||||
"cost": ewi_esimtated_cost + iwi_esimtated_cost,
|
||||
}
|
||||
self.recommendations.append(recommendation)
|
||||
|
||||
self.prune_diminishing_recommendations()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -503,3 +503,28 @@ class TestCavityWallRecommensations:
|
|||
|
||||
assert np.isclose(recommender.recommendations[1]["new_u_value"], 0.57)
|
||||
assert np.isclose(recommender.recommendations[1]["cost"], 1250)
|
||||
|
||||
def test_system_built_wall(self):
|
||||
input_property2 = Property(id=1, postcode="F4k3 2", address1="223 fake street", epc_client=Mock())
|
||||
input_property2.walls = {
|
||||
'original_description': 'System built, as built, no insulation (assumed)',
|
||||
'clean_description': 'System built, as built, no insulation',
|
||||
'thermal_transmittance': None, 'thermal_transmittance_unit': None,
|
||||
'is_cavity_wall': False, 'is_filled_cavity': False, 'is_solid_brick': False,
|
||||
'is_system_built': True, 'is_timber_frame': False, 'is_granite_or_whinstone': False,
|
||||
'is_as_built': True, 'is_cob': False, 'is_assumed': True,
|
||||
'is_sandstone_or_limestone': False, 'is_park_home': False,
|
||||
'insulation_thickness': 'none', 'external_insulation': False,
|
||||
'internal_insulation': False
|
||||
}
|
||||
input_property2.age_band = "F"
|
||||
input_property2.insulation_wall_area = 120
|
||||
|
||||
recommender2 = WallRecommendations(
|
||||
property_instance=input_property2,
|
||||
materials=internal_wall_insulation_parts + external_wall_insulation_parts
|
||||
)
|
||||
|
||||
assert not recommender2.recommendations
|
||||
|
||||
recommender2.recommend()
|
||||
Loading…
Add table
Reference in a new issue