Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

OMPython output equidistant results w/o events

OMPython output equidistant results w/o events

I'm using OMPython to plot, analyze and fit simulation data against measurements.
A common problem is that many functions expect a time series to be continuously increasing. Having two values for the same time instance as they occur at event can cause problems.
Now I found the simulation flag: -noEventEmit, which should do the job.
Unfortunately I got error messages trying the following:

Code:


mod.setSimulationOptions(["stopTime=3.0","tolerance=1e-04",simflags="-noEventEmit"])
File "<ipython-input-14-8d83ca9df2b1>", line 1
    mod.setSimulationOptions(["stopTime=3.0","tolerance=1e-04",simflags="-noEventEmit"])
                                                                       ^
SyntaxError: invalid syntax

and also this does not work as expected:

Code:

mod.simulate(resultfile="res.mat",simflags="-noEventEmit")

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-edca1ffb54de> in <module>
      1 #mod.setSimulationOptions(["stopTime=3.0","tolerance=1e-04",simflags="-noEventEmit"])
----> 2 mod.simulate(resultfile="initial.mat",simflags="-noEventEmit")

TypeError: simulate() got an unexpected keyword argument 'simflags'

Seems like I'm not calling the methods in the right way.
I could not find an example in the OMPython doc how to do this properly.

Re: OMPython output equidistant results w/o events

I had a quick look at the python code and we don't support this yet.

I guess one could add a new constructor for simulate that supports named argument "simflags" and all the other options we have in the OMC simulate command:
https://build.openmodelica.org/Document … ulate.html

I will see if Arun has time to fix this.

Re: OMPython output equidistant results w/o events

Yes, that would be an important enhancement. It's not very intuitive that the ModelicaSystem.simulate() behaves differently than described in the general API.

As a work around I tried to enable the corresponding flag in the OMEdit settings dialog and save these settings as annotation.
I expected that loading the model throughOMPython would also consider these annotations.
This does not seem to be the case as I getSolutions gives the same results.

Unfortunately this does not make either.

Is this another flaw of the ModelicaSystem?

Re: OMPython output equidistant results w/o events

__OpenModelica_simulationFlags is only read by OMEdit.

Adeel.

Edited by: adeas - Nov-13-19 10:47:08

Re: OMPython output equidistant results w/o events

@olivleno, and adrpo,

I have added this feature, This is now available in the Latest OMPython See . Update the latest OMPython and test it.

Example Usage:

Code:


from OMPython import ModelicaSystem
mod=ModelicaSystem("BouncingBall.mo" , "BouncingBall");
mod.simulate(simflags="-noEventEmit")

More runtime simulation flags can be added something like below

Code:


mod.simulate(simflags="-noEventEmit -noRestart -override=e=0.3,g=9.71")

Edited by: arupa54 - Dec-18-19 11:00:33
There are 0 guests and 0 other users also viewing this topic
You are here: