At max, how many systems of odes can we solve at once?

9 views (last 30 days)
I need to solve the 5*n^2 system of odes at once.
I got a solution till n = 61 (18605 ODEs). I want to know the maximum number of ODEs that can be solved in Matlab because when I run the code for n = 91, it is showing out of memory error.
Currently, I'm using i7-6th gen, 32GB Ram with 4.2GHz computer.
Thanks
Jagadeesh
  2 Comments
Torsten
Torsten on 29 Dec 2022
Edited: Torsten on 29 Dec 2022
I think at the moment something in between 18605 and 41405 equations :-)
As you noted above, the answer does not depend on MATLAB, but on your available RAM and on how much time you are willing to wait to get a solution.
I don't know which integrator you use at the moment. If it's ODE15S or another stiff solver, try to prescribe the Jacobian matrix in sparse format or try to switch to a non-stiff integrator (e.g. ODE45).
John D'Errico
John D'Errico on 29 Dec 2022
Edited: John D'Errico on 29 Dec 2022
I checked: ODE45 does not see the JPattern (or Jacobian) option.
The only solvers that use it are: ODE15s, ODE23s, ODE23t, ODE23tb, ODE15i.

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 29 Dec 2022
Edited: John D'Errico on 29 Dec 2022
There is no maximum number. Or, there is, but it is purely dependent on how much RAM you have, and the time you are willing to spend.
Looking at your question, I see you have 5*n^2 equations. With n=61,
N = 5*61^2
N = 18605
N^2*8/1024^3
ans = 2.5790
this will involve creating and solving a system of equations where the matrices will take 2.5 gigabytes of RAM. And no matter what, you always need to accept that at least double that memory will be used, sometimes a factor of 3 is safer. So I would expect that 7.5 GB of RAM will be necessary to solve the smaller problem. But MATLAB and your OS will get in the way too. They use RAM too. So 10-12 GB would have been sufficient with no worries for the smaller problem.
But when n = 91,
N = 5*91^2
N = 41405
N^2*8/1024^3
ans = 12.7731
Now we see close to 13 gigabytes of RAM necessry, just to store the basic system of equations formed. Double or triple that, and now you run out of room when you have only 40GB. It may have been close. I'd bet you would have not seen a problem had you tried n = 81 with the memory you have. 91 was just a bit too much though.
If your system is sparse, then ABSOLUTELY you need to make the problem a sparse one. The problem internally involves solving linear systems of equations. But if the equations are full, the solve takes a huge amount of memory and time. This is where the problem arises. So forcing them to be sparse helps a great deal.
You can enforce that using the JPattern option. This allows you to specify the sparsity pattern of the Jacobian matrix. And if your problem is that large, then it must surely have a sparsity pattern.
Next, I checked the docs to see which ODE solvers allow you to specify the Jpattern option. They are ODE15s, ODE23s, ODE23t, ODE23tb, ODE15i.
ODE45 is NOT one of the solvers that uses the JPattern option.
Of course, the simple alternative is just more RAM, which is cheap these days.
  3 Comments
Jagadeesh Korukonda
Jagadeesh Korukonda on 30 Dec 2022
I'm working on DAE systems, so I've to use stiff-solver (either ode15s or ode23s). I'll check that Jpattern thing.
Thanks for your valuable time.
Torsten
Torsten on 30 Dec 2022
Edited: Torsten on 30 Dec 2022
I don't know how complicated your algebraic equations are. Often, they are only linear equations in the algebraic unknowns. In your case, you should check whether they can be solved "on the fly" (thus directly in the function where you supply the time derivatives) and if it is really necessary to include them in the ODE system.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!