At max, how many systems of odes can we solve at once?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jagadeesh Korukonda
el 29 de Dic. de 2022
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 comentarios
Torsten
el 29 de Dic. de 2022
Editada: Torsten
el 29 de Dic. de 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
el 29 de Dic. de 2022
Editada: John D'Errico
el 29 de Dic. de 2022
I checked: ODE45 does not see the JPattern (or Jacobian) option.
The only solvers that use it are: ODE15s, ODE23s, ODE23t, ODE23tb, ODE15i.
Respuesta aceptada
John D'Errico
el 29 de Dic. de 2022
Editada: John D'Errico
el 29 de Dic. de 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^2*8/1024^3
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^2*8/1024^3
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 comentarios
Torsten
el 30 de Dic. de 2022
Editada: Torsten
el 30 de Dic. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!