Speeding up my code for solving large number of ODE's

5 views (last 30 days)
I have a very large set of stiff ODE's (~0.15million) to be solved. The processing time is coming out to be very large. The system has to be solved in small time steps since peripheral calculations need to be performed in between. Thus the next iteration is dependent on the previous one and parallelization cannot be done. I've done pre-allocation of all matrices and arrays. Is there anything more that can be done?
  1 Comment
Jan
Jan on 22 Jun 2014
Without seeing any line of the code only rough suggestions are possible.

Sign in to comment.

Answers (1)

Jan
Jan on 22 Jun 2014
  1. Ask the profiler for the bottlenecks. If the function to be integrated takes a dominant part of the time, it is worth to be accelerated. If it contains very expensive operations like EXP in double precision, but the results depend only weakly on this function, you find cheaper versions with a reduced accuracy e.g. at NETLIB.org. If you integrate with a tolerance of 0.1, there is no reason to calculate EXP with 16 valid digits.
  2. Avoid repeated calculations. E.g. for solving many similar ODEs the determination of the initial stepsize can be avoided - if the ODE solver is capable to define it as input argument. Matlab's integrators can easily enhanced to support this feature.
  3. Use an appropriate solver. E.g. the non-stiff solver ODE45 cannot handle stiff ODEs efficiently.
  4. Be sure, that the function to be integrated does not contain discontinuities.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!