Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#5656 closed enhancement (worksforme)

Allow step-by-step translation and simulation with scripting API

Reported by: robert.sandmann@… Owned by: somebody
Priority: high Milestone: 1.16.0
Component: Interactive Environment Version: v1.14.0-dev-nightly
Keywords: translate simulate build Cc:

Description

Dear developers,

currently, it is not possible to simulate a model without translating it at the same time. That means that if a translated model is available in the working directory, a call to simulate translates the model again.

To be able to compare timing statistics of the separate steps check, translate and simulate, it would be great to be able to only simulate a model without translating it at the same time using the scripting API (also via the Python interface).

I thank you in advance for looking into this.

Kind regards, Robert

Change History (5)

comment:1 by massimo ceraolo, 5 years ago

Maybe to solve your problem you just need ticket #4565 be fixed?
The solution of that ticket indeed would give users a lot of information on where computing time goes.

Last edited 5 years ago by massimo ceraolo (previous) (diff)

comment:2 by Francesco Casella, 5 years ago

Component: *unknown*Interactive Environment
Milestone: Future2.0.0

comment:3 by Andreas Heuermann, 5 years ago

I'm not sure if this solves your issue but you can use API function OpenModelica.Scripting.system to call your executable directly. See also the API-documentation
So for simulating a model bouncingBall.mo you could do something like this mos-Script

// Load your Modelica model
loadFile("bouncingBall.mo"); getErrorString();

// Get time informations for build process
setCommandLineOptions("-d=execstat"); getErrorString();

// Check and translate and build model
buildModel(bouncingBall); getErrorString();

// Simulate model
// with some example flags
system(realpath(".") + "/bouncingBall -lv=LOG_INIT,LOG_STATS_V -override stopTime=2.0", "bouncingBall.log"); getErrorString();

On Linux systems you don't need to save the output to some log file, but on Windows you do and then can read the file with OpenModelica.Scripting.readFile.

comment:4 by Martin Sjölund, 5 years ago

Resolution: worksforme
Status: newclosed

You can also do translateModel, which will not compile the code. Or use execstat in the scripting API to get timing (or access the timers directly like the library testing scripts do).

comment:5 by Francesco Casella, 5 years ago

Milestone: 2.0.01.16.0
Note: See TracTickets for help on using tickets.