- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Set dynamic model path in .mos file
Set dynamic model path in .mos file
Set dynamic model path in .mos file
Hello,
i want to generate an FMU file from a model.mo which is located in the same folder.
The folder is part of a git repository, which has many users, so the absolute path changes.
The .mos file works, but it draws the model.mo from the default path Openmodelica/lib/omlibrary
My File is
Code:
loadModel(grid); getErrorString();
setCommandLineOptions("-d=newInst"); getErrorString();
setCommandLineOptions("-d=initialization"); getErrorString();
setCommandLineOptions("--simCodeTarget=Cpp"); getErrorString();
setCommandLineOptions("-d=-disableDirectionalDerivatives"); getErrorString();
translateModelFMU(grid.network); getErrorString();
According to https://openmodelica.org/forum/default- … ndline-use , i should be able to set an absolute model path directly as a string in the loadModel("C:\Users\myname\PycharmProjects\projectName/grid.mo"); but even this doess not work, i just receive the error (translated) Class loadModel could not be found in the aim area (global scope).
Can anyone give me the right command line to load the model directly from the current directory from where the .mos file is called? Would be awesome :-)
Best regards
Henrik
Re: Set dynamic model path in .mos file
If your model.mo is located in the same directory where the .mos file is then you can call,
Code:
loadFile("model.mo")
instead of
Code:
loadModel(grid)
Adeel.
- adeas
- 454 Posts
Re: Set dynamic model path in .mos file
If you want to see slightly better error-messages, call
Code:
OpenModelica.Scripting.loadModel("xxx"); getErrorString()
Code:
[model.mos:1:1-1:39:writable] Error: Failed to elaborate "xxx" as a code expression of type OpenModelica.Code.TypeName.
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Set dynamic model path in .mos file