@@ -1800,52 +1800,52 @@ def run_doe():
18001800
18011801 def __init__ (
18021802 self ,
1803- fileName : Optional [str | os .PathLike | pathlib .Path ] = None ,
1803+ # data to be used for ModelicaSystem
1804+ fileName : Optional [str | os .PathLike ] = None ,
18041805 modelName : Optional [str ] = None ,
18051806 lmodel : Optional [list [str | tuple [str , str ]]] = None ,
18061807 commandLineOptions : Optional [list [str ]] = None ,
18071808 variableFilter : Optional [str ] = None ,
1808- customBuildDirectory : Optional [str | os .PathLike | pathlib . Path ] = None ,
1809+ customBuildDirectory : Optional [str | os .PathLike ] = None ,
18091810 omhome : Optional [str ] = None ,
1810-
1811+ omc_process : Optional [OMCProcess ] = None , # TODO: use omc session
1812+ # simulation specific input
1813+ # TODO: add more settings (simulation options, input options, ...)
18111814 simargs : Optional [dict [str , Optional [str | dict [str , str ] | numbers .Number ]]] = None ,
18121815 timeout : Optional [int ] = None ,
1813-
1814- resultpath : Optional [pathlib . Path ] = None ,
1816+ # DoE specific inputs
1817+ resultpath : Optional [str | os . PathLike ] = None ,
18151818 parameters : Optional [dict [str , list [str ] | list [int ] | list [float ]]] = None ,
18161819 ) -> None :
18171820 """
18181821 Initialisation of ModelicaSystemDoE. The parameters are based on: ModelicaSystem.__init__() and
18191822 ModelicaSystem.simulate(). Additionally, the path to store the result files is needed (= resultpath) as well as
18201823 a list of parameters to vary for the Doe (= parameters). All possible combinations are considered.
18211824 """
1822- self ._lmodel = lmodel
1823- self ._modelName = modelName
1824- self ._fileName = fileName
1825-
1826- self ._CommandLineOptions = commandLineOptions
1827- self ._variableFilter = variableFilter
1828- self ._customBuildDirectory = customBuildDirectory
1829- self ._omhome = omhome
18301825
1831- # reference for the model; not used for any simulations but to evaluate parameters, etc.
18321826 self ._mod = ModelicaSystem (
1833- fileName = self ._fileName ,
1834- modelName = self ._modelName ,
1835- lmodel = self ._lmodel ,
1836- commandLineOptions = self ._CommandLineOptions ,
1837- variableFilter = self ._variableFilter ,
1838- customBuildDirectory = self ._customBuildDirectory ,
1839- omhome = self ._omhome ,
1827+ fileName = fileName ,
1828+ modelName = modelName ,
1829+ lmodel = lmodel ,
1830+ commandLineOptions = commandLineOptions ,
1831+ variableFilter = variableFilter ,
1832+ customBuildDirectory = customBuildDirectory ,
1833+ omhome = omhome ,
1834+ omc_process = omc_process ,
18401835 )
18411836
1837+ self ._model_name = modelName
1838+
18421839 self ._simargs = simargs
18431840 self ._timeout = timeout
18441841
1845- if isinstance ( resultpath , pathlib . Path ) :
1846- self ._resultpath = resultpath
1842+ if resultpath is None :
1843+ self ._resultpath = self . _mod . _getconn . omcpath_tempdir ()
18471844 else :
1848- self ._resultpath = pathlib .Path ('.' )
1845+ self ._resultpath = self ._mod ._getconn .omcpath (resultpath )
1846+ if not self ._resultpath .is_dir ():
1847+ raise ModelicaSystemError ("Argument resultpath must be set to a valid path within the environment used "
1848+ f"for the OpenModelica session: { resultpath } !" )
18491849
18501850 if isinstance (parameters , dict ):
18511851 self ._parameters = parameters
@@ -1892,15 +1892,15 @@ def prepare(self) -> int:
18921892
18931893 pk_value = pc_structure [idx_structure ]
18941894 if isinstance (pk_value , str ):
1895- expression = f"setParameterValue({ self ._modelName } , { pk_structure } , \" { pk_value } \" )"
1895+ expression = f"setParameterValue({ self ._model_name } , { pk_structure } , \" { pk_value } \" )"
18961896 elif isinstance (pk_value , bool ):
18971897 pk_value_bool_str = "true" if pk_value else "false"
1898- expression = f"setParameterValue({ self ._modelName } , { pk_structure } , { pk_value_bool_str } );"
1898+ expression = f"setParameterValue({ self ._model_name } , { pk_structure } , { pk_value_bool_str } );"
18991899 else :
1900- expression = f"setParameterValue({ self ._modelName } , { pk_structure } , { pk_value } )"
1901- res = mod_structure .sendExpression (expression )
1900+ expression = f"setParameterValue({ self ._model_name } , { pk_structure } , { pk_value } )"
1901+ res = self . _mod .sendExpression (expression )
19021902 if not res :
1903- raise ModelicaSystemError (f"Cannot set structural parameter { self ._modelName } .{ pk_structure } "
1903+ raise ModelicaSystemError (f"Cannot set structural parameter { self ._model_name } .{ pk_structure } "
19041904 f"to { pk_value } using { repr (expression )} " )
19051905
19061906 self ._mod .buildModel ()
0 commit comments