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

조회 수: 9 (최근 30일)
Jagadeesh Korukonda
Jagadeesh Korukonda 2022년 12월 29일
편집: Torsten 2022년 12월 30일
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
Torsten
Torsten 2022년 12월 29일
편집: Torsten 2022년 12월 29일
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 2022년 12월 29일
편집: John D'Errico 2022년 12월 29일
I checked: ODE45 does not see the JPattern (or Jacobian) option.
The only solvers that use it are: ODE15s, ODE23s, ODE23t, ODE23tb, ODE15i.

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
John D'Errico 2022년 12월 29일
편집: John D'Errico 2022년 12월 29일
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
Jagadeesh Korukonda
Jagadeesh Korukonda 2022년 12월 30일
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 2022년 12월 30일
편집: Torsten 2022년 12월 30일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by