- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Modelica functions in OMShell for...
Modelica functions in OMShell for model linearization
Modelica functions in OMShell for model linearization
Hi,
I am trying to linearize a model and export the matrices into a .mat file with an OpenModelica script but I have several issues.
-Some of the the Modelica.Utilities.Files functions do now work OM scripts. The output is just a while line. For example:
Modelica.Utilities.Strings.length("test") works correctly but Modelica.Utilities.Files.exist("C:") gives no result.
Is is a matter of system APIs?
-The Modelica_LinearSystems2 liearize function does not work (I know the OM API has a linearize() function but it does not allow me to change parameters) an example is shown here:
loadModel(Modelica);
loadModel(Modelica_LinearSystems2);
loadFile("PackagewithModels.mo");
Modelica_LinearSystems2.ModelAnalysis.Linearize(ModelToBeLinearized)
>>Modelica_LinearSystems2.ModelAnalysis.Linearize[<interactive>:1:1-1:0:writable] Error: Variable Modelica_LinearSystems2.ModelAnalysis.Linearize not found in scope <global scope>.
Finally, if I use the OpenModelica.Scripting.linearize() function it produces a .mo linear model, I have found no way to extract the matrices and write them into a .mat file within an OM script. I only could use the getParameterValue() to extract the matrices as strings and write them into a .m ASCII file, then open it in matlab.
Do you have any suggestion?
Many Thanks
Bruno
Re: Modelica functions in OMShell for model linearization
You need to enable code generation of functions (slow, may cause crashes) if you want to call custom C-code in scripts:
Code:
>>> loadModel(Modelica)
true
>>> Modelica.Utilities.Files.exist("C:")
>>> setCommandLineOptions("-d=gen")
true
>>> Modelica.Utilities.Files.exist("C:")
false
Modelica_LinearSystems2 is a partially Dymola-specific library which is why some parts of it don't work in OpenModelica.
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Modelica functions in OMShell for...