Made energy demand file a parameter for insel simulation

This commit is contained in:
Peter Yefi 2022-08-10 15:44:40 -04:00
parent e5e75bfe24
commit caa6e9e1d3
7 changed files with 12 additions and 7 deletions

View File

@ -15,17 +15,19 @@ class AirSourceHPExport(HeatPumpExport):
after executing insel
"""
def __init__(self, base_path, city, output_path, sim_type):
def __init__(self, base_path, city, output_path, sim_type, demand_path=None):
"""
: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: 0 for series, 1 for parallel
:param demand_path: path to hourly energy demand file
"""
tmp_file = 'heat_pumps/as_series.txt' if sim_type == 0 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, demand_path)
def _extract_model_coff(self, hp_model: str, data_type='heat') -> Union[List, None]:
"""

View File

@ -17,12 +17,12 @@ class HeatPumpExport:
of some defined function
"""
def __init__(self, base_path, city, output_path, template, water_temp=None):
def __init__(self, base_path, city, output_path, template, demand_path=None, water_temp=None):
self._template_path = template
self._water_temp = water_temp
self._constants_path = (base_path / 'heat_pumps/constants.yaml')
# needed to compute max demand.
self._demand_path = (base_path / 'heat_pumps/demand.txt')
self._demand_path = (base_path / 'heat_pumps/demand.txt') if demand_path is None else demand_path
self._city = city
self._input_data = None
self._base_path = base_path

View File

@ -15,17 +15,19 @@ class WaterToWaterHPExport(HeatPumpExport):
after executing insel
"""
def __init__(self, base_path, city, output_path, sim_type):
def __init__(self, base_path, city, output_path, sim_type, demand_path):
"""
: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
:param demand_path: path to hourly energy demand file
"""
tmp_file = 'heat_pumps/w2w_series.txt' if sim_type == 0 else 'heat_pumps/w2w_parallel.txt'
template_path = (base_path / tmp_file)
water_temp = (base_path / 'heat_pumps/wt_hourly3.txt')
super().__init__(base_path, city, output_path, template_path, water_temp)
super().__init__(base_path=base_path, city=city, output_path=output_path, template=template_path,
demand_path=demand_path, water_temp=water_temp)
def _extract_model_coff(self, hp_model: str) -> Union[List, None]:
"""

View File

@ -50,7 +50,8 @@ class TestEnergySystemsFactory(TestCase):
'HPSupTemp': 60
}
EnergySystemsExportFactory(self._city, user_input, '012', self._output_path).export()
EnergySystemsExportFactory(city=self._city, user_input=user_input, hp_model='012',
output_path=self._output_path).export()
df = pd.read_csv(self._output_path)
self.assertEqual(df.shape, (13, 3))
self.assertEqual(df.iloc[0, 1], 1867715.88)