upgraded catalogs with to_dictionary method and __str__

This commit is contained in:
Pilar Monsalvete 2023-07-13 13:05:23 -04:00
parent c69f071958
commit 639e5a952d
29 changed files with 421 additions and 73 deletions

View File

@ -132,3 +132,24 @@ class Archetype:
:return: float :return: float
""" """
return self._infiltration_rate_for_ventilation_system_on return self._infiltration_rate_for_ventilation_system_on
def to_dictionary(self):
"""Class content to dictionary"""
_constructions = []
for _construction in self.constructions:
_constructions.append(_construction.to_dictionary())
content = {'Archetype': {'id': self.id,
'name': self.name,
'function': self.function,
'climate zone': self.climate_zone,
'period of construction': self.construction_period,
'average storey height [m]': self.average_storey_height,
'thermal capacity [J/m3K]': self.thermal_capacity,
'extra loses due to thermal bridges [W/m2K]': self.extra_loses_due_to_thermal_bridges,
'indirect heated ratio': self.indirect_heated_ratio,
'infiltration rate for ventilation off [ACH]': self.infiltration_rate_for_ventilation_system_off,
'infiltration rate for ventilation on [ACH]': self.infiltration_rate_for_ventilation_system_on,
'constructions': _constructions
}
}
return content

View File

@ -4,6 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group Copyright © 2022 Concordia CERC group
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
""" """
from hub.catalog_factories.data_models.construction.layer import Layer from hub.catalog_factories.data_models.construction.layer import Layer
from hub.catalog_factories.data_models.construction.window import Window from hub.catalog_factories.data_models.construction.window import Window
@ -67,3 +68,21 @@ class Construction:
:return: Window :return: Window
""" """
return self._window return self._window
def to_dictionary(self):
"""Class content to dictionary"""
_layers = []
for _layer in self.layers:
_layers.append(_layer.to_dictionary())
_window = None
if self.window is not None:
_window = self.window.to_dictionary()
content = {'Construction': {'id': self.id,
'name': self.name,
'type': self.type,
'window ratio': self.window_ratio,
'window': _window,
'layers': _layers
}
}
return content

View File

@ -43,3 +43,21 @@ class Content:
All windows in the catalog All windows in the catalog
""" """
return self._windows return self._windows
def to_dictionary(self):
"""Class content to dictionary"""
_archetypes = []
for _archetype in self.archetypes:
_archetypes.append(_archetype.to_dictionary())
content = {'Archetypes': _archetypes}
return content
def __str__(self):
"""Print content"""
_archetypes = []
for _archetype in self.archetypes:
_archetypes.append(_archetype.to_dictionary())
content = {'Archetypes': _archetypes}
return str(content)

View File

@ -5,6 +5,8 @@ Copyright © 2022 Concordia CERC group
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
""" """
from hub.catalog_factories.data_models.construction.material import Material
class Layer: class Layer:
""" """
@ -33,7 +35,7 @@ class Layer:
return self._name return self._name
@property @property
def material(self): def material(self) -> Material:
""" """
Get layer material Get layer material
:return: Material :return: Material
@ -47,3 +49,13 @@ class Layer:
:return: None or float :return: None or float
""" """
return self._thickness return self._thickness
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Layer': {'id': self.id,
'name': self.name,
'thickness [m]': self.thickness,
'material': self.material.to_dictionary()
}
}
return content

View File

@ -110,3 +110,19 @@ class Material:
:return: None or float :return: None or float
""" """
return self._thermal_resistance return self._thermal_resistance
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Material': {'id': self.id,
'name': self.name,
'is no-mass': self.no_mass,
'density [kg/m3]': self.density,
'specific heat [J/kgK]': self.specific_heat,
'conductivity [W/mK]': self.conductivity,
'thermal resistance [m2K/W]': self.thermal_resistance,
'solar absorptance': self.solar_absorptance,
'thermal absorptance': self.thermal_absorptance,
'visible absorptance': self.visible_absorptance
}
}
return content

View File

@ -64,4 +64,16 @@ class Window:
Get transparent surface type, 'window' or 'skylight' Get transparent surface type, 'window' or 'skylight'
:return: str :return: str
""" """
return self.type return self._type
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Window': {'id': self.id,
'name': self.name,
'type': self.type,
'frame ratio': self.frame_ratio,
'g-value': self.g_value,
'overall U value [W/m2K]': self.overall_u_value
}
}
return content

View File

@ -114,3 +114,19 @@ class Archetype:
:return: Income :return: Income
""" """
return self._income return self._income
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Archetype': {'name': self.name,
'level of detail': self.lod,
'municipality': self.municipality,
'country': self.country,
'currency': self.currency,
'function': self.function,
'capital cost': self.capital_cost.to_dictionary(),
'operational cost': self.operational_cost.to_dictionary(),
f'end of life cost [currency]': self.end_of_life_cost,
'income': self.income.to_dictionary()
}
}
return content

View File

@ -51,3 +51,16 @@ class CapitalCost:
if chapter.chapter_type == name: if chapter.chapter_type == name:
return chapter return chapter
raise KeyError(f'Chapter name {name} not found') raise KeyError(f'Chapter name {name} not found')
def to_dictionary(self):
"""Class content to dictionary"""
_chapters = []
for _chapter in self.general_chapters:
_chapters.append(_chapter.to_dictionary())
content = {'Capital cost': {'design allowance': self.design_allowance,
'overhead and profit': self.overhead_and_profit,
'chapters': _chapters
}
}
return content

View File

@ -43,3 +43,15 @@ class Chapter:
if item.type == name: if item.type == name:
return item return item
raise KeyError(f'Item name {name} not found') raise KeyError(f'Item name {name} not found')
def to_dictionary(self):
"""Class content to dictionary"""
_items = []
for _item in self.items:
_items.append(_item.to_dictionary())
content = {'Chapter': {'chapter type': self.chapter_type,
'items': _items
}
}
return content

View File

@ -20,3 +20,21 @@ class Content:
All archetypes in the catalog All archetypes in the catalog
""" """
return self._archetypes return self._archetypes
def to_dictionary(self):
"""Class content to dictionary"""
_archetypes = []
for _archetype in self.archetypes:
_archetypes.append(_archetype.to_dictionary())
content = {'Archetypes': _archetypes}
return content
def __str__(self):
"""Print content"""
_archetypes = []
for _archetype in self.archetypes:
_archetypes.append(_archetype.to_dictionary())
content = {'Archetypes': _archetypes}
return str(content)

View File

@ -55,3 +55,14 @@ class Fuel:
:return: None, None or float, str :return: None, None or float, str
""" """
return self._variable, self._variable_units return self._variable, self._variable_units
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Fuel': {'fuel type': self.type,
'fixed operational costs [currency/month]': self.fixed_monthly,
'fixed operational costs depending on the peak power consumed [currency/month kW]': self.fixed_power,
f'variable costs [{self.variable[1]}]': self.variable[0]
}
}
return content

View File

@ -63,3 +63,15 @@ class Income:
:return: None or float :return: None or float
""" """
return self._reductions_tax return self._reductions_tax
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Income': {'construction subsidy': self.construction_subsidy,
'hvac subsidy': self.hvac_subsidy,
'photovoltaic subsidy': self.photovoltaic_subsidy,
'electricity export': self.electricity_export,
'reductions tax': self.reductions_tax
}
}
return content

View File

@ -69,3 +69,15 @@ class ItemDescription:
:return: None or float :return: None or float
""" """
return self._lifetime return self._lifetime
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Item': {'type': self.type,
f'initial investment [{self.initial_investment[1]}]': self.initial_investment[0],
f'refurbishment [{self.refurbishment[1]}]': self.refurbishment[0],
f'reposition [{self.reposition[1]}]': self.reposition[0],
'life time [years]': self.lifetime
}
}
return content

View File

@ -59,3 +59,18 @@ class OperationalCost:
:return: float :return: float
""" """
return self._co2 return self._co2
def to_dictionary(self):
"""Class content to dictionary"""
_fuels = []
for _fuel in self.fuels:
_fuels.append(_fuel.to_dictionary())
content = {'Maintenance': {'fuels': _fuels,
'cost of maintaining the heating system [currency/W]': self.maintenance_heating,
'cost of maintaining the cooling system [currency/W]': self.maintenance_cooling,
'cost of maintaining the PV system [currency/W]': self.maintenance_pv,
'cost of CO2 emissions [currency/kgCO2]': self.co2
}
}
return content

View File

@ -43,3 +43,15 @@ class Archetype:
:return: [Equipment] :return: [Equipment]
""" """
return self._systems return self._systems
def to_dictionary(self):
"""Class content to dictionary"""
_systems = []
for _system in self.systems:
_systems.append(_system.to_dictionary())
content = {'Archetype': {'name': self.name,
'level of detail': self.lod,
'systems': _systems
}
}
return content

View File

@ -51,3 +51,21 @@ class Content:
All emission equipments in the catalog All emission equipments in the catalog
""" """
return self._emissions return self._emissions
def to_dictionary(self):
"""Class content to dictionary"""
_archetypes = []
for _archetype in self.archetypes:
_archetypes.append(_archetype.to_dictionary())
content = {'Archetypes': _archetypes}
return content
def __str__(self):
"""Print content"""
_archetypes = []
for _archetype in self.archetypes:
_archetypes.append(_archetype.to_dictionary())
content = {'Archetypes': _archetypes}
return str(content)

View File

@ -29,14 +29,6 @@ class DistributionSystem:
""" """
return self._system_id return self._system_id
@id.setter
def id(self, value):
"""
Set system id
:param value: float
"""
self._system_id = value
@property @property
def name(self): def name(self):
""" """
@ -45,14 +37,6 @@ class DistributionSystem:
""" """
return self._name return self._name
@name.setter
def name(self, value):
"""
Set name
:param value: string
"""
self._name = value
@property @property
def type(self): def type(self):
""" """
@ -81,7 +65,7 @@ class DistributionSystem:
def distribution_consumption_variable_flow(self): def distribution_consumption_variable_flow(self):
""" """
Get distribution_consumption if the pump or fan work at variable mass or volume flow in ratio Get distribution_consumption if the pump or fan work at variable mass or volume flow in ratio
over energy produced (Wh/Wh) over energy produced (J/J)
:return: float :return: float
""" """
return self._distribution_consumption_variable_flow return self._distribution_consumption_variable_flow
@ -89,7 +73,20 @@ class DistributionSystem:
@property @property
def heat_losses(self): def heat_losses(self):
""" """
Get heat_losses in ratio over energy produced Get heat_losses in ratio over energy produced in J/J
:return: float :return: float
""" """
return self._heat_losses return self._heat_losses
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Layer': {'id': self.id,
'name': self.name,
'type': self.type,
'supply temperature [Celsius]': self.supply_temperature,
'distribution consumption if fix flow over peak power [W/W]': self.distribution_consumption_fix_flow,
'distribution consumption if variable flow over peak power [J/J]': self.distribution_consumption_variable_flow,
'heat losses per energy produced [J/J]': self.heat_losses
}
}
return content

View File

@ -25,14 +25,6 @@ class EmissionSystem:
""" """
return self._system_id return self._system_id
@id.setter
def id(self, value):
"""
Set system id
:param value: float
"""
self._system_id = value
@property @property
def name(self): def name(self):
""" """
@ -41,14 +33,6 @@ class EmissionSystem:
""" """
return self._name return self._name
@name.setter
def name(self, value):
"""
Set name
:param value: string
"""
self._name = value
@property @property
def type(self): def type(self):
""" """
@ -60,7 +44,17 @@ class EmissionSystem:
@property @property
def parasitic_energy_consumption(self): def parasitic_energy_consumption(self):
""" """
Get parasitic_energy_consumption in ratio (Wh/Wh) Get parasitic_energy_consumption in ratio (J/J)
:return: float :return: float
""" """
return self._parasitic_energy_consumption return self._parasitic_energy_consumption
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Layer': {'id': self.id,
'name': self.name,
'type': self.type,
'parasitic energy consumption per energy produced [J/J]': self.parasitic_energy_consumption
}
}
return content

View File

@ -37,14 +37,6 @@ class GenerationSystem:
""" """
return self._system_id return self._system_id
@id.setter
def id(self, value):
"""
Set system id
:param value: float
"""
self._system_id = value
@property @property
def name(self): def name(self):
""" """
@ -53,14 +45,6 @@ class GenerationSystem:
""" """
return self._name return self._name
@name.setter
def name(self, value):
"""
Set name
:param value: string
"""
self._name = value
@property @property
def type(self): def type(self):
""" """
@ -140,3 +124,24 @@ class GenerationSystem:
:return: GenerationSystem :return: GenerationSystem
""" """
return self._auxiliary_equipment return self._auxiliary_equipment
def to_dictionary(self):
"""Class content to dictionary"""
_auxiliary_equipment = []
if self.auxiliary_equipment is not None:
_auxiliary_equipment = self.auxiliary_equipment.to_dictionary()
content = {'Layer': {'id': self.id,
'name': self.name,
'type': self.type,
'fuel type': self.fuel_type,
'source types': self.source_types,
'source temperature [Celsius]': self.source_temperature,
'source mass flow [kg/s]': self.source_mass_flow,
'heat efficiency': self.heat_efficiency,
'cooling efficiency': self.cooling_efficiency,
'electricity efficiency': self.electricity_efficiency,
'it has storage': self.storage,
'auxiliary equipment': _auxiliary_equipment
}
}
return content

View File

@ -88,3 +88,22 @@ class System:
:return: EmissionSystem :return: EmissionSystem
""" """
return self._emission_system return self._emission_system
def to_dictionary(self):
"""Class content to dictionary"""
_distribution_system = None
if self.distribution_system is not None:
_distribution_system = self.distribution_system.to_dictionary()
_emission_system = None
if self.emission_system is not None:
_emission_system = self.emission_system.to_dictionary()
content = {'Layer': {'id': self.id,
'name': self.name,
'level of detail': self.lod,
'demand types': self.demand_types,
'generation system': self.generation_system.to_dictionary(),
'distribution system': _distribution_system,
'emission system': _emission_system
}
}
return content

View File

@ -61,3 +61,16 @@ class Appliances:
:return: None or [Schedule] :return: None or [Schedule]
""" """
return self._schedules return self._schedules
def to_dictionary(self):
"""Class content to dictionary"""
_schedules = []
for _schedule in self.schedules:
_schedules.append(_schedule.to_dictionary())
content = {'Appliances': {'density [W/m2]': self.density,
'convective fraction': self.convective_fraction,
'radiative fraction': self.radiative_fraction,
'latent fraction': self.latent_fraction,
'schedules': _schedules}
}
return content

View File

@ -20,3 +20,21 @@ class Content:
Get catalog usages Get catalog usages
""" """
return self._usages return self._usages
def to_dictionary(self):
"""Class content to dictionary"""
_usages = []
for _usage in self.usages:
_usages.append(_usage.to_dictionary())
content = {'Usages': _usages}
return content
def __str__(self):
"""Print content"""
_usages = []
for _usage in self.usages:
_usages.append(_usage.to_dictionary())
content = {'Usages': _usages}
return str(content)

View File

@ -52,3 +52,15 @@ class DomesticHotWater:
:return: None or [Schedule] :return: None or [Schedule]
""" """
return self._schedules return self._schedules
def to_dictionary(self):
"""Class content to dictionary"""
_schedules = []
for _schedule in self.schedules:
_schedules.append(_schedule.to_dictionary())
content = {'Domestic hot water': {'density [W/m2]': self.density,
'peak flow [m3/sm2]': self.peak_flow,
'service temperature [Celsius]': self.service_temperature,
'schedules': _schedules}
}
return content

View File

@ -1,20 +0,0 @@
"""
Usage catalog internal gain
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
class InternalGain:
"""
InternalGain class
"""
def __init__(self, internal_gain_type, average_internal_gain, convective_fraction, radiative_fraction, latent_fraction, schedules):
self._type = internal_gain_type
self._average_internal_gain = average_internal_gain
self._convective_fraction = convective_fraction
self._radiative_fraction = radiative_fraction
self._latent_fraction = latent_fraction
self._schedules = schedules

View File

@ -61,3 +61,16 @@ class Lighting:
:return: None or [Schedule] :return: None or [Schedule]
""" """
return self._schedules return self._schedules
def to_dictionary(self):
"""Class content to dictionary"""
_schedules = []
for _schedule in self.schedules:
_schedules.append(_schedule.to_dictionary())
content = {'Lighting': {'density [W/m2]': self.density,
'convective fraction': self.convective_fraction,
'radiative fraction': self.radiative_fraction,
'latent fraction': self.latent_fraction,
'schedules': _schedules}
}
return content

View File

@ -65,3 +65,16 @@ class Occupancy:
:return: None or [Schedule] :return: None or [Schedule]
""" """
return self._schedules return self._schedules
def to_dictionary(self):
"""Class content to dictionary"""
_schedules = []
for _schedule in self.schedules:
_schedules.append(_schedule.to_dictionary())
content = {'Occupancy': {'occupancy density [persons/m2]': self.occupancy_density,
'sensible convective internal gain [W/m2]': self.sensible_convective_internal_gain,
'sensible radiative internal gain [W/m2]': self.sensible_radiative_internal_gain,
'latent internal gain [W/m2]': self.latent_internal_gain,
'schedules': _schedules}
}
return content

View File

@ -73,3 +73,14 @@ class Schedule:
:return: None or [str] :return: None or [str]
""" """
return self._day_types return self._day_types
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Schedule': {'type': self.type,
'time range': self.time_range,
'time step': self.time_step,
'data type': self.data_type,
'day types': self.day_types,
'values': self.values}
}
return content

View File

@ -76,3 +76,23 @@ class ThermalControl:
:return: None or [Schedule] :return: None or [Schedule]
""" """
return self._cooling_set_point_schedules return self._cooling_set_point_schedules
def to_dictionary(self):
"""Class content to dictionary"""
_hvac_schedules = []
for _schedule in self.hvac_availability_schedules:
_hvac_schedules.append(_schedule.to_dictionary())
_heating_set_point_schedules = []
for _schedule in self.heating_set_point_schedules:
_heating_set_point_schedules.append(_schedule.to_dictionary())
_cooling_set_point_schedules = []
for _schedule in self.cooling_set_point_schedules:
_cooling_set_point_schedules.append(_schedule.to_dictionary())
content = {'Thermal control': {'mean heating set point [Celsius]': self.mean_heating_set_point,
'heating set back [Celsius]': self.heating_set_back,
'mean cooling set point [Celsius]': self.mean_cooling_set_point,
'hvac availability schedules': _hvac_schedules,
'heating set point schedules': _heating_set_point_schedules,
'cooling set point schedules': _cooling_set_point_schedules}
}
return content

View File

@ -125,3 +125,19 @@ class Usage:
:return: None or DomesticHotWater :return: None or DomesticHotWater
""" """
return self._domestic_hot_water return self._domestic_hot_water
def to_dictionary(self):
"""Class content to dictionary"""
content = {'Usage': {'name': self.name,
'hours a day': self.hours_day,
'days a year': self.days_year,
'mechanical air change [ACH]': self.mechanical_air_change,
'ventilation rate [m3/sm2]': self.ventilation_rate,
'occupancy': self.occupancy.to_dictionary(),
'lighting': self.lighting.to_dictionary(),
'appliances': self.appliances.to_dictionary(),
'thermal control': self.thermal_control.to_dictionary(),
'domestic hot water': self.domestic_hot_water.to_dictionary()
}
}
return content