Muutke küpsiste eelistusi

E-raamat: Finite Difference Computing with PDEs: A Modern Software Approach

  • Formaat - PDF+DRM
  • Hind: 4,08 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

This book is open access under a CC BY 4.0 license.



This easy-to-read book introduces the basics of solving partial differential equations by means of finite difference methods. Unlike many of the traditional academic works on the topic, this book was written for practitioners. Accordingly, it especially addresses: the construction of finite difference schemes, formulation and implementation of algorithms, verification of implementations, analyses of physical behavior as implied by the numerical solutions, and how to apply the methods and software to solve problems in the fields of physics and biology.
1 Vibration ODEs
1(92)
1.1 Finite Difference Discretization
1(3)
1.1.1 A Basic Model for Vibrations
1(1)
1.1.2 A Centered Finite Difference Scheme
2(2)
1.2 Implementation
4(7)
1.2.1 Making a Solver Function
4(2)
1.2.2 Verification
6(4)
1.2.3 Scaled Model
10(1)
1.3 Visualization of Long Time Simulations
11(10)
1.3.1 Using a Moving Plot Window
11(2)
1.3.2 Making Animations
13(2)
1.3.3 Using Bokeh to Compare Graphs
15(3)
1.3.4 Using a Line-by-Line Ascii Plotter
18(1)
1.3.5 Empirical Analysis of the Solution
19(2)
1.4 Analysis of the Numerical Scheme
21(8)
1.4.1 Deriving a Solution of the Numerical Scheme
21(1)
1.4.2 The Error in the Numerical Frequency
22(2)
1.4.3 Empirical Convergence Rates and Adjusted ω
24(1)
1.4.4 Exact Discrete Solution
24(1)
1.4.5 Convergence
24(1)
1.4.6 The Global Error
25(1)
1.4.7 Stability
26(1)
1.4.8 About the Accuracy at the Stability Limit
27(2)
1.5 Alternative Schemes Based on 1st-Order Equations
29(7)
1.5.1 The Forward Euler Scheme
29(1)
1.5.2 The Backward Euler Scheme
30(1)
1.5.3 The Crank-Nicolson Scheme
30(2)
1.5.4 Comparison of Schemes
32(1)
1.5.5 Runge-Kutta Methods
33(1)
1.5.6 Analysis of the Forward Euler Scheme
34(2)
1.6 Energy Considerations
36(4)
1.6.1 Derivation of the Energy Expression
36(2)
1.6.2 An Error Measure Based on Energy
38(2)
1.7 The Euler-Cromer Method
40(6)
1.7.1 Forward-Backward Discretization
40(2)
1.7.2 Equivalence with the Scheme for the Second-Order ODE
42(1)
1.7.3 Implementation
43(2)
1.7.4 The Stormer-Verlet Algorithm
45(1)
1.8 Staggered Mesh
46(4)
1.8.1 The Euler-Cromer Scheme on a Staggered Mesh
46(2)
1.8.2 Implementation of the Scheme on a Staggered Mesh
48(2)
1.9 Exercises and Problems
50(7)
1.10 Generalization: Damping, Nonlinearities, and Excitation
57(9)
1.10.1 A Centered Scheme for Linear Damping
57(1)
1.10.2 A Centered Scheme for Quadratic Damping
58(1)
1.10.3 A Forward-Backward Discretization of the Quadratic Damping Term
59(1)
1.10.4 Implementation
59(1)
1.10.5 Verification
60(1)
1.10.6 Visualization
61(1)
1.10.7 User Interface
62(1)
1.10.8 The Euler-Cromer Scheme for the Generalized Model
63(1)
1.10.9 The Stormer-Verlet Algorithm for the Generalized Model
64(1)
1.10.10 A Staggered Euler-Cromer Scheme for a Generalized Model
64(1)
1.10.11 The PEFRL 4th-Order Accurate Algorithm
65(1)
1.11 Exercises and Problems
66(1)
1.12 Applications of Vibration Models
67(21)
1.12.1 Oscillating Mass Attached to a Spring
67(2)
1.12.2 General Mechanical Vibrating System
69(1)
1.12.3 A Sliding Mass Attached to a Spring
70(1)
1.12.4 A Jumping Washing Machine
71(1)
1.12.5 Motion of a Pendulum
71(3)
1.12.6 Dynamic Free Body Diagram During Pendulum Motion
74(5)
1.12.7 Motion of an Elastic Pendulum
79(4)
1.12.8 Vehicle on a Bumpy Road
83(2)
1.12.9 Bouncing Ball
85(1)
1.12.10 Two-Body Gravitational Problem
85(3)
1.12.11 Electric Circuits
88(1)
1.13 Exercises
88(5)
2 Wave Equations
93(114)
2.1 Simulation of Waves on a String
93(6)
2.1.1 Discretizing the Domain
94(1)
2.1.2 The Discrete Solution
94(1)
2.1.3 Fulfilling the Equation at the Mesh Points
94(1)
2.1.4 Replacing Derivatives by Finite Differences
95(1)
2.1.5 Formulating a Recursive Algorithm
96(2)
2.1.6 Sketch of an Implementation
98(1)
2.2 Verification
99(5)
2.2.1 A Slightly Generalized Model Problem
99(1)
2.2.2 Using an Analytical Solution of Physical Significance
99(1)
2.2.3 Manufactured Solution and Estimation of Convergence Rates
100(2)
2.2.4 Constructing an Exact Solution of the Discrete Equations
102(2)
2.3 Implementation
104(10)
2.3.1 Callback Function for User-Specific Actions
104(1)
2.3.2 The Solver Function
105(1)
2.3.3 Verification: Exact Quadratic Solution
106(1)
2.3.4 Verification: Convergence Rates
107(1)
2.3.5 Visualization: Animating the Solution
108(4)
2.3.6 Running a Case
112(1)
2.3.7 Working with a Scaled PDE Model
113(1)
2.4 Vectorization
114(8)
2.4.1 Operations on Slices of Arrays
115(2)
2.4.2 Finite Difference Schemes Expressed as Slices
117(1)
2.4.3 Verification
118(1)
2.4.4 Efficiency Measurements
119(2)
2.4.5 Remark on the Updating of Arrays
121(1)
2.5 Exercises
122(3)
2.6 Generalization: Reflecting Boundaries
125(10)
2.6.1 Neumann Boundary Condition
126(1)
2.6.2 Discretization of Derivatives at the Boundary
126(1)
2.6.3 Implementation of Neumann Conditions
127(1)
2.6.4 Index Set Notation
128(2)
2.6.5 Verifying the Implementation of Neumann Conditions
130(2)
2.6.6 Alternative Implementation via Ghost Cells
132(3)
2.7 Generalization: Variable Wave Velocity
135(6)
2.7.1 The Model PDE with a Variable Coefficient
135(1)
2.7.2 Discretizing the Variable Coefficient
136(1)
2.7.3 Computing the Coefficient Between Mesh Points
137(1)
2.7.4 How a Variable Coefficient Affects the Stability
138(1)
2.7.5 Neumann Condition and a Variable Coefficient
138(1)
2.7.6 Implementation of Variable Coefficients
139(1)
2.7.7 A More General PDE Model with Variable Coefficients
140(1)
2.7.8 Generalization: Damping
140(1)
2.8 Building a General 1D Wave Equation Solver
141(7)
2.8.1 User Action Function as a Class
142(2)
2.8.2 Pulse Propagation in Two Media
144(4)
2.9 Exercises
148(7)
2.10 Analysis of the Difference Equations
155(12)
2.10.1 Properties of the Solution of the Wave Equation
155(2)
2.10.2 More Precise Definition of Fourier Representations
157(1)
2.10.3 Stability
158(2)
2.10.4 Numerical Dispersion Relation
160(3)
2.10.5 Extending the Analysis to 2D and 3D
163(4)
2.11 Finite Difference Methods for 2D and 3D Wave Equations
167(4)
2.11.1 Multi-Dimensional Wave Equations
167(1)
2.11.2 Mesh
168(1)
2.11.3 Discretization
169(2)
2.12 Implementation
171(10)
2.12.1 Scalar Computations
172(2)
2.12.2 Vectorized Computations
174(2)
2.12.3 Verification
176(1)
2.12.4 Visualization
177(4)
2.13 Exercises
181(2)
2.14 Applications of Wave Equations
183(12)
2.14.1 Waves on a String
183(3)
2.14.2 Elastic Waves in a Rod
186(1)
2.14.3 Waves on a Membrane
186(1)
2.14.4 The Acoustic Model for Seismic Waves
186(2)
2.14.5 Sound Waves in Liquids and Gases
188(1)
2.14.6 Spherical Waves
189(1)
2.14.7 The Linear Shallow Water Equations
190(2)
2.14.8 Waves in Blood Vessels
192(2)
2.14.9 Electromagnetic Waves
194(1)
2.15 Exercises
195(12)
3 Diffusion Equations
207(116)
3.1 An Explicit Method for the 1D Diffusion Equation
208(10)
3.1.1 The Initial-Boundary Value Problem for 1D Diffusion
208(1)
3.1.2 Forward Euler Scheme
208(2)
3.1.3 Implementation
210(2)
3.1.4 Verification
212(3)
3.1.5 Numerical Experiments
215(3)
3.2 Implicit Methods for the 1D Diffusion Equation
218(11)
3.2.1 Backward Euler Scheme
219(4)
3.2.2 Sparse Matrix Implementation
223(1)
3.2.3 Crank-Nicolson Scheme
224(2)
3.2.4 The Unifying θ Rule
226(1)
3.2.5 Experiments
227(1)
3.2.6 The Laplace and Poisson Equation
227(2)
3.3 Analysis of Schemes for the Diffusion Equation
229(13)
3.3.1 Properties of the Solution
229(4)
3.3.2 Analysis of Discrete Equations
233(1)
3.3.3 Analysis of the Finite Difference Schemes
233(1)
3.3.4 Analysis of the Forward Euler Scheme
234(2)
3.3.5 Analysis of the Backward Euler Scheme
236(1)
3.3.6 Analysis of the Crank-Nicolson Scheme
237(1)
3.3.7 Analysis of the Leapfrog Scheme
237(1)
3.3.8 Summary of Accuracy of Amplification Factors
238(1)
3.3.9 Analysis of the 2D Diffusion Equation
239(2)
3.3.10 Explanation of Numerical Artifacts
241(1)
3.4 Exercises
242(3)
3.5 Diffusion in Heterogeneous Media
245(9)
3.5.1 Discretization
245(1)
3.5.2 Implementation
246(1)
3.5.3 Stationary Solution
247(1)
3.5.4 Piecewise Constant Medium
247(1)
3.5.5 Implementation of Diffusion in a Piecewise Constant Medium
248(3)
3.5.6 Axi-Symmetric Diffusion
251(1)
3.5.7 Spherically-Symmetric Diffusion
252(2)
3.6 Diffusion in 2D
254(33)
3.6.1 Discretization
254(1)
3.6.2 Numbering of Mesh Points Versus Equations and Unknowns
255(4)
3.6.3 Algorithm for Setting Up the Coefficient Matrix
259(1)
3.6.4 Implementation with a Dense Coefficient Matrix
260(4)
3.6.5 Verification: Exact Numerical Solution
264(1)
3.6.6 Verification: Convergence Rates
265(1)
3.6.7 Implementation with a Sparse Coefficient Matrix
266(4)
3.6.8 The Jacobi Iterative Method
270(3)
3.6.9 Implementation of the Jacobi Method
273(1)
3.6.10 Test Problem: Diffusion of a Sine Hill
274(2)
3.6.11 The Relaxed Jacobi Method and Its Relation to the Forward Euler Method
276(1)
3.6.12 The Gauss-Seidel and SOR Methods
277(1)
3.6.13 Scalar Implementation of the SOR Method
277(1)
3.6.14 Vectorized Implementation of the SOR Method
278(4)
3.6.15 Direct Versus Iterative Methods
282(3)
3.6.16 The Conjugate Gradient Method
285(2)
3.6.17 What Is the Recommended Method for Solving Linear Systems?
287(1)
3.7 Random Walk
287(21)
3.7.1 Random Walk in 1D
288(1)
3.7.2 Statistical Considerations
288(2)
3.7.3 Playing Around with Some Code
290(3)
3.7.4 Equivalence with Diffusion
293(1)
3.7.5 Implementation of Multiple Walks
294(6)
3.7.6 Demonstration of Multiple Walks
300(1)
3.7.7 Ascii Visualization of 1D Random Walk
300(3)
3.7.8 Random Walk as a Stochastic Equation
303(1)
3.7.9 Random Walk in 2D
304(1)
3.7.10 Random Walk in Any Number of Space Dimensions
305(2)
3.7.11 Multiple Random Walks in Any Number of Space Dimensions
307(1)
3.8 Applications
308(8)
3.8.1 Diffusion of a Substance
308(1)
3.8.2 Heat Conduction
309(3)
3.8.3 Porous Media Flow
312(1)
3.8.4 Potential Fluid Flow
312(1)
3.8.5 Streamlines for 2D Fluid Flow
313(1)
3.8.6 The Potential of an Electric Field
313(1)
3.8.7 Development of Flow Between Two Flat Plates
313(1)
3.8.8 Flow in a Straight Tube
314(1)
3.8.9 Tribology: Thin Film Fluid Flow
315(1)
3.8.10 Propagation of Electrical Signals in the Brain
316(1)
3.9 Exercises
316(7)
4 Advection-Dominated Equations
323(30)
4.1 One-Dimensional Time-Dependent Advection Equations
323(21)
4.1.1 Simplest Scheme: Forward in Time, Centered in Space
324(3)
4.1.2 Analysis of the Scheme
327(1)
4.1.3 Leapfrog in Time, Centered Differences in Space
328(3)
4.1.4 Upwind Differences in Space
331(2)
4.1.5 Periodic Boundary Conditions
333(1)
4.1.6 Implementation
333(4)
4.1.7 A Crank-Nicolson Discretization in Time and Centered Differences in Space
337(2)
4.1.8 The Lax-Wendroff Method
339(1)
4.1.9 Analysis of Dispersion Relations
340(4)
4.2 One-Dimensional Stationary Advection-Diffusion Equation
344(5)
4.2.1 A Simple Model Problem
344(1)
4.2.2 A Centered Finite Difference Scheme
345(2)
4.2.3 Remedy: Upwind Finite Difference Scheme
347(2)
4.3 Time-dependent Convection-Diffusion Equations
349(1)
4.3.1 Forward in Time, Centered in Space Scheme
349(1)
4.3.2 Forward in Time, Upwind in Space Scheme
349(1)
4.4 Applications of Advection Equations
350(1)
4.4.1 Transport of a Substance
350(1)
4.4.2 Transport of Heat in Fluids
350(1)
4.5 Exercises
351(2)
5 Nonlinear Problems
353(56)
5.1 Introduction of Basic Concepts
353(15)
5.1.1 Linear Versus Nonlinear Equations
353(1)
5.1.2 A Simple Model Problem
354(1)
5.1.3 Linearization by Explicit Time Discretization
355(1)
5.1.4 Exact Solution of Nonlinear Algebraic Equations
356(1)
5.1.5 Linearization
357(1)
5.1.6 Picard Iteration
357(2)
5.1.7 Linearization by a Geometric Mean
359(1)
5.1.8 Newton's Method
360(1)
5.1.9 Relaxation
361(1)
5.1.10 Implementation and Experiments
362(3)
5.1.11 Generalization to a General Nonlinear ODE
365(2)
5.1.12 Systems of ODEs
367(1)
5.2 Systems of Nonlinear Algebraic Equations
368(5)
5.2.1 Picard Iteration
369(1)
5.2.2 Newton's Method
369(2)
5.2.3 Stopping Criteria
371(1)
5.2.4 Example: A Nonlinear ODE Model from Epidemiology
372(1)
5.3 Linearization at the Differential Equation Level
373(5)
5.3.1 Explicit Time Integration
373(1)
5.3.2 Backward Euler Scheme and Picard Iteration
374(1)
5.3.3 Backward Euler Scheme and Newton's Method
375(2)
5.3.4 Crank-Nicolson Discretization
377(1)
5.4 1D Stationary Nonlinear Differential Equations
378(6)
5.4.1 Finite Difference Discretization
378(1)
5.4.2 Solution of Algebraic Equations
379(5)
5.5 Multi-Dimensional Nonlinear PDE Problems
384(3)
5.5.1 Finite Difference Discretization
384(2)
5.5.2 Continuation Methods
386(1)
5.6 Operator Splitting Methods
387(14)
5.6.1 Ordinary Operator Splitting for ODEs
387(1)
5.6.2 Strang Splitting for ODEs
388(1)
5.6.3 Example: Logistic Growth
388(3)
5.6.4 Reaction-Diffusion Equation
391(1)
5.6.5 Example: Reaction-Diffusion with Linear Reaction Term
392(8)
5.6.6 Analysis of the Splitting Method
400(1)
5.7 Exercises
401(8)
A Useful Formulas
409(6)
A.1 Finite Difference Operator Notation
409(1)
A.2 Truncation Errors of Finite Difference Approximations
410(1)
A.3 Finite Differences of Exponential Functions
411(1)
A.4 Finite Differences of tn
411(4)
A.4.1 Software
412(3)
B Truncation Error Analysis
415(36)
B.1 Overview of Truncation Error Analysis
415(2)
B.1.1 Abstract Problem Setting
415(1)
B.1.2 Error Measures
416(1)
B.2 Truncation Errors in Finite Difference Formulas
417(5)
B.2.1 Example: The Backward Difference for u'(t)
417(1)
B.2.2 Example: The Forward Difference for u'(t)
418(1)
B.2.3 Example: The Central Difference for u'(t)
419(1)
B.2.4 Overview of Leading-Order Error Terms in Finite Difference Formulas
420(1)
B.2.5 Software for Computing Truncation Errors
421(1)
B.3 Exponential Decay ODEs
422(12)
B.3.1 Forward Euler Scheme
422(1)
B.3.2 Crank-Nicolson Scheme
423(1)
B.3.3 The θ-Rule
424(1)
B.3.4 Using Symbolic Software
424(1)
B.3.5 Empirical Verification of the Truncation Error
425(5)
B.3.6 Increasing the Accuracy by Adding Correction Terms
430(2)
B.3.7 Extension to Variable Coefficients
432(2)
B.3.8 Exact Solutions of the Finite Difference Equations 433 B.3.9 Computing Truncation Errors in Nonlinear Problems
434(1)
B.4 Vibration ODEs
434(6)
B.4.1 Linear Model Without Damping
434(3)
B.4.2 Model with Damping and Nonlinearity
437(1)
B.4.3 Extension to Quadratic Damping
438(1)
B.4.4 The General Model Formulated as First-Order ODEs
439(1)
B.5 Wave Equations
440(5)
B.5.1 Linear Wave Equation in 1D
440(1)
B.5.2 Finding Correction Terms
441(1)
B.5.3 Extension to Variable Coefficients
442(2)
B.5.4 Linear Wave Equation in 2D/3D
444(1)
B.6 Diffusion Equations
445(2)
B.6.1 Linear Diffusion Equation in 1D
445(1)
B.6.2 Nonlinear Diffusion Equation in 1D
446(1)
B.7 Exercises
447(4)
C Software Engineering; Wave Equation Model
451(42)
C.1 A 1D Wave Equation Simulator
451(4)
C.1.1 Mathematical Model
451(1)
C.1.2 Numerical Discretization
451(1)
C.1.3 A Solver Function
452(3)
C.2 Saving Large Arrays in Files
455(4)
C.2.1 Using savez to Store Arrays in Files
455(2)
C.2.2 Using joblib to Store Arrays in Files
457(1)
C.2.3 Using a Hash to Create a File or Directory Name
458(1)
C.3 Software for the 1D Wave Equation
459(3)
C.3.1 Making Hash Strings from Input Data
460(1)
C.3.2 Avoiding Rerunning Previously Run Cases
460(1)
C.3.3 Verification
461(1)
C.4 Programming the Solver with Classes
462(13)
C.4.1 Class Parameters
463(2)
C.4.2 Class Problem
465(1)
C.4.3 Class Mesh
465(3)
C.4.4 Class Function
468(3)
C.4.5 Class Solver
471(4)
C.5 Migrating Loops to Cython
475(5)
C.5.1 Declaring Variables and Annotating the Code
476(2)
C.5.2 Visual Inspection of the C Translation
478(1)
C.5.3 Building the Extension Module
479(1)
C.5.4 Calling the Cython Function from Python
480(1)
C.6 Migrating Loops to Fortran
480(5)
C.6.1 The Fortran Subroutine
481(1)
C.6.2 Building the Fortran Module with f2py
482(1)
C.6.3 How to Avoid Array Copying
483(2)
C.7 Migrating Loops to C via Cython
485(3)
C.7.1 Translating Index Pairs to Single Indices
485(1)
C.7.2 The Complete C Code
486(1)
C.7.3 The Cython Interface File
486(1)
C.7.4 Building the Extension Module
487(1)
C.8 Migrating Loops to C via f2py
488(2)
C.8.1 Migrating Loops to C++ via f2py
489(1)
C.9 Exercises
490(3)
References 493(2)
Index 495
Svein Linge is a professor of modelling and simulation at the University College of Southeast Norway and holds a Dr. Scient. degree in biomechanics from the Norwegian School of Sport Sciences. He works part-time at a Norwegian Center of Excellence: "Center for Biomedical Computing", at Simula Research Laboratory, to which he has been linked for the last 13 years. His main research interests includes cerebrospinal fluid dynamics, cardiac electro-mechanics and sport biomechanics. Over the last decade, Linge has been particularly engaged in reforming the engineering education in mathematics and physics to take advantage of computer programming and simulation.





Hans Petter Langtangen was a professor of computer science at the University of Oslo. He had formerly been a professor of mechanics and was the director of a Norwegian Center of Excellence: "Center for Biomedical Computing", at Simula Research Laboratory. Langtangen published over 100 scientific publications and written several books, including papers and the bestseller TCSE 6 "A Primer on Scientific Programming with Python", now in its 5th edition. He also developed open source and commercial software systems for computational sciences. Hans Petter Langtangen passed away in October 2016.