Simulation of Newtonian gravitation for a two-body system. The simulation panel is a visualisation of the motion of the two bodies, the larger one (red) of mass M and the smaller one (blue) of mass m. The first graph plots energy as a function of time. The second graph plots analytic expressions of energy as a function of radial position.
Vary the ratio of masses M/m. You can also vary the initial radial velocity of the smaller (blue) mass. The simulation automatically sets the initial conditions for the larger (red) mass such that the centre of mass (white) is at the centre of the panel and is stationary. The initial tangential velocities are also chosen automatically to default to a circular orbit when the initial radial velocity is zero.
In the first graph, the red line is the kinetic energy of the larger (red) mass, while the blue line is the kinetic energy of the smaller (blue) mass. The black line is the gravitational potential energy of their interaction, while the dashed line is the total energy (if shown). These are calculated as the simulation is running.
In the second graph, the analytic form for the effective radial potential is initially shown, as a function of the (radial) distance of the smaller mass from the centre of mass (origin). An exact expression involving m/M is used. The total energy is shown as a dashed line. The radial potential is calculated and traced when the simulation is running. U_{eff} is obtained by subtracting the contribution to the kinetic energies of the radial velocities, from the total energy of the system.