Docsity

3 Problems on Computational Physics I - Homework 2 | PHYS 105, Assignments of Physics

Toggle sidebar
bg1
PHYS 105: Introduction to Computational Physics
Spring 2009
Homework #2
(Due: April 23, 2009)
Write a program to perform a numerical integration of the trajectory of a particle moving in one
dimension. The particle’s position and velocity are updated at each time step according to the
rules
ti+1 =ti+δt
xi+1 =xi+viδt +1
2aiδt2
vi+1 =vi+aiδt
where the acceleration ai=a(xi, vi, ti) is recomputed at the start of each step, allowing the possi-
bility of arbitrarily complex motion.
1. First prove analytically that the above rule is exact for the case of constant acceleration. That
is, if ti=i δt and
xi=x0+v0ti+1
2a t2
i
vi=v0+a ti
for fixed a, show that the rule applied to (xi, vi, ti) gives
xi+1 =x0+v0ti+1 +1
2a t2
i+1
vi+1 =v0+a ti+1
Now use your program to answer the following questions.
2. Consider the force law
a(x) = −k x ,
with k= 4, corresponding to simple harmonic motion with natural frequency ω0= 2.
(a) With initial conditions x0= 0, v0= 1 at time t= 0, follow the particle’s motion with
time step δt = 0.05. Plot the particle’s trajectory (xversus t) for 0 ≤t≤4π.
(b) What is the exact (analytical) solution to this motion?
(c) Is the “amplitude” of the numerically determined motion (i.e. the absolute value of xat
each successive maximum or minimum) constant, as expected? If not, by what factor does
the amplitude change from peak to peak for δ t = 0.05. Try decreasing δt until the amplitude
remains constant to within 1 percent from one cycle to the next. (You can estimate the
amplitude “by eye” from a graph or modify your program to determine it more accurately
by looking for instants when v= 0.) What is the value of δt thus obtained?
pf2

Partial preview of the text

Download 3 Problems on Computational Physics I - Homework 2 | PHYS 105 and more Assignments Physics in PDF only on Docsity!

PHYS 105: Introduction to Computational Physics

Spring 2009

Homework

(Due: April 23, 2009)

Write a program to perform a numerical integration of the trajectory of a particle moving in one dimension. The particle’s position and velocity are updated at each time step according to the rules

ti+1 = ti + δt xi+1 = xi + vi δt + 12 ai δt^2 vi+1 = vi + ai δt

where the acceleration ai = a(xi, vi, ti) is recomputed at the start of each step, allowing the possi- bility of arbitrarily complex motion.

  1. First prove analytically that the above rule is exact for the case of constant acceleration. That is, if ti = i δt and

xi = x 0 + v 0 ti + 12 a t^2 i vi = v 0 + a ti

for fixed a, show that the rule applied to (xi, vi, ti) gives

xi+1 = x 0 + v 0 ti+1 + 12 a t^2 i+ vi+1 = v 0 + a ti+

Now use your program to answer the following questions.

  1. Consider the force law a(x) = −k x ,

with k = 4, corresponding to simple harmonic motion with natural frequency ω 0 = 2. (a) With initial conditions x 0 = 0, v 0 = 1 at time t = 0, follow the particle’s motion with time step δt = 0.05. Plot the particle’s trajectory (x versus t) for 0 ≤ t ≤ 4 π. (b) What is the exact (analytical) solution to this motion? (c) Is the “amplitude” of the numerically determined motion (i.e. the absolute value of x at each successive maximum or minimum) constant, as expected? If not, by what factor does the amplitude change from peak to peak for δt = 0.05. Try decreasing δt until the amplitude remains constant to within 1 percent from one cycle to the next. (You can estimate the amplitude “by eye” from a graph or modify your program to determine it more accurately by looking for instants when v = 0.) What is the value of δt thus obtained?

(d) Write down an expression for the instantaneous total energy (kinetic plus potential) E of the particle. This should be a conserved quantity of the motion. Plot the energy error E(t) − E(0) as a function of time for 0 ≤ t ≤ 4 π for the time step δt obtained in part (c). (e) Using the value of δt determined in part (c), compute the period of the motion by finding the time taken for the particle to reach x = 0 again with v > 0. Use linear interpolation to refine your estimate, and compare your result with the analytic solution. (f) Repeat part (e) for v 0 = 0. 25 , 0. 5 , 1 , 2 , 4 , 8, and plot the numerically obtained period as a function of E(0).

  1. Repeat parts (c)–(f) of question 2 for the nonlinear force law

a(x) = −k x^3 ,

again with k = 4.

In addition to answers to specific questions, for problems 2 and 3, turn in hardcopy of your programs and the output produced when they run, as well as all requested plots, with axes clearly labeled.