Would it be more efficient to switch to a different ODE solver?

Warning, I'm not certain if this question belongs on here or Math Stack Exchange. It's primarily a question of performance, but it heavily involves a differential equation solver.

Anyway, in Matlab, I am currently using the following code syntax to solve a differential equation:

f0 = [tot;zeros(size-1,1)];
options=odeset('RelTol',1e-7, 'AbsTol', 1e-10);
[T,S] = ode15s(@myfunc, [t0,tF], f0, options, k1, k2, k3, n, size, r);
%Rest of code, including a function myfunc

Now, my issue is as follows: the "size" variable needs to be set to numbers on the order of 10000 for my system of differential equations. In addition, I'm currently using ODE15s primarily because I was reusing code: I recently found that it's designed for stiff differential equations, and the differential equations I'm using have fairly stable gross behavior regardless of step size. Right now, it takes my code over a week (close to two, in fact) to run on a fairly quickly processing machine.

So my question is: would it be faster for me to switch to a nonstiff ODE solver like ODE45 or ODE23? All the Googling I did on this subject gave me was that, if my equation was stiff, then it would be faster to use a stiff differential equation solver.

Upvotes: 1

Views: 242

Answers (1)

crbah
crbah

Reputation: 336

Exactly ode45!

It's because ode45 uses 4th orderrunge-kutta method (which is explicit), however ode15s uses Gear's method (which is implicit). That's why if your system is not stiff you would better choose ode45.

And for ode23 (which is bogacki shampine method), for sure it is better than ode15s, however still choose ode45 as matlab also suggest this way.

Upvotes: 1

Related Questions