1 \documentclass[pdf]{prosper}
4 \usepackage[german]{babel}
5 \usepackage[latin1]{inputenc}
6 \usepackage[T1]{fontenc}
12 \graphicspath{{./img/}}
15 \title{introduction to computational physics}
16 \subtitle{basic concepts and approaches}
17 \author{frank zirkelbach}
18 \email{frank.zirkelbach@physik.uni-augsburg.de}
19 \institution{experimantal physics {\footnotesize IV} - university of augsburg}
26 \begin{slide}{outline}
29 \item history of computing hardware/software
31 \item computational techniques
37 \begin{slide}{motivation}
41 \includegraphics[width=8cm]{cp_appl_field.eps}
48 \item precise mathematical theory
49 \item often: solving theory's equations ab-initio is not realistic
50 \item only a few models can be solved exactly
53 $\Rightarrow$ study and implementation of numerical algorithms
58 \begin{slide}{history of computing hardware}
59 \begin{minipage}[t]{10cm}
60 \onlySlide*{1}{\begin{center} \includegraphics[height=3cm]{abacus.eps} \end{center}}
61 \onlySlide*{2}{\begin{center} \includegraphics[height=3cm]{eniac.eps} \hspace{1cm} \includegraphics[height=3cm]{tube.eps} \end{center}}
62 \onlySlide*{3}{\begin{center} \includegraphics[height=3cm]{z1.eps} \end{center}}
63 \onlySlide*{4}{\begin{center} \includegraphics[height=3cm]{pdp1.eps} \hspace{1pt} \includegraphics[height=3cm]{transistor.eps} \end{center}}
64 \onlySlide*{5}{\begin{center} \includegraphics[height=3cm]{pdp8.eps} \hspace{1cm} \includegraphics[height=3cm]{ic.eps} \end{center}}
65 %\FromSlide{6}{\begin{center} \includegraphics[height=3cm]{} \end{center}}
67 \begin{minipage}[b]{10cm}
69 \item $3000 \, bc$: abacus - first calculating device
70 \item $1945$: eniac - electrical digital computer
71 \item $1938/41$: z1/3 - featuring memory and programmability
72 \item $1960$: pdp-1 - transistor based computers
73 \item $1964$: pdp-8 - integrated circuit computers
79 \begin{slide}{history of computing hardware}
80 \begin{minipage}[t]{10cm}
81 \onlySlide*{1}{\begin{center} \includegraphics[height=3cm]{4004.eps} \end{center}}
82 \onlySlide*{2}{\begin{center} \includegraphics[height=3cm]{cray2.eps} \hspace{1pt} \includegraphics[height=3cm]{cray2_i.eps} \end{center}}
83 \onlySlide*{3}{\begin{center} \includegraphics[height=3cm]{apple2.eps} \includegraphics[height=3cm]{c64.eps} \end{center}}
84 \onlySlide*{4}{\begin{center} \includegraphics[height=3cm]{intel1.eps} \includegraphics[height=3cm]{intel2.eps} \end{center}}
85 \onlySlide*{5}{\begin{center} \includegraphics[height=3cm]{mips.eps} \hspace{1pt} \includegraphics[height=3cm]{ppc.eps} \end{center}}
86 \onlySlide*{6}{\begin{center} \includegraphics[height=3cm]{cluster1.eps} \hspace{1cm} \includegraphics[height=3cm]{cluster2.eps} \end{center}}
88 \begin{minipage}[b]{10cm}
90 \item $1970$: intel 4004 - first single chip $\mu$-processor
91 \item $1977/85$: cray1/2 - vector supercomputer
92 \item $1977/82/85$: 6502/6510/m68k - first pc
93 \item $1978/82/85 $: 8086/80286/80386
94 \item $1985$: mips - first risc design
95 \item $1990/2000$: massive parallel computing
101 \begin{slide}{history of computing software}
103 \item $1946$: plankalk"ul - high-level programming language
104 \item $1950$: assembler - translating instruction mnemonics
105 \item $1954$: fortran - {\scriptsize formula translation}
106 \item $1963$: basic - {\scriptsize beginner's all purpose symbolic instruction code}
107 \item $1964$: os/360 - batch processing operating system
108 \item $1969$: unix - multics port to pdp-8, pdp-11/20
109 \item $1972$: c programming language - thompson, ritchie
110 \item $1978/84/85$: apple os/atari, amiga os/mac os
111 \item $1981/85/92/95$: ms-dos/windows 1.0/3.x/95
112 \item $1983$: gnu project - unix-like free software development
113 \item $1991$: linux - open-source kernel
118 \begin{slide}{warning - numerical errors}
120 \item machine accuracy $\epsilon_m$
122 \item ieee 64-bit floating point format: $v = -1^s 2^{-e} m$ \\
124 $s$: & signe & 1 bit \\
125 $m$: & mantissa & 52 bit \\
126 $e$: & exponent & 11 bit \\
128 \item $\epsilon_m$: smallest floating point with $1 + \epsilon_m \neq 1$ \\
129 $\epsilon_m \approx 2.22 \times 10^{-16}$ \hspace{2pt} (roundoff error)
131 \item truncation error $\epsilon_t$
133 \item discrete approximation of continuous quantity
134 \item persists even on hypothetical perfect computer ($\epsilon_m = 0$)
135 \item machine independent, characteristic of used algorithm
141 \begin{slide}{warning - recursive functions}
143 \item avoid recursive functions!
144 \verbatiminput{fak1.c}
146 \verbatiminput{fak2.c}
150 \begin{slide}{computational techniques}
151 \begin{minipage}{5.5cm}
153 \item rough discretization
154 \item solution of linear algebraic equations
155 \item interpolation and extrapolation
156 \item integration of functions
157 \item evaluation of (special) functions
158 \item monte carlo methods
161 \begin{minipage}{5.5cm}
164 \item spectral applications
165 \item modeling of data
166 \item ordinary differential equations
167 \item two point boundary value problems
168 \item partial differential \\
172 \footnote{http://www.nr.com/}
176 \begin{slide}{first steps: rough discretization}
178 \item example: homogenous field of force $\vec{F} = (0,-mg)$ \\
180 equation of motion: & $\vec{F} = m \vec{a} = m \frac{d^2 \vec{r}}{dt^2}$ \\
181 initial condition: & $\vec{r}(t=0) = \vec{r_0} = (x_0,y_0)$ \\
182 & $\frac{d \vec{r}}{dt}|_{t=0} = (v_{x_0},v_{y_0})$ \\
184 \item algorithm using discretized time ($T = N \tau$):
186 $x^1 = x_0;$ & $y^1 = y_0;$ & \\
187 $v^1_x = v_{x_0};$ & $v^1_y = v_{y_0};$ & \\
188 loop: & $x^2 = x^1 + \tau v^1_x;$ & $y^2 = y^1 + \tau v^1_y;$ \\
189 & $v^2_x = v^1_x;$ & $v^2_y = v^1_y - g \tau;$ \\
190 & $x^1 = x^2;$ & $y^1 = y^2$ \\
191 & $v^1_x = v^2_x;$ & $v^1_y = v^2_y;$ \\
193 \item euler's method for solving o.d.e.
198 \begin{slide}{euler's method: error estimation}
200 \item truncation error $\epsilon_t$:
202 \item $x_{t+\tau} = x(t) + v(t,x) \tau + O(\tau^2)$
203 \item period $T$: $O(\tau^{-1})$ steps $\Rightarrow \epsilon_t \sim O(\tau)$
205 \item machine accuracy:
207 \item every floating point step: error of $O(\epsilon_m)$
208 \item $O(\tau^{-1})$ steps $\Rightarrow$ error of $O(\frac{\epsilon_m}{\tau})$
212 \item $\epsilon \sim \frac{\epsilon_m}{\tau} + \tau$
213 \item 64-bit: $\epsilon_m \sim 10^{-16} \Rightarrow \tau \sim 10^{-8}$
214 \item 32-bit: $\epsilon_m = 1.19 \times 10^{-7} \Rightarrow \tau \sim 3 \times 10^{-4}$
219 \begin{slide}{euler's method: accuracy}
220 \includegraphics[width=10cm]{euler.eps}
224 \begin{slide}{monte carlo methods}
226 \item algorithms for solving computational problems using random numbers
227 \item deterministic pseudo-random sequences
230 \item monte carlo integration
231 \item metropolis algorithm
232 \item simulated annealing
236 \item more efficient than other methods
237 \item no need fo simplifying assumptions
243 \begin{slide}{random number generator}
244 linear congruential generator:
246 \item $I_{j+1} = ( a I_{j} + c ) \, mod \, m$ \\
247 $a$: multiplier, $c$: increment \\
248 $m$: modulus, $I_0$: seed
249 \item minimal standard by park and miller: \\
250 $a = 7^5 = 16807, \quad m = 2^{31} - 1 = 2147483647, \quad c = 0$
251 \item always seed the rng
254 $\Rightarrow$ sequence of integers $\in [0,m[$ \\
258 division by modulus $\Rightarrow$ uniform deviates : \\
270 \begin{slide}{special deviates}
272 \item transformation method:
274 \item arbitrary probability distribution $\rho(y)$
275 \item trafo: $p(x) dx = \rho(y) dy \Rightarrow x = \int_{- \infty}^y \rho(y) dy$
276 \item get inverse of $x(y) \Rightarrow y(x)$
278 \item rejection method: \\
279 \begin{minipage}{5cm}
281 \item $p(x) \in [a,b]$ mit $p(x) \geq 0 \quad \forall x \in [a,b]$
282 \item uniformly distributed $x \in [a,b]$ und $y \in [0,p_m]$
283 \item if $y \leq p(x)$ use $x$, else reject $x$
286 \begin{minipage}{5cm}
287 \includegraphics[width=5cm]{rej_meth.eps} \\
293 \begin{slide}{monte carlo integration}
296 \item $I = \int_{\Omega} f d \Omega$
297 \item instead of regular $x_i$, choose them at random
298 \item $I \approx \Omega <f> \pm \Omega \sqrt{\frac{<f^2> - <f>^2}{N}}$ \\
299 $<f> = \frac{1}{N} \sum_{i=1}^{N} f(\vec{x_i})$ \\[6pt]
300 $<f^2> = \frac{1}{N} \sum_{i=1}^{N} f^2(\vec{x_i})$
303 example: gambling for $\pi$ \\
308 \pi = \int_{-1}^1 \int_{-1}^1 p(x,y) dx dy \approx \frac{4}{N} \sum_{i=1}^N p(x_i,y_i) \\[6pt]
309 \textrm{with } p(x,y) = \left\{
311 1 & x^2 + y^2 \leq 1 \\
320 \begin{slide}{metropolis algorithm}
323 \item $d$-dimensional periodic lattice
324 \item two possible states for magnetic moment at site $i$: \\
325 $\mu_i = \mu S_i \qquad S_i = \pm 1 \quad \forall i$
326 \item nearest neighbors moments interact, \\
327 interaction strength $\frac{J_{ij}}{\mu^2}$
330 $\Rightarrow$ hamiltonian: $H = - \sum_{(i,j)} J_{ij} S_i S_j$ \\
333 partition function: \\
335 Z = \sum_{i=1}^N e^{\frac{-E_i}{k_B T}} = Tr(e^{-\beta H})
341 \begin{slide}{metropolis algorithm}
343 \item importance sampling: \\
344 $<A> = \sum_i p_i A_i \approx \frac{1}{N} \sum_{i=1}^N A_i$ , with \\[6pt]
345 $\qquad p_i = \frac{e^{- \beta E_i}}{Z}$
346 \item detailed balance \\[6pt]
347 sufficient condition for equilibrium: \\
349 W(A \rightarrow B) p(A) = W(B \rightarrow A) p(B)
351 $\Rightarrow \frac{W(A \rightarrow B)}{W(B \rightarrow A)} = \frac{p(B)}{p(A)} = e^{\frac{- \Delta E}{k_B T}}$ \\[6pt]
352 with $\Delta E = E(B) - E(A)$
357 \begin{slide}{metropolis algorithm}
361 W(A \rightarrow B) = \left\{
363 e^{- \beta \Delta E} & : \Delta E > 0 \\
369 \item visit every lattice site
370 \item calculate $\Delta E$ for spin flip
371 \item flip spin if $r \leq e^{\frac{-\Delta E}{k_B T}}$
376 \begin{slide}{summary}
378 \item importance of computational physics
379 \item things to keep in mind when doing computational physics
380 \item euler's method for solving o.d.e.
381 \item introduction to monte carlo methods