Skip to content

Commit 677e9e6

Browse files
committed
[ModelicaSystemDoE] cleanup & extend & document dict key constants
* remove DICT_RESULT_FILENAME * add comment * add DICT_ID_STRUCTURE and DICT_ID_NON_STRUCTURE * rename param_simple => param_non_structure
1 parent e7de3cc commit 677e9e6

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,10 @@ def run_doe():
18571857
18581858
"""
18591859

1860-
DICT_RESULT_FILENAME: str = 'result filename'
1860+
# Dictionary keys used in simulation dict (see _sim_dict or get_doe()). These dict keys contain a space and, thus,
1861+
# cannot be used as OM variable identifiers. They are defined here as reference for any evaluation of the data.
1862+
DICT_ID_STRUCTURE: str = 'ID structure'
1863+
DICT_ID_NON_STRUCTURE: str = 'ID non-structure'
18611864
DICT_RESULT_AVAILABLE: str = 'result available'
18621865

18631866
def __init__(
@@ -1926,18 +1929,18 @@ def prepare(self) -> int:
19261929
"""
19271930

19281931
param_structure = {}
1929-
param_simple = {}
1932+
param_non_structure = {}
19301933
for param_name in self._parameters.keys():
19311934
changeable = self._mod.isParameterChangeable(name=param_name)
19321935
logger.info(f"Parameter {repr(param_name)} is changeable? {changeable}")
19331936

19341937
if changeable:
1935-
param_simple[param_name] = self._parameters[param_name]
1938+
param_non_structure[param_name] = self._parameters[param_name]
19361939
else:
19371940
param_structure[param_name] = self._parameters[param_name]
19381941

19391942
param_structure_combinations = list(itertools.product(*param_structure.values()))
1940-
param_simple_combinations = list(itertools.product(*param_simple.values()))
1943+
param_simple_combinations = list(itertools.product(*param_non_structure.values()))
19411944

19421945
self._sim_dict = {}
19431946
for idx_pc_structure, pc_structure in enumerate(param_structure_combinations):
@@ -1973,7 +1976,7 @@ def prepare(self) -> int:
19731976

19741977
for idx_pc_simple, pc_simple in enumerate(param_simple_combinations):
19751978
sim_param_simple = {}
1976-
for idx_simple, pk_simple in enumerate(param_simple.keys()):
1979+
for idx_simple, pk_simple in enumerate(param_non_structure.keys()):
19771980
sim_param_simple[pk_simple] = cast(Any, pc_simple[idx_simple])
19781981

19791982
resfilename = f"DOE_{idx_pc_structure:09d}_{idx_pc_simple:09d}.mat"
@@ -1984,11 +1987,11 @@ def prepare(self) -> int:
19841987

19851988
df_data = (
19861989
{
1987-
'ID structure': idx_pc_structure,
1990+
self.DICT_ID_STRUCTURE: idx_pc_structure,
19881991
}
19891992
| sim_param_structure
19901993
| {
1991-
'ID non-structure': idx_pc_simple,
1994+
self.DICT_ID_NON_STRUCTURE: idx_pc_simple,
19921995
}
19931996
| sim_param_simple
19941997
| {

0 commit comments

Comments
 (0)