@@ -329,18 +329,18 @@ class ModelicaSystem:
329329
330330 def __init__ (
331331 self ,
332- commandLineOptions : Optional [list [str ]] = None ,
333- customBuildDirectory : Optional [str | os .PathLike ] = None ,
332+ command_line_options : Optional [list [str ]] = None ,
333+ work_directory : Optional [str | os .PathLike ] = None ,
334334 omhome : Optional [str ] = None ,
335335 omc_process : Optional [OMCProcess ] = None ,
336336 ) -> None :
337337 """Create a ModelicaSystem instance. To define the model use model() or convertFmu2Mo().
338338
339339 Args:
340- commandLineOptions : List with extra command line options as elements. The list elements are
340+ command_line_options : List with extra command line options as elements. The list elements are
341341 provided to omc via setCommandLineOptions(). If set, the default values will be overridden.
342342 To disable any command line options, use an empty list.
343- customBuildDirectory : Path to a directory to be used for temporary
343+ work_directory : Path to a directory to be used for temporary
344344 files like the model executable. If left unspecified, a tmp
345345 directory will be created.
346346 omhome: path to OMC to be used when creating the OMC session (see OMCSessionZMQ).
@@ -378,20 +378,20 @@ def __init__(
378378 self ._session = OMCSessionZMQ (omhome = omhome )
379379
380380 # set commandLineOptions using default values or the user defined list
381- if commandLineOptions is None :
381+ if command_line_options is None :
382382 # set default command line options to improve the performance of linearization and to avoid recompilation if
383383 # the simulation executable is reused in linearize() via the runtime flag '-l'
384- commandLineOptions = [
384+ command_line_options = [
385385 "--linearizationDumpLanguage=python" ,
386386 "--generateSymbolicLinearization" ,
387387 ]
388- for opt in commandLineOptions :
389- self .setCommandLineOptions ( commandLineOptions = opt )
388+ for opt in command_line_options :
389+ self .set_command_line_options ( command_line_option = opt )
390390
391391 self ._simulated = False # True if the model has already been simulated
392392 self ._result_file : Optional [OMCPath ] = None # for storing result file
393393
394- self ._work_dir : OMCPath = self .setWorkDirectory (customBuildDirectory )
394+ self ._work_dir : OMCPath = self .setWorkDirectory (work_directory )
395395
396396 self ._model_name : Optional [str ] = None
397397 self ._libraries : Optional [list [str | tuple [str , str ]]] = None
@@ -400,8 +400,8 @@ def __init__(
400400
401401 def model (
402402 self ,
403- name : Optional [str ] = None ,
404- file : Optional [str | os .PathLike ] = None ,
403+ model_name : Optional [str ] = None ,
404+ model_file : Optional [str | os .PathLike ] = None ,
405405 libraries : Optional [list [str | tuple [str , str ]]] = None ,
406406 variable_filter : Optional [str ] = None ,
407407 build : bool = True ,
@@ -411,9 +411,9 @@ def model(
411411 This method loads the model file and builds it if requested (build == True).
412412
413413 Args:
414- file : Path to the model file. Either absolute or relative to
414+ model_file : Path to the model file. Either absolute or relative to
415415 the current working directory.
416- name : The name of the model class. If it is contained within
416+ model_name : The name of the model class. If it is contained within
417417 a package, "PackageName.ModelName" should be used.
418418 libraries: List of libraries to be loaded before the model itself is
419419 loaded. Two formats are supported for the list elements:
@@ -439,7 +439,7 @@ def model(
439439 raise ModelicaSystemError ("Can not reuse this instance of ModelicaSystem "
440440 f"defined for { repr (self ._model_name )} !" )
441441
442- if name is None or not isinstance (name , str ):
442+ if model_name is None or not isinstance (model_name , str ):
443443 raise ModelicaSystemError ("A model name must be provided!" )
444444
445445 if libraries is None :
@@ -449,16 +449,16 @@ def model(
449449 raise ModelicaSystemError (f"Invalid input type for libraries: { type (libraries )} - list expected!" )
450450
451451 # set variables
452- self ._model_name = name # Model class name
452+ self ._model_name = model_name # Model class name
453453 self ._libraries = libraries # may be needed if model is derived from other model
454454 self ._variable_filter = variable_filter
455455
456456 if self ._libraries :
457457 self ._loadLibrary (libraries = self ._libraries )
458458
459459 self ._file_name = None
460- if file is not None :
461- file_path = pathlib .Path (file )
460+ if model_file is not None :
461+ file_path = pathlib .Path (model_file )
462462 # special handling for OMCProcessLocal - consider a relative path
463463 if isinstance (self ._session .omc_process , OMCProcessLocal ) and not file_path .is_absolute ():
464464 file_path = pathlib .Path .cwd () / file_path
@@ -487,11 +487,11 @@ def session(self) -> OMCSessionZMQ:
487487 """
488488 return self ._session
489489
490- def setCommandLineOptions (self , commandLineOptions : str ):
490+ def set_command_line_options (self , command_line_option : str ):
491491 """
492492 Set the provided command line option via OMC setCommandLineOptions().
493493 """
494- exp = f'setCommandLineOptions("{ commandLineOptions } ")'
494+ exp = f'setCommandLineOptions("{ command_line_option } ")'
495495 self .sendExpression (exp )
496496
497497 def _loadFile (self , fileName : OMCPath ):
@@ -522,15 +522,15 @@ def _loadLibrary(self, libraries: list):
522522 '1)["Modelica"]\n '
523523 '2)[("Modelica","3.2.3"), "PowerSystems"]\n ' )
524524
525- def setWorkDirectory (self , customBuildDirectory : Optional [str | os .PathLike ] = None ) -> OMCPath :
525+ def setWorkDirectory (self , work_directory : Optional [str | os .PathLike ] = None ) -> OMCPath :
526526 """
527527 Define the work directory for the ModelicaSystem / OpenModelica session. The model is build within this
528528 directory. If no directory is defined a unique temporary directory is created.
529529 """
530- if customBuildDirectory is not None :
531- workdir = self ._session .omcpath (customBuildDirectory ).absolute ()
530+ if work_directory is not None :
531+ workdir = self ._session .omcpath (work_directory ).absolute ()
532532 if not workdir .is_dir ():
533- raise IOError (f"Provided work directory does not exists: { customBuildDirectory } !" )
533+ raise IOError (f"Provided work directory does not exists: { work_directory } !" )
534534 else :
535535 workdir = self ._session .omcpath_tempdir ().absolute ()
536536 if not workdir .is_dir ():
@@ -1709,8 +1709,8 @@ def convertFmu2Mo(
17091709 raise ModelicaSystemError (f"Missing file { filepath .as_posix ()} " )
17101710
17111711 self .model (
1712- name = f"{ fmu_path .stem } _me_FMU" ,
1713- file = filepath ,
1712+ model_name = f"{ fmu_path .stem } _me_FMU" ,
1713+ model_file = filepath ,
17141714 )
17151715
17161716 return filepath
@@ -1744,7 +1744,7 @@ def optimize(self) -> dict[str, Any]:
17441744 """
17451745 cName = self ._model_name
17461746 properties = ',' .join (f"{ key } ={ val } " for key , val in self ._optimization_options .items ())
1747- self .setCommandLineOptions ("-g=Optimica" )
1747+ self .set_command_line_options ("-g=Optimica" )
17481748 optimizeResult = self ._requestApi (apiName = 'optimize' , entity = cName , properties = properties )
17491749
17501750 return optimizeResult
@@ -1926,8 +1926,8 @@ def run_doe():
19261926 resdir.mkdir(exist_ok=True)
19271927
19281928 doe_mod = OMPython.ModelicaSystemDoE(
1929- fileName=model.as_posix() ,
1930- modelName="M" ,
1929+ model_name="M" ,
1930+ model_file=model.as_posix() ,
19311931 parameters=param,
19321932 resultpath=resdir,
19331933 simargs={"override": {'stopTime': 1.0}},
@@ -1955,12 +1955,12 @@ def run_doe():
19551955 def __init__ (
19561956 self ,
19571957 # data to be used for ModelicaSystem
1958- fileName : Optional [str | os .PathLike ] = None ,
1959- modelName : Optional [str ] = None ,
1960- lmodel : Optional [list [str | tuple [str , str ]]] = None ,
1961- commandLineOptions : Optional [list [str ]] = None ,
1962- variableFilter : Optional [str ] = None ,
1963- customBuildDirectory : Optional [str | os .PathLike ] = None ,
1958+ model_file : Optional [str | os .PathLike ] = None ,
1959+ model_name : Optional [str ] = None ,
1960+ libraries : Optional [list [str | tuple [str , str ]]] = None ,
1961+ command_line_options : Optional [list [str ]] = None ,
1962+ variable_filter : Optional [str ] = None ,
1963+ work_directory : Optional [str | os .PathLike ] = None ,
19641964 omhome : Optional [str ] = None ,
19651965 omc_process : Optional [OMCProcess ] = None ,
19661966 # simulation specific input
@@ -1976,21 +1976,23 @@ def __init__(
19761976 ModelicaSystem.simulate(). Additionally, the path to store the result files is needed (= resultpath) as well as
19771977 a list of parameters to vary for the Doe (= parameters). All possible combinations are considered.
19781978 """
1979+ if model_name is None :
1980+ raise ModelicaSystemError ("No model name provided!" )
19791981
19801982 self ._mod = ModelicaSystem (
1981- commandLineOptions = commandLineOptions ,
1982- customBuildDirectory = customBuildDirectory ,
1983+ command_line_options = command_line_options ,
1984+ work_directory = work_directory ,
19831985 omhome = omhome ,
19841986 omc_process = omc_process ,
19851987 )
19861988 self ._mod .model (
1987- file = fileName ,
1988- name = modelName ,
1989- libraries = lmodel ,
1990- variable_filter = variableFilter ,
1989+ model_file = model_file ,
1990+ model_name = model_name ,
1991+ libraries = libraries ,
1992+ variable_filter = variable_filter ,
19911993 )
19921994
1993- self ._model_name = modelName
1995+ self ._model_name = model_name
19941996
19951997 self ._simargs = simargs
19961998 self ._timeout = timeout
@@ -2046,7 +2048,7 @@ def prepare(self) -> int:
20462048
20472049 build_dir = self ._resultpath / f"DOE_{ idx_pc_structure :09d} "
20482050 build_dir .mkdir ()
2049- self ._mod .setWorkDirectory (customBuildDirectory = build_dir )
2051+ self ._mod .setWorkDirectory (work_directory = build_dir )
20502052
20512053 sim_param_structure = {}
20522054 for idx_structure , pk_structure in enumerate (param_structure .keys ()):
0 commit comments