4444import subprocess
4545import tempfile
4646import textwrap
47- from typing import Optional , Any
48- import warnings
47+ from typing import Any , Optional
4948import xml .etree .ElementTree as ET
5049
5150from OMPython .OMCSession import OMCSessionException , OMCSessionZMQ , OMCProcessLocal
@@ -307,44 +306,6 @@ def run(self) -> int:
307306
308307 return returncode
309308
310- @staticmethod
311- def parse_simflags (simflags : str ) -> dict [str , Optional [str | dict [str , Any ] | numbers .Number ]]:
312- """
313- Parse a simflag definition; this is deprecated!
314-
315- The return data can be used as input for self.args_set().
316- """
317- warnings .warn ("The argument 'simflags' is depreciated and will be removed in future versions; "
318- "please use 'simargs' instead" , DeprecationWarning , stacklevel = 2 )
319-
320- simargs : dict [str , Optional [str | dict [str , Any ] | numbers .Number ]] = {}
321-
322- args = [s for s in simflags .split (' ' ) if s ]
323- for arg in args :
324- if arg [0 ] != '-' :
325- raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
326- arg = arg [1 :]
327- parts = arg .split ('=' )
328- if len (parts ) == 1 :
329- simargs [parts [0 ]] = None
330- elif parts [0 ] == 'override' :
331- override = '=' .join (parts [1 :])
332-
333- override_dict = {}
334- for item in override .split (',' ):
335- kv = item .split ('=' )
336- if not 0 < len (kv ) < 3 :
337- raise ModelicaSystemError (f"Invalid value for '-override': { override } " )
338- if kv [0 ]:
339- try :
340- override_dict [kv [0 ]] = kv [1 ]
341- except (KeyError , IndexError ) as ex :
342- raise ModelicaSystemError (f"Invalid value for '-override': { override } " ) from ex
343-
344- simargs [parts [0 ]] = override_dict
345-
346- return simargs
347-
348309
349310class ModelicaSystem :
350311 def __init__ (
@@ -999,7 +960,6 @@ def getOptimizationOptions(self, names: Optional[str | list[str]] = None) -> dic
999960 def simulate_cmd (
1000961 self ,
1001962 result_file : pathlib .Path ,
1002- simflags : Optional [str ] = None ,
1003963 simargs : Optional [dict [str , Optional [str | dict [str , Any ] | numbers .Number ]]] = None ,
1004964 timeout : Optional [float ] = None ,
1005965 ) -> ModelicaSystemCmd :
@@ -1013,13 +973,6 @@ def simulate_cmd(
1013973 However, if only non-structural parameters are used, it is possible to reuse an existing instance of
1014974 ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
1015975
1016- Parameters
1017- ----------
1018- result_file
1019- simflags
1020- simargs
1021- timeout
1022-
1023976 Returns
1024977 -------
1025978 An instance if ModelicaSystemCmd to run the requested simulation.
@@ -1034,11 +987,7 @@ def simulate_cmd(
1034987 # always define the result file to use
1035988 om_cmd .arg_set (key = "r" , val = result_file .as_posix ())
1036989
1037- # allow runtime simulation flags from user input
1038- if simflags is not None :
1039- om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
1040-
1041- if simargs :
990+ if simargs is not None :
1042991 om_cmd .args_set (args = simargs )
1043992
1044993 if self ._override_variables or self ._simulate_options_override :
@@ -1077,7 +1026,6 @@ def simulate_cmd(
10771026 def simulate (
10781027 self ,
10791028 resultfile : Optional [str ] = None ,
1080- simflags : Optional [str ] = None ,
10811029 simargs : Optional [dict [str , Optional [str | dict [str , Any ] | numbers .Number ]]] = None ,
10821030 timeout : Optional [float ] = None ,
10831031 ) -> None :
@@ -1087,8 +1035,6 @@ def simulate(
10871035
10881036 Args:
10891037 resultfile: Path to a custom result file
1090- simflags: String of extra command line flags for the model binary.
1091- This argument is deprecated, use simargs instead.
10921038 simargs: Dict with simulation runtime flags.
10931039 timeout: Maximum execution time in seconds.
10941040
@@ -1109,7 +1055,6 @@ def simulate(
11091055
11101056 om_cmd = self .simulate_cmd (
11111057 result_file = self ._result_file ,
1112- simflags = simflags ,
11131058 simargs = simargs ,
11141059 timeout = timeout ,
11151060 )
@@ -1604,7 +1549,6 @@ def optimize(self) -> dict[str, Any]:
16041549 def linearize (
16051550 self ,
16061551 lintime : Optional [float ] = None ,
1607- simflags : Optional [str ] = None ,
16081552 simargs : Optional [dict [str , Optional [str | dict [str , Any ] | numbers .Number ]]] = None ,
16091553 timeout : Optional [float ] = None ,
16101554 ) -> LinearizationResult :
@@ -1614,8 +1558,6 @@ def linearize(
16141558
16151559 Args:
16161560 lintime: Override "stopTime" value.
1617- simflags: String of extra command line flags for the model binary.
1618- This argument is deprecated, use simargs instead.
16191561 simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
16201562 timeout: Maximum execution time in seconds.
16211563
@@ -1664,11 +1606,7 @@ def linearize(
16641606
16651607 om_cmd .arg_set (key = "l" , val = str (lintime or self ._linearization_options ["stopTime" ]))
16661608
1667- # allow runtime simulation flags from user input
1668- if simflags is not None :
1669- om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
1670-
1671- if simargs :
1609+ if simargs is not None :
16721610 om_cmd .args_set (args = simargs )
16731611
16741612 # the file create by the model executable which contains the matrix and linear inputs, outputs and states
0 commit comments