Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7529a3719a
23
city_model_structure/lca_calculations.py
Normal file
23
city_model_structure/lca_calculations.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
"""
|
||||
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
|
||||
|
||||
|
||||
|
78
city_model_structure/machine.py
Normal file
78
city_model_structure/machine.py
Normal file
|
@ -0,0 +1,78 @@
|
|||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
class Machine:
|
||||
"""
|
||||
Machine class
|
||||
"""
|
||||
|
||||
def __init__(self, machine_id, name, work_efficiency, work_efficiency_unit, energy_consumption_rate, energy_consumption_unit,
|
||||
carbon_emission_factor, carbon_emission_unit):
|
||||
self._machine_id = machine_id
|
||||
self._name = name
|
||||
self._work_efficiency = work_efficiency
|
||||
self._work_efficiency_unit = work_efficiency_unit
|
||||
self._energy_consumption_rate = energy_consumption_rate
|
||||
self._energy_consumption_unit = energy_consumption_unit
|
||||
self._carbon_emission_factor = carbon_emission_factor
|
||||
self._carbon_emission_unit = carbon_emission_unit
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Get machine id
|
||||
"""
|
||||
return self._machine_id
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Get machine name
|
||||
"""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def work_efficiency(self):
|
||||
"""
|
||||
Get machine work efficiency
|
||||
"""
|
||||
return self._work_efficiency
|
||||
|
||||
@property
|
||||
def work_efficiency_unit(self):
|
||||
"""
|
||||
Get machine work efficiency unit
|
||||
"""
|
||||
return self._work_efficiency_unit
|
||||
|
||||
@property
|
||||
def energy_consumption_rate(self):
|
||||
"""
|
||||
Get energy consumption rate
|
||||
"""
|
||||
return self._energy_consumption_rate
|
||||
|
||||
@property
|
||||
def energy_consumption_unit(self):
|
||||
"""
|
||||
Get energy consumption unit
|
||||
"""
|
||||
return self._energy_consumption_unit
|
||||
|
||||
@property
|
||||
def carbon_emission_factor(self):
|
||||
"""
|
||||
Get carbon emission factor
|
||||
"""
|
||||
return self._carbon_emission_factor
|
||||
|
||||
@property
|
||||
def carbon_emission_unit(self):
|
||||
"""
|
||||
Get carbon emission unit
|
||||
"""
|
||||
return self._carbon_emission_unit
|
||||
|
118
city_model_structure/material.py
Normal file
118
city_model_structure/material.py
Normal file
|
@ -0,0 +1,118 @@
|
|||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
class Material:
|
||||
"""
|
||||
LCA Material class
|
||||
"""
|
||||
|
||||
def __init__(self, material_name, material_id, type, density, density_unit, embodied_carbon, embodied_carbon_unit, recycling_ratio,
|
||||
onsite_recycling_ratio, company_recycling_ratio, landfilling_ratio, cost, cost_unit):
|
||||
self._material_name = material_name
|
||||
self._material_id = material_id
|
||||
self._type = type
|
||||
self._density = density
|
||||
self._density_unit = density_unit
|
||||
self._embodied_carbon = embodied_carbon
|
||||
self._embodied_carbon_unit = embodied_carbon_unit
|
||||
self._recycling_ratio = recycling_ratio
|
||||
self._onsite_recycling_ratio = onsite_recycling_ratio
|
||||
self._company_recycling_ratio = company_recycling_ratio
|
||||
self._landfilling_ratio = landfilling_ratio
|
||||
self._cost = cost
|
||||
self._cost_unit = cost_unit
|
||||
|
||||
@property
|
||||
def material_name(self):
|
||||
"""
|
||||
Get material name
|
||||
"""
|
||||
return self._material_name
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Get material id
|
||||
"""
|
||||
return self._material_id
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
"""
|
||||
Get material type
|
||||
"""
|
||||
return self._type
|
||||
|
||||
@property
|
||||
def density(self):
|
||||
"""
|
||||
Get material density
|
||||
"""
|
||||
return self._density
|
||||
|
||||
@property
|
||||
def density_unit(self):
|
||||
"""
|
||||
Get material density unit
|
||||
"""
|
||||
return self._density_unit
|
||||
|
||||
@property
|
||||
def embodied_carbon(self):
|
||||
"""
|
||||
Get material embodied carbon
|
||||
"""
|
||||
return self._embodied_carbon
|
||||
|
||||
@property
|
||||
def embodied_carbon_unit(self):
|
||||
"""
|
||||
Get material embodied carbon unit
|
||||
"""
|
||||
return self._embodied_carbon_unit
|
||||
|
||||
@property
|
||||
def recycling_ratio(self):
|
||||
"""
|
||||
Get material recycling ratio
|
||||
"""
|
||||
return self._recycling_ratio
|
||||
|
||||
@property
|
||||
def onsite_recycling_ratio(self):
|
||||
"""
|
||||
Get material onsite recycling ratio
|
||||
"""
|
||||
return self._onsite_recycling_ratio
|
||||
|
||||
@property
|
||||
def company_recycling_ratio(self):
|
||||
"""
|
||||
Get material company recycling ratio
|
||||
"""
|
||||
return self._company_recycling_ratio
|
||||
|
||||
@property
|
||||
def landfilling_ratio(self):
|
||||
"""
|
||||
Get material landfilling ratio
|
||||
"""
|
||||
return self._landfilling_ratio
|
||||
|
||||
@property
|
||||
def cost(self):
|
||||
"""
|
||||
Get material cost
|
||||
"""
|
||||
return self._cost
|
||||
|
||||
@property
|
||||
def cost_unit(self):
|
||||
"""
|
||||
Get material cost unit
|
||||
"""
|
||||
return self._cost_unit
|
||||
|
61
city_model_structure/vehicle.py
Normal file
61
city_model_structure/vehicle.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
class Vehicle:
|
||||
"""
|
||||
Vehicle class
|
||||
"""
|
||||
|
||||
def __init__(self, vehicle_id, name, fuel_consumption_rate, fuel_consumption_unit, carbon_emission_factor, carbon_emission_factor_unit):
|
||||
self._vehicle_id = vehicle_id
|
||||
self._name = name
|
||||
self._fuel_consumption_rate = fuel_consumption_rate
|
||||
self._fuel_consumption_unit = fuel_consumption_unit
|
||||
self._carbon_emission_factor = carbon_emission_factor
|
||||
self._carbon_emission_factor_unit = carbon_emission_factor_unit
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Get vehicle id
|
||||
"""
|
||||
return self._vehicle_id
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Get vehicle name
|
||||
"""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def fuel_consumption_rate(self):
|
||||
"""
|
||||
Get vehicle fuel consumption rate
|
||||
"""
|
||||
return self._fuel_consumption_rate
|
||||
|
||||
@property
|
||||
def fuel_consumption_unit(self):
|
||||
"""
|
||||
Get fuel consumption unit
|
||||
"""
|
||||
return self._fuel_consumption_unit
|
||||
|
||||
@property
|
||||
def carbon_emission_factor(self):
|
||||
"""
|
||||
Get vehicle carbon emission factor
|
||||
"""
|
||||
return self._carbon_emission_factor
|
||||
|
||||
@property
|
||||
def carbon_emission_unit(self):
|
||||
"""
|
||||
Get carbon emission units
|
||||
"""
|
||||
return self._carbon_emission_unit
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
"""
|
||||
ConstructionFactory (before PhysicsFactory) retrieve the specific construction module for the given region
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Atiya
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from imports.life_cicle_analize.lca_fuel import LcaFuel
|
||||
|
||||
|
||||
class LifeCicleAnalizeFactory:
|
||||
"""
|
||||
Life cicle analize factory class
|
||||
"""
|
||||
def __init__(self, handler, city, base_path=None):
|
||||
if base_path is None:
|
||||
base_path = Path(Path(__file__).parent.parent / 'data/construction')
|
||||
self._handler = '_' + handler.lower().replace(' ', '_')
|
||||
self._city = city
|
||||
self._base_path = base_path
|
||||
|
||||
def _fuel(self):
|
||||
"""
|
||||
Enrich the city by adding the fuel carbon information
|
||||
"""
|
||||
LcaFuel(self._city, self._base_path).enrich()
|
||||
|
||||
def enrich(self):
|
||||
"""
|
||||
Enrich the city given to the class using the class given handler
|
||||
:return: None
|
||||
"""
|
||||
getattr(self, self._handler, lambda: None)()
|
|
@ -19,6 +19,6 @@ class LcaFuel:
|
|||
|
||||
with open(path) as xml:
|
||||
self._lca = xmltodict.parse(xml.read())
|
||||
for fuel in self._lca["library"]["Fuels"]['fuel']:
|
||||
for fuel in self._lca["library"]["fuels"]['fuel']:
|
||||
self._city.fuels.append(Fuel(fuel['@id'], fuel['@name'], fuel['carbon_emission_factor']['#text'],
|
||||
fuel['carbon_emission_factor']['@unit']))
|
26
imports/life_cycle_assessment/lca_machine.py
Normal file
26
imports/life_cycle_assessment/lca_machine.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
"""
|
||||
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.machine import Machine
|
||||
|
||||
class LcaMachine:
|
||||
def __init__(self, city, base_path):
|
||||
self._city = city
|
||||
self._base_path = base_path
|
||||
self._lca = None
|
||||
|
||||
def enrich(self):
|
||||
self._city.machines = []
|
||||
path = Path(self._base_path / 'lca_data.xml').resolve()
|
||||
|
||||
with open(path) as xml:
|
||||
self._lca = xmltodict.parse(xml.read())
|
||||
for machine in self._lca["library"]["machines"]['machine']:
|
||||
self._city.machines.append(Machine(machine['@id'], machine['@name'], machine['work_efficiency']['#text'],
|
||||
machine['work_efficiency']['@unit'], machine['energy_consumption_rate']['#text'],
|
||||
machine['energy_consumption_rate']['@unit'], machine['carbon_emission_factor']['#text'],
|
||||
machine['carbon_emission_factor']['@unit']))
|
25
imports/life_cycle_assessment/lca_vehicle.py
Normal file
25
imports/life_cycle_assessment/lca_vehicle.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
"""
|
||||
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.vehicle import Vehicle
|
||||
|
||||
class LcaVehicle:
|
||||
def __init__(self, city, base_path):
|
||||
self._city = city
|
||||
self._base_path = base_path
|
||||
self._lca = None
|
||||
|
||||
def enrich(self):
|
||||
self._city.vehicles = []
|
||||
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']))
|
54
imports/life_cycle_assessment_factory.py
Normal file
54
imports/life_cycle_assessment_factory.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
"""
|
||||
ConstructionFactory (before PhysicsFactory) retrieve the specific construction module for the given region
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Atiya
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from imports.life_cycle_assessment.lca_fuel import LcaFuel
|
||||
from imports.life_cycle_assessment.lca_vehicle import LcaVehicle
|
||||
from imports.life_cycle_assessment.lca_machine import LcaMachine
|
||||
from imports.life_cycle_assessment.lca_material import LcaMaterial
|
||||
|
||||
|
||||
class LifeCycleAssessment:
|
||||
"""
|
||||
Life cicle analize factory class
|
||||
"""
|
||||
def __init__(self, handler, city, base_path=None):
|
||||
if base_path is None:
|
||||
base_path = Path(Path(__file__).parent.parent / 'data/life_cycle_assessment')
|
||||
self._handler = '_' + handler.lower().replace(' ', '_')
|
||||
self._city = city
|
||||
self._base_path = base_path
|
||||
|
||||
def _fuel(self):
|
||||
"""
|
||||
Enrich the city by adding the fuel carbon information
|
||||
"""
|
||||
LcaFuel(self._city, self._base_path).enrich()
|
||||
|
||||
def _vehicle(self):
|
||||
"""
|
||||
Enrich the city by adding the vehicle carbon information
|
||||
"""
|
||||
LcaVehicle(self._city, self._base_path).enrich()
|
||||
|
||||
def _machine(self):
|
||||
"""
|
||||
Enrich the city by adding the machine carbon information
|
||||
"""
|
||||
LcaMachine(self._city, self._base_path).enrich()
|
||||
|
||||
def _material(self):
|
||||
"""
|
||||
Enrich the city by adding the material carbon information
|
||||
"""
|
||||
LcaMaterial(self._city, self._base_path).enrich()
|
||||
|
||||
def enrich(self):
|
||||
"""
|
||||
Enrich the city given to the class using the class given handler
|
||||
:return: None
|
||||
"""
|
||||
getattr(self, self._handler, lambda: None)()
|
58
unittests/test_life_cycle_assessment_factory.py
Normal file
58
unittests/test_life_cycle_assessment_factory.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
"""
|
||||
Building test
|
||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||
Copyright © 2020 Project Author Guille Gutierrez Morote Guillermo.GutierrezMorote@concordia.ca
|
||||
"""
|
||||
from pathlib import Path
|
||||
from unittest import TestCase
|
||||
from imports.geometry_factory import GeometryFactory
|
||||
from imports.life_cycle_assessment_factory import LifeCycleAssessment
|
||||
|
||||
|
||||
class TestLifeCycleAssessment(TestCase):
|
||||
"""
|
||||
TestBuilding TestCase 1
|
||||
"""
|
||||
def setUp(self) -> None:
|
||||
"""
|
||||
Test setup
|
||||
:return: None
|
||||
"""
|
||||
self._city_gml = None
|
||||
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
||||
|
||||
def test_fuel(self):
|
||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||
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):
|
||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||
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):
|
||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||
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):
|
||||
city_file = "../unittests/tests_data/C40_Final.gml"
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user