-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create helper module to read parameter files.
- Loading branch information
1 parent
25be330
commit 6af8a7b
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import json | ||
import os | ||
|
||
__model_names = { | ||
'HeatPumpSimple': 'simple', | ||
'HeatPumpSimpleTrans': 'simple_trans', | ||
'HeatPumpIHX': 'ihx', | ||
'HeatPumpIHXTrans': 'ihx_trans', | ||
'HeatPumpIC': 'ic', | ||
'HeatPumpICTrans': 'ic_trans', | ||
'HeatPumpEcon_closed': 'econ_closed', | ||
'HeatPumpEconTrans_closed': 'econ_closed_trans', | ||
'HeatPumpEconIHX_closed': 'econ_closed_ihx', | ||
'HeatPumpEconIHXTrans_closed': 'econ_closed_ihx_trans', | ||
'HeatPumpIHXEcon_closed': 'ihx_econ_closed', | ||
'HeatPumpIHXEconTrans_closed': 'ihx_econ_closed_trans', | ||
'HeatPumpEcon_open': 'econ_open', | ||
'HeatPumpEconTrans_open': 'econ_open_trans', | ||
'HeatPumpEconIHX_open': 'econ_open_ihx', | ||
'HeatPumpEconIHXTrans_open': 'econ_open_ihx_trans', | ||
'HeatPumpIHXEcon_open': 'ihx_econ_open', | ||
'HeatPumpIHXEconTrans_open': 'ihx_econ_open_trans', | ||
'HeatPumpPC_closed': 'pc_econ_closed', | ||
'HeatPumpPCTrans_closed': 'pc_econ_closed_trans', | ||
'HeatPumpIHXPC_closed': 'ihx_pc_econ_closed', | ||
'HeatPumpIHXPCTrans_closed': 'ihx_pc_econ_closed_trans', | ||
'HeatPumpPCIHX_closed': 'pc_econ_closed_ihx', | ||
'HeatPumpPCIHXTrans_closed': 'pc_econ_closed_ihx_trans', | ||
'HeatPumpIHXPCIHX_closed': 'ihx_pc_econ_closed_ihx', | ||
'HeatPumpIHXPCIHXTrans_closed': 'ihx_pc_econ_closed_ihx_trans', | ||
'HeatPumpPC_open': 'pc_econ_open', | ||
'HeatPumpPCTrans_open': 'pc_econ_open_trans', | ||
'HeatPumpIHXPC_open': 'ihx_pc_econ_open', | ||
'HeatPumpIHXPCTrans_open': 'ihx_pc_econ_open_trans', | ||
'HeatPumpPCIHX_open': 'pc_econ_open_ihx', | ||
'HeatPumpPCIHXTrans_open': 'pc_econ_open_ihx_trans', | ||
'HeatPumpIHXPCIHX_open': 'ihx_pc_econ_open_ihx', | ||
'HeatPumpIHXPCIHXTrans_open': 'ihx_pc_econ_open_ihx_trans', | ||
'HeatPumpFlash': 'flash', | ||
'HeatPumpFlashTrans': 'flash_trans', | ||
'HeatPumpCascade': 'cascade', | ||
'HeatPumpCascadeTrans': 'cascade_trans', | ||
'HeatPumpCascade2IHX': 'cascade_2ihx', | ||
'HeatPumpCascade2IHXTrans': 'cascade_2ihx_trans' | ||
} | ||
|
||
def get_params(heat_pump_model, econ_type=None): | ||
"""Get params dict for heat pump model class. | ||
Parameters | ||
---------- | ||
heat_pump_model : str | ||
Name of heat pump model class (e.g. 'HeatPumpEconIHX') | ||
econ_type : str or None | ||
If heat pump model class has an economizer, the econ_type has to be | ||
set. Either 'closed' or 'open'. Default is `None`. | ||
""" | ||
if econ_type is not None and econ_type.lower() not in ['closed', 'open']: | ||
raise ValueError( | ||
f"Parameter '{econ_type}' is not a valid econ_type. " | ||
+ "Supported values are 'open' and 'closed'." | ||
) | ||
|
||
if econ_type is not None: | ||
hpfilename = __model_names[f'{heat_pump_model}_{econ_type.lower()}'] | ||
else: | ||
hpfilename = __model_names[heat_pump_model] | ||
parampath = os.path.abspath( | ||
os.path.join( | ||
os.path.dirname(__file__), 'models', 'input', | ||
f'params_hp_{hpfilename}.json' | ||
) | ||
) | ||
with open(parampath, 'r', encoding='utf-8') as file: | ||
params = json.load(file) | ||
|
||
return params |