next up previous
Next: 2. Linear Algebra Up: 1. Finite Difference Calculus Previous: 1.3.4 Second derivatives in


1.4 Sample Applications

A. Newton' equation for an oscillator
$\displaystyle \frac{d^{2}x}{dt^{2}}$ $\textstyle =$ $\displaystyle - \omega_{0}^{2}   x$  

$\Longrightarrow$
$\displaystyle \frac{\delta^{2} x_{n}}{(\Delta t)^{2}}$ $\textstyle =$ $\displaystyle - \omega_{0}^{2} x_{n}
+ O[(\Delta t)^{2}]  $  

$\Longrightarrow$
$\displaystyle \fbox{
$
x_{n+1} = 2x_{n} - x_{n-1} + (- \omega_{0}^{2} x_{n}) (\Delta t)^{2}
+ O[(\Delta t)^{4}]
$
}$      


Step-by-step integration!

This is the famous Stoermer-Verlet algorithm.

Applicable for any right hand side, and for any number of coupled equations of motion!

Here is a realization of this algorithm, along with several others that will be explained later:


(An-) Harmonic Oscillator:
Start Applet



(1) To try out various harmonic and anharmonic oscillators, you may change the parameters $\omega^{2}$ and $\beta$ in the text panels.

(2) To get a feeling for the limitations of the Verlet algorithm, play around with $dt$.



EXERCISE:
a) Write a program to tabulate and/or draw the analytical solution to the HO equation. (You may achieve a very concise visualization by displaying the trajectory in phase space, i.e. in the coordinate system $\{ x; \dot{x} \}$; where for $\dot{x}$ the approximation $\dot{x} \approx (x_{n+1}-x_{n-1})/2 \Delta t$ may be used.) Choose values of $\omega_{0}^{2}$, $\Delta t$ and $x_{0}, \dot{x}_{0}$, and use these to determine the exact value of $x_{1}$. Starting with $x_{0}$ and $x_{1}$, employ the above algorithm to compute the further path $\{x_{n}   ; n=2,3,\dots \}$. Test the performance of your program by varying $\Delta t$ and $\omega_{0}^{2}$.
b) Now apply your code to the anharmonic oscillator

\begin{displaymath}
\frac{d^{2}x}{dt^{2}} = - \omega_{0}^{2}   x - \beta   x^{3}
\end{displaymath}

To start the algorithm you may use the approximate value given by
$\displaystyle x_{1}$ $\textstyle \approx$ $\displaystyle x_{0} + \dot{x}_{0} \Delta t + \ddot{x}_{0}
\frac{(\Delta t)^{2}}{2}$  






EXERCISE:
The planar pendulum is described by the equation of motion

\begin{displaymath}
\frac{d^{2}\phi}{dt^{2}} = - \frac{g}{l}   sin \phi
\end{displaymath}

Solution strategies vary between the three regions: $\phi$ very small; $\phi$ small; $\phi$ arbitrary.

Very small $\phi$: Here $\sin \phi \approx \phi$, and the e.o.m. is that of a harmonic oscillator, with the usual analytic solution.

Small $\phi$: We may put $\sin \phi \approx \phi - \phi^{3}/6$, adding an anharmonic term to the e.o.m. Again, an analytical solution may be found, but it is more involved than in the harmonic case; see Landau-Lifshitz, Mechanics.

Any $\phi$: The exact solution is known in implicit form:

\begin{displaymath}
t(\phi) =
\int_{0}^{\phi} \frac{d \phi'}{\sqrt{(2/ml^{2})\left[E+mgl \cos \phi' \right]}}
\end{displaymath}

One may clumsily invert this equation for regular times $t_{k}$, using Newton-Raphson.

Instead, one may choose to simulate the pendulum, using the Stoermer-Verlet algorithm:

\begin{displaymath}
\phi(t_{n+1})=2 \phi(t_{n})-\phi(t_{n-1})-\frac{g}{l}   \sin \phi(t_{n})
\end{displaymath}

As a starting value for $\phi(t_{1})$ one may use the Taylor approximation
$\displaystyle \phi_{1}$ $\textstyle \approx$ $\displaystyle \phi_{0} + \dot{\phi}_{0} \Delta t + \ddot{\phi}_{0}
\frac{(\Delta t)^{2}}{2}$  





B. Thermal Conduction
$\displaystyle \frac{\partial T(x,t)}{\partial t}$ $\textstyle =$ $\displaystyle \lambda \frac{\partial^{2} T(x,t)}{\partial x^{2}}$  



Writing $T_{i}^{n} \equiv T(x_{i},t_{n}) $, $\Longrightarrow$ ``FTCS scheme'' (``forward-time, centered-space'')
$\displaystyle \frac{1}{\Delta t}[T_{i}^{n+1}-T_{i}^{n}]$ $\textstyle \approx$ $\displaystyle \frac{\lambda}{(\Delta x)^{2}}
[T_{i+1}^{n}-2 T_{i}^{n}+T_{i-1}^{n}]$  

or
$\displaystyle \fbox{
$
T_{i}^{n+1}=(1-2a) T_{i}^{n} + a(T_{i-1}^{n}+T_{i+1}^{n}) \; ,
\;\;\;
$
with
$\;\;\;
a \equiv D   \Delta t/(\Delta x)^{2}$
}$      

for $i=1, \dots N-1$ (and $T_{0}^{n+1}$, $T_{N}^{n+1}$ given as boundary conditions).



EXERCISE: Let us divide the rod into $N=10$ pieces of equal length, with node points $i=0,\dots N$, and assume the boundary conditions $T(0,t) \equiv T_{0}^{n}=1.0$ and $T(L,t) \equiv T_{10}^{n}=0.5$. The values for the temperature at time $t=0$ (the initial values) are $T_{1}^{0}=T_{2}^{0}=$ $ \dots T_{5}^{0}=$$1.0$ and $T_{6}^{0}=T_{7}^{0}=$ $ \dots T_{9}^{0}=$$0.5$ (step function).

next up previous
Next: 2. Linear Algebra Up: 1. Finite Difference Calculus Previous: 1.3.4 Second derivatives in
Franz J. Vesely Oct 2005
See also:
"Computational Physics - An Introduction," Kluwer-Plenum 2001