@@ -1735,52 +1735,52 @@ def run_doe():
17351735
17361736 def __init__ (
17371737 self ,
1738- fileName : Optional [str | os .PathLike | pathlib .Path ] = None ,
1738+ # data to be used for ModelicaSystem
1739+ fileName : Optional [str | os .PathLike ] = None ,
17391740 modelName : Optional [str ] = None ,
17401741 lmodel : Optional [list [str | tuple [str , str ]]] = None ,
17411742 commandLineOptions : Optional [str ] = None ,
17421743 variableFilter : Optional [str ] = None ,
1743- customBuildDirectory : Optional [str | os .PathLike | pathlib . Path ] = None ,
1744+ customBuildDirectory : Optional [str | os .PathLike ] = None ,
17441745 omhome : Optional [str ] = None ,
1745-
1746- simargs : Optional [dict [str , Optional [str | dict [str , str ]]]] = None ,
1746+ omc_process : Optional [OMCProcessLocal ] = None , # TODO: use omc session
1747+ # simulation specific input
1748+ # TODO: add more settings (simulation options, input options, ...)
1749+ simargs : Optional [dict [str , Optional [str | dict [str , Any ]]]] = None ,
17471750 timeout : Optional [int ] = None ,
1748-
1749- resultpath : Optional [pathlib . Path ] = None ,
1751+ # DoE specific inputs
1752+ resultpath : Optional [str | os . PathLike ] = None ,
17501753 parameters : Optional [dict [str , list [str ] | list [int ] | list [float ]]] = None ,
17511754 ) -> None :
17521755 """
17531756 Initialisation of ModelicaSystemDoE. The parameters are based on: ModelicaSystem.__init__() and
17541757 ModelicaSystem.simulate(). Additionally, the path to store the result files is needed (= resultpath) as well as
17551758 a list of parameters to vary for the Doe (= parameters). All possible combinations are considered.
17561759 """
1757- self ._lmodel = lmodel
1758- self ._modelName = modelName
1759- self ._fileName = fileName
1760-
1761- self ._CommandLineOptions = commandLineOptions
1762- self ._variableFilter = variableFilter
1763- self ._customBuildDirectory = customBuildDirectory
1764- self ._omhome = omhome
17651760
1766- # reference for the model; not used for any simulations but to evaluate parameters, etc.
17671761 self ._mod = ModelicaSystem (
1768- fileName = self ._fileName ,
1769- modelName = self ._modelName ,
1770- lmodel = self ._lmodel ,
1771- commandLineOptions = self ._CommandLineOptions ,
1772- variableFilter = self ._variableFilter ,
1773- customBuildDirectory = self ._customBuildDirectory ,
1774- omhome = self ._omhome ,
1762+ fileName = fileName ,
1763+ modelName = modelName ,
1764+ lmodel = lmodel ,
1765+ commandLineOptions = commandLineOptions ,
1766+ variableFilter = variableFilter ,
1767+ customBuildDirectory = customBuildDirectory ,
1768+ omhome = omhome ,
1769+ omc_process = omc_process ,
17751770 )
17761771
1772+ self ._model_name = modelName
1773+
17771774 self ._simargs = simargs
17781775 self ._timeout = timeout
17791776
1780- if isinstance ( resultpath , pathlib . Path ) :
1781- self ._resultpath = resultpath
1777+ if resultpath is None :
1778+ self ._resultpath = self . _mod . _getconn . omcpath_tempdir ()
17821779 else :
1783- self ._resultpath = pathlib .Path ('.' )
1780+ self ._resultpath = self ._mod ._getconn .omcpath (resultpath )
1781+ if not self ._resultpath .is_dir ():
1782+ raise ModelicaSystemError ("Argument resultpath must be set to a valid path within the environment used "
1783+ f"for the OpenModelica session: { resultpath } !" )
17841784
17851785 if isinstance (parameters , dict ):
17861786 self ._parameters = parameters
@@ -1827,15 +1827,15 @@ def prepare(self) -> int:
18271827
18281828 pk_value = pc_structure [idx_structure ]
18291829 if isinstance (pk_value , str ):
1830- expression = f"setParameterValue({ self ._modelName } , { pk_structure } , \" { pk_value } \" )"
1830+ expression = f"setParameterValue({ self ._model_name } , { pk_structure } , \" { pk_value } \" )"
18311831 elif isinstance (pk_value , bool ):
18321832 pk_value_bool_str = "true" if pk_value else "false"
1833- expression = f"setParameterValue({ self ._modelName } , { pk_structure } , { pk_value_bool_str } );"
1833+ expression = f"setParameterValue({ self ._model_name } , { pk_structure } , { pk_value_bool_str } );"
18341834 else :
1835- expression = f"setParameterValue({ self ._modelName } , { pk_structure } , { pk_value } )"
1836- res = mod_structure .sendExpression (expression )
1835+ expression = f"setParameterValue({ self ._model_name } , { pk_structure } , { pk_value } )"
1836+ res = self . _mod .sendExpression (expression )
18371837 if not res :
1838- raise ModelicaSystemError (f"Cannot set structural parameter { self ._modelName } .{ pk_structure } "
1838+ raise ModelicaSystemError (f"Cannot set structural parameter { self ._model_name } .{ pk_structure } "
18391839 f"to { pk_value } using { repr (expression )} " )
18401840
18411841 self ._mod .buildModel ()
0 commit comments