Docsity

Problem Set 5 | Computational Astrophysics | ASTR 615, Assignments of Astronomy

Toggle sidebar
bg1
ASTR615 Fall 2007 Problem Set #5
Due November 13, 2007
Write a program to integrate any number of coupled differential equations using the Euler
method, fourth-order Runge-Kutta, and Leapfrog (note: Leapfrog only applies to special
cases). You will be using this program in a future assignment, so make sure it’s well docu-
mented. Use double precision throughout.
1. Use your program to solve the following differential equation for x(t):
d2x
dt2+x= 0,
with initial conditions x(0) = 1, ˙x(0) = 0. Note the analytical solution is x= cos(t).
(a) Integrate the equation for 0 ≤t≤15 using each of the methods, and stepsizes of
1, 0.3, 0.1, 0.03, and 0.01.
(b) Plot your integration results against the analytical solution for each case. (Hint :
do all the Euler plots on one page, with one plot per timestep; then all the
Leapfrog plots on another page, etc.) Comment on the results.
(c) Plot log |xnumerical(15) −xexact(15)|as a function of log(stepsize) in each case and
comment. (Hint: does the error have the expected dependence on the stepsize?
Remember you’re integrating over many steps, not just one.
2. Now try the two-dimensional orbit described by the potential:
Φ = −1
p1 + αx2+βy2,
where we are assuming unit mass for the particle in this potential. Show analytically
that the orbit is given by the coupled differential equations:
d2x
dt2=−αx
(1 + αx2+βy2)3/2
d2y
dt2=−βy
(1 + αx2+βy2)3/2
and then reduce these to 4 coupled first-order equations.
(a) Integrate this system for α= 2, β= 2, and 0 ≤t≤100, with the initial conditions
x= 1, y= 0, ˙x= 0, ˙y= 0.1. Try this with Leapfrog and Runge-Kutta, and
stepsizes of 1, 0.5, 0.25, and 0.1. Plot xvs. yfor these integrations.
(b) Plot the energy E= ( ˙x2+ ˙y2)/2+Φ(x, y) as a function of time for your integrations
and comment.
(c) Explore the behaviour for different choices of αand βand comment (no need to
include any plots).
1
pf2

Partial preview of the text

Download Problem Set 5 | Computational Astrophysics | ASTR 615 and more Assignments Astronomy in PDF only on Docsity!

ASTR615 Fall 2007 Problem Set

Due November 13, 2007

Write a program to integrate any number of coupled differential equations using the Euler method, fourth-order Runge-Kutta, and Leapfrog (note: Leapfrog only applies to special cases). You will be using this program in a future assignment, so make sure it’s well docu- mented. Use double precision throughout.

  1. Use your program to solve the following differential equation for x(t):

d^2 x dt^2

  • x = 0,

with initial conditions x(0) = 1, ˙x(0) = 0. Note the analytical solution is x = cos(t).

(a) Integrate the equation for 0 ≤ t ≤ 15 using each of the methods, and stepsizes of 1, 0.3, 0.1, 0.03, and 0.01. (b) Plot your integration results against the analytical solution for each case. (Hint: do all the Euler plots on one page, with one plot per timestep; then all the Leapfrog plots on another page, etc.) Comment on the results. (c) Plot log |xnumerical(15) − xexact(15)| as a function of log(stepsize) in each case and comment. (Hint: does the error have the expected dependence on the stepsize? Remember you’re integrating over many steps, not just one.

  1. Now try the two-dimensional orbit described by the potential:

1 + αx^2 + βy^2

where we are assuming unit mass for the particle in this potential. Show analytically that the orbit is given by the coupled differential equations:

d^2 x dt^2

αx (1 + αx^2 + βy^2 )^3 /^2

d^2 y dt^2

βy (1 + αx^2 + βy^2 )^3 /^2

and then reduce these to 4 coupled first-order equations.

(a) Integrate this system for α = 2, β = 2, and 0 ≤ t ≤ 100, with the initial conditions x = 1, y = 0, ˙x = 0, y˙ = 0.1. Try this with Leapfrog and Runge-Kutta, and stepsizes of 1, 0.5, 0.25, and 0.1. Plot x vs. y for these integrations. (b) Plot the energy E = ( ˙x^2 + ˙y^2 )/2+Φ(x, y) as a function of time for your integrations and comment. (c) Explore the behaviour for different choices of α and β and comment (no need to include any plots).

  1. BONUS (2 points max): Plot phase diagrams (x vs. y) for the Lotka-Volterra Predator- Prey model:

x˙ = Ax − Bxy − dx y ˙ = −Cy + Dxy − ey

where x is the prey density (rabbits), y the predator density (foxes), A = 1 (rabbit reproduction rate), B = 0.1 (rabbit consumption rate by foxes), C = 1.5 (fox death rate by natural causes), D = 0.03 (fox population growth rate due to consumption of rabbits), and d = e = 0 (hunting rate of foxes and rabbits, respectively). Use only your Runge-Kutta integrator, with t = 0 to 100 and timesteps of 1, 0.5, 0.25, and 0. to solve this system, starting with x = 30 and y = 3. If d = e = q, for roughly what value of q do both populations drop below 10−^9 by t = 100 for a timestep of 0.1?