Due date: 1/28/2019
To prepare for your first code, you might want to download and modify a simple numerical program. The source code is available in either C (leapint.c) or gfortran (leapint.f). To compile the program, try either of the commands
% gcc -o leapint leapint.cdepending on which language you are using and after you located the path to the compilers. Sometimes the gcc requires the -lm linking of the math libraries during compilation: gcc -lm -o leapint leapint.c. To run the compiled program, give the command
% gfortran -o leapint leapint.f
% leapint
The output consists of four columns, listing (1) time, (2) point index, (3) position x, and (4) velocity v. Running the program as supplied yields the trajectory of a point starting at (X0,V0) = (1,0) in the phase flow defined by the `linear pendulum' or harmonic oscillator, a(x) = -x. The total number of steps taken, number of steps between outputs, and timestep used are determined by the parameters mstep, nout, dt, respectively; these parameters are set in the main procedure of the program.
(a) Modify the statements which set up initial conditions in the main program to produce trajectories starting from the points (2.5,0) and (3.5,0). On the (x,v) plane, plot these trajectories (gnuplot, or your favorite plotting platform) together with the one starting from (1,0).
(b) Replace the linear pendulum in the accel routine with the "inverse linear pendulum", a(x) = x, and again plot trajectories starting from the points (1,0), (2.5,0), & (3.5,0).
(c) Plot trajectories starting from the same three points for the "nonlinear pendulum", a(x) = - sin(x).
Make two-dimensional (x,v) plots and three-dimensional (x,v,t) plots for (a), (b), and (c).
(a) Write leapfrog code (or some other equivalent finite step integrator) for Mercury,Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto, orbiting around the Sun. Put the Sun at the origin of your coordinate system. Do some web based research for setting up the initial conditions to have realistic scales of the orbits. Ignore the interactions of the planets in the time integration and keep the Sun fixed at the origin.
(b) Make a composite plot of all the planetary orbits you calculated.
(a) Compare your numerically integrated orbits to the analytic form of the elliptic orbits. Investigate the error behavior over several revolutions of the planets. Do you detect a deterioration with each revolution?
(b) For each planet, plot the numerically integrated orbit and the analytic elliptic orbit on the same plot. Each planet will have its own plot.
(c) Do a simple animation of the earth motion in gnuplot or some other plotting method of your choice.
Problem 4 (for Physics 241 only)
Prove the exact conservation of angular momentum of the discretized leapfrog Verlet algorithm on Kepler orbits. Generalize the proof to general spherically symmetric potetials.
Problem 5 (for Physics 141/241)
Problem 6 (for Physics 241 only)
Kepler error illustrations pdf file