Skip to content

Commit c048d86

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 db6702a commit c048d86

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
@@ -1821,7 +1821,10 @@ def run_doe():
18211821
18221822
"""
18231823

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

18271830
def __init__(
@@ -1890,18 +1893,18 @@ def prepare(self) -> int:
18901893
"""
18911894

18921895
param_structure = {}
1893-
param_simple = {}
1896+
param_non_structure = {}
18941897
for param_name in self._parameters.keys():
18951898
changeable = self._mod.isParameterChangeable(name=param_name)
18961899
logger.info(f"Parameter {repr(param_name)} is changeable? {changeable}")
18971900

18981901
if changeable:
1899-
param_simple[param_name] = self._parameters[param_name]
1902+
param_non_structure[param_name] = self._parameters[param_name]
19001903
else:
19011904
param_structure[param_name] = self._parameters[param_name]
19021905

19031906
param_structure_combinations = list(itertools.product(*param_structure.values()))
1904-
param_simple_combinations = list(itertools.product(*param_simple.values()))
1907+
param_simple_combinations = list(itertools.product(*param_non_structure.values()))
19051908

19061909
self._sim_dict = {}
19071910
for idx_pc_structure, pc_structure in enumerate(param_structure_combinations):
@@ -1937,7 +1940,7 @@ def prepare(self) -> int:
19371940

19381941
for idx_pc_simple, pc_simple in enumerate(param_simple_combinations):
19391942
sim_param_simple = {}
1940-
for idx_simple, pk_simple in enumerate(param_simple.keys()):
1943+
for idx_simple, pk_simple in enumerate(param_non_structure.keys()):
19411944
sim_param_simple[pk_simple] = cast(Any, pc_simple[idx_simple])
19421945

19431946
resfilename = f"DOE_{idx_pc_structure:09d}_{idx_pc_simple:09d}.mat"
@@ -1948,11 +1951,11 @@ def prepare(self) -> int:
19481951

19491952
df_data = (
19501953
{
1951-
'ID structure': idx_pc_structure,
1954+
self.DICT_ID_STRUCTURE: idx_pc_structure,
19521955
}
19531956
| sim_param_structure
19541957
| {
1955-
'ID non-structure': idx_pc_simple,
1958+
self.DICT_ID_NON_STRUCTURE: idx_pc_simple,
19561959
}
19571960
| sim_param_simple
19581961
| {

0 commit comments

Comments
 (0)