Table of Contents
1 Introduction 1
1.1 Goal, contents, and outline 1
1.2 The environment required for program development 4
1.2.1 Operating system 4
1.2.2 Software packages 5
1.2.3 Graphics 5
1.2.4 Program development and a simple script 6
1.3 A first example - the logistic map 7
1.3.1 Map 7
1.3.2 Fortran 8
1.3.3 Problems 11
2 Nonlinear maps 12
2.1 Frenkel-Kotorova model 12
2.1.1 Classical formulation 12
2.1.2 Equilibrium solutions 13
2.1.3 The standard map 13
2.1.4 Problems 14
2.2 Chaos and Lyapunov exponents 15
2.2.1 Stability, butterfly effect, and chaos 15
2.2.2 Lyapunov exponent of the logistic map 16
2.2.3 Lyapunov exponents for multidimensional maps 17
2.3 Affine maps and fractals 20
2.3.1 Sierpinski triangle 22
2.3.2 About ferns and other plants 23
2.3.3 Problems 24
2.4 Fractal dimension 25
2.4.1 Box-counting 25
2.4.2 Application: Sierpinski triangle 26
2.4.3 Problem 27
2.5 Neural networks 27
2.5.1 Perceptron 28
2.5.2 Self-organized maps: Kohonen's model 34
2.5.3 Problems 39
3 Dynamical systems 40
3.1 Quasilinear differential equations 40
3.1.1 Example: logistic map and logistic ODE 41
3.1.2 Problems 42
3.2 Fixed points and instabilities 43
3.2.1 Fixed points 43
3.2.2 Stability 43
3.2.3 Trajectories 44
3.2.4 Gradient dynamics 45
3.2.5 Special case N = 1 45
3.2.6 Special case N = 2 45
3.2.7 Special case N = 3 47
3.3 Hamiltonian systems 50
3.3.1 Hamilton function and canonical equations 50
3.3.2 Symplectic integrators 51
3.3.3 Poincaré section 56
4 Ordinary differential equations 1 58
4.1 Newton's mechanics 58
4.1.1 Equations of motion 58
4.1.2 The mathematical pendulum 59
4.2 Numerical methods of the lowest order 60
4.2.1 Euler method 60
4.2.2 Numerical stability of the Euler method 60
4.2.3 Implicit and explicit methods 63
4.3 Higher order methods 64
4.3.1 Heun's method 64
4.3.2 Problems 67
4.3.3 Runge-Kutta method 67
4.4 RK4 applications: celestial mechanics 73
4.4.1 Kepler problem: closed orbits 73
4.4.2 Quasiperiodic orbits and apsidal precession 76
4.4.3 Multiple planets: is our solar system stable? 76
4.4.4 The reduced three-body problem 79
4.4.5 Problems 86
4.5 Molecular dynamics (MD) 86
4.5.1 Classical formulation 86
4.5.2 Boundary conditions 87
4.5.3 Microcanonical and canonical ensemble 88
4.5.4 A symplectic algorithm 89
4.5.5 Evaluation 90
4.5.6 Problems 94
4.6 Chaos 95
4.6.1 Harmonically driven pendulum 95
4.6.2 Poincaré section and bifurcation diagrams 97
4.6.3 Lyapunov exponents 98
4.6.4 Fractal dimension 106
4.6.5 Reconstruction of attractors 109
4.7 ODEs with periodic coefficients 111
4.7.1 Floquet theorem 111
4.7.2 Stability of limit cycles 112
4.7.3 Parametric instability: pendulum with an oscillating support 112
4.7.4 Mathieu equation 114
4.7.5 Problems 116
5 Ordinary differential equations II 117
5.1 Preliminary remarks 117
5.1.1 Boundary conditions 117
5.1.2 Example: ballistic flight 118
5.2 Finite differences 118
5.2.1 Discretization 119
5.2.2 Example: Schrödinger equation 122
5.3 Weighted residual methods 128
5.3.1 Weight and base functions 128
5.3.2 Example: Stark effect 130
5.4 Nonlinear boundary value problems 132
5.4.1 Nonlinear systems 132
5.4.2 Newton-Raphson 133
5.4.3 Example: the nonlinear Schrödinger equation 134
5.4.4 Example: a moonshot 136
5.5 Shooting 140
5.5.1 The method 140
5.5.2 Example: free fall with quadratic friction 141
5.5.3 Systems of equations 142
5.6 Problems 143
6 Partial differential equations I, basics 144
6.1 Classification 144
6.1.1 PDEs of the first order 144
6.1.2 PDEs of the second order 147
6.1.3 Boundary and initial conditions 149
6.2 Finite differences 153
6.2.1 Discretization 153
6.2.2 Elliptic PDEs, example: Poisson equation 156
6.2.3 Parabolic PDEs, example: heat equation 162
6.2.4 Hyperbolic PDEs, example: convection equation, wave equation 167
6.3 Alternative discretization methods 173
6.3.1 Chebyshev spectral method 173
6.3.2 Spectral method by Fourier transformation 178
6.3.3 Finite-element method 182
6.4 Nonlinear PDEs 186
6.4.1 Real Ginzburg-Landau equation 186
6.4.2 Numerical solution, explicit method 188
6.4.3 Numerical solution, semi-implicit method 189
6.4.4 Problems 190
7 Partial differential equations II, applications 193
7.1 Quantum mechanics in one dimension 193
7.1.1 Stationary two-particle equation 193
7.1.2 Time-dependent Schrödinger equation 196
7.2 Quantum mechanics in two dimensions 202
7.2.1 Schrödinger equation 202
7.2.2 Algorithm 202
7.2.3 Evaluation 203
7.3 Fluid mechanics: flow of an incompressible liquid 204
7.3.1 Hydrodynamic basic equations 204
7.3.2 Example: driven cavity 206
7.3.3 Thermal convection: (A) square geometry 211
7.3.4 Thermal convection: (B) Rayleigh-Bénard convection 218
7.4 Pattern formation out of equilibrium 225
7.4.1 Reaction-diffusion systems 225
7.4.2 Swift-Hohenberg equation 234
7.4.3 Problems 238
8 Monte Carlo methods (MC) 240
8.1 Random numbers and distributions 240
8.1.1 Random number generator 240
8.1.2 Distribution function, probability density, mean values 241
8.1.3 Other distribution functions 242
8.2 Monte Carlo integration 245
8.2.1 Integrals in one dimension 245
8.2.2 Integrals in higher dimensions 247
8.3 Applications from statistical physics 250
8.3.1 Two-dimensional classical gas 250
8.3.2 The Ising model 255
8.4 Differential equations derived from variational problems 265
8.4.1 Diffusion equation 265
8.4.2 Swift-Hohenberg equation 267
A Matrices and systems of linear equations 270
A.l Real matrices 270
A.1.1 Eigenvalues and eigenvectors 270
A.1.2 Characteristic polynomial 270
A.1.3 Notations 271
A.1.4 Normal matrices 271
A.2 Complex matrices 272
A.2.1 Notations 272
A.2.2 Jordan canonical form 273
A.3 Inhomogeneous systems of linear equations 274
A.3.1 Regular and singular system matrices 274
A.3.2 Fredholm alternative 275
A.3.3 Regular matrices 275
A.3.4 LU decomposition 276
A.3.5 Thomas algorithm 278
A.4 Homogeneous systems of linear equations 279
A.4.1 Eigenvalue problems 279
A.4.2 Diagonalization 279
A.4.3 Application: zeros of a polynomial 282
B Program library 284
B.1 Routines 284
B.2 Graphics 285
B.2.1 Init 285
B.2.2 Contur 285
B.2.3 Contur1 285
B.2.4 Ccontu 286
B.2.5 Image 286
B.2.6 Ccircl 286
B.3 Runge-Kutta 286
B.3.1 Rkg 286
B.3.2 Drkg 287
B.3.3 Drkadt 287
B.4 Miscellaneous 287
B.4.1 Tridag-Thomas algorithm 287
B.4.2 Ctrida 287
B.4.3 Dlyap_exp - Lyapunov exponents 288
B.4.4 Schmid - orthogonalization 288
B.4.5 Function volum -volume in n dimensions 288
B.4.6 Function deter - determinant 289
B.4.7 random_init - random numbers 289
C Solutions of the problems 290
C.1 Chapter 1 290
C.2 Chapter 2 291
C.3 Chapters 292
C.4 Chapter 4 292
C.5 Chapter 5 301
C.6 Chapter 6 303
C.7 Chapter 7 306
D Readme and a short guide to FE-tools 310
D.1 Readme 310
D.2 Short guide to finite-element tools from Chapter 6 313
D.2.1 Mesh_generator 313
D.2.2 Laplace_solver 315
D.2.3 Grid_contur 315
Index 317