#5656 closed enhancement (worksforme)
Allow step-by-step translation and simulation with scripting API
Reported by: | 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:2 by , 5 years ago
Component: | *unknown* → Interactive Environment |
---|---|
Milestone: | Future → 2.0.0 |
comment:3 by , 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 , 5 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
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 , 5 years ago
Milestone: | 2.0.0 → 1.16.0 |
---|
OMEdit already does accurate timing measures, which are accessible using OMC. For instance in par. 1.2.5 of OpenModelicaUserGuide.pdf the following very detailed timing report is shown:
Unfortunately the same level of detail is not accessible from OMEdit GUI.
There should be also an open ticket asking for having a similar timing report also when simulations are run from OMEdit, but I cannot find it today.
I suppose that if these figures are made available (something that I strongly hope) to OMEdit GUI, and therefore reported at the end of every simulation, your timing requirements are satisfied.