Class OMOctave
GNU Octave scripting for OpenModelica
GNU Octave scripting OpenModelica interface using ZEROMQ based on OMMatlab available at: github.com/OpenModelica/OMMatlab/.
OpenModelica is an open-source Modelica-based modeling and simulation environment intended for industrial and academic usage. It is often used for modeling, simulating, optimizing, and analyzing complex dynamic systems.
Source Code
Source code for this class is available at: github.com/PR-DC/PRDC_OMOctave
Requirements
Provided interface is partially tested with GNU Octave 6.2.0.
Installation
Clone the repository and add the installation directory to Octave PATH. For Example
>> addpath('C:\OMOctave\')
You can also directly use the OMOctave package directly from the directory where you have cloned, without need to perform the above steps. But the package cannot be used globally.
Usage
>> omc = OMOctave();
>> omc.sendExpression("getVersion()")
ans =
{
[1,1] = OpenModelica v1.16.5 (64-bit)
}
>> omc.sendExpression("model a end a;")
ans =
{
[1,1] = a
}
>> omc.sendExpression('loadFile("C:/Program Files/OpenModelica1.16.5-64bit/OMSens/resource/BouncingBall.mo")')
ans =
{
[1,1] = true
}
>> omc.sendExpression("getClassNames()")
ans =
{
[1,1] = BouncingBall
[1,2] = a
}
>> omc.sendExpression("simulate(BouncingBall)")
ans =
scalar structure containing the fields:
resultFile = C:/Users/User/Desktop/OMOctave/BouncingBall_res.mat
simulationOptions = startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'BouncingBall', options = '', outputFormat = 'mat', variabl
eFilter = '.*', cflags = '', simflags = ''
messages = LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
timeFrontend = 0.0065355
timeBackend = 0.0096361
timeSimCode = 0.0013927
timeTemplates = 0.0318059
timeCompile = 8.706928700000001
timeSimulation = 0.3084547
timeTotal = 9.0651016
>> omc.close();
To see the list of available OpenModelicaScripting API see: openmodelica.org/doc/OpenModelicaUsersGuide/latest/scripting_api.html
Discussion
Discussion about this class is avialable at Discourse.
Author and Licensing
Author: Miloš Petrašinović <mpetrasinovic@pr-dc.com>
PR-DC, Aerospace Company, Republic of Serbia
Distributed under the GNU General Public License v3.0 or later license.