first attempt to energy system catalog. Not working

This commit is contained in:
Pilar Monsalvete 2023-04-27 15:40:59 -04:00
parent 2650dccf57
commit 7a29847132
10 changed files with 405 additions and 207 deletions

View File

@ -0,0 +1,75 @@
"""
Energy System catalog archetype
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from hub.catalog_factories.data_models.energy_systems.generation_system import GenerationSystem
from hub.catalog_factories.data_models.energy_systems.distribution_system import DistributionSystem
from hub.catalog_factories.data_models.energy_systems.emission_system import EmissionSystem
class Archetype:
def __init__(self,
lod,
name,
demand_types,
generation_system,
distribution_system,
emission_system):
self._lod = lod
self._name = name
self._demand_types = demand_types
self._generation_system = generation_system
self._distribution_system = distribution_system
self._emission_system = emission_system
@property
def lod(self):
"""
Get level of detail of the catalog
:return: string
"""
return self._lod
@property
def name(self):
"""
Get name
:return: string
"""
return f'{self._name}_{self._lod}'
@property
def demand_types(self):
"""
Get demand able to cover from [heating, cooling, domestic_hot_water, electricity]
:return: [string]
"""
return self._demand_types
@property
def generation_system(self) -> GenerationSystem:
"""
Get generation system
:return: GenerationSystem
"""
return self._generation_system
@property
def distribution_system(self) -> DistributionSystem:
"""
Get distribution system
:return: DistributionSystem
"""
return self._distribution_system
@property
def emission_system(self) -> EmissionSystem:
"""
Get emission system
:return: EmissionSystem
"""
return self._emission_system

View File

@ -0,0 +1,18 @@
"""
Energy System catalog content
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
class Content:
def __init__(self, archetypes):
self._archetypes = archetypes
@property
def archetypes(self):
"""
All archetypes in the catalog
"""
return self._archetypes

View File

@ -0,0 +1,66 @@
"""
Energy System catalog distribution system
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
class DistributionSystem:
def __init__(self, system_type, distribution_power, supply_temperature, mass_flow, distribution_consumption,
heat_losses):
self._type = system_type
self._distribution_power = distribution_power
self._supply_temperature = supply_temperature
self._mass_flow = mass_flow
self._distribution_consumption = distribution_consumption
self._heat_losses = heat_losses
@property
def type(self):
"""
Get type from [air, water, refrigerant]
:return: string
"""
return self._type
@property
def distribution_power(self):
"""
Get distribution_power (pump or fan) in W
:return: float
"""
return self._distribution_power
@property
def supply_temperature(self):
"""
Get supply_temperature in degree Celsius
:return: float
"""
return self._supply_temperature
@property
def mass_flow(self):
"""
Get mass_flow in kg/s
:return: float
"""
return self._mass_flow
@property
def distribution_consumption(self):
"""
Get distribution_consumption in % over energy produced
:return: float
"""
return self._distribution_consumption
@property
def heat_losses(self):
"""
Get heat_losses in % over energy produced
:return: float
"""
return self._heat_losses

View File

@ -0,0 +1,41 @@
"""
Energy System catalog emission system
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from hub.catalog_factories.data_models.usages.schedule import Schedule
class EmissionSystem:
def __init__(self, system_type, parasitic_energy_consumption, hvac_availability):
self._type = system_type
self._parasitic_energy_consumption = parasitic_energy_consumption
self._hvac_availability = hvac_availability
@property
def type(self):
"""
Get type
:return: string
"""
return self._type
@property
def parasitic_energy_consumption(self):
"""
Get parasitic_energy_consumption in W
:return: float
"""
return self._parasitic_energy_consumption
# todo: should be here??? Related to control and associated to usage!!!
@property
def hvac_availability(self) -> [Schedule]:
"""
Get hvac_availability in degree Celsius
:return: [Schedule]
"""
return self._hvac_availability

View File

@ -0,0 +1,130 @@
"""
Energy System catalog generation system
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
class GenerationSystem:
def __init__(self, system_type, fuel_type, source_type, heat_power, cooling_power,
electricity_power, heat_efficiency, cooling_efficiency, electricity_efficiency,
source_temperature, source_mass_flow, storage_capacity, auxiliary_equipment):
self._type = system_type
self._fuel_type = fuel_type
self._source_type = source_type
self._heat_power = heat_power
self._cooling_power = cooling_power
self._electricity_power = electricity_power
self._heat_efficiency = heat_efficiency
self._cooling_efficiency = cooling_efficiency
self._electricity_efficiency = electricity_efficiency
self._source_temperature = source_temperature
self._source_mass_flow = source_mass_flow
self._storage_capacity = storage_capacity
self._auxiliary_equipment = auxiliary_equipment
@property
def type(self):
"""
Get type
:return: string
"""
return self._type
@property
def fuel_type(self):
"""
Get fuel_type from [renewable, gas, diesel, electricity, wood, coal]
:return: string
"""
return self._fuel_type
@property
def source_type(self):
"""
Get source_type from [air, water, geothermal, district_heating, grid, on_site_electricity]
:return: string
"""
return self._source_type
@property
def heat_power(self):
"""
Get heat_power in W
:return: float
"""
return self._heat_power
@property
def cooling_power(self):
"""
Get cooling_power in W
:return: float
"""
return self._cooling_power
@property
def electricity_power(self):
"""
Get electricity_power in W
:return: float
"""
return self._electricity_power
@property
def heat_efficiency(self):
"""
Get heat_efficiency
:return: float
"""
return self._heat_efficiency
@property
def cooling_efficiency(self):
"""
Get cooling_efficiency
:return: float
"""
return self._cooling_efficiency
@property
def electricity_efficiency(self):
"""
Get electricity_efficiency
:return: float
"""
return self._electricity_efficiency
@property
def source_temperature(self):
"""
Get source_temperature in degree Celsius
:return: float
"""
return self._source_temperature
@property
def source_mass_flow(self):
"""
Get source_mass_flow in kg/s
:return: float
"""
return self._source_mass_flow
@property
def storage_capacity(self):
"""
Get storage_capacity in J
:return: float
"""
return self._storage_capacity
@property
def auxiliary_equipment(self) -> GenerationSystem:
"""
Get auxiliary_equipment
:return: GenerationSystem
"""
return self._auxiliary_equipment

View File

@ -0,0 +1,64 @@
"""
Montreal custom energy systems catalog
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import xmltodict
from hub.catalog_factories.catalog import Catalog
from hub.catalog_factories.data_models.energy_systems.archetype import Archetype
from hub.catalog_factories.data_models.energy_systems.content import Content
class MontrealCustomCatalog(Catalog):
def __init__(self, path):
path = str(path / 'montreal_custom_systems.xml')
with open(path) as xml:
self._archetypes = xmltodict.parse(xml.read(), force_list='archetype')
# store the full catalog data model in self._content
self._content = Content(self._load_archetypes())
def _load_archetypes(self):
_catalog_archetypes = []
archetypes = self._archetypes['archetypes']['archetype']
for archetype in archetypes:
name = archetype['@name']
lod = float(archetype['@lod'])
demand_types = archetype['@demands']
_catalog_archetypes.append(Archetype(lod,
name,
demand_types,
generation_system,
distribution_system,
emission_system))
return _catalog_archetypes
def names(self, category=None):
"""
Get the catalog elements names
:parm: for energy systems catalog category filter does nothing as there is only one category (archetypes)
"""
_names = {'archetypes': []}
for archetype in self._content.archetypes:
_names['archetypes'].append(archetype.name)
return _names
def entries(self, category=None):
"""
Get the catalog elements
:parm: for energy systems catalog category filter does nothing as there is only one category (archetypes)
"""
return self._content
def get_entry(self, name):
"""
Get one catalog element by names
:parm: entry name
"""
for entry in self._content.archetypes:
if entry.name.lower() == name.lower():
return entry
raise IndexError(f"{name} doesn't exists in the catalog")

View File

@ -1,189 +0,0 @@
"""
NRCAN energy systems catalog
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import json
import urllib.request
import xmltodict
import hub.helpers.constants as cte
from hub.catalog_factories.catalog import Catalog
from hub.catalog_factories.data_models.usages.appliances import Appliances
from hub.catalog_factories.data_models.usages.content import Content
from hub.catalog_factories.data_models.usages.lighting import Lighting
from hub.catalog_factories.data_models.usages.ocupancy import Occupancy
from hub.catalog_factories.data_models.usages.schedule import Schedule
from hub.catalog_factories.data_models.usages.thermal_control import ThermalControl
from hub.catalog_factories.data_models.usages.usage import Usage
from hub.catalog_factories.usage.usage_helper import UsageHelper
class NrcanCatalog(Catalog):
def __init__(self, path):
path = str(path / 'nrcan.xml')
self._content = None
self._schedules = {}
with open(path) as xml:
self._metadata = xmltodict.parse(xml.read())
self._base_url = self._metadata['nrcan']['@base_url']
self._load_schedules()
self._content = Content(self._load_archetypes())
def _load_archetypes(self):
usages = []
name = self._metadata['nrcan']
url = f'{self._base_url}{name["space_types_location"]}'
with urllib.request.urlopen(url) as json_file:
space_types = json.load(json_file)['tables']['space_types']['table']
# space_types = [st for st in space_types if st['building_type'] == 'Space Function']
space_types = [st for st in space_types if st['space_type'] == 'WholeBuilding']
for space_type in space_types:
# usage_type = space_type['space_type']
usage_type = space_type['building_type']
occupancy_schedule_name = space_type['occupancy_schedule']
lighting_schedule_name = space_type['lighting_schedule']
appliance_schedule_name = space_type['electric_equipment_schedule']
hvac_schedule_name = space_type['exhaust_schedule']
if 'FAN' in hvac_schedule_name:
hvac_schedule_name = hvac_schedule_name.replace('FAN', 'Fan')
heating_setpoint_schedule_name = space_type['heating_setpoint_schedule']
cooling_setpoint_schedule_name = space_type['cooling_setpoint_schedule']
occupancy_schedule = self._get_schedules(occupancy_schedule_name)
lighting_schedule = self._get_schedules(lighting_schedule_name)
appliance_schedule = self._get_schedules(appliance_schedule_name)
heating_schedule = self._get_schedules(heating_setpoint_schedule_name)
cooling_schedule = self._get_schedules(cooling_setpoint_schedule_name)
hvac_availability = self._get_schedules(hvac_schedule_name)
occupancy_density = space_type['occupancy_per_area']
# ACH
mechanical_air_change = space_type['ventilation_air_changes']
# cfm/ft2 to m3/m2.s
ventilation_rate = space_type['ventilation_per_area'] / (cte.METERS_TO_FEET * cte.MINUTES_TO_SECONDS)
if ventilation_rate == 0:
# cfm/person to m3/m2.s
ventilation_rate = space_type['ventilation_per_person'] / occupancy_density\
/ (cte.METERS_TO_FEET * cte.MINUTES_TO_SECONDS)
# W/sqft to W/m2
lighting_density = space_type['lighting_per_area'] * cte.METERS_TO_FEET * cte.METERS_TO_FEET
lighting_radiative_fraction = space_type['lighting_fraction_radiant']
lighting_convective_fraction = 0
if lighting_radiative_fraction is not None:
lighting_convective_fraction = 1 - lighting_radiative_fraction
lighting_latent_fraction = 0
# W/sqft to W/m2
appliances_density = space_type['electric_equipment_per_area'] * cte.METERS_TO_FEET * cte.METERS_TO_FEET
appliances_radiative_fraction = space_type['electric_equipment_fraction_radiant']
appliances_latent_fraction = space_type['electric_equipment_fraction_latent']
appliances_convective_fraction = 0
if appliances_radiative_fraction is not None and appliances_latent_fraction is not None:
appliances_convective_fraction = 1 - appliances_radiative_fraction - appliances_latent_fraction
occupancy = Occupancy(occupancy_density,
None,
None,
None,
occupancy_schedule)
lighting = Lighting(lighting_density,
lighting_convective_fraction,
lighting_radiative_fraction,
lighting_latent_fraction,
lighting_schedule)
appliances = Appliances(appliances_density,
appliances_convective_fraction,
appliances_radiative_fraction,
appliances_latent_fraction,
appliance_schedule)
thermal_control = ThermalControl(None,
None,
None,
hvac_availability,
heating_schedule,
cooling_schedule)
hours_day = None
days_year = None
usages.append(Usage(usage_type,
hours_day,
days_year,
mechanical_air_change,
ventilation_rate,
occupancy,
lighting,
appliances,
thermal_control))
return usages
def names(self, category=None):
"""
Get the catalog elements names
:parm: optional category filter
"""
if category is None:
_names = {'archetypes': [], 'constructions': [], 'materials': [], 'windows': []}
for archetype in self._content.archetypes:
_names['archetypes'].append(archetype.name)
for construction in self._content.constructions:
_names['constructions'].append(construction.name)
for material in self._content.materials:
_names['materials'].append(material.name)
for window in self._content.windows:
_names['windows'].append(window.name)
else:
_names = {category: []}
if category.lower() == 'archetypes':
for archetype in self._content.archetypes:
_names[category].append(archetype.name)
elif category.lower() == 'constructions':
for construction in self._content.constructions:
_names[category].append(construction.name)
elif category.lower() == 'materials':
for material in self._content.materials:
_names[category].append(material.name)
elif category.lower() == 'windows':
for window in self._content.windows:
_names[category].append(window.name)
else:
raise ValueError(f'Unknown category [{category}]')
def entries(self, category=None):
"""
Get the catalog elements
:parm: optional category filter
"""
if category is None:
return self._content
else:
if category.lower() == 'archetypes':
return self._content.archetypes
elif category.lower() == 'constructions':
return self._content.constructions
elif category.lower() == 'materials':
return self._content.materials
elif category.lower() == 'windows':
return self._content.windows
else:
raise ValueError(f'Unknown category [{category}]')
def get_entry(self, name):
"""
Get one catalog element by names
:parm: entry name
"""
for entry in self._content.archetypes:
if entry.name.lower() == name.lower():
return entry
for entry in self._content.constructions:
if entry.name.lower() == name.lower():
return entry
for entry in self._content.materials:
if entry.name.lower() == name.lower():
return entry
for entry in self._content.windows:
if entry.name.lower() == name.lower():
return entry
raise IndexError(f"{name} doesn't exists in the catalog")

View File

@ -1,5 +1,5 @@
"""
Usage catalog factory, publish the usage information
Energy Systems catalog factory, publish the energy systems information
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
@ -7,18 +7,18 @@ Project Coder Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.c
from pathlib import Path
from typing import TypeVar
from hub.catalog_factories.energy_systems.nrcan_catalog import NrcanCatalog
from hub.catalog_factories.energy_systems.montreal_custom_catalog import MontrealCustomCatalog
from hub.hub_logger import logger
from hub.helpers.utils import validate_import_export_type
Catalog = TypeVar('Catalog')
class UsageCatalogFactory:
class EnergySystemsCatalogFactory:
def __init__(self, file_type, base_path=None):
if base_path is None:
base_path = Path(Path(__file__).parent.parent / 'data/energy_systems')
self._catalog_type = '_' + file_type.lower()
class_funcs = validate_import_export_type(UsageCatalogFactory)
class_funcs = validate_import_export_type(EnergySystemsCatalogFactory)
if self._catalog_type not in class_funcs:
err_msg = f"Wrong import type. Valid functions include {class_funcs}"
logger.error(err_msg)
@ -26,12 +26,11 @@ class UsageCatalogFactory:
self._path = base_path
@property
def _nrcan(self):
def _montreal_custom(self):
"""
Retrieve NRCAN catalog
"""
# nrcan retrieves the data directly from github
return NrcanCatalog(self._path)
return MontrealCustomCatalog(self._path)
@property
def catalog(self) -> Catalog:

View File

@ -0,0 +1,5 @@
<archetypes>
<archetype name="boiler" lod="1" demands="[heating, domestic_hot_water]">
</archetype>
</archetypes>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<nrcan base_url="https://raw.githubusercontent.com/NREL/openstudio-standards/master/lib/openstudio-standards/standards/necb/ECMS/data/">
<boilers_location>boiler_set.json</boilers_location>
<chillers_location>chiller_set.json</chillers_location>
<curves_location>curves.json</curves_location>
<furnaces_location>furnace_set.json </furnaces_location>
<heat_pumps_location>heat_pumps.json</heat_pumps_location>
<domestic_hot_water_systems_location>shw_set.json</domestic_hot_water_systems_location>
<pvs_location>pv.json</pvs_location>
<air_conditioners_location>unitary_acs.json</air_conditioners_location>
</nrcan>