Computational physics combines physics, applied mathematics, and computer science in a cutting-edge multidisciplinary approach to solving realistic physical problems. It has become integral to modern physics research because of its capacity to bridge the gap between mathematical theory and real-world system behavior.
Computational Physics provides the reader with the essential knowledge to understand computational tools and mathematical methods well enough to be successful. Its philosophy is rooted in “learning by doing”, assisted by many sample programs in the popular Python programming language. The first third of the book lays the fundamentals of scientific computing, including programming basics, stable algorithms for differentiation and integration, and matrix computing. The latter two-thirds of the textbook cover more advanced topics such linear and nonlinear differential equations, chaos and fractals, Fourier analysis, nonlinear dynamics, and finite difference and finite elements methods. A particular focus in on the applications of these methods for solving realistic physical problems.
Readers of the fourth edition of Computational Physics will also find: - An exceptionally broad range of topics, from simple matrix manipulations to intricate computations in nonlinear dynamics- A whole suite of supplementary material: Python programs, Jupyter notebooks and videos
Computational Physics is ideal for students in physics, engineering, materials science, and any subjects drawing on applied physics.
Table of Contents
Preface xvii
Acknowledgments xix
Part I Basics 1
1 Introduction 3
1.1 Computational Physics and Science 3
1.2 This Book’s Subjects 4
1.3 Video Lecture Supplements 4
1.4 This Book’s Codes and Problems 5
1.5 Our Language: The Python Ecosystem 6
1.6 The Easy Way: Python Distributions 6
2 Software Basics 9
2.1 Making Computers Obey 9
2.2 Computer Number Representations 11
2.3 Python Mini Tutorial 18
2.4 Programming Warmup 25
2.5 Python’s Visualization Tools 30
2.6 Plotting Exercises 36
2.7 Code Listings 38
3 Errors and Uncertainties 44
3.1 Types of Errors 44
3.2 Experimental Error Investigation 49
3.3 Errors with Power Series 52
3.4 Errors in Bessel Functions 55
3.5 Code Listing 58
4 Monte Carlo Simulations 59
4.1 Random Numbers 59
4.2 Simulating a Random Walk 63
4.3 Spontaneous Decay 68
4.4 Testing and Generating Random Distributions 71
4.5 Code Listings 73
5 Differentiation and Integration 78
5.1 Differentiation Algorithms 78
5.2 Extrapolated Difference 80
5.3 Integration Algorithms 83
5.4 Gaussian Quadrature 89
5.5 Monte Carlo Integrations 91
5.6 Mean Value and N-D Integration 94
5.7 mc Variance Reduction 96
5.8 Importance Sampling and von Neumann Rejection 96
5.9 Code Listings 97
6 Trial-and-Error Searching and Data Fitting 100
6.1 Quantum Bound States I 100
6.2 Bisection Search 101
6.3 Newton-Raphson Search 102
6.4 Magnetization Search 105
6.5 Data Fitting 107
6.6 Fitting Exponential Decay 112
6.7 Least-Squares Fitting 113
6.8 Nonlinear Fit to a Resonance 118
6.9 Code Listings 120
7 Matrix Computing and N-D Searching 123
7.1 Masses on a String and N-D Searching 123
7.2 Matrix Generalities 126
7.3 Matrices in Python 129
7.4 Exercise: Tests Before Use 136
7.5 Solution to String Problem 139
7.6 Spin States and Hyperfine Structure 139
7.7 Speeding Up Matrix Computing ⊙ 141
7.8 Code Listing 144
8 Differential Equations and Nonlinear Oscillations 147
8.1 Nonlinear Oscillators 147
8.2 ODE Review 149
8.3 Dynamic Form of ODEs 150
8.4 ODE Algorithms 152
8.5 Solution for Nonlinear Oscillations 157
8.6 Extensions: Nonlinear Resonances, Beats, Friction 159
8.7 Code Listings 161
Part II Data Science 165
9 Fourier Analyses 167
9.1 Fourier Series 167
9.2 Fourier Transforms 170
9.3 Discrete Fourier Transforms 172
9.4 Noise Filtering 178
9.5 Fast Fourier Transform ⊙ 185
9.6 FFT Implementation 189
9.7 FFT Assessment 190
9.8 Code Listings 190
10 Wavelet and Principal Components Analysis 193
10.1 Part I: Wavelet Analysis 193
10.2 Wave Packets and Uncertainty Principle 195
10.3 Short-Time Fourier Transforms 197
10.4 Wavelet Transforms 198
10.5 Discrete Wavelet Transforms ⊙ 203
10.6 Part II: Principal Components Analysis 213
10.7 Code Listings 220
11 Neural Networks and Machine Learning 224
11.1 Part I: Biological and Artificial Neural Networks 225
11.2 A Simple Neural Network 226
11.3 A Graphical Deep Net 232
11.4 Part II: Machine Learning Software 234
11.5 TensorFlow and SkLearn Examples 235
11.6 ml Clustering 240
11.7 Keras: Python’s Deep Learning API 244
11.8 Image Processing with OpenCV 244
11.9 Explore ML Data Repositories 247
11.10 Code Listings 247
12 Quantum Computing (G. He, Coauthor) 254
12.1 Dirac Notation in Quantum Mechanics 254
12.2 From Bits to Qubits 255
12.3 Entangled and Separable States 257
12.4 Logic Gates 260
12.5 An Intro to QC Programming 264
12.6 Accessing the IBM Quantum Computer 270
12.7 Qiskit Plus IBM Quantum 272
12.8 The Quantum Fourier Transform 275
12.9 Oracle + Diffuser = Grover’s Search Algorithm 278
12.10 Shor’s Factoring ⊙ 281
12.11 Code Listings 284
Part III Applications 289
13 ODE Applications; Eigenvalues, Scattering, Trajectories 291
13.1 Quantum Eigenvalues for Arbitrary Potentials 291
13.2 Algorithm: ODE Solver + Search 293
13.3 Classical Chaotic Scattering 296
13.4 Projectile Motion with Drag 299
13.5 2- and 3-Body Planetary Orbits 301
13.6 Code Listings 303
14 Fractals and Statistical Growth Models 307
14.1 The Sierpiński Gasket 308
14.2 Growing Plants 310
14.3 Ballistic Deposition 312
14.4 Length of British Coastline 313
14.5 Correlated Growth 317
14.6 Diffusion-Limited Aggregation 318
14.7 Fractals in Bifurcations 320
14.8 Cellular Automata Fractals 320
14.9 Perlin Noise Adds Realism ⊙ 321
14.10 Code Listings 324
15 Nonlinear Population Dynamics 329
15.1 The Logistic Map, A Bug Population Model 329
15.2 Chaos 333
15.3 Bifurcation Diagrams 333
15.4 Measures of Chaos 336
15.5 Coupled Predator-Prey Models ⨀ 338
15.6 Code Listings 344
16 Nonlinear Dynamics of Continuous Systems 348
16.1 The Chaotic Pendulum 348
16.2 Phase Space 351
16.3 Chaotic Explorations 354
16.4 Other Chaotic Systems 358
16.5 Code Listings 364
17 Thermodynamics Simulations and Feynman Path Integrals 365
17.1 An Ising Magnetic Chain 365
17.2 Metropolis Algorithm 368
17.3 Fast Equilibration via Wang-Landau Sampling ⊙ 372
17.4 Path Integral Quantum Mechanics ⊙ 374
17.5 Lattice Path Integration 377
17.6 Implementation 381
17.7 Code Listings 385
18 Molecular Dynamics Simulations 391
18.1 MD Versus Thermodynamics 394
18.2 Initial, Boundary, and Large r Conditions 394
18.3 Verlet Algorithms 396
18.4 MD for 16 Particles 400
18.5 Code Listing 402
19 General Relativity 408
19.1 Einstein’s Field Equations 408
19.2 Gravitational Deflection of Light 412
19.3 Planetary Orbits in GR Gravity 414
19.4 Visualizing Wormholes 418
19.5 Problems 420
19.6 Code Listings 420
20 Integral Equations 425
20.1 Nonlocal Potential Binding 425
20.2 Momentum-Space Schrödinger Equation 425
20.3 Scattering in Momentum Space ⊙ 429
20.4 Code Listings 434
Part IV PDE Applications 437
21 PDE Review, Electrostatics and Relaxation 439
21.1 Review 439
21.2 Laplace’s Equation 441
21.3 Finite-Difference Algorithm 444
21.4 Alternate Capacitor Problems 447
21.5 Electric Field Visualization 449
21.6 Code Listings 450
22 Heat Flow and Leapfrogging 452
22.1 The Parabolic Heat Equation 452
22.2 Time Stepping (Leapfrog) Algorithm 454
22.3 Newton’s Radiative Cooling 457
22.4 The Crank-Nicolson Algorithm 458
22.5 Code Listings 462
23 String and Membrane Waves 464
23.1 A Vibrating String’s Hyperbolic Wave Equation 464
23.2 Time-Stepping Algorithm 466
23.3 von Neumann Stability Analysis 468
23.4 Beyond The Simple Wave Equation 469
23.5 Vibrating Membrane (2D Waves) 474
23.6 Analytical Solution 475
23.7 Numerical Solution 476
23.8 Code Listings 478
24 Quantum Wave Packets and EM Waves 480
24.1 Time-Dependent Schrödinger Equation 480
24.2 Split-Time Algorithm 482
24.3 Special Schrödinger Algorithm 484
24.4 Quantum Chaos 485
24.5 E&M Waves: Finite Difference Time Domain 488
24.6 Maxwell’s Equations 488
24.7 Split-Time FDTD 489
24.8 More E&M Problems 492
24.9 Code Listings 496
25 Shock and Soliton Waves 501
25.1 The Continuity and Advection Equations 502
25.2 Shock Waves via Burgers’ Equation 503
25.3 Including Dispersion 505
25.4 KdeV Solitons 506
25.5 Pendulum Chain Solitons 510
25.6 Continuum Limit, the Sine-Gordon Equation 512
25.7 Code Listings 516
26 Fluid Hydrodynamics 518
26.1 Navier-Stokes Equation 518
26.2 Flow Through Parallel Plates 520
26.3 Navier-Stokes Difference Equation 522
26.4 Vorticity Form of Navier-Stokes Equation 523
26.5 Assessment and Exploration 527
26.6 Code Lisitings 529
27 Finite Element Electrostatics ⊙ 531
27.1 The Potential of Two Metal Plates 531
27.2 Finite Element Method 532
27.3 1D FEM Problems 536
27.4 2D FEM Exercises 537
27.5 Code Listings 539
Appendix Codes and Animations 543
References 546
Index 555