[Mathematica] NDsolve eating stacks of RAM

In summary, when attempting to perform n-body simulations in Mathematica, it is important to keep in mind that it is not the ideal software for this type of computation. Consider using specialized software or programming languages such as C++ or Fortran for better performance. If using Mathematica, make sure you are using the latest version, utilize parallel computing, and optimize your code for efficiency. Seeking assistance from the Mathematica community may also be beneficial.
  • #1
FunkyDwarf
489
0
Hey guys,

I know i really shouldn't be doing n-body simulations in mathematica and I'm trying to cobble together some c++ stuff but in the meantime...

i have a system of say 2000 non-interacting particles in a central potential and am solving for their orbits via the Euler-Lagrange equation, ie generating a table of euler-lagrange equations for each particle (they have different initial positions) and then solving using NDsolve. Its all fine and dandy when the mass of the central potential is within about 1000 of the mass of the incoming particle but as soon as i make that difference larger (which i need to) the RAM usage blows out and it keeps giving kernel errors. I've taken into account (or at least tried to) the fact that in a larger potential they will move faster and so the algorithm needs more steps and also I've reduced the time interval but it still blows up in my face and its quite irritiating, any ideas?

Cheers
-G
 
Physics news on Phys.org
  • #2
reetings,

I would advise against using Mathematica for n-body simulations as it is not designed for this type of computation and can lead to errors and memory issues, as you have experienced. It would be best to use a specialized software or programming language such as C++ or Fortran, which are better suited for this type of simulation.

However, if you are determined to use Mathematica, there are a few things you can try to improve the performance and reduce the memory usage. First, make sure you are using the latest version of Mathematica as it may have improvements for handling large computations.

Next, consider using parallel computing techniques to distribute the computation among multiple processors. This can significantly speed up the simulation and reduce the memory usage.

You may also want to optimize your code by using more efficient algorithms and data structures. This can help reduce the number of steps and memory needed for the simulation.

If these suggestions do not help, I would recommend reaching out to the Mathematica community for further assistance. They may have additional tips and insights on how to improve the performance of your n-body simulation. Best of luck with your research!
 
  • #3
ary

I understand the frustration of dealing with technical issues while trying to conduct research. In this case, it seems like the issue is with the limitations of Mathematica when it comes to simulating large numbers of particles in a central potential. While it may be possible to tweak the algorithm and reduce the time interval, there may be a limit to how much can be done within the confines of Mathematica's capabilities.

One suggestion would be to consider using a different software or programming language that is better suited for n-body simulations. C++ can be a good choice, as it allows for more control and optimization compared to Mathematica. However, it may require more time and effort to set up and implement the simulation.

Another option would be to consider using a supercomputer or high-performance computing cluster, which can handle large simulations more efficiently. This would require access to such resources and some knowledge of parallel computing.

In any case, it is important to carefully consider the limitations and capabilities of the tools being used for research, and to be open to exploring alternative solutions when faced with technical challenges.
 

Related to [Mathematica] NDsolve eating stacks of RAM

1. Why does NDsolve in Mathematica use so much RAM when solving differential equations?

The NDsolve function in Mathematica uses a large amount of RAM because it stores all of the intermediate steps and solutions of the differential equations being solved. This allows for accurate and efficient numerical solutions, but can lead to high RAM usage for complex problems.

2. How can I reduce the amount of RAM used by NDsolve in Mathematica?

There are a few ways to reduce the amount of RAM used by NDsolve in Mathematica. One way is to use a higher order method, such as the "Method->"LSODA"" option, which can reduce the number of intermediate steps needed. Another option is to use the "Method->"ExplicitRungeKutta"" option, which uses less memory but may be less accurate. Additionally, you can try breaking up the problem into smaller pieces or using a more efficient coding approach.

3. My computer crashes when I try to use NDsolve in Mathematica. What can I do?

If you are experiencing crashes when using NDsolve in Mathematica, it is likely due to the large amount of RAM being used. You can try using the above methods to reduce RAM usage, or consider using a computer with more RAM or a GPU that can handle the computational load.

4. Can I parallelize NDsolve in Mathematica to reduce its RAM usage?

Yes, NDsolve in Mathematica can be parallelized to distribute the computational load among multiple processors, which can help reduce RAM usage. This can be done by using the "Method->"Parallel" option or by manually splitting up the problem and using the Parallelize function.

5. Is there a way to monitor the RAM usage of NDsolve in Mathematica?

Yes, you can use the MemoryConstrained function in Mathematica to set a limit on the amount of RAM used by NDsolve. You can also use the MemoryInUse function to monitor the current RAM usage during the computation. Additionally, some operating systems have built-in tools for monitoring RAM usage.

Similar threads

Replies
1
Views
891
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • Advanced Physics Homework Help
Replies
1
Views
2K
  • Special and General Relativity
Replies
27
Views
3K
  • Special and General Relativity
Replies
2
Views
1K
  • Advanced Physics Homework Help
Replies
19
Views
2K
Replies
7
Views
1K
  • Advanced Physics Homework Help
Replies
1
Views
5K
Back
Top