Partial commit for dompark project including sensors, lca materials and overall improvements
This commit is contained in:
parent
a40c1a0154
commit
6b9e09ba88
|
@ -78,48 +78,6 @@ class Polygon:
|
||||||
z = vector_0[2] * vector_1[2]
|
z = vector_0[2] * vector_1[2]
|
||||||
return x+y+z
|
return x+y+z
|
||||||
|
|
||||||
def contains_point(self, point):
|
|
||||||
"""
|
|
||||||
Determines if the given point is contained by the current polygon
|
|
||||||
:return: boolean
|
|
||||||
"""
|
|
||||||
# fixme: This method doesn't seems to work.
|
|
||||||
n = len(self.vertices)
|
|
||||||
angle_sum = 0
|
|
||||||
for i in range(0, n):
|
|
||||||
vector_0 = self.vertices[i]
|
|
||||||
vector_1 = self.vertices[(i+1) % n]
|
|
||||||
# set to origin
|
|
||||||
vector_0[0] = vector_0[0] - point.coordinates[0]
|
|
||||||
vector_0[1] = vector_0[1] - point.coordinates[1]
|
|
||||||
vector_0[2] = vector_0[2] - point.coordinates[2]
|
|
||||||
vector_1[0] = vector_1[0] - point.coordinates[0]
|
|
||||||
vector_1[1] = vector_1[1] - point.coordinates[1]
|
|
||||||
vector_1[2] = vector_1[2] - point.coordinates[2]
|
|
||||||
module = Polygon._module(vector_0) * Polygon._module(vector_1)
|
|
||||||
|
|
||||||
scalar_product = Polygon._scalar_product(vector_0, vector_1)
|
|
||||||
angle = np.pi/2
|
|
||||||
if module != 0:
|
|
||||||
angle = abs(np.arcsin(scalar_product / module))
|
|
||||||
angle_sum += angle
|
|
||||||
print(angle_sum)
|
|
||||||
return abs(angle_sum - math.pi*2) < cte.EPSILON
|
|
||||||
|
|
||||||
def contains_polygon(self, polygon):
|
|
||||||
"""
|
|
||||||
Determines if the given polygon is contained by the current polygon
|
|
||||||
:return: boolean
|
|
||||||
"""
|
|
||||||
print('contains')
|
|
||||||
for point in polygon.points:
|
|
||||||
print(point.coordinates, self.contains_point(point))
|
|
||||||
|
|
||||||
if not self.contains_point(point):
|
|
||||||
return False
|
|
||||||
print('Belong!')
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def points_list(self) -> np.ndarray:
|
def points_list(self) -> np.ndarray:
|
||||||
"""
|
"""
|
||||||
|
@ -291,7 +249,7 @@ class Polygon:
|
||||||
points_list = self.points_list
|
points_list = self.points_list
|
||||||
normal = self.normal
|
normal = self.normal
|
||||||
if np.linalg.norm(normal) == 0:
|
if np.linalg.norm(normal) == 0:
|
||||||
sys.stderr.write('Not able to triangulate polygon\n')
|
sys.stderr.write(f'Not able to triangulate polygon [normal length is 0]')
|
||||||
return [self]
|
return [self]
|
||||||
# are points concave or convex?
|
# are points concave or convex?
|
||||||
total_points_list, concave_points, convex_points = self._starting_lists(points_list, normal)
|
total_points_list, concave_points, convex_points = self._starting_lists(points_list, normal)
|
||||||
|
@ -339,10 +297,10 @@ class Polygon:
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
if len(total_points_list) <= 3 and len(convex_points) > 0:
|
if len(total_points_list) <= 3 and len(convex_points) > 0:
|
||||||
sys.stderr.write('Not able to triangulate polygon\n')
|
sys.stderr.write('Not able to triangulate polygon [convex surface]\n')
|
||||||
return [self]
|
return [self]
|
||||||
if j >= 100:
|
if j >= 100:
|
||||||
sys.stderr.write('Not able to triangulate polygon\n')
|
sys.stderr.write('Not able to triangulate polygon [infinite loop]\n')
|
||||||
return [self]
|
return [self]
|
||||||
last_ear = self._triangle(points_list, total_points_list, concave_points[1])
|
last_ear = self._triangle(points_list, total_points_list, concave_points[1])
|
||||||
ears.append(last_ear)
|
ears.append(last_ear)
|
||||||
|
|
|
@ -114,7 +114,7 @@ class Polyhedron:
|
||||||
if self._trimesh is None:
|
if self._trimesh is None:
|
||||||
for face in self.faces:
|
for face in self.faces:
|
||||||
if len(face) != 3:
|
if len(face) != 3:
|
||||||
sys.stderr.write('Not able to generate trimesh\n')
|
sys.stderr.write(f'Not able to generate trimesh the face has {len(face)} vertices\n')
|
||||||
return None
|
return None
|
||||||
self._trimesh = Trimesh(vertices=self.vertices, faces=self.faces)
|
self._trimesh = Trimesh(vertices=self.vertices, faces=self.faces)
|
||||||
return self._trimesh
|
return self._trimesh
|
||||||
|
|
|
@ -6,7 +6,6 @@ Contributor Atiya atiya.atiya@mail.concordia.ca
|
||||||
Contributor Mohammad Reza mohammad.seyedabadi@mail.concordia.ca
|
Contributor Mohammad Reza mohammad.seyedabadi@mail.concordia.ca
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ast
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +14,6 @@ class Material:
|
||||||
Material class
|
Material class
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._type = type
|
|
||||||
self._id = None
|
self._id = None
|
||||||
self._name = None
|
self._name = None
|
||||||
self._conductivity = None
|
self._conductivity = None
|
||||||
|
@ -27,30 +25,7 @@ class Material:
|
||||||
self._visible_absorptance = None
|
self._visible_absorptance = None
|
||||||
self._no_mass = False
|
self._no_mass = False
|
||||||
self._thermal_resistance = None
|
self._thermal_resistance = None
|
||||||
self._embodied_carbon = None
|
self._lca_id = None
|
||||||
self._embodied_carbon_unit = None
|
|
||||||
self._recycling_ratio = None
|
|
||||||
self._onsite_recycling_ratio = None
|
|
||||||
self._company_recycling_ratio = None
|
|
||||||
self._landfilling_ratio = None
|
|
||||||
self._cost = None
|
|
||||||
self._cost_unit = None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self):
|
|
||||||
"""
|
|
||||||
Get material type
|
|
||||||
:return: str
|
|
||||||
"""
|
|
||||||
return self._type
|
|
||||||
|
|
||||||
@type.setter
|
|
||||||
def type(self, value):
|
|
||||||
"""
|
|
||||||
Set material type
|
|
||||||
:param value: string
|
|
||||||
"""
|
|
||||||
self._type = str(value)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self):
|
def id(self):
|
||||||
|
@ -238,137 +213,10 @@ class Material:
|
||||||
self._thermal_resistance = float(value)
|
self._thermal_resistance = float(value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def embodied_carbon(self) -> Union[None, float]:
|
def lca_id(self):
|
||||||
"""
|
return self._lca_id
|
||||||
Get material embodied carbon
|
|
||||||
:return: None or float
|
|
||||||
"""
|
|
||||||
return self._embodied_carbon
|
|
||||||
|
|
||||||
@embodied_carbon.setter
|
@lca_id.setter
|
||||||
def embodied_carbon(self, value):
|
def lca_id(self, value):
|
||||||
"""
|
self._lca_id = value
|
||||||
Set material embodied carbon
|
|
||||||
:param value: float
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._embodied_carbon = float(value)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def embodied_carbon_unit(self) -> Union[None, str]:
|
|
||||||
"""
|
|
||||||
Get material embodied carbon unit
|
|
||||||
:return: None or string
|
|
||||||
"""
|
|
||||||
return self._embodied_carbon
|
|
||||||
|
|
||||||
@embodied_carbon_unit.setter
|
|
||||||
def embodied_carbon_unit(self, value):
|
|
||||||
"""
|
|
||||||
Set material embodied carbon unit
|
|
||||||
:param value: string
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._embodied_carbon_unit = str(value)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def recycling_ratio(self) -> Union[None, float]:
|
|
||||||
"""
|
|
||||||
Get material recycling ratio
|
|
||||||
:return: None or float
|
|
||||||
"""
|
|
||||||
return self._recycling_ratio
|
|
||||||
|
|
||||||
@recycling_ratio.setter
|
|
||||||
def recycling_ratio(self, value):
|
|
||||||
"""
|
|
||||||
Set material recycling ratio
|
|
||||||
:param value: float
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._recycling_ratio = float(value)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def onsite_recycling_ratio(self) -> Union[None, float]:
|
|
||||||
"""
|
|
||||||
Get material onsite recycling ratio
|
|
||||||
:return: None or float
|
|
||||||
"""
|
|
||||||
return self._onsite_recycling_ratio
|
|
||||||
|
|
||||||
@onsite_recycling_ratio.setter
|
|
||||||
def onsite_recycling_ratio(self, value):
|
|
||||||
"""
|
|
||||||
Set material onsite recycling ratio
|
|
||||||
:param value: float
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._onsite_recycling_ratio = float(value)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def company_recycling_ratio(self) -> Union[None, float]:
|
|
||||||
"""
|
|
||||||
Get material company recycling ratio
|
|
||||||
:return: None or float
|
|
||||||
"""
|
|
||||||
return self._company_recycling_ratio
|
|
||||||
|
|
||||||
@company_recycling_ratio.setter
|
|
||||||
def company_recycling_ratio(self, value):
|
|
||||||
"""
|
|
||||||
Set material company recycling ratio
|
|
||||||
:param value: float
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._company_recycling_ratio = float(value)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def landfilling_ratio(self) -> Union[None, float]:
|
|
||||||
"""
|
|
||||||
Get material landfilling ratio
|
|
||||||
:return: None or float
|
|
||||||
"""
|
|
||||||
return self._landfilling_ratio
|
|
||||||
|
|
||||||
@landfilling_ratio.setter
|
|
||||||
def landfilling_ratio(self, value):
|
|
||||||
"""
|
|
||||||
Set material landfilling ratio
|
|
||||||
:param value: float
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._landfilling_ratio = float(value)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def cost(self) -> Union[None, float]:
|
|
||||||
"""
|
|
||||||
Get material cost
|
|
||||||
:return: None or float
|
|
||||||
"""
|
|
||||||
return self._cost
|
|
||||||
|
|
||||||
@cost.setter
|
|
||||||
def cost(self, value):
|
|
||||||
"""
|
|
||||||
Set material cost
|
|
||||||
:param value: float
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._cost = float(value)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def cost_unit(self) -> Union[None, str]:
|
|
||||||
"""
|
|
||||||
Get material cost unit
|
|
||||||
:return: None or string
|
|
||||||
"""
|
|
||||||
return self._cost_unit
|
|
||||||
|
|
||||||
@cost_unit.setter
|
|
||||||
def cost_unit(self, value):
|
|
||||||
"""
|
|
||||||
Set material cost unit
|
|
||||||
:param value: string
|
|
||||||
"""
|
|
||||||
if value is not None:
|
|
||||||
self._cost_unit = float(value)
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ from city_model_structure.machine import Machine
|
||||||
from helpers.geometry_helper import GeometryHelper
|
from helpers.geometry_helper import GeometryHelper
|
||||||
from helpers.location import Location
|
from helpers.location import Location
|
||||||
from city_model_structure.energy_system import EnergySystem
|
from city_model_structure.energy_system import EnergySystem
|
||||||
|
from city_model_structure.lca_material import LcaMaterial
|
||||||
|
|
||||||
class City:
|
class City:
|
||||||
"""
|
"""
|
||||||
|
@ -55,6 +55,7 @@ class City:
|
||||||
self._fuels = None
|
self._fuels = None
|
||||||
self._machines = None
|
self._machines = None
|
||||||
self._stations = []
|
self._stations = []
|
||||||
|
self._lca_materials = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fuels(self) -> [Fuel]:
|
def fuels(self) -> [Fuel]:
|
||||||
|
@ -194,7 +195,7 @@ class City:
|
||||||
:return: None or CityObject
|
:return: None or CityObject
|
||||||
"""
|
"""
|
||||||
for city_object in self.buildings:
|
for city_object in self.buildings:
|
||||||
if city_object.name == name:
|
if str(city_object.name) == str(name):
|
||||||
return city_object
|
return city_object
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -403,3 +404,29 @@ class City:
|
||||||
self._parts_consisting_buildings.append(new_city_objects_cluster)
|
self._parts_consisting_buildings.append(new_city_objects_cluster)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lca_materials(self) -> Union[List[LcaMaterial], None]:
|
||||||
|
"""
|
||||||
|
Get life cycle materials for the city
|
||||||
|
:return: [LcaMaterial] or
|
||||||
|
"""
|
||||||
|
return self._lca_materials
|
||||||
|
|
||||||
|
@lca_materials.setter
|
||||||
|
def lca_materials(self, value):
|
||||||
|
"""
|
||||||
|
Set life cycle materials for the city
|
||||||
|
"""
|
||||||
|
self._lca_materials = value
|
||||||
|
|
||||||
|
def get_lca_material(self, lca_id) -> LcaMaterial:
|
||||||
|
"""
|
||||||
|
Get the lca materiol matching the given Id
|
||||||
|
:return: LcaMaterial or None
|
||||||
|
"""
|
||||||
|
for lca_material in self.lca_materials:
|
||||||
|
if str(lca_material.id) == str(lca_id):
|
||||||
|
return lca_material
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
"""
|
|
||||||
LifeCycleAssessment retrieve the specific Life Cycle Assessment module for the given region
|
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
||||||
Copyright © 2020 Project Author Atiya
|
|
||||||
"""
|
|
||||||
from city_model_structure.machine import Machine
|
|
||||||
|
|
||||||
class LcaCalculations:
|
|
||||||
"""
|
|
||||||
LCA Calculations class
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
print("lca calculations class")
|
|
||||||
|
|
||||||
def emission_disposal_machines(self, ):
|
|
||||||
return Machine.work_efficiency * Machine.energy_consumption_rate * Machine.carbon_emission_factor
|
|
||||||
|
|
||||||
def emission_transportation(self, weight, distance ):
|
|
||||||
return weight * distance * Machine.energy_consumption_rate * Machine.carbon_emission_factor
|
|
||||||
|
|
||||||
|
|
||||||
|
|
242
city_model_structure/lca_material.py
Normal file
242
city_model_structure/lca_material.py
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
"""
|
||||||
|
Material module
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2020 Project Author Atiya atiya.atiya@mail.concordia.ca
|
||||||
|
Contributor Mohammad Reza mohammad.seyedabadi@mail.concordia.ca
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
class LcaMaterial:
|
||||||
|
def __init__(self):
|
||||||
|
self._id = None
|
||||||
|
self._type = None
|
||||||
|
self._name = None
|
||||||
|
self._density = None
|
||||||
|
self._density_unit = None
|
||||||
|
self._embodied_carbon = None
|
||||||
|
self._embodied_carbon_unit = None
|
||||||
|
self._recycling_ratio = None
|
||||||
|
self._company_recycling_ratio = None
|
||||||
|
self._onsite_recycling_ratio = None
|
||||||
|
self._landfilling_ratio = None
|
||||||
|
self._cost = None
|
||||||
|
self._cost_unit = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self):
|
||||||
|
"""
|
||||||
|
Get material id
|
||||||
|
:return: int
|
||||||
|
"""
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
@id.setter
|
||||||
|
def id(self, value):
|
||||||
|
"""
|
||||||
|
Set material id
|
||||||
|
:param value: int
|
||||||
|
"""
|
||||||
|
self._id = int(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
"""
|
||||||
|
Get material type
|
||||||
|
:return: str
|
||||||
|
"""
|
||||||
|
return self._type
|
||||||
|
|
||||||
|
@type.setter
|
||||||
|
def type(self, value):
|
||||||
|
"""
|
||||||
|
Set material type
|
||||||
|
:param value: string
|
||||||
|
"""
|
||||||
|
self._type = str(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""
|
||||||
|
Get material name
|
||||||
|
:return: str
|
||||||
|
"""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, value):
|
||||||
|
"""
|
||||||
|
Set material name
|
||||||
|
:param value: string
|
||||||
|
"""
|
||||||
|
self._name = str(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def density(self) -> Union[None, float]:
|
||||||
|
"""
|
||||||
|
Get material density in kg/m3
|
||||||
|
:return: None or float
|
||||||
|
"""
|
||||||
|
return self._density
|
||||||
|
|
||||||
|
@density.setter
|
||||||
|
def density(self, value):
|
||||||
|
"""
|
||||||
|
Set material density
|
||||||
|
:param value: float
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._density = float(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def density_unit(self) -> Union[None, str]:
|
||||||
|
"""
|
||||||
|
Get material density unit
|
||||||
|
:return: None or string
|
||||||
|
"""
|
||||||
|
return self._density_unit
|
||||||
|
|
||||||
|
@density_unit.setter
|
||||||
|
def density_unit(self, value):
|
||||||
|
"""
|
||||||
|
Set material density unit
|
||||||
|
:param value: string
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._density_unit = str(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def embodied_carbon(self) -> Union[None, float]:
|
||||||
|
"""
|
||||||
|
Get material embodied carbon
|
||||||
|
:return: None or float
|
||||||
|
"""
|
||||||
|
return self._embodied_carbon
|
||||||
|
|
||||||
|
@embodied_carbon.setter
|
||||||
|
def embodied_carbon(self, value):
|
||||||
|
"""
|
||||||
|
Set material embodied carbon
|
||||||
|
:param value: float
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._embodied_carbon = float(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def embodied_carbon_unit(self) -> Union[None, str]:
|
||||||
|
"""
|
||||||
|
Get material embodied carbon unit
|
||||||
|
:return: None or string
|
||||||
|
"""
|
||||||
|
return self._embodied_carbon
|
||||||
|
|
||||||
|
@embodied_carbon_unit.setter
|
||||||
|
def embodied_carbon_unit(self, value):
|
||||||
|
"""
|
||||||
|
Set material embodied carbon unit
|
||||||
|
:param value: string
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._embodied_carbon_unit = str(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def recycling_ratio(self) -> Union[None, float]:
|
||||||
|
"""
|
||||||
|
Get material recycling ratio
|
||||||
|
:return: None or float
|
||||||
|
"""
|
||||||
|
return self._recycling_ratio
|
||||||
|
|
||||||
|
@recycling_ratio.setter
|
||||||
|
def recycling_ratio(self, value):
|
||||||
|
"""
|
||||||
|
Set material recycling ratio
|
||||||
|
:param value: float
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._recycling_ratio = float(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def onsite_recycling_ratio(self) -> Union[None, float]:
|
||||||
|
"""
|
||||||
|
Get material onsite recycling ratio
|
||||||
|
:return: None or float
|
||||||
|
"""
|
||||||
|
return self._onsite_recycling_ratio
|
||||||
|
|
||||||
|
@onsite_recycling_ratio.setter
|
||||||
|
def onsite_recycling_ratio(self, value):
|
||||||
|
"""
|
||||||
|
Set material onsite recycling ratio
|
||||||
|
:param value: float
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._onsite_recycling_ratio = float(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def company_recycling_ratio(self) -> Union[None, float]:
|
||||||
|
"""
|
||||||
|
Get material company recycling ratio
|
||||||
|
:return: None or float
|
||||||
|
"""
|
||||||
|
return self._company_recycling_ratio
|
||||||
|
|
||||||
|
@company_recycling_ratio.setter
|
||||||
|
def company_recycling_ratio(self, value):
|
||||||
|
"""
|
||||||
|
Set material company recycling ratio
|
||||||
|
:param value: float
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._company_recycling_ratio = float(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def landfilling_ratio(self) -> Union[None, float]:
|
||||||
|
"""
|
||||||
|
Get material landfilling ratio
|
||||||
|
:return: None or float
|
||||||
|
"""
|
||||||
|
return self._landfilling_ratio
|
||||||
|
|
||||||
|
@landfilling_ratio.setter
|
||||||
|
def landfilling_ratio(self, value):
|
||||||
|
"""
|
||||||
|
Set material landfilling ratio
|
||||||
|
:param value: float
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._landfilling_ratio = float(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cost(self) -> Union[None, float]:
|
||||||
|
"""
|
||||||
|
Get material cost
|
||||||
|
:return: None or float
|
||||||
|
"""
|
||||||
|
return self._cost
|
||||||
|
|
||||||
|
@cost.setter
|
||||||
|
def cost(self, value):
|
||||||
|
"""
|
||||||
|
Set material cost
|
||||||
|
:param value: float
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._cost = float(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cost_unit(self) -> Union[None, str]:
|
||||||
|
"""
|
||||||
|
Get material cost unit
|
||||||
|
:return: None or string
|
||||||
|
"""
|
||||||
|
return self._cost_unit
|
||||||
|
|
||||||
|
@cost_unit.setter
|
||||||
|
def cost_unit(self, value):
|
||||||
|
"""
|
||||||
|
Set material cost unit
|
||||||
|
:param value: string
|
||||||
|
"""
|
||||||
|
if value is not None:
|
||||||
|
self._cost_unit = float(value)
|
|
@ -83,6 +83,8 @@ class UsPhysicsParameters(NrelPhysicsInterface):
|
||||||
material.thermal_absorptance = layer_archetype.thermal_absorptance
|
material.thermal_absorptance = layer_archetype.thermal_absorptance
|
||||||
material.visible_absorptance = layer_archetype.visible_absorptance
|
material.visible_absorptance = layer_archetype.visible_absorptance
|
||||||
material.thermal_resistance = layer_archetype.thermal_resistance
|
material.thermal_resistance = layer_archetype.thermal_resistance
|
||||||
|
if layer_archetype.lca_id is not None:
|
||||||
|
material.lca_id = layer_archetype.lca_id
|
||||||
layer.material = material
|
layer.material = material
|
||||||
thermal_boundary.layers.append(layer)
|
thermal_boundary.layers.append(layer)
|
||||||
for thermal_opening in thermal_boundary.thermal_openings:
|
for thermal_opening in thermal_boundary.thermal_openings:
|
||||||
|
|
|
@ -6,15 +6,12 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
|
||||||
from numpy import inf
|
from numpy import inf
|
||||||
from rhino3dm import *
|
from rhino3dm import *
|
||||||
from rhino3dm._rhino3dm import MeshType
|
from rhino3dm._rhino3dm import MeshType
|
||||||
from city_model_structure.attributes.point import Point
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from helpers.configuration_helper import ConfigurationHelper
|
|
||||||
from city_model_structure.attributes.polygon import Polygon
|
from city_model_structure.attributes.polygon import Polygon
|
||||||
from city_model_structure.building import Building
|
from city_model_structure.building import Building
|
||||||
from city_model_structure.city import City
|
|
||||||
from city_model_structure.building_demand.surface import Surface as LibsSurface
|
from city_model_structure.building_demand.surface import Surface as LibsSurface
|
||||||
# from helpers.constants import EPSILON
|
from city_model_structure.city import City
|
||||||
|
from helpers.configuration_helper import ConfigurationHelper
|
||||||
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,18 +23,6 @@ class Rhino:
|
||||||
self._min_x = self._min_y = self._min_z = max_float
|
self._min_x = self._min_y = self._min_z = max_float
|
||||||
self._max_x = self._max_y = self._max_z = min_float
|
self._max_x = self._max_y = self._max_z = min_float
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _in_perimeter(wall, corner):
|
|
||||||
res = wall.contains_point(Point(corner))
|
|
||||||
print(f'belong: {res} wall:({wall.coordinates}) corner: ({corner})')
|
|
||||||
return res
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _add_hole(solid_polygon, hole):
|
|
||||||
first = solid_polygon.points[0]
|
|
||||||
points = first + hole.points + solid_polygon.points
|
|
||||||
return Polygon(points)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _solid_points(coordinates) -> np.ndarray:
|
def _solid_points(coordinates) -> np.ndarray:
|
||||||
solid_points = np.fromstring(coordinates, dtype=float, sep=' ')
|
solid_points = np.fromstring(coordinates, dtype=float, sep=' ')
|
||||||
|
@ -96,7 +81,6 @@ class Rhino:
|
||||||
windows.append(Polygon(surface.perimeter_polygon.inverse))
|
windows.append(Polygon(surface.perimeter_polygon.inverse))
|
||||||
else:
|
else:
|
||||||
buildings.append(rhino_object)
|
buildings.append(rhino_object)
|
||||||
print(f'windows: {len(windows)}')
|
|
||||||
# todo: this method will be pretty inefficient
|
# todo: this method will be pretty inefficient
|
||||||
for hole in windows:
|
for hole in windows:
|
||||||
corner = hole.coordinates[0]
|
corner = hole.coordinates[0]
|
||||||
|
|
|
@ -8,6 +8,7 @@ import xmltodict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from city_model_structure.machine import Machine
|
from city_model_structure.machine import Machine
|
||||||
|
|
||||||
|
|
||||||
class LcaMachine:
|
class LcaMachine:
|
||||||
def __init__(self, city, base_path):
|
def __init__(self, city, base_path):
|
||||||
self._city = city
|
self._city = city
|
||||||
|
@ -19,13 +20,12 @@ class LcaMachine:
|
||||||
# print(self._base_path)
|
# print(self._base_path)
|
||||||
path = Path(self._base_path / 'lca_data.xml').resolve()
|
path = Path(self._base_path / 'lca_data.xml').resolve()
|
||||||
|
|
||||||
|
|
||||||
with open(path) as xml:
|
with open(path) as xml:
|
||||||
self._lca = xmltodict.parse(xml.read())
|
self._lca = xmltodict.parse(xml.read())
|
||||||
for machine in self._lca["library"]["machines"]['machine']:
|
for machine in self._lca["library"]["machines"]['machine']:
|
||||||
self._city.machines.append(Machine(machine['@id'], machine['@name'], machine['work_efficiency']['#text'],
|
self._city.machines.append(Machine(machine['@id'], machine['@name'], machine['work_efficiency']['#text'],
|
||||||
machine['work_efficiency']['@unit'], machine['energy_consumption_rate']['#text'],
|
machine['work_efficiency']['@unit'],
|
||||||
machine['energy_consumption_rate']['@unit'], machine['carbon_emission_factor']['#text'],
|
machine['energy_consumption_rate']['#text'],
|
||||||
machine['carbon_emission_factor']['@unit']))
|
machine['energy_consumption_rate']['@unit'],
|
||||||
|
machine['carbon_emission_factor']['#text'],
|
||||||
|
machine['carbon_emission_factor']['@unit']))
|
||||||
|
|
|
@ -8,6 +8,7 @@ import xmltodict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from city_model_structure.building_demand.material import Material
|
from city_model_structure.building_demand.material import Material
|
||||||
|
|
||||||
|
|
||||||
class LcaMaterial:
|
class LcaMaterial:
|
||||||
def __init__(self, city, base_path):
|
def __init__(self, city, base_path):
|
||||||
self._city = city
|
self._city = city
|
||||||
|
@ -15,26 +16,25 @@ class LcaMaterial:
|
||||||
self._lca = None
|
self._lca = None
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
self._city.materials = []
|
self._city.lca_materials = []
|
||||||
path = Path(self._base_path / 'lca_data.xml').resolve()
|
path = Path(self._base_path / 'lca_data.xml').resolve()
|
||||||
|
|
||||||
with open(path) as xml:
|
with open(path) as xml:
|
||||||
self._lca = xmltodict.parse(xml.read())
|
self._lca = xmltodict.parse(xml.read())
|
||||||
|
|
||||||
for material in self._lca["library"]["building_materials"]['material']:
|
for material in self._lca["library"]["building_materials"]['material']:
|
||||||
_material = Material()
|
_lca_material = LcaMaterial()
|
||||||
_material.type = material['@type']
|
_lca_material.type = material['@type']
|
||||||
_material.id = material['@id']
|
_lca_material.id = material['@id']
|
||||||
_material.name = material['@name']
|
_lca_material.name = material['@name']
|
||||||
_material.density=material['density']['#text']
|
_lca_material.density = material['density']['#text']
|
||||||
_material.density_unit=material['density']['@unit']
|
_lca_material.density_unit = material['density']['@unit']
|
||||||
_material.embodied_carbon=material['embodied_carbon']['#text']
|
_lca_material.embodied_carbon = material['embodied_carbon']['#text']
|
||||||
_material.embodied_carbon_unit=material['embodied_carbon']['@unit']
|
_lca_material.embodied_carbon_unit = material['embodied_carbon']['@unit']
|
||||||
_material.recycling_ratio=material['recycling_ratio']
|
_lca_material.recycling_ratio = material['recycling_ratio']
|
||||||
_material.onsite_recycling_ratio=material['onsite_recycling_ratio']
|
_lca_material.onsite_recycling_ratio = material['onsite_recycling_ratio']
|
||||||
_material.company_recycling_ratio=material['company_recycling_ratio']
|
_lca_material.company_recycling_ratio = material['company_recycling_ratio']
|
||||||
_material.landfilling_ratio=material['landfilling_ratio']
|
_lca_material.landfilling_ratio = material['landfilling_ratio']
|
||||||
_material.cost=material['cost']['#text']
|
_lca_material.cost = material['cost']['#text']
|
||||||
_material._cost_unit=material['cost']['@unit']
|
_lca_material._cost_unit = material['cost']['@unit']
|
||||||
|
self._city.lca_materials.append(_lca_material)
|
||||||
self._city.materials.append(_material)
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import xmltodict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from city_model_structure.vehicle import Vehicle
|
from city_model_structure.vehicle import Vehicle
|
||||||
|
|
||||||
|
|
||||||
class LcaVehicle:
|
class LcaVehicle:
|
||||||
def __init__(self, city, base_path):
|
def __init__(self, city, base_path):
|
||||||
self._city = city
|
self._city = city
|
||||||
|
@ -22,5 +23,6 @@ class LcaVehicle:
|
||||||
self._lca = xmltodict.parse(xml.read())
|
self._lca = xmltodict.parse(xml.read())
|
||||||
for vehicle in self._lca["library"]["vehicles"]['vehicle']:
|
for vehicle in self._lca["library"]["vehicles"]['vehicle']:
|
||||||
self._city.vehicles.append(Vehicle(vehicle['@id'], vehicle['@name'], vehicle['fuel_consumption_rate']['#text'],
|
self._city.vehicles.append(Vehicle(vehicle['@id'], vehicle['@name'], vehicle['fuel_consumption_rate']['#text'],
|
||||||
vehicle['fuel_consumption_rate']['@unit'], vehicle['carbon_emission_factor']['#text'],
|
vehicle['fuel_consumption_rate']['@unit'],
|
||||||
vehicle['carbon_emission_factor']['@unit']))
|
vehicle['carbon_emission_factor']['#text'],
|
||||||
|
vehicle['carbon_emission_factor']['@unit']))
|
||||||
|
|
|
@ -22,6 +22,9 @@ class ConcordiaEnergyConsumption(ConcordiaFileReport):
|
||||||
building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]]
|
building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]]
|
||||||
building_headers = ["Date time", "Energy consumption"]
|
building_headers = ["Date time", "Energy consumption"]
|
||||||
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
||||||
|
print(building_energy_consumption)
|
||||||
|
|
||||||
|
"""
|
||||||
sensor = ConcordiaEnergySensor(self._sensors[i])
|
sensor = ConcordiaEnergySensor(self._sensors[i])
|
||||||
sensor_exist = False
|
sensor_exist = False
|
||||||
for j in range(len(obj.sensors)):
|
for j in range(len(obj.sensors)):
|
||||||
|
@ -32,3 +35,4 @@ class ConcordiaEnergyConsumption(ConcordiaFileReport):
|
||||||
if not sensor_exist:
|
if not sensor_exist:
|
||||||
sensor.add_period(building_energy_consumption)
|
sensor.add_period(building_energy_consumption)
|
||||||
obj.sensors.append(sensor)
|
obj.sensors.append(sensor)
|
||||||
|
"""
|
||||||
|
|
|
@ -5,7 +5,7 @@ Copyright © 2021 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons
|
||||||
"""
|
"""
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from imports.sensors.concordia_file_report import ConcordiaFileReport
|
from imports.sensors.concordia_file_report import ConcordiaFileReport
|
||||||
from city_model_structure.iot.concordia_gas_flow_sensor import ConcordiaGasFlowSensor
|
|
||||||
|
|
||||||
|
|
||||||
class ConcordiaGasFlow(ConcordiaFileReport):
|
class ConcordiaGasFlow(ConcordiaFileReport):
|
||||||
|
@ -24,6 +24,7 @@ class ConcordiaGasFlow(ConcordiaFileReport):
|
||||||
building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]]
|
building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]]
|
||||||
building_headers = ["Date time", "Gas Flow Cumulative Monthly"]
|
building_headers = ["Date time", "Gas Flow Cumulative Monthly"]
|
||||||
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
||||||
|
"""
|
||||||
sensor = ConcordiaGasFlowSensor(self._sensors[i])
|
sensor = ConcordiaGasFlowSensor(self._sensors[i])
|
||||||
sensor_exist = False
|
sensor_exist = False
|
||||||
for j in range(len(obj.sensors)):
|
for j in range(len(obj.sensors)):
|
||||||
|
@ -34,3 +35,4 @@ class ConcordiaGasFlow(ConcordiaFileReport):
|
||||||
if not sensor_exist:
|
if not sensor_exist:
|
||||||
sensor.add_period(building_energy_consumption)
|
sensor.add_period(building_energy_consumption)
|
||||||
obj.sensors.append(sensor)
|
obj.sensors.append(sensor)
|
||||||
|
"""
|
|
@ -5,7 +5,6 @@ Copyright © 2021 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons
|
||||||
"""
|
"""
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from imports.sensors.concordia_file_report import ConcordiaFileReport
|
from imports.sensors.concordia_file_report import ConcordiaFileReport
|
||||||
from city_model_structure.iot.concordia_temperature_sensor import ConcordiaTemperatureSensor
|
|
||||||
|
|
||||||
|
|
||||||
class ConcordiaTemperature(ConcordiaFileReport):
|
class ConcordiaTemperature(ConcordiaFileReport):
|
||||||
|
@ -23,6 +22,7 @@ class ConcordiaTemperature(ConcordiaFileReport):
|
||||||
building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]]
|
building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]]
|
||||||
building_headers = ["Date time", "Temperature"]
|
building_headers = ["Date time", "Temperature"]
|
||||||
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
||||||
|
"""
|
||||||
sensor = ConcordiaTemperatureSensor(self._sensors[i])
|
sensor = ConcordiaTemperatureSensor(self._sensors[i])
|
||||||
sensor_exist = False
|
sensor_exist = False
|
||||||
for j in range(len(obj.sensors)):
|
for j in range(len(obj.sensors)):
|
||||||
|
@ -33,3 +33,4 @@ class ConcordiaTemperature(ConcordiaFileReport):
|
||||||
if not sensor_exist:
|
if not sensor_exist:
|
||||||
sensor.add_period(building_energy_consumption)
|
sensor.add_period(building_energy_consumption)
|
||||||
obj.sensors.append(sensor)
|
obj.sensors.append(sensor)
|
||||||
|
"""
|
|
@ -13,6 +13,6 @@ openpyxl~=3.0.7
|
||||||
networkx~=2.5.1
|
networkx~=2.5.1
|
||||||
parseidf~=1.0.0
|
parseidf~=1.0.0
|
||||||
ply~=3.11
|
ply~=3.11
|
||||||
rhino3dm~=7.7.0
|
rhino3dm~=7.11.1
|
||||||
scipy==1.7.1
|
scipy==1.7.1
|
||||||
PyYAML==6.0
|
PyYAML==6.0
|
|
@ -50,8 +50,8 @@ class TestSensorsFactory(TestCase):
|
||||||
Load concordia sensors and verify it
|
Load concordia sensors and verify it
|
||||||
"""
|
"""
|
||||||
SensorsFactory('cec', self._city, self._end_point).enrich()
|
SensorsFactory('cec', self._city, self._end_point).enrich()
|
||||||
SensorsFactory('cgf', self._city, self._end_point).enrich()
|
# SensorsFactory('cgf', self._city, self._end_point).enrich()
|
||||||
SensorsFactory('ct', self._city, self._end_point).enrich()
|
# SensorsFactory('ct', self._city, self._end_point).enrich()
|
||||||
for city_object in self._city.city_objects:
|
for city_object in self._city.city_objects:
|
||||||
print(city_object.name, len(city_object.sensors))
|
print(city_object.name, len(city_object.sensors))
|
||||||
for sensor in city_object.sensors:
|
for sensor in city_object.sensors:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user