Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Relational approach to quantum physics wikipedia , lookup

Elementary particle wikipedia , lookup

Fictitious force wikipedia , lookup

N-body problem wikipedia , lookup

Brownian motion wikipedia , lookup

Relativistic mechanics wikipedia , lookup

Center of mass wikipedia , lookup

Force wikipedia , lookup

Fundamental interaction wikipedia , lookup

Matter wave wikipedia , lookup

Inertia wikipedia , lookup

Classical mechanics wikipedia , lookup

Newton's theorem of revolving orbits wikipedia , lookup

Kinematics wikipedia , lookup

Equations of motion wikipedia , lookup

Rigid body dynamics wikipedia , lookup

Mass versus weight wikipedia , lookup

Centripetal force wikipedia , lookup

Modified Newtonian dynamics wikipedia , lookup

Classical central-force problem wikipedia , lookup

Newton's laws of motion wikipedia , lookup

Gravity wikipedia , lookup

Transcript
MA/CS 375
Fall 2002
Lecture 12
MA/CS 375 Fall 2002
1
Office Hours
• My office hours
– Rm 435, Humanities, Tuesdays from 1:30pm to 3:00pm
– Rm 435, Humanities, Thursdays from 1:30pm to 3:00pm
• Tom Hunt is the TA for this class. His lab hours are
now as follow
– SCSI 1004, Tuesdays from 3:30 until 4:45
– SCSI 1004, Wednesdays from 12:00 until 12:50
– Hum 346 on Wednesdays from 2:30-3:30
MA/CS 375 Fall 2002
2
This Lecture
Solving Ordinary Differential Equations (ODE’s)
• Accuracy
• Stability
• Forward Euler time integrator
• Runge Kutta time integrators
• Newton’s Equations
MA/CS 375 Fall 2002
3
Ordinary Differential Equation
• Example:
u 0  a
du
 u
dt
u T   ?
MA/CS 375 Fall 2002
• t is a variable for time
• u is a function dependent on t
• given u at t = 0
• given that for all t the slope of
us is –u
• what is the value of u at t=T
4
Ordinary Differential Equation
• Example:
u 0  a
du
 u
dt
u T   ?
MA/CS 375 Fall 2002
• we should know from intro
calculus that:
t
u  t   ae
• then obviously: u  T   ae
T
5
Just in Case You Forgot How…
du
 u
dt
1 du
 1
u dt
d ln  u 
 1
dt
T
T
d ln  u 
0 dt dt  0 dt
ln  u  t 0   t 0
t T
T
ln  u  T    ln  u  0     T  0 
ok if u!=0
ok if u>0
integrate in time
Fundamental theorem
of calculus
u T   u  0  e T
MA/CS 375 Fall 2002
6
Family of Solutions
u(0)=4 curve
u(t)
u(t )  u(0)e
t
u(0)=-4 curve
t
MA/CS 375 Fall 2002
7
Forward Euler
Numerical Scheme
• There are many ways to figure this out
on the computer.
• Simplest first.
• We discretize the derivative by
du  t  u  t  t   u  t 

dt
t
MA/CS 375 Fall 2002
8
Forward Euler
Numerical Scheme
• Numerical scheme:
u
n 1
u
n
 u
t
n
• Discrete scheme:
u
n 1
 1  t  u
n
where: un  approximate solution at t=nt
MA/CS 375 Fall 2002
9
Stability of Forward Euler
Numerical Scheme
• Discrete scheme:
u
n 1
 1  t  u
n
• The solution at the n’th time step is
then:
n 0
n
u  1  t  u
 1  t  u  0 
n
MA/CS 375 Fall 2002
10
Stability of Forward Euler
Numerical Scheme
• The solution at the n’th time step is then:
u  1  t  u  1  t  u  0 
n
n
0
n
• Notice that if 1  t  1 then |un| is going to
get very large very quickly !!. This is clearly
not what we want for an approximate solution
to an exponentially decaying exact solution.
MA/CS 375 Fall 2002
11
Stable Approximations
• 0<dt<1
dt
dt=0.125
dt=0.5
dt=0.25
MA/CS 375 Fall 2002
12
Stable But Oscillatory
Approximations
• 1<=dt<2
dt=1.25
dt=1.5
dt=1.5
MA/CS 375 Fall 2002
13
Unstable
(i.e. Bad) Approximations
• 2<dt
dt=4.5
dt=3
dt=2.5
MA/CS 375 Fall 2002
14
Summary of dt Stability
• 0 < dt <1
stable and convergent since as
dt  0 the solution approached
the actual solution.
• 1 <= dt < 2 bounded but not cool.
• 2 <= dt exponentially growing,
unstable and definitely not cool.
MA/CS 375 Fall 2002
15
Accuracy of the
Forward Euler Scheme
• Next lecture
MA/CS 375 Fall 2002
16
Application: Newtonian Motion
MA/CS 375 Fall 2002
17
Two of Newton’s Law of Motions
1) In the absence of forces, an object ("body") at rest will stay at rest,
and a body moving at a constant velocity in straight line continues
doing so indefinitely.
2) When a force is applied to an object, it accelerates. The
acceleration a is in the direction of the force and proportional to its
strength, and is also inversely proportional to the mass (m) being
moved. In suitable units:
F = ma
with both F and a vectors in the same direction (denoted here in
bold face).
MA/CS 375 Fall 2002
18
Newton’s Law of Gravitation
Gravitational force: an attractive force that exists
between all objects with mass; an object with mass
attracts another object with mass; the magnitude of the
force is directly proportional to the masses of the two
objects and inversely proportional to the square of the
distance between the two objects.
MA/CS 375 Fall 2002
19
Real Application
• You can blame Newton for this:
F = ma
Consider an object with mass m
2
t = time
m = mass of object
F = force on object
a = acceleration object
x = location of object
v = velocity of object
MA/CS 375 Fall 2002
dx
=a
2
dt
dx
=v
dt
dv
=a
dt
20
Two Gravitating Particle Masses
m2
m1
Each particle has a scalar mass quantitiy
MA/CS 375 Fall 2002
21
Particle Positions
Each particle has a vector position
x2
x1
(0,0)
MA/CS 375 Fall 2002
22
Particle Velocities
Each particle has a vector velocity
v1
v2
MA/CS 375 Fall 2002
23
Particle Accelerations
Each particle has a vector acceleration
a1
MA/CS 375 Fall 2002
a2
24
Definition of ||.||2
• In the following we will use the following
notation:
x 2  x x x
2
1
2
2
3
2
• Formally the function ||x||2 known as
the Euclidean norm of x. It returns the
length of the vector x
MA/CS 375 Fall 2002
25
Two-body Newtonian Gravitation
• Two objects of mass M1 and M2 exert a
gravitational force on each other:
Force exerted by mass 2 on 1:
Force exerted by mass 1 on 2:
F12
F21
x 2 - x1  M 1 M 2 G


x 2 - x1
3
2
x1 - x 2  M 2 M 1G


x1 - x 2
3
2
where G is the gravitational constant.
MA/CS 375 Fall 2002
26
Newtonian Gravitation
• Newton’s second law (rate of change of
momentum = force on body) :
d
2
 M 1x1    x 2 - x1  M 1M 2G
dt
d
2
2
2
 M 2 x 2    x1 - x 2  M 2 M 1G
dt
MA/CS 375 Fall 2002
x 2 - x1
3
2
x1 - x 2
3
2
27
Newtonian Gravitation
• Acceleration:
d 2 x1  x 2 - x1  M 2 G

3
2
dt
x 2 - x1 2
d 2 x 2  x1 - x 2  M 1G

3
2
dt
x1 - x 2 2
MA/CS 375 Fall 2002
28
Newtonian Gravitation
• Using velocity:
dx1
 v1
dt
dx 2
 v2
dt
dv1  x 2 - x1  M 2G

3
dt
x 2 - x1 2
dv 2  x1 - x 2  M 1G

3
dt
x1 - x 2 2
MA/CS 375 Fall 2002
29
N-Body Newtonian Gravitation
• For particle n out of N
dx n
 vn
dt
iN
xi - x n  M iG

dv n
 
3
dt i 1,i n x i  x n
2
The force on each particle is a sum of the
gravitational force between each other particle
MA/CS 375 Fall 2002
30
N-Body Newtonian
Gravitation Simulation
• Goal: to find out where all the objects are after
a time T
• We need to specify the initial velocity and
positions of the objects.
• Next we need a numerical scheme to advance
the equations in time.
• Can use forward Euler…. as a first approach.
MA/CS 375 Fall 2002
31
Numerical Scheme
For m=1 to FinalTime/dt
For n=1 to number of objects
v
m 1
n
 v  dt
m
n
x
iN

i 1,i  n
m
i
-x
x
 x  dt  v
m
n
m
n
M G
x x
m
i
End
For n=1 to number of objects
m 1
n
m
n
i
m 3
n 2

End
End
MA/CS 375 Fall 2002
32
planets1.m Matlab script
• I have written a planets1.m script.
• The quantities in the file are in units of
– kg (kilograms -- mass)
– m (meters
– length)
– s (seconds – time)
• It evolves the planet positions in time according to
Newton’s law of gravitation.
• It uses Euler-Forward to discretize the motion.
• All planets are lined up at y=0 at t=0
• All planets are set to travel in the y-direction at t=0
MA/CS 375 Fall 2002
33
Parameters
Object masses:
Mean distances
from sun:
MA/CS 375 Fall 2002
34
Initial velocities of objects:
MA/CS 375 Fall 2002
35
Set dt:
Time loop:
Calculate
acceleration:
Advance
X,Y,VX,VY
Plot the first
four planets
and the sun
end Time loop
MA/CS 375 Fall 2002
36
Venus
Earth
Mercury
MA/CS 375 Fall 2002
37
Mercury has nearly completed its orbit. Data shows 88
days. Run for 3 more days and the simulation agrees!!!.
Earth
Venus
Sun
Mercury
MA/CS 375 Fall 2002
38
Team Exercise
• Get the planets1.m file from the web site
• This scripts includes:
– the mass of all planets and the sun
– their mean distance from the sun
– the mean velocity of the planets.
• Run the script, see how the planets run!
• Add a comet to the system (increase Nsphere etc.)
• Start the comet out near Jupiter with an initial velocity
heading in system.
• Add a moon near the earth.
• Extra credit if you can make the comet loop the sun
and hit a planet 
MA/CS 375 Fall 2002
39
Next Lecture
• More accurate schemes
• More complicated ODEs
• Variable time step and embedded
methods used to make sure errors are
within a tolerance.
MA/CS 375 Fall 2002
40