Solving the N Body Problem with RK4: Verification & Convergence

  • Context: Graduate 
  • Thread starter Thread starter DivergentSpectrum
  • Start date Start date
  • Tags Tags
    Body
Click For Summary
SUMMARY

The forum discussion focuses on solving the N Body Problem using the Runge-Kutta 4th order (RK4) method. The user reports successful convergence when one object is significantly more massive than the others, but encounters unexpected behaviors in two-body systems, such as non-elliptical trajectories and energy divergence in dynamic systems. The user seeks clarification on calculating total conserved energy and angular momentum, questioning the applicability of the work-energy theorem in scenarios with location-dependent forces.

PREREQUISITES
  • Understanding of the N Body Problem in classical mechanics
  • Familiarity with the Runge-Kutta 4th order (RK4) numerical method
  • Knowledge of conservation laws, specifically energy and momentum
  • Basic principles of force fields and trajectory calculations
NEXT STEPS
  • Research methods for calculating total conserved energy in multi-body systems
  • Explore the implications of momentum conservation in two-body systems
  • Study the effects of varying mass ratios on trajectory shapes in N Body simulations
  • Investigate numerical stability and error analysis in RK4 implementations
USEFUL FOR

Physicists, computational scientists, and anyone interested in numerical simulations of dynamical systems, particularly those studying celestial mechanics and trajectory analysis.

DivergentSpectrum
Messages
149
Reaction score
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: 452
  • converges.jpg
    converges.jpg
    20.3 KB · Views: 467
  • diverges.jpg
    diverges.jpg
    34.9 KB · Views: 440
  • equalmass.jpg
    equalmass.jpg
    19.7 KB · Views: 455
Last edited:
Physics news on Phys.org
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 v_1 = - \frac {m_2 }{m_1} v_2 with 2 bodies to get a momentum of 0.
 
  • Like
Likes   Reactions: 1 person
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: 427

Similar threads

  • · Replies 65 ·
3
Replies
65
Views
8K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
10K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
1
Views
1K
  • · Replies 30 ·
2
Replies
30
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 54 ·
2
Replies
54
Views
6K