mcs 320project three: simulating the -bodyproblemhomepages.math.uic.edu › ~jan › mcs320s15 ›...

3
MCS 320 Project Three due Wednesday 29 April at 11AM Spring 2015 MCS 320 Project Three : simulating the n-body problem The goal of this project is to use Sage to simulate the n-body problem from celestial mechanics. We will plot trajectories computed by solving a system of differential equations numericallly. 0. numerically solving ordinary differential equations Consider the pendulum problem with damping. The problem consists of a unit mass suspended from a string, subject to gravity. The independent variable is time t. The angle θ(t) measures the deviation of the current state of the pendulum, relative to its equilibrium, when at rest. The second order differential equation is d 2 θ(t) dt 2 = (t) dt 9.8 sin(θ(t)). To solve this problem numerically with desolve system rk4, we must rewrite this second order differential equation as a system of first order differential equations. We do this by introducing a new variable v(t), which represents the velocity of θ(t). Then the original second order differential equation from above becomes (t) dt = v(t), dv(t) dt = v(t) 9.8 sin(θ(t)). The first argument of desolve system rk4 are the expressions for the right hand sides of the system of first order differential equations. In a Sage cell we can type var(’t, theta, velocity’) des = [velocity, -velocity -9.8*sin(theta)] P = desolve_system_rk4(des, [theta, velocity], ics=[0, pi/10, 0], ivar=t, end_points=10, step=0.01) Q=[ [i,j] for i,j,k in P] list_plot(Q) The list plot shows the evolution of θ(t): The outcome P of desolve system rk4 is a list of points. Instead of an animation, we can make an interact to plot the first n points in P, where the input parameter n is controlled by a slider. UIC, Department of Mathematics, Statistics and Computer Science page 1

Upload: others

Post on 28-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MCS 320Project Three: simulating the -bodyproblemhomepages.math.uic.edu › ~jan › mcs320s15 › celestial.pdfMCS320 ProjectThree due Wednesday 29 April at 11AM Spring2015 MCS 320Project

MCS 320 Project Three due Wednesday 29 April at 11AM Spring 2015

MCS 320 Project Three : simulating the n-body problem

The goal of this project is to use Sage to simulate the n-body problem from celestial mechanics.We will plot trajectories computed by solving a system of differential equations numericallly.

0. numerically solving ordinary differential equations

Consider the pendulum problem with damping. The problem consists of a unit mass suspendedfrom a string, subject to gravity. The independent variable is time t. The angle θ(t) measures thedeviation of the current state of the pendulum, relative to its equilibrium, when at rest. The secondorder differential equation is

d2θ(t)

dt2= −dθ(t)

dt− 9.8 sin(θ(t)).

To solve this problem numerically with desolve system rk4, we must rewrite this second orderdifferential equation as a system of first order differential equations. We do this by introducing anew variable v(t), which represents the velocity of θ(t). Then the original second order differentialequation from above becomes

dθ(t)

dt= v(t),

dv(t)

dt= −v(t)− 9.8 sin(θ(t)).

The first argument of desolve system rk4 are the expressions for the right hand sides of the systemof first order differential equations. In a Sage cell we can type

var(’t, theta, velocity’)

des = [velocity, -velocity -9.8*sin(theta)]

P = desolve_system_rk4(des, [theta, velocity], ics=[0, pi/10, 0], ivar=t, end_points=10, step=0.01)

Q=[ [i,j] for i,j,k in P]

list_plot(Q)

The list plot shows the evolution of θ(t):

The outcome P of desolve system rk4 is a list of points. Instead of an animation, we can makean interact to plot the first n points in P, where the input parameter n is controlled by a slider.

UIC, Department of Mathematics, Statistics and Computer Science page 1

Page 2: MCS 320Project Three: simulating the -bodyproblemhomepages.math.uic.edu › ~jan › mcs320s15 › celestial.pdfMCS320 ProjectThree due Wednesday 29 April at 11AM Spring2015 MCS 320Project

MCS 320 Project Three due Wednesday 29 April at 11AM Spring 2015

1. modeling with differential equations

We consider three bodies with respective massesm1,m2, m3 in the plane with positions (x1(t), y1(t)),(x2(t), y2(t)), (x3(t), y3(t)) evolving over time t, governed by a system of second order differentialequations, shown below for the movement of the first body:

d2x1(t)

dt2= − m2(x1(t)− x2(t))

((x1(t)− x2(t))2 + (y1(t)− y2(t))2)3/2

− m3(x1(t)− x3(t))

((x1(t)− x3(t))2 + (y1(t)− y3(t))2)3/2

d2y1(t)

dt2= − m2(y1(t)− y2(t))

((x1(t)− x2(t))2 + (y1(t)− y2(t))2)3/2

− m3(y1(t)− y3(t))

((x1(t)− x3(t))2 + (y1(t)− y3(t))2)3/2

Four additional equations determine the positions for the second and third body. To turn this into asystem of first order differential equations (as required for desolve system rk4) we introduce newvariables ui, vi for the velocities of xi, yi so we have

dx1(t)

dt= u1(t)

du1(t)

dt2= − m2(x1(t)− x2(t))

((x1(t)− x2(t))2 + (y1(t)− y2(t))2)3/2

− m3(x1(t)− x3(t))

((x1(t)− x3(t))2 + (y1(t)− y3(t))2)3/2

dy1(t)

dt= v1(t)

dv1(t)

dt= − m2(y1(t)− y2(t))

((x1(t)− x2(t))2 + (y1(t)− y2(t))2)3/2

− m3(y1(t)− y3(t))

((x1(t)− x3(t))2 + (y1(t)− y3(t))2)3/2

Applying this rewriting leads to a system of 12 first order differential equations in the positions andvelocities of the three bodies. Defining the masses, initial positions and velocities leads to an initialvalue problem. Solving this initial value problem with desolve system rk4 leads to the trajectoriesof the bodies.

2. the assignments

The three assignments below can be solved independently from each other.

Assignment One: Generalize to 4 Bodies

The example is set up to work with three bodies. The goal of the first assignment is to generalizethe model to four bodies.

Assignment One. Give your Sage worksheet to generalize the model to four bodies. Choose somegood initial values to make a nice plot of the trajectories. Make an interact to plot the points onthe trajectories where the number of points is controlled by a slider. Note that as the bodies collide,numerical problems may arise.

Assignment Two: Make a Spatial Model

Extend the model to three dimensions. To keep the complexity of the computations a bit undercontrol, you may still work with three bodies, i.e.: solve this assignment independently of the

UIC, Department of Mathematics, Statistics and Computer Science page 2

Page 3: MCS 320Project Three: simulating the -bodyproblemhomepages.math.uic.edu › ~jan › mcs320s15 › celestial.pdfMCS320 ProjectThree due Wednesday 29 April at 11AM Spring2015 MCS 320Project

MCS 320 Project Three due Wednesday 29 April at 11AM Spring 2015

previous assignment.

Assignment Two. Give your Sage worksheetto make a spatial model of the n-body problem. Plotthe trajectories. Make an interact to plot the points on the trajectories where the number of pointsis controlled by a slider.

Assignment Three: a Stable Figure Eight Configuration

Take a look at the online paper [2] and check out the links this paper makes. The goal of thisassignment is to make the figure eight configuration which has been used in space missions.

Assignment Three. Give the script to define the planar 3-body problem where the trajectoriesof the three bodies make a horizontal figure 8, as ∞. Also provide a print out of the plot, whichshould be as below:

Make an interact to plot the points on the trajectories where the number of points is controlledby a slider.

3. the deadline is Wednesday 29 April 2015, at 11AM

Bring your solution to the project to class. The your is emphasized to stress that your solution isthe result of an individual effort. Collaborations are not permitted.

The solution to this project consists in two parts:1. A print out of the Sage worksheet that you bring to class. Include a summary of your experiments,description of your observation and explanation of the results.2. Email your scripts as an attachment to me so I can verify your runs.

If you have questions or difficulties, feel free to come to my office for help.

References

[1] Donald G. Saari. Collisions, Rings, and Other Newtonian N -body Problems. Number 104 of CBMSRegional Conference Series in Mathematics, A.M.S., 2005.

[2] Ivars Petersen. Strange Orbits. Science News 168(7), 2005.http://www.sciencenews.org/articles/20050813/mathtrek.asp

UIC, Department of Mathematics, Statistics and Computer Science page 3