'How to save OpenModelica Simulation results
I am using OpenModelica in my work.
How do I save OpenModelica simulations results?
Solution 1:[1]
It depends. If you are using OMEdit you can find the result in the working directory of OMEdit
If you want to save your model as an executable via OpenModelica-scripting you can use mos scripts in the following way:
setCommandLineOptions({"-d=execstat"});
loadFile("model.mo");getErrorString();
buildModel(model); getErrorString();
To run the executable for two seconds, here with the IDA solver:
"./model -override=stopTime=2.0 -s=ida", "log.log"
The resulting simulation will be saved in your working directory with this approach.
Or you can write the following mos script:
loadFile("HelloWorld.mo");getErrorString();
simulate(HelloWorld);getErrorString();
with the following Modelica model:
model HelloWorld
Real x( start = 1, fixed = true );
parameter Real a = 1;
equation
der(x) = - a * x;
end HelloWorld;
The output will be as follows:
true
""
record SimulationResult
resultFile = "/mnt/c/<Path>/HelloWorld_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'HelloWorld', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.007985600000000001,
timeBackend = 0.0152096,
timeSimCode = 0.0033462,
timeTemplates = 0.09332140000000001,
timeCompile = 1.7051749,
timeSimulation = 0.0506992,
timeTotal = 1.8771728
end SimulationResult;
The result will then be available in HelloWorld_res.mat in your working directory
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

