Fast ODE45 with for-loops
Show older comments
Hello,
I have a coupled first order ODE to solve of the form
dy = f(t, x) dx = d(f, x)
which depends on a common parameter which I have to solve for over some range. I can solve the system using ODE45 and a for loops which increments the parameter of interest at each loop, however, this is very slow. Can I avoid solving this problem in loops? Or what is best practice with problems of this type.
Accepted Answer
More Answers (1)
Paul
on 24 Aug 2013
0 votes
1 Comment
Marc
on 25 Aug 2013
I have compared limex in fortran with ode15s and cvode from Sundials in Matlab and find Matlab to be close to fortran. I did not try to optimize the fortran code, simply tested as is.
You already have available what you are asking. cvode and ida codes, part of the Sundials package have already been "mexed" and packaged for Matlab. This is from Lawrence Livermore National lab. Cvode has some nice features and requires you to format things a bit differently. Not sure if you'll get a speed up.
Limex, lsode, cvode, ida are codes I have compared to ode45 and ode15s over the years and found the Matlab codes to hold up.
So, I think you are stuck from the integrator standpoint.
My only comment would be try running your parameter maybe 5 times, say at the min, max and three intermediate points to see if you can minimize that 25,000 runs. Maybe there is something special about your system, but I tend to believe if you pick say 32 points and randomize the runs, you should get a good enough picture of what is going on.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!