THREE_BODY_SIMULATION
Planar Three Body Problem Simulation


THREE_BODY_SIMULATION is a FORTRAN77 program which simulates the solution of the planar three body problem.

Three bodies, regarded as point masses, are constrained to lie in a plane. The masses of each body are given, as are the positions and velocities at a starting time T = 0. The bodies move in accordance with the gravitational force between them.

The force exerted on the 0-th body by the 1st body can be written:

        F = - m0 m1 ( p0 - p1 ) / |p0 - p1|^3
      
assuming that units have been normalized to that the gravitational coefficient is 1. Newton's laws of motion can be written:
  
        m0 p0'' = - m0 m1 ( p0 - p1 ) / |p0 - p1|^3 
                  - m0 m2 ( p0 - p2 ) / |p0 - p2|^3
  
        m1 p1'' = - m1 m0 ( p1 - p0 ) / |p1 - p0|^3 
                  - m1 m2 ( p1 - p2 ) / |p1 - p2|^3
  
        m2 p2'' = - m2 m0 ( p2 - p0 ) / |p2 - p0|^3 
                  - m2 m1 ( p2 - p1 ) / |p2 - p1|^3
      

Letting

        y1 = p0(x)
        y2 = p0(y)
        y3 = p0'(x)
        y4 = p0'(y)
      
and using similar definitions for p1 and p2, the 3 second order vector equations can be rewritten as 12 first order equations. In particular, the first four are:
        y1' = y3
        y2' = y4
        y3' = - m1 ( y1 - y5  ) / |(y1,y2) - (y5,y6) |^3 
              - m2 ( y1 - y9  ) / |(y1,y2) - (y9,y10)|^3
        y4' = - m1 ( y2 - y6  ) / |(y1,y2) - (y5,y6) |^3 
              - m2 ( y2 - y10 ) / |(y1,y2) - (y9,y10)|^3
      
and so on. This first order system can be integrated by a standard ODE solver.

Note that when any two bodies come close together, the solution changes very rapidly, and very small steps must be taken by the ODE solver. For this system, the first near collision occurs around T=15.8299, and the results produced by the ODE solver will not be very accurate after that point.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

THREE_BODY_SIMULATION is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

BROWNIAN_MOTION_SIMULATION, a FORTRAN77 program which simulates Brownian motion in an M-dimensional region.

DUEL_SIMULATION, a FORTRAN77 program which simulates N repetitions of a duel between two players, each of whom has a known firing accuracy.

FAIR_DICE_SIMULATION, a FORTRAN77 program which simulates N tosses of 2 dice, making a histogram of the results.

HIGH_CARD_SIMULATION, a FORTRAN77 program which simulates a situation in which you see the cards in a deck one by one, and must select the one you think is the highest and stop; the program uses GNUPLOT for graphics.

ISING_2D_SIMULATION, a FORTRAN77 program which carries out a Monte Carlo simulation of an Ising model. a 2D array of positive and negative charges, each of which is likely to flip to be in agreement with neighbors.

POISSON_SIMULATION, a FORTRAN77 library which simulates a Poisson process in which events randomly occur with an average waiting time of Lambda.

REACTOR_SIMULATION, a FORTRAN77 program which is a simple Monte Carlo simulation of the shielding effect of a slab of a certain thickness in front of a neutron source. This program was provided as an example with the book "Numerical Methods and Software."

RKF45, a FORTRAN77 library which implements the Runge-Kutta-Fehlberg ODE solver.

Author:

Original MATLAB version by Dominik Gruntz, Joerg Waldvogel; FORTRAN77 version by John Burkardt.

Reference:

  1. Dominik Gruntz, Joerg Waldvogel,
    "Orbits in the Planar Three-Body Problem",
    Walter Gander, Jiri Hrebicek,
    Solving Problems in Scientific Computing using Maple and Matlab,
    Springer, 1997,
    ISBN: 3-540-61793-0,
    LC: Q183.9.G36.

Source Code:

List of Routines:

SIMPLE_RKF45 simulates the problem by calling the ODE integrator RKF45. This approach loses accuracy when the bodies come close to colliding, which is likely to happen often.

You can go up one level to the FORTRAN77 source codes.


Last modified on 07 October 2012.