cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Odesolve vs. Rkadapt

JohnRudnicki
15-Moonstone

Odesolve vs. Rkadapt

Curious minds want to know: I am solving a simple (linear) ode for a number of various parameters. When I use Odesolve, passing the various parameters, it runs relatively slowly compared with using Rkadapt passing the parameters via the initial conditions (since I have a lot of cases to look at, using Rkadapt seems the better choice). Why is this? Is it typical?

ACCEPTED SOLUTION

Accepted Solutions

John Rudnicki wrote:

Curious minds want to know: I am solving a simple (linear) ode for a number of various parameters. When I use Odesolve, passing the various parameters, it runs relatively slowly compared with using Rkadapt passing the parameters via the initial conditions (since I have a lot of cases to look at, using Rkadapt seems the better choice). Why is this? Is it typical?

The way you use the solve block function you force the solve block to be evaluated for every single point which is plotted and that are quite a few.

If you precalculate the odesolve function just once with the parameters needed and use this I guess its equally fast (apart from the effort the odesolve solution has to put into interpolating).

See attached.

View solution in original post

3 REPLIES 3

John Rudnicki wrote:

Curious minds want to know: I am solving a simple (linear) ode for a number of various parameters. When I use Odesolve, passing the various parameters, it runs relatively slowly compared with using Rkadapt passing the parameters via the initial conditions (since I have a lot of cases to look at, using Rkadapt seems the better choice). Why is this? Is it typical?

The way you use the solve block function you force the solve block to be evaluated for every single point which is plotted and that are quite a few.

If you precalculate the odesolve function just once with the parameters needed and use this I guess its equally fast (apart from the effort the odesolve solution has to put into interpolating).

See attached.

Thanks. That makes sense. And thanks for your help on various other problems and questions. Happy New Year.

John Rudnicki wrote:

Thanks. That makes sense. And thanks for your help on various other problems and questions. Happy New Year.

You are welcome!

The remarkable part is the difference in results, even if you chose "Adaptive" for odesolve. At max more than 2%. Not sure why.

Happy New Year! (6 hours to go 😉

1.png

Announcements

Top Tags