two_body_ode
Planar Two Body Problem Simulation


two_body_ode, an Octave code which simulates the solution of the planar two body problem.

Two 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. One body is assume to be much more massive than the other. Therefore, the common motion of the two bodies about their center of mass can be approximated by assuming that the large body remains fixed.

Under these assumptions, Newton's equations for (x(t),y(t)), the positition of the lighter body with respect to the heavy body at (0,0), can be written as:

        r(t) = sqrt ( x(t)^2 + y(t)^2 )
        x''(t) = - x(t) / r^3
        y''(t) = - y(t) / r^3
      

These two second order equations can be rewritten as a system of four first order equations using the variable u = [ x(t), x'(t), y(t), y'(t) ], resulting in the equations:

        r = sqrt ( u(1)^2 + u(3)^2 )
        u'(1) =   u(2)
        u'(2) = - u(1) / r^3
        u'(3) =   u(4)
        u'(4) = - u(3) / r^3
      

By specifying some initial condition for u, the system can then be integrated in time using a standard ODE solver.

Licensing:

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

Languages:

two_body_ode is available in a FORTRAN90 version and a MATLAB version and an Octave version.

Related Data and codes:

allen_cahn_ode, an Octave code which sets up and solves the 1D Allen-Cahn reaction-diffusion ordinary differential equation (ODE).

arenstorf_ode, an Octave code which describes an ordinary differential equation (ODE) which defines a stable periodic orbit of a spacecraft around the Earth and the Moon.

biochemical_linear_ode, an Octave code which defines a linear biochemical ordinary differential equation (ODE).

biochemical_nonlinear_ode, an Octave code which defines a nonlinear biochemical ordinary differential equation (ODE).

brusselator_ode, an Octave code which defines the Brusselator ordinary differential equation (ODE) system.

double_pendulum_ode, an Octave code which defines the double pendulum ordinary differential equation (ODE).

flame_ode, an Octave code which considers an ordinary differential equation (ODE) which models the growth of a ball of flame in a combustion process.

henon_heiles_ode, an Octave code which solves the Henon-Heiles system of ordinary differential equations (ODEs) which model the motion of a star around the galactic center.

humps_ode, an Octave code which solves an ordinary differential equation (ODE) whose solution is a double hump curve.

kepler_ode_test an Octave code which considers an ordinary differential equation (ODE) which models a Kepler two-body gravitational problem.

kepler_perturbed_ode_test an Octave code which considers an ordinary differential equation (ODE) which models a perturbed Kepler two-body gravitational problem.

lorenz_ode, an Octave code which approximates solutions to the Lorenz system, creating output files that can be displayed by gnuplot.

oscillator_ode, an Octave code which defines the highly oscillatory ordinary differential equation (ODE).

pendulum_nonlinear_ode, an Octave code which sets up the ordinary differential equations (ODEs) that represent a nonlinear model ofthe behavior of a pendulum of length L under a gravitational force of strength G.

pendulum_ode, an Octave code which sets up the ordinary differential equations (ODEs) that represent a linear model ofthe behavior of a pendulum of length L under a gravitational force of strength G.

predator_prey_ode, an Octave code which solves a pair of predator prey ordinary differential equations (ODEs).

quasiperiodic_ode, an Octave code which sets up a system of ordinary differential equations (ODEs) for a problem with a quasiperiodic solution.

rk12, an Octave code which implements Runge-Kutta ODE solvers of orders 1 and 2.

rk23, an Octave code which implements Runge-Kutta ODE solvers of orders 2 and 3.

rk34, an Octave code which implements Runge-Kutta ODE solvers of orders 3 and 4.

rk45, an Octave code which implements Runge-Kutta ODE solvers of orders 4 and 5.

rkf45, an Octave code which implements the Runge-Kutta-Fehlberg ODE solver.

roessler_ode, an Octave code which defines the right hand side of the Roessler ODE system, which exhibits chaotic behavior.

rubber_band_ode, an Octave code which defines and solves a set of ordinary differential equations (ODEs) describing a mass suspended by a spring and rubber band, which can exhibit chaotic behavior.

sir_ode, an Octave code which sets up the ordinary differential equations (ODEs) which simulate the spread of a disease using the Susceptible/Infected/Recovered (SIR) model.

sphere_ode, an Octave code which sets up the ordinary differential equations (ODEs) which model motion on the surface of a sphere.

spring_ode, an Octave code which shows how line printer graphics can be used to make a crude illustration of a solution of the ordinary differential equation (ODE) that describes the motion of a weight attached to a spring.

spring_ode2, an Octave code which shows how gnuplot graphics can be used to illustrate a solution of the ordinary differential equation (ODE) that describes the motion of a weight attached to a spring.

stiff_ode, an Octave code which considers an ordinary differential equation (ODE) which is an example of a stiff ODE.

string_ode, an Octave code which simulates the behavior of a vibrating string by solving the corresponding initial boundary value problem (IBVP).

test_ode, an Octave code which defines ordinary differential equations (ODE) test problems.

three_body_ode, an Octave code which simulates the behavior of three planets, constrained to lie in a plane, and moving under the influence of gravity, by Walter Gander and Jiri Hrebicek.

two_body_ode_test

zombie_ode, an Octave code which sets up a system of ordinary differential equations (ODE)s for a generalized SIR infection model to simulate a zombie attack, developed by Philip Munz.

Reference:

  1. Charles VanLoan,
    Introduction to Scientific Computing,
    Prentice Hall, 1997,
    ISBN: 0-13-125444-8,
    LC: QA76.9.M35V375.

Source Code:


Last modified on 04 August 2020.