How to use ode45 efficiently on a large input vector
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I am using ode45 to solve a set of coupled ODEs. I need to solve them for >2M points. This is taking a long time (~45 minutes). I was wondering if I could solve the problem faster by dividing my long input vector into many smaller vectors (i.e. of length on the order of 1000) and then "stitching" the results of the ode45 solution together. I am aware that I would need to iteratively update initial conditions as I loop over subsections. However, in principle, would reducing the input vector size and running over many of those result in a speed up?
Alternatively, do you have any other advice on how to speed up the evaluation of ode45 over many points?
3 Commenti
Bjorn Gustavsson
il 24 Ott 2022
To me it seems as if your problem is in that your ode-system have discontinuities whenever you step from one element in Tp to the next, i.e. whenever floor(t/t_step) ticks up. The ode-integrating functions dont like that, they expect the RHS to be continouos and even smooth. Your best approach would be to integrate it step-wise for time-periods with constant Tp.
HTH
Risposte (1)
Bjorn Gustavsson
il 21 Ott 2022
If the ODE-system you're trying to solve is something like a set of independend equations of motion that only couple "pairwise" ( and ) and there are no coupling between the eqs of motion for different particles then it might very well be so that the ode-integration needs to take very short time-steps during one period to get sufficient accuracy for particle i and short time-steps during some other period for particle j. When you integrate all EQs simultaneously short time-steps will be taken for all of the particles every time short time-steps is required for any particle. For this type of problem it can be faster to integrate the equations of motion particle-by-particle. However if all the ODEs couple then this is not a viable route.
HTH
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!