Added option for running series or parallel simulation

This commit is contained in:
Peter Yefi 2022-02-26 11:47:23 -05:00
parent 5269caba9d
commit 883461782c
3 changed files with 34 additions and 13 deletions

View File

@ -14,8 +14,16 @@ class AirSourceHPExport(HeatPumpExport):
after executing insel after executing insel
""" """
def __init__(self, base_path, city, output_path): def __init__(self, base_path, city, output_path, sim_type):
template_path = (base_path / 'heat_pumps/air_source_tmpl.txt') """
:param base_path: path to energy system files
:param city: the city object
:param output_path: the file to hold insel simulation results
:param sim_type: the simulation type to run: 1 for series, 0 for parallel
"""
tmp_file = 'heat_pumps/as_series.txt' if sim_type == 1 else 'heat_pumps/as_parallel.txt'
template_path = (base_path / tmp_file)
super().__init__(base_path, city, output_path, template_path) super().__init__(base_path, city, output_path, template_path)
def _extract_model_coff(self, hp_model: str, data_type='heat') -> Union[Tuple[List, List], None]: def _extract_model_coff(self, hp_model: str, data_type='heat') -> Union[Tuple[List, List], None]:

View File

@ -7,14 +7,22 @@ Copyright © 2021 Project Author Peter Yefi peteryefi@gmail.com
from exports.energy_systems.heat_pump_export import HeatPumpExport from exports.energy_systems.heat_pump_export import HeatPumpExport
from typing import List, Tuple, Union from typing import List, Tuple, Union
class WaterToWaterHPExport(HeatPumpExport): class WaterToWaterHPExport(HeatPumpExport):
""" """
Exports heat pump values as multiple output files Exports heat pump values as multiple output files
after executing insel after executing insel
""" """
def __init__(self, base_path, city, output_path): def __init__(self, base_path, city, output_path, sim_type):
template_path = (base_path / 'heat_pumps/water_to_water_tmpl.txt') """
:param base_path: path to energy system files
:param city: the city object
:param output_path: the file to hold insel simulation results
:param sim_type: the simulation type to run: 1 for series, 0 for parallel
"""
tmp_file = 'heat_pumps/w2w_series.txt' if sim_type == 1 else 'heat_pumps/w2w_parallel.txt'
template_path = (base_path / tmp_file)
water_temp = (base_path / 'heat_pumps/wt_hourly3.txt') water_temp = (base_path / 'heat_pumps/wt_hourly3.txt')
super().__init__(base_path, city, output_path, template_path, water_temp) super().__init__(base_path, city, output_path, template_path, water_temp)
@ -48,9 +56,3 @@ class WaterToWaterHPExport(HeatPumpExport):
""" """
pow_demand_coeff, heat_output_coeff = self._extract_model_coff(hp_model, data_type) pow_demand_coeff, heat_output_coeff = self._extract_model_coff(hp_model, data_type)
super(WaterToWaterHPExport, self)._run_insel(user_input, pow_demand_coeff, heat_output_coeff, 'w2w.insel') super(WaterToWaterHPExport, self)._run_insel(user_input, pow_demand_coeff, heat_output_coeff, 'w2w.insel')

View File

@ -15,7 +15,17 @@ class EnergySystemsExportFactory:
Exports factory class for energy systems Exports factory class for energy systems
""" """
def __init__(self, city, user_input, hp_model, output_path, data_type='heat', base_path=None): def __init__(self, city, user_input, hp_model, output_path, sim_type=1, data_type='heat', base_path=None):
"""
: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
:param sim_type: the simulation type, 1 for series 0 for parallel
:param data_type: indicates whether cooling or heating data is used
:param base_path: the data directory of energy systems
"""
self._city = city self._city = city
if base_path is None: if base_path is None:
base_path = base_path = Path(Path(__file__).parent.parent / 'data/energy_systems') base_path = base_path = Path(Path(__file__).parent.parent / 'data/energy_systems')
@ -24,6 +34,7 @@ class EnergySystemsExportFactory:
self._hp_model = hp_model self._hp_model = hp_model
self._data_type = data_type self._data_type = data_type
self._output_path = output_path self._output_path = output_path
self._sim_type = sim_type
def _export_heat_pump(self, source): def _export_heat_pump(self, source):
""" """
@ -32,10 +43,10 @@ class EnergySystemsExportFactory:
:return: None :return: None
""" """
if source == 'air': if source == 'air':
AirSourceHPExport(self._base_path, self._city, self._output_path)\ AirSourceHPExport(self._base_path, self._city, self._output_path, self._sim_type)\
.execute_insel(self._user_input, self._hp_model, self._data_type) .execute_insel(self._user_input, self._hp_model, self._data_type)
elif source == 'water': elif source == 'water':
WaterToWaterHPExport(self._base_path, self._city, self._output_path)\ WaterToWaterHPExport(self._base_path, self._city, self._output_path, self._sim_type)\
.execute_insel(self._user_input, self._hp_model, self._data_type) .execute_insel(self._user_input, self._hp_model, self._data_type)
def export(self, source='air'): def export(self, source='air'):