2021-10-29 11:28:10 -04:00
|
|
|
"""
|
|
|
|
EnergySystemsFactory exports energy systems into several formats
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Peter Yefi peteryefi@gmail.com
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
from exports.energy_systems.heat_pump_export import HeatPumpExport
|
2022-01-26 10:42:01 -05:00
|
|
|
from exports.energy_systems.air_source_hp_export import AirSourceHPExport
|
|
|
|
from exports.energy_systems.water_to_water_hp_export import WaterToWaterHPExport
|
2021-10-29 11:28:10 -04:00
|
|
|
|
|
|
|
|
2021-11-10 05:14:31 -05:00
|
|
|
class EnergySystemsExportFactory:
|
2021-10-29 11:28:10 -04:00
|
|
|
"""
|
|
|
|
Exports factory class for energy systems
|
|
|
|
"""
|
|
|
|
|
2022-03-03 13:48:02 -05:00
|
|
|
def __init__(self, city, user_input, hp_model, output_path, sim_type=0, data_type='heat', base_path=None):
|
2022-02-26 11:47:23 -05:00
|
|
|
"""
|
|
|
|
|
|
|
|
:param city: the city object
|
|
|
|
:param user_input: user provided input from UI
|
|
|
|
:param hp_model: the heat pump model to run
|
|
|
|
:param output_path: the file to hold simulation results
|
2022-03-03 13:48:02 -05:00
|
|
|
:param sim_type: the simulation type, 0 for series 1 for parallel
|
2022-02-26 11:47:23 -05:00
|
|
|
:param data_type: indicates whether cooling or heating data is used
|
|
|
|
:param base_path: the data directory of energy systems
|
|
|
|
"""
|
2021-10-29 11:28:10 -04:00
|
|
|
self._city = city
|
|
|
|
if base_path is None:
|
2022-03-09 17:02:12 -05:00
|
|
|
base_path = Path(Path(__file__).parent.parent / 'data/energy_systems')
|
2021-10-29 11:28:10 -04:00
|
|
|
self._base_path = base_path
|
2021-11-10 05:14:31 -05:00
|
|
|
self._user_input = user_input
|
|
|
|
self._hp_model = hp_model
|
|
|
|
self._data_type = data_type
|
2021-11-12 05:16:22 -05:00
|
|
|
self._output_path = output_path
|
2022-02-26 11:47:23 -05:00
|
|
|
self._sim_type = sim_type
|
2021-10-29 11:28:10 -04:00
|
|
|
|
2022-01-26 10:42:01 -05:00
|
|
|
def _export_heat_pump(self, source):
|
2021-10-29 11:28:10 -04:00
|
|
|
"""
|
|
|
|
Exports heat pump performance data as coefficients
|
|
|
|
of some objective function
|
|
|
|
:return: None
|
|
|
|
"""
|
2022-01-26 10:42:01 -05:00
|
|
|
if source == 'air':
|
2022-02-26 11:47:23 -05:00
|
|
|
AirSourceHPExport(self._base_path, self._city, self._output_path, self._sim_type)\
|
2022-01-26 10:42:01 -05:00
|
|
|
.execute_insel(self._user_input, self._hp_model, self._data_type)
|
|
|
|
elif source == 'water':
|
2022-02-26 11:47:23 -05:00
|
|
|
WaterToWaterHPExport(self._base_path, self._city, self._output_path, self._sim_type)\
|
2022-03-17 10:37:47 -04:00
|
|
|
.execute_insel(self._user_input, self._hp_model)
|
2021-11-12 05:16:22 -05:00
|
|
|
|
2022-01-26 10:42:01 -05:00
|
|
|
def export(self, source='air'):
|
2021-11-12 05:16:22 -05:00
|
|
|
"""
|
|
|
|
Export the city given to the class using the given export type handler
|
|
|
|
:return: None
|
|
|
|
"""
|
2022-01-26 10:42:01 -05:00
|
|
|
return getattr(self, '_export_heat_pump', lambda: None)(source)
|