modelica

Open nested Modelica model in package via OMShell


I want to know if it's possible to simulate a model in OMShell, that is nested inside a package, that I loaded in OMShell via loadFile(). None of my attempts doing it via loadModel() or loadFile() were successful.

Situation is as follows: I have a self written (Modelica) package named Testpackage that contains a model named Testmodel that i want to simulate in OMShell. The package is not organized in a folder-structure - it's just the package.mo file.

I manage to load the package-file by navigating via cd("/path/to/Testpackage") and then loading the package via loadFile(Testpackage).

After that I am lost. When trying to load Testmodel with command loadModel(Testmodel) I get the message that it tried to load it from the standard Modelica library. Specifying the path it tells me things I don`t know how to interpret.

Thank you for your help in advance! Roman

EDIT:

I just ran into another problem and i hope its ok to append my question to this topic and edit my original question.

The reason why i am trying to get familiar with OMShell is that i need to do multiple simulations with models in my self-written package extending models of the buildings library...multiple runs, where i want to vary weatherfiles used and some values within a parameter-record defining my model. I'd like to write a script (.mos) to automate this process and came across the command "setParameterValue()".

Trying to use it to manipulate a parameter of a model within the model i simulate doesn*t seem to work as i get the Error-message stating that it couldn't find the class. But it works when i want to manipulate a parameter in the model i want to simulate itself.

Is there a restriction for this command to only be applicable on the model that i simulate and not on ones within it? I would like to know how to access the parameters that are on a "deeper level"....hope you get what i want to express. Thank you very much for your help in advance!

Roman


Solution

  • Loading TestModel is not necessary. You just load the package and then simulate using the full class path. This should work:

    loadFile("/path/to/Testpackage.mo") // loads the package and its content
    simulate(Testpackage.Testmodel)
    

    I suggest to check the users guide to get an impression what the functions do. Apparently loadModel is meant to load models from the Modelica Standard Library, which is also reflected by the error message you get (actually I think it loads anything from MODELICAPATH, not just the MSL, so the docs are misleading).