Message Boards Message Boards

0
|
4664 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to speed up NDSolve when there are ~400k equations?

Posted 5 years ago

I'm trying to use NDSolve to solve a set of ~400k equations. The problem I met is: when I ran the evaluation, Mathematica (version 11.0) raised an error:

NDSolve::ntdv: Cannot solve to find an explicit formula for the derivatives. Consider using the option Method->{"EquationSimplification"->"Residual"}.

However, after I added the option Method->{"EquationSimplification"->"Residual"} into the evaluation, it took almost 24h to get the anwsers.

So, what does the option Method->{"EquationSimplification"->"Residual"} really means? Are there other ways I can get the equations solved correctly and quickly, maybe in 1h?

Are there any useful suggestions to speed up my evaluation? Thanks a lot!!!

POSTED BY: Lammond Wan
3 Replies
Posted 5 years ago

Thanks for your patience and kindness and detailed anwser. I'll figure it out step by step and then reply to you ^_^

POSTED BY: Lammond Wan

Also,

You asked about Method->{"EquationSimplification"->"Residual"}. Instead of solving the equations in the form y'[t] = f[y[t]], Mathematica uses a DAE solver on your unaltered equations. There are more details in the links above.

Regards,

Neil

POSTED BY: Neil Singer

There must be a problem with your setup. I ran your code with 400,000 equations:

In[10]:= {mSys, mBc} = PrepareEquations[tMin, tMax, 2000, 200];
AbsoluteTiming[ans = SolveEquations[mSys, mBc]; ans // Length]

Out[11]= {1200.81, 402201}

I have a fast machine but it took only 20 minutes. I am using Mathematica 12. I suspect your machine has a physical bottleneck (too little RAM, or some other issue)

Try stepping up to successively larger problems to see where the problem is. For example, When I run this:

{mSys, mBc} = PrepareEquations[tMin, tMax, 1600, 200];

It took 791 seconds for 321,000 equations.

Using

{mSys, mBc} = PrepareEquations[tMin, tMax, 800, 200];

It takes 270 seconds for 161,000 equations

My suggestion is to start with a smaller problem and try various solver options in the documentation here or advanced topics. and time the solve (as above). Find the settings that work best for your problem and then scale back up to the larger problems.

I hope this helps,

Regards,

Neil

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract