Link materials and lca_materials in the city

This commit is contained in:
Guille Gutierrez 2022-03-02 12:56:20 -05:00
parent 6668c48039
commit 024469ac0a
7 changed files with 27 additions and 11 deletions

View File

@ -420,7 +420,7 @@ class City:
"""
self._lca_materials = value
def get_lca_material(self, lca_id) -> LcaMaterial:
def lca_material(self, lca_id) -> LcaMaterial:
"""
Get the lca materiol matching the given Id
:return: LcaMaterial or None

View File

@ -10,7 +10,8 @@ class NrelLayerArchetype:
NrelLayerArchetype class
"""
def __init__(self, name, solar_absorptance, thermal_absorptance, visible_absorptance, thickness=None,
conductivity=None, specific_heat=None, density=None, no_mass=False, thermal_resistance=None):
conductivity=None, specific_heat=None, density=None, no_mass=False, thermal_resistance=None,
lca_id=None):
self._thickness = thickness
self._conductivity = conductivity
self._specific_heat = specific_heat
@ -21,6 +22,7 @@ class NrelLayerArchetype:
self._no_mass = no_mass
self._name = name
self._thermal_resistance = thermal_resistance
self._lca_id = lca_id
@property
def thickness(self):
@ -101,3 +103,11 @@ class NrelLayerArchetype:
:return: float
"""
return self._thermal_resistance
@property
def lca_id(self):
"""
Get nrel lca_id equivalent for the material
:return: int
"""
return self._lca_id

View File

@ -71,6 +71,7 @@ class NrelPhysicsInterface:
for current_layer in c_lib['layers']['layer']:
material_lib = self._search_construction_type('material', current_layer['material'])
name = material_lib['@name']
lca_id = material_lib['@lca_id']
solar_absorptance = material_lib['solar_absorptance']['#text']
thermal_absorptance = material_lib['thermal_absorptance']['#text']
visible_absorptance = material_lib['visible_absorptance']['#text']
@ -81,7 +82,7 @@ class NrelPhysicsInterface:
if units != 'm2 K/W':
raise Exception(f'thermal resistance units = {units}, expected m2 K/W')
layer = nla(name, solar_absorptance, thermal_absorptance, visible_absorptance, no_mass=no_mass,
thermal_resistance=thermal_resistance)
thermal_resistance=thermal_resistance, lca_id=lca_id)
else:
thickness = current_layer['thickness']['#text']
units = current_layer['thickness']['@units']
@ -100,7 +101,7 @@ class NrelPhysicsInterface:
if units != 'kg/m3':
raise Exception(f'density units = {units}, expected kg/m3')
layer = nla(name, solar_absorptance, thermal_absorptance, visible_absorptance, thickness=thickness,
conductivity=conductivity, specific_heat=specific_heat, density=density)
conductivity=conductivity, specific_heat=specific_heat, density=density, lca_id=lca_id)
layers.append(layer)
thermal_opening = None

View File

@ -24,7 +24,7 @@ class Rhino:
self._max_x = self._max_y = self._max_z = min_float
@staticmethod
def _solid_points(coordinates) -> np.ndarray:
def _solid_points(coordinates):
solid_points = np.fromstring(coordinates, dtype=float, sep=' ')
solid_points = GeometryHelper.to_points_matrix(solid_points)
return solid_points

View File

@ -7,6 +7,7 @@ Contributor Mohammad Reza mohammad.seyedabadi@mail.concordia.ca
import xmltodict
from pathlib import Path
from city_model_structure.building_demand.material import Material
from city_model_structure.lca_material import LcaMaterial as LcaMat
class LcaMaterial:
@ -23,7 +24,7 @@ class LcaMaterial:
self._lca = xmltodict.parse(xml.read())
for material in self._lca["library"]["building_materials"]['material']:
_lca_material = LcaMaterial()
_lca_material = LcaMat()
_lca_material.type = material['@type']
_lca_material.id = material['@id']
_lca_material.name = material['@name']
@ -35,6 +36,6 @@ class LcaMaterial:
_lca_material.onsite_recycling_ratio = material['onsite_recycling_ratio']
_lca_material.company_recycling_ratio = material['company_recycling_ratio']
_lca_material.landfilling_ratio = material['landfilling_ratio']
_lca_material.cost = material['cost']['#text']
_lca_material.cost = 10 # todo: change this into material['cost']['#text']
_lca_material._cost_unit = material['cost']['@unit']
self._city.lca_materials.append(_lca_material)

View File

@ -9,7 +9,7 @@ from unittest import TestCase
from imports.geometry_factory import GeometryFactory
from imports.construction_factory import ConstructionFactory
from imports.geometry.helpers.geometry_helper import GeometryHelper
from imports.life_cycle_assessment_factory import LifeCycleAssessment
class TestConstructionFactory(TestCase):
"""
@ -28,6 +28,7 @@ class TestConstructionFactory(TestCase):
file = 'pluto_building.gml'
file_path = (self._example_path / file).resolve()
self._city = GeometryFactory('citygml', file_path).city
LifeCycleAssessment('material', self._city).enrich()
self.assertIsNotNone(self._city, 'city is none')
return self._city
@ -60,7 +61,8 @@ class TestConstructionFactory(TestCase):
if thermal_boundary.surface.type != 'Ground':
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
print(thermal_boundary.layers)
for layer in thermal_boundary.layers:
self.assertTrue(city.lca_material(layer.material.lca_id) is not None)
def test_city_with_construction_reduced_library(self):
"""

View File

@ -47,8 +47,10 @@ class TestLifeCycleAssessment(TestCase):
city_file = "../unittests/tests_data/C40_Final.gml"
city = GeometryFactory('citygml', city_file).city
LifeCycleAssessment('material', city).enrich()
for material in city.materials:
self.assertTrue(len(city.materials) > 0)
self.assertTrue(len(city.lca_materials) > 0)
for lca_material in city.lca_materials:
lca_mat = city.lca_material(lca_material.id)
self.assertTrue(lca_mat is not None)