Solving the N Body Problem with RK4: Verification & Convergence

  • Thread starter DivergentSpectrum
  • Start date
  • Tags
    Body
In summary, the speaker discusses their use of a force field trajectory calculator to solve the famous n body problem. They used the rk4 method and verified their solution by calculating the work done and kinetic energy of each particle. However, they noticed some strange behavior in systems with more dynamic interactions and questioned how to calculate the total conserved energy of the system. The speaker also shares pictures of their simulations and notes that the center of mass will keep moving if the total initial momentum is not zero. They suggest setting the initial velocity of one body to be the opposite of the other to achieve a momentum of zero. They also mention the possibility of divergences in the numerical method.
  • #1
DivergentSpectrum
149
15
the force field trajectory calculator worked pretty good, so i decided to step it up and solve the famous n body problem.

i used rk4 to solve it, and to verify my solution i calculate the work done on each particle and the kinetic energy of each particle at the beginning and end.
it appears to converge pretty nicely when one object is very massive compared to the other, but i notice some strange behavior otherwise. for one, i always thought a 2 body system would be two elipses sharing a focus (barycenter), but instead i get all kinds of different shapes.
also the energy diverges in more "dynamic" systems.
How does one calculate the "total conserved energy" of a system? (or analogous conserved quantities such as angular momentum) i had been just using the work energy theorem, (line integral of force equals change in kinetic energy) but I am not sure if that still holds when the force depends on the location of an object, that is also experiencing a force due to the same object.
do these pictures qualitatively look like a 2 body system?

edit: in each of these the blue particles initial velocity is 0, and the black particles initial velocity is non zero. the step size is the same, but the mass of the black particle is different. the more "chaotic" looking patterns have a larger mass set for the black particle(up to where the masses are equal)
 

Attachments

  • pic1.jpg
    pic1.jpg
    29.6 KB · Views: 400
  • converges.jpg
    converges.jpg
    20.3 KB · Views: 415
  • diverges.jpg
    diverges.jpg
    34.9 KB · Views: 387
  • equalmass.jpg
    equalmass.jpg
    19.7 KB · Views: 387
Last edited:
Physics news on Phys.org
  • #2
bluntwcrackrap said:
edit: in each of these the blue particles initial velocity is 0, and the black particles initial velocity is non zero. the step size is the same, but the mass of the black particle is different. the more "chaotic" looking patterns have a larger mass set for the black particle(up to where the masses are equal)

If the total initial momentum isn't zero, the center of mass will keep moving, and you get spirals instead of ellipses. You'll need to set [itex] v_1 = - \frac {m_2 }{m_1} v_2 [/itex] with 2 bodies to get a momentum of 0.
 
  • Like
Likes 1 person
  • #3
thanks, i had a feeling the system as a whole might be undergoing some kind of translational motion. as far as the divergences go i might just be expecting too much from a numerical method.
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    22.8 KB · Views: 354

1. What is an N body solver?

An N body solver is a computational algorithm used to simulate the motion and interactions of a system with multiple bodies. These bodies can be planets, stars, particles, or any other objects with mass and velocity.

2. How does an N body solver work?

An N body solver uses Newton's laws of motion, specifically the law of universal gravitation, to calculate the forces acting on each body in the system. It then uses numerical integration techniques to update the positions and velocities of the bodies over time, creating a simulation of their movements.

3. What are the applications of an N body solver?

An N body solver can be used in various fields such as astrophysics, cosmology, and engineering. It can be used to study the dynamics of celestial bodies like planets and galaxies, or to simulate the behavior of particles in a fluid or gas. It can also be used to model the motion of objects in space missions or spacecraft trajectories.

4. Are there different types of N body solvers?

Yes, there are different types of N body solvers, such as direct, hierarchical, and tree-based methods. Direct methods calculate the forces between every pair of bodies, while hierarchical and tree-based methods use approximations to reduce the computation time. There are also specialized N body solvers for specific types of systems, such as molecular dynamics simulations.

5. What are the limitations of an N body solver?

An N body solver can face challenges when dealing with large systems with a high number of bodies, as the computation time and memory requirements increase significantly. It also assumes that the bodies are point masses and do not take into account factors like collisions or external forces. Additionally, the accuracy of the simulation may decrease over time due to numerical errors and approximations made by the algorithm.

Similar threads

  • Introductory Physics Homework Help
Replies
8
Views
240
Replies
2
Views
10K
Replies
16
Views
1K
  • Classical Physics
Replies
2
Views
1K
Replies
30
Views
2K
Replies
6
Views
2K
  • Classical Physics
Replies
12
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
1K
Replies
4
Views
1K
Replies
30
Views
2K
Back
Top