4646import subprocess
4747import tempfile
4848import textwrap
49- from typing import Optional , Any
50- import warnings
49+ from typing import Any , Optional
5150import xml .etree .ElementTree as ET
5251
5352from OMPython .OMCSession import OMCSessionException , OMCSessionZMQ , OMCProcessLocal
@@ -255,45 +254,6 @@ def run(self) -> int:
255254
256255 return returncode
257256
258- @staticmethod
259- def parse_simflags (simflags : str ) -> dict [str , Optional [str | dict [str , str ]]]:
260- """
261- Parse a simflag definition; this is deprecated!
262-
263- The return data can be used as input for self.args_set().
264- """
265- warnings .warn ("The argument 'simflags' is depreciated and will be removed in future versions; "
266- "please use 'simargs' instead" , DeprecationWarning , stacklevel = 2 )
267-
268- simargs : dict [str , Optional [str | dict [str , str ]]] = {}
269-
270- args = [s for s in simflags .split (' ' ) if s ]
271- for arg in args :
272- if arg [0 ] != '-' :
273- raise ModelicaSystemError (f"Invalid simulation flag: { arg } " )
274- arg = arg [1 :]
275- parts = arg .split ('=' )
276- if len (parts ) == 1 :
277- simargs [parts [0 ]] = None
278- elif parts [0 ] == 'override' :
279- override = '=' .join (parts [1 :])
280-
281- override_dict = {}
282- for item in override .split (',' ):
283- kv = item .split ('=' )
284- if not 0 < len (kv ) < 3 :
285- raise ModelicaSystemError (f"Invalid value for '-override': { override } " )
286- if kv [0 ]:
287- try :
288- override_dict [kv [0 ]] = kv [1 ]
289- except (KeyError , IndexError ) as ex :
290- raise ModelicaSystemError (f"Invalid value for '-override': { override } " ) from ex
291-
292- simargs [parts [0 ]] = override_dict
293-
294- return simargs
295-
296-
297257class ModelicaSystem :
298258 def __init__ (
299259 self ,
@@ -917,7 +877,6 @@ def getOptimizationOptions(self, names: Optional[str | list[str]] = None) -> dic
917877 def simulate_cmd (
918878 self ,
919879 result_file : pathlib .Path ,
920- simflags : Optional [str ] = None ,
921880 simargs : Optional [dict [str , Optional [str | dict [str , str ]]]] = None ,
922881 timeout : Optional [float ] = None ,
923882 ) -> ModelicaSystemCmd :
@@ -931,13 +890,6 @@ def simulate_cmd(
931890 However, if only non-structural parameters are used, it is possible to reuse an existing instance of
932891 ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
933892
934- Parameters
935- ----------
936- result_file
937- simflags
938- simargs
939- timeout
940-
941893 Returns
942894 -------
943895 An instance if ModelicaSystemCmd to run the requested simulation.
@@ -948,11 +900,7 @@ def simulate_cmd(
948900 # always define the result file to use
949901 om_cmd .arg_set (key = "r" , val = result_file .as_posix ())
950902
951- # allow runtime simulation flags from user input
952- if simflags is not None :
953- om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
954-
955- if simargs :
903+ if simargs is not None :
956904 om_cmd .args_set (args = simargs )
957905
958906 overrideFile = self ._tempdir / f"{ self ._model_name } _override.txt"
@@ -990,7 +938,6 @@ def simulate_cmd(
990938 def simulate (
991939 self ,
992940 resultfile : Optional [str ] = None ,
993- simflags : Optional [str ] = None ,
994941 simargs : Optional [dict [str , Optional [str | dict [str , str ]]]] = None ,
995942 timeout : Optional [float ] = None ,
996943 ) -> None :
@@ -1000,8 +947,6 @@ def simulate(
1000947
1001948 Args:
1002949 resultfile: Path to a custom result file
1003- simflags: String of extra command line flags for the model binary.
1004- This argument is deprecated, use simargs instead.
1005950 simargs: Dict with simulation runtime flags.
1006951 timeout: Maximum execution time in seconds.
1007952
@@ -1022,7 +967,6 @@ def simulate(
1022967
1023968 om_cmd = self .simulate_cmd (
1024969 result_file = self ._result_file ,
1025- simflags = simflags ,
1026970 simargs = simargs ,
1027971 timeout = timeout ,
1028972 )
@@ -1516,17 +1460,18 @@ def optimize(self) -> dict[str, Any]:
15161460
15171461 return optimizeResult
15181462
1519- def linearize (self , lintime : Optional [float ] = None , simflags : Optional [str ] = None ,
1520- simargs : Optional [dict [str , Optional [str | dict [str , str ]]]] = None ,
1521- timeout : Optional [float ] = None ) -> LinearizationResult :
1463+ def linearize (
1464+ self ,
1465+ lintime : Optional [float ] = None ,
1466+ simargs : Optional [dict [str , Optional [str | dict [str , str ]]]] = None ,
1467+ timeout : Optional [int ] = None ,
1468+ ) -> LinearizationResult :
15221469 """Linearize the model according to linearization options.
15231470
15241471 See setLinearizationOptions.
15251472
15261473 Args:
15271474 lintime: Override "stopTime" value.
1528- simflags: String of extra command line flags for the model binary.
1529- This argument is deprecated, use simargs instead.
15301475 simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
15311476 timeout: Maximum execution time in seconds.
15321477
@@ -1579,11 +1524,7 @@ def load_module_from_path(module_name, file_path):
15791524
15801525 om_cmd .arg_set (key = "l" , val = str (lintime or self ._linearization_options ["stopTime" ]))
15811526
1582- # allow runtime simulation flags from user input
1583- if simflags is not None :
1584- om_cmd .args_set (args = om_cmd .parse_simflags (simflags = simflags ))
1585-
1586- if simargs :
1527+ if simargs is not None :
15871528 om_cmd .args_set (args = simargs )
15881529
15891530 returncode = om_cmd .run ()
0 commit comments