Skip to content

Commit 6ba03d1

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 7f15c99 commit 6ba03d1

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
@@ -1842,7 +1842,10 @@ def run_doe():
18421842
18431843
"""
18441844

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

18481851
def __init__(
@@ -1911,18 +1914,18 @@ def prepare(self) -> int:
19111914
"""
19121915

19131916
param_structure = {}
1914-
param_simple = {}
1917+
param_non_structure = {}
19151918
for param_name in self._parameters.keys():
19161919
changeable = self._mod.isParameterChangeable(name=param_name)
19171920
logger.info(f"Parameter {repr(param_name)} is changeable? {changeable}")
19181921

19191922
if changeable:
1920-
param_simple[param_name] = self._parameters[param_name]
1923+
param_non_structure[param_name] = self._parameters[param_name]
19211924
else:
19221925
param_structure[param_name] = self._parameters[param_name]
19231926

19241927
param_structure_combinations = list(itertools.product(*param_structure.values()))
1925-
param_simple_combinations = list(itertools.product(*param_simple.values()))
1928+
param_simple_combinations = list(itertools.product(*param_non_structure.values()))
19261929

19271930
self._sim_dict = {}
19281931
for idx_pc_structure, pc_structure in enumerate(param_structure_combinations):
@@ -1958,7 +1961,7 @@ def prepare(self) -> int:
19581961

19591962
for idx_pc_simple, pc_simple in enumerate(param_simple_combinations):
19601963
sim_param_simple = {}
1961-
for idx_simple, pk_simple in enumerate(param_simple.keys()):
1964+
for idx_simple, pk_simple in enumerate(param_non_structure.keys()):
19621965
sim_param_simple[pk_simple] = cast(Any, pc_simple[idx_simple])
19631966

19641967
resfilename = f"DOE_{idx_pc_structure:09d}_{idx_pc_simple:09d}.mat"
@@ -1969,11 +1972,11 @@ def prepare(self) -> int:
19691972

19701973
df_data = (
19711974
{
1972-
'ID structure': idx_pc_structure,
1975+
self.DICT_ID_STRUCTURE: idx_pc_structure,
19731976
}
19741977
| sim_param_structure
19751978
| {
1976-
'ID non-structure': idx_pc_simple,
1979+
self.DICT_ID_NON_STRUCTURE: idx_pc_simple,
19771980
}
19781981
| sim_param_simple
19791982
| {

0 commit comments

Comments
 (0)