0

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?

asked Nov 24, 2020 at 4:25

1 Answer 1

1

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:


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.

answered Dec 4, 2020 at 18:40
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.