hub/imports/life_cycle_assessment/lca_material.py

72 lines
5.4 KiB
Python
Raw Normal View History

2021-11-15 10:35:31 -05:00
"""
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']))