Search code examples
simulationopenmodelica

Using pre-built model for simulation in openmodelica script


So, here is one of the most basic script you can run in OMShell:

loadFile(getInstallationDirectoryPath() + "/share/doc/omc/testmodels/BouncingBall.mo")
simulate(BouncingBall, startTime=0.0, stopTime=1.0)

Now, the call to simulate is slow and the output indicates that the the compilation is what take the most time:

...
    timeFrontend = 0.0041435,
    timeBackend = 0.003568,
    timeSimCode = 0.0010321,
    timeTemplates = 0.0145525,
    timeCompile = 5.0517363,
    timeSimulation = 0.2011517,
    timeTotal = 5.2764338
...

Now, I would like to run the simulation as quickly as possible. Is there a way to split up the call to simulate so that compilation and simulation is done separately?

It seems I can use buildModel to compile the model but how do I run the model after compilation?


Solution

  • As you pointed out, you can use buildModel. Afterwards, simply run the executable. If you want to use OMShell, you can call system("./BouncingBall")