diff --git a/city_model_structure/fuel.py b/city_model_structure/fuel.py index e78a9f76..6c7f4468 100644 --- a/city_model_structure/fuel.py +++ b/city_model_structure/fuel.py @@ -12,28 +12,28 @@ class Fuel: self._unit = unit @property - def id(self): + def id(self) -> int: """ Get fuel id """ return self._fuel_id @property - def name(self): + def name(self) -> str: """ Get fuel name """ return self._name @property - def carbon_emission_factor(self): + def carbon_emission_factor(self) -> float: """ Get fuel carbon emission factor """ return self._carbon_emission_factor @property - def unit(self): + def unit(self) -> str: """ Get fuel units """ diff --git a/city_model_structure/machine.py b/city_model_structure/machine.py index 5c25fc71..86857125 100644 --- a/city_model_structure/machine.py +++ b/city_model_structure/machine.py @@ -21,56 +21,56 @@ class Machine: self._carbon_emission_unit = carbon_emission_unit @property - def id(self): + def id(self) -> int: """ Get machine id """ return self._machine_id @property - def name(self): + def name(self) -> str: """ Get machine name """ return self._name @property - def work_efficiency(self): + def work_efficiency(self) -> float: """ Get machine work efficiency """ return self._work_efficiency @property - def work_efficiency_unit(self): + def work_efficiency_unit(self) -> str: """ Get machine work efficiency unit """ return self._work_efficiency_unit @property - def energy_consumption_rate(self): + def energy_consumption_rate(self) -> float: """ Get energy consumption rate """ return self._energy_consumption_rate @property - def energy_consumption_unit(self): + def energy_consumption_unit(self) -> str: """ Get energy consumption unit """ return self._energy_consumption_unit @property - def carbon_emission_factor(self): + def carbon_emission_factor(self) -> float: """ Get carbon emission factor """ return self._carbon_emission_factor @property - def carbon_emission_unit(self): + def carbon_emission_unit(self) -> str: """ Get carbon emission unit """ diff --git a/city_model_structure/material.py b/city_model_structure/material.py index d0ef2c53..fa2f4f29 100644 --- a/city_model_structure/material.py +++ b/city_model_structure/material.py @@ -26,91 +26,91 @@ class Material: self._cost_unit = cost_unit @property - def material_name(self): + def material_name(self) -> str: """ Get material name """ return self._material_name @property - def id(self): + def id(self) -> int: """ Get material id """ return self._material_id @property - def type(self): + def type(self) -> str: """ Get material type """ return self._type @property - def density(self): + def density(self) -> float: """ Get material density """ return self._density @property - def density_unit(self): + def density_unit(self) -> str: """ Get material density unit """ return self._density_unit @property - def embodied_carbon(self): + def embodied_carbon(self) -> float: """ Get material embodied carbon """ return self._embodied_carbon @property - def embodied_carbon_unit(self): + def embodied_carbon_unit(self) -> str: """ Get material embodied carbon unit """ return self._embodied_carbon_unit @property - def recycling_ratio(self): + def recycling_ratio(self) -> float: """ Get material recycling ratio """ return self._recycling_ratio @property - def onsite_recycling_ratio(self): + def onsite_recycling_ratio(self) -> float: """ Get material onsite recycling ratio """ return self._onsite_recycling_ratio @property - def company_recycling_ratio(self): + def company_recycling_ratio(self) -> float: """ Get material company recycling ratio """ return self._company_recycling_ratio @property - def landfilling_ratio(self): + def landfilling_ratio(self) -> float: """ Get material landfilling ratio """ return self._landfilling_ratio @property - def cost(self): + def cost(self) -> float: """ Get material cost """ return self._cost @property - def cost_unit(self): + def cost_unit(self) -> str: """ Get material cost unit """ diff --git a/city_model_structure/vehicle.py b/city_model_structure/vehicle.py index 95aff94a..ec4b1b31 100644 --- a/city_model_structure/vehicle.py +++ b/city_model_structure/vehicle.py @@ -18,42 +18,42 @@ class Vehicle: self._carbon_emission_factor_unit = carbon_emission_factor_unit @property - def id(self): + def id(self) -> int: """ Get vehicle id """ return self._vehicle_id @property - def name(self): + def name(self) -> str: """ Get vehicle name """ return self._name @property - def fuel_consumption_rate(self): + def fuel_consumption_rate(self) -> float: """ Get vehicle fuel consumption rate """ return self._fuel_consumption_rate @property - def fuel_consumption_unit(self): + def fuel_consumption_unit(self) -> str: """ Get fuel consumption unit """ return self._fuel_consumption_unit @property - def carbon_emission_factor(self): + def carbon_emission_factor(self) -> float: """ Get vehicle carbon emission factor """ return self._carbon_emission_factor @property - def carbon_emission_unit(self): + def carbon_emission_unit(self) -> str: """ Get carbon emission units """ diff --git a/data/life_cicle_analize/lca_data.xml b/data/life_cycle_assessment/lca_data.xml similarity index 94% rename from data/life_cicle_analize/lca_data.xml rename to data/life_cycle_assessment/lca_data.xml index bc3ab8ee..22ad467b 100644 --- a/data/life_cicle_analize/lca_data.xml +++ b/data/life_cycle_assessment/lca_data.xml @@ -1,6 +1,6 @@ - + 0.32 @@ -76,99 +76,99 @@ 0.61 - - - + + + 0.347 16.5 0.918 - + 0.033 25.2 4.16 - + 0.027 16.8 2.239 - + 0.023 16.8 2.239 - + 0.109 25.2 2.239 - + 0.003 16.4 4.16 - + 0.002 11 0.918 - + 0.002 90 0.918 - + 0.002 10 0.918 - + 0.002 11 0.918 - + 0.002 132 0.918 - + 0.002 15 0.918 - + 0.002 5.5 0.918 - + 0.002 22.5 0.918 - - - + + + 0.0123 2.239 - + 0.042 0.918 - + 0.01 1.00000 - + 1.3 1.00000 - - - + + + 1.8 560 @@ -205,8 +205,8 @@ 0.2 .... - - + + 1.6 900 @@ -315,7 +315,7 @@ 0.2 .... - + 2.58 @@ -336,8 +336,8 @@ .... - - + + 0.06 1760 0.9 @@ -345,8 +345,8 @@ 1 0.1 .... - - + + 0.122 3080 0.9 @@ -354,8 +354,8 @@ 1 0.1 .... - - + + 0.028 3180 0.9 @@ -363,8 +363,8 @@ 1 0.1 .... - - + + 0.024 5140 0.9 @@ -372,8 +372,8 @@ 1 0.1 .... - - + + 0.1 6040 0.9 @@ -381,8 +381,8 @@ 1 0.1 .... - - + + 0.3 5380 0.9 @@ -390,8 +390,8 @@ 1 0.1 .... - - + + 0.032 2150 0.9 @@ -399,8 +399,8 @@ 1 0.1 .... - - + + 0.9 @@ -569,5 +569,5 @@ .... - + \ No newline at end of file diff --git a/imports/life_cycle_assessment/lca_material.py b/imports/life_cycle_assessment/lca_material.py new file mode 100644 index 00000000..6b88496d --- /dev/null +++ b/imports/life_cycle_assessment/lca_material.py @@ -0,0 +1,72 @@ +""" +CityGml module parses citygml_classes files and import the geometry into the city model structure +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2020 Project Author Atiya +""" +import xmltodict +from pathlib import Path +from city_model_structure.material import Material + +class LcaMaterial: + def __init__(self, city, base_path): + self._city = city + self._base_path = base_path + self._lca = None + + def enrich(self): + self._city.materials = [] + path = Path(self._base_path / 'lca_data.xml').resolve() + + with open(path) as xml: + self._lca = xmltodict.parse(xml.read()) + + # for vehicle in self._lca["library"]["vehicles"]['vehicle']: + # 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['carbon_emission_factor']['@unit'])) + for brick in self._lca["library"]["building_materials"]['bricks']['brick']: + material_name = "brick" + self._city.materials.append(Material(material_name, brick['@id'], brick['@type'], brick['density']['#text'], brick['density']['@unit'], + brick['embodied_carbon']['#text'], brick['embodied_carbon']['@unit'], brick['recycling_ratio'], + brick['onsite_recycling_ratio'], brick['company_recycling_ratio'], brick['landfilling_ratio'], + brick['cost']['#text'], brick['cost']['@unit'])) + for concrete in self._lca["library"]["building_materials"]['concretes']['concrete']: + material_name = "concrete" + self._city.materials.append(Material(material_name, concrete['@id'], brick['@type'], concrete['density']['#text'], concrete['density']['@unit'], + concrete['embodied_carbon']['#text'], concrete['embodied_carbon']['@unit'], concrete['recycling_ratio'], + concrete['onsite_recycling_ratio'], concrete['company_recycling_ratio'], concrete['landfilling_ratio'], + concrete['cost']['#text'], concrete['cost']['@unit'])) + for glass in self._lca["library"]["building_materials"]['glasses']['glass']: + material_name = "glass" + self._city.materials.append(Material(material_name, glass['@id'], brick['@type'], glass['density']['#text'], glass['density']['@unit'], + glass['embodied_carbon']['#text'], glass['embodied_carbon']['@unit'], glass['recycling_ratio'], + glass['onsite_recycling_ratio'], glass['company_recycling_ratio'], glass['landfilling_ratio'], + glass['cost']['#text'], glass['cost']['@unit'])) + + for insulation in self._lca["library"]["building_materials"]['insulations']['insulation']: + material_name = "insulation" + self._city.materials.append(Material(material_name, insulation['@id'], brick['@type'], insulation['density']['#text'], insulation['density']['@unit'], + insulation['embodied_carbon']['#text'], insulation['embodied_carbon']['@unit'], insulation['recycling_ratio'], + insulation['onsite_recycling_ratio'], insulation['company_recycling_ratio'], insulation['landfilling_ratio'], + insulation['cost']['#text'], insulation['cost']['@unit'])) + + for wood in self._lca["library"]["building_materials"]['woods']['wood']: + material_name = "wood" + self._city.materials.append(Material(material_name, wood['@id'], brick['@type'], wood['density']['#text'], wood['density']['@unit'], + wood['embodied_carbon']['#text'], wood['embodied_carbon']['@unit'], wood['recycling_ratio'], + wood['onsite_recycling_ratio'], wood['company_recycling_ratio'], wood['landfilling_ratio'], + wood['cost']['#text'], wood['cost']['@unit'])) + + for covering in self._lca["library"]["building_materials"]['coverings']['covering']: + material_name = "covering" + self._city.materials.append(Material(material_name, covering['@id'], brick['@type'], covering['density']['#text'], covering['density']['@unit'], + covering['embodied_carbon']['#text'], covering['embodied_carbon']['@unit'], covering['recycling_ratio'], + covering['onsite_recycling_ratio'], covering['company_recycling_ratio'], covering['landfilling_ratio'], + covering['cost']['#text'], covering['cost']['@unit'])) + + for metal in self._lca["library"]["building_materials"]['metals']['metal']: + material_name = "metal" + self._city.materials.append(Material(material_name, metal['@id'], brick['@type'], metal['density']['#text'], metal['density']['@unit'], + metal['embodied_carbon']['#text'], metal['embodied_carbon']['@unit'], metal['recycling_ratio'], + metal['onsite_recycling_ratio'], metal['company_recycling_ratio'], metal['landfilling_ratio'], + metal['cost']['#text'], metal['cost']['@unit'])) \ No newline at end of file diff --git a/unittests/test_life_cycle_assessment_factory.py b/unittests/test_life_cycle_assessment_factory.py index 3245d56b..2ea8adcb 100644 --- a/unittests/test_life_cycle_assessment_factory.py +++ b/unittests/test_life_cycle_assessment_factory.py @@ -26,7 +26,6 @@ class TestLifeCycleAssessment(TestCase): city = GeometryFactory('citygml', city_file).city LifeCycleAssessment('fuel', city).enrich() for fuel in city.fuels: - # print(fuel.name) self.assertTrue(len(city.fuels) > 0) def test_vehicle(self): @@ -34,7 +33,6 @@ class TestLifeCycleAssessment(TestCase): city = GeometryFactory('citygml', city_file).city LifeCycleAssessment('vehicle', city).enrich() for vehicle in city.vehicles: - # print(vehicle.name) self.assertTrue(len(city.vehicles) > 0) def test_machine(self): @@ -42,7 +40,6 @@ class TestLifeCycleAssessment(TestCase): city = GeometryFactory('citygml', city_file).city LifeCycleAssessment('machine', city).enrich() for machine in city.machines: - # print(machine.name) self.assertTrue(len(city.machines) > 0) def test_material(self): @@ -50,7 +47,6 @@ class TestLifeCycleAssessment(TestCase): city = GeometryFactory('citygml', city_file).city LifeCycleAssessment('material', city).enrich() for material in city.materials: - print(material.material_name) self.assertTrue(len(city.materials) > 0)