api_v1.4/utils/hp_simulator.py
2023-01-17 18:59:59 -05:00

44 lines
1.6 KiB
Python

"""
HeatPumpSimulator: Module for running simulations
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Project Author Peter Yefi peteryefi@gmail.com
"""
from pathlib import Path
from typing import Dict
from exports.energy_systems_factory import EnergySystemsExportFactory
from imports.energy_systems_factory import EnergySystemsFactory
class HeatPumpSimulator:
def __init__(self, city, user_input: Dict):
"""
:param user_input: the user parameters for running simulation
"""
self._user_input = user_input
self._hp_type = user_input['HeatPumpType'].replace(" ", "_").lower()
# file to have results after simulation is run
self._city = city
EnergySystemsFactory(user_input['HeatPumpType'].lower(), self._city).enrich()
def run_hp_simulation(self) -> str:
"""
Runs heat pump simulation and dumps output
in self._output_path
:return: None
"""
hp_type = 'water' if 'water' in self._hp_type else 'air'
del self._user_input['HeatPumpType']
del self._user_input['EnergyDemand']
model = self._user_input.pop('HeatPumpModel')
energy_demand_path = Path(Path(__file__).parent.parent / "data/energy_demand.txt")
return EnergySystemsExportFactory(city=self._city,
user_input=self._user_input,
hp_model=model,
output_path=None,
sim_type=self._user_input['SimType'],
demand_path=energy_demand_path).export(hp_type)