In Open Modelica, in the settings of IDA solver, we can define the initial and maximum time step as well. In a simulation, I have set these parameters, but after simulation and checking the solutions points, I found the IDA has not bounded to the defined maximum time step. is there anyone to advise me why the parameter did not work?
1 Answers
You can check which maximum allowed step size your simulation executable is using by adding -lv=LOG_SOLVER
to the simulation flags and search in the log for maximum step size
. If its not there IDA will be use with the default setting.
To change the maximum step size for IDA you can't use -maxstepsize, it's not implemented for IDA. I had to check the source code to find out how to do it correctly. It's possible but way to complicated.
You need to:
- Disable equidistant time step with -noEquidistantTimeGrid
- Set a value to -noEquidistantOutputTime=value
So the following example script will use IDA with a maximum stepsize of π to simulate a pendulum from the MSL:
loadModel(Modelica); getErrorString();
setCommandLineOptions("-d=newInst"); getErrorString();
simulate(Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum, method="ida", simflags="-noEquidistantOutputTime=3.14159265358979 -noEquidistantTimeGrid -lv=LOG_SOLVER"); getErrorString();
Save this script to runTest.mos
and run it with omc $omc runTest.mos &> some.log
.
Check some.log
and you will find
LOG_SOLVER | info | recognized solver: ida
LOG_SOLVER | info | Initializing IDA DAE Solver
LOG_SOLVER | info | ## IDA ## Initializing solver of size 2 .
| | | | | The relative tolerance is 1e-06. Following absolute tolerances are used for the states:
| | | | | IDA uses internal root finding method YES
| | | | | Maximum integration order 5
| | | | | use equidistant time grid NO
| | | | | maximum step size 3.14159
| | | | | as the output frequency control is used: 0
| | | | | as the output frequency time step control is used: 3.141593
| | | | | IDA linear solver method selected ida use sparse direct solver KLU. (default)
| | | | | Jacobian is calculated by \"Colored numerical Jacobian, which is default for dassl and ida. With option -idaLS=klu a sparse matrix is used.\"
| | | | | initial step size is set automatically.
You can do the same in OMedit with the simflags -noEquidistantOutputTime=3.14159265358979 -noEquidistantTimeGrid
added to your simulation.
Note: Of course this is ridiculous and the documentation of -maxstepsize is wrong:
Value specifies maximum absolute step size, used by the methods: dassl, ida.
Please open a ticket about this on the OpenModelica GitHub so it get's fixed.

- 761
- 3
- 14