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
  • Index
  • » Users
  • » olivleno
  • » Profile

Posts

Posts

Dec-11-19 17:53:47
How to use the inline integration capabilities of OpenModelica?

In the announcement of OpenModelica 1.12 I found:


New methods for inline integration for continuous equations in clocked partitions, now covering: ExplicitEuler, ImplicitEuler, SemiImplicitEuler and ImplicitTrapezoid

I also found a compiler flag:
inlineSolver

From Dymola I know that one can choose a real time solver on the corresponding tab of the simulation settings.

In OMEdit I tried to add the following text to the translation flags edit field:

Code:

+inlineSolver

and have chosen the ImpEuler as a solver.
This didn't make any difference in the simulation.

Do I have to define a clocked system with Synchronous to make use of the mentioned inline integration features?

Thanks for your systematic testing to figure this out.

About your proposed solution:
Suppose one has setup his model to be initialized from a file.
Then he is running the simulation in OMEdit and want to fine tune the parameters by changing the values and running the simulation.

I'm not sure when and how OMEdit is using override to set values, but I'd assume that according to your proposal the user would get an error message, e.g. parameter xy is already overiden by a file.
Then the user would have to remove xy from the file until he has figured out a better value. Then he will have to restore previous condition of the file. As long he's only changing one parameter at a time this might work. But if he's performing a full blown parameter study or optimization then he's in trouble.

The proposed solution might be easy to implement but is for sure not user friendly.
Another question is, if it might collide with other parameter changing modules like OMOptim?

In the scenario above I'd propose that instead of an error, a warning is given saying: The modified parameter xy will overrule the value from the file abc.txt. It's easier for the user to remove an undesired modification, if he wants the file to dominate, than the other way round.

Hi,
seems like we're trying to do a similar thing and I'm also struggling to understand the proper syntax and usage of -overrideFile.

What I'm trying to do is:
- create a simple text file that contains all relevant parameters of my system model.
- Keep multiple versions of this to capture different parameter sets for the same system model.
- Run a simulation through OMPython referring to one of the files.

In a first test I tried to use OMEdit/Simulation Setup/Simulation Flags/Additional Simulation Flags edit field:

Code:


-overrideFile=C:\Repos\ompython_tutorial\Modelica\InputData\override_params.txt

The compiler completes without warning. The simulation error message is:

Code:


C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle/OMPythonTutorial.Examples.ElectricDriveAxle.exe -port=53851 -logFormat=xmltcp -override=startTime=0,stopTime=10,stepSize=0.02,tolerance=1e-06,solver=dassl,outputFormat=mat,variableFilter=.* -r=C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle/OMPythonTutorial.Examples.ElectricDriveAxle_res.mat -noEventEmit -iim=symbolic -w -lv=LOG_STATS -overrideFile=C:\Repos\ompython_tutorial\Modelica\InputData\override_params.txt -inputPath=C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle -outputPath=C:/Work/OMEdit/OMPythonTutorial.Examples.ElectricDriveAxle
Simulation process failed. Exited with code -1.

The txt file is empty, to avoid possible errors in the content of the file.
I also tried the following:

Code:


-overrideFile=C:/Repos/ompython_tutorial/Modelica/InputData/override_params.txt
-overrideFile="C:/Repos/ompython_tutorial/Modelica/InputData/override_params.txt"

leading to the same error message.

The simflags docusimflags documentation is saying:

Code:


-overrideFile=value or -overrideFile value

Is there a definition of the syntax of "value" that I have missed?

Would highly appreciate if someone could provide an example line of code for the case that "value" refers to a txt file in the file system. A sample line of the content of the file would also be helpful to avoid further problems.

A comment on how to generate this file from a model would also be helpful. Being able to write the return value of getParameters() in OMPython to a file would be fine, but maybe there is already another approach to this.

Hope someone can comment on this.

Nov-13-19 10:38:19
Using OMPython ModelicaSystem to generate an outfile that avoids double entries at the same time...

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?

Nov-13-19 08:50:51
Using OMPython ModelicaSystem to generate an outfile that avoids double entries at the same time...

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.

Nov-13-19 08:26:38
please help why I see this command line error

To me it looks as if there is an issue with the path name using "/" on windows?

Nov-13-19 08:19:11
Topic: OMPython
Changing (overriding) openmodelica parameters using OMPython
Category: Programming

In the Enhanced features section of OMPython
you find an example for setting parameters, if that's what you mean by overrride:

Code:

mod.setParameters("radius=14")

using the ModelicaSystem.

I have created a model and would like to compare the impact of a change in the model on the results in OMEdit.
In Dymola the varaibel explorer gives access to the results of all revious simulation runs. In OMEdit there is a root node only the last run.

How can I keep the results of the latest run to compare it with the new simulation run?

Mar-09-17 14:14:35
What kind of output does the compiler flag -m --modelicaOutput generate?

The OpenModelica Docu mentions that it is possible to "Enables valid modelica output for flat modelica."

This sounds interesting but is not very specific in terms what to expect as output.

After applying --modelicaOutput=true as simulation flag in OMEdit and simulating a model I expected to get the flattened model as .mo file of created in the OMEdit work directory.

Is there anything wrong with my statement, is this feature disabled or what else is this flag doing?

  • Index
  • » Users
  • » olivleno
  • » Profile
You are here: