Skip to content

Commit f5517cf

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 468a095 commit f5517cf

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

OMPython/ModelicaSystem.py

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

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

18641867
def __init__(
@@ -1927,18 +1930,18 @@ def prepare(self) -> int:
19271930
"""
19281931

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

19351938
if changeable:
1936-
param_simple[param_name] = self._parameters[param_name]
1939+
param_non_structure[param_name] = self._parameters[param_name]
19371940
else:
19381941
param_structure[param_name] = self._parameters[param_name]
19391942

19401943
param_structure_combinations = list(itertools.product(*param_structure.values()))
1941-
param_simple_combinations = list(itertools.product(*param_simple.values()))
1944+
param_simple_combinations = list(itertools.product(*param_non_structure.values()))
19421945

19431946
self._sim_dict = {}
19441947
for idx_pc_structure, pc_structure in enumerate(param_structure_combinations):
@@ -1974,7 +1977,7 @@ def prepare(self) -> int:
19741977

19751978
for idx_pc_simple, pc_simple in enumerate(param_simple_combinations):
19761979
sim_param_simple = {}
1977-
for idx_simple, pk_simple in enumerate(param_simple.keys()):
1980+
for idx_simple, pk_simple in enumerate(param_non_structure.keys()):
19781981
sim_param_simple[pk_simple] = cast(Any, pc_simple[idx_simple])
19791982

19801983
resfilename = f"DOE_{idx_pc_structure:09d}_{idx_pc_simple:09d}.mat"
@@ -1985,11 +1988,11 @@ def prepare(self) -> int:
19851988

19861989
df_data = (
19871990
{
1988-
'ID structure': idx_pc_structure,
1991+
self.DICT_ID_STRUCTURE: idx_pc_structure,
19891992
}
19901993
| sim_param_structure
19911994
| {
1992-
'ID non-structure': idx_pc_simple,
1995+
self.DICT_ID_NON_STRUCTURE: idx_pc_simple,
19931996
}
19941997
| sim_param_simple
19951998
| {

0 commit comments

Comments
 (0)