$$ \newcommand{\uex}{{u_{\small\mbox{e}}}} \newcommand{\uexd}[1]{{u_{\small\mbox{e}, #1}}} \newcommand{\vex}{{v_{\small\mbox{e}}}} \newcommand{\vexd}[1]{{v_{\small\mbox{e}, #1}}} \newcommand{\Aex}{{A_{\small\mbox{e}}}} \newcommand{\half}{\frac{1}{2}} \newcommand{\halfi}{{1/2}} \newcommand{\tp}{\thinspace .} \newcommand{\Ddt}[1]{\frac{D #1}{dt}} \newcommand{\E}[1]{\hbox{E}\lbrack #1 \rbrack} \newcommand{\Var}[1]{\hbox{Var}\lbrack #1 \rbrack} \newcommand{\Std}[1]{\hbox{Std}\lbrack #1 \rbrack} \newcommand{\xpoint}{\boldsymbol{x}} \newcommand{\normalvec}{\boldsymbol{n}} \newcommand{\Oof}[1]{\mathcal{O}(#1)} \newcommand{\x}{\boldsymbol{x}} \newcommand{\X}{\boldsymbol{X}} \renewcommand{\u}{\boldsymbol{u}} \renewcommand{\v}{\boldsymbol{v}} \newcommand{\w}{\boldsymbol{w}} \newcommand{\V}{\boldsymbol{V}} \newcommand{\e}{\boldsymbol{e}} \newcommand{\f}{\boldsymbol{f}} \newcommand{\F}{\boldsymbol{F}} \newcommand{\stress}{\boldsymbol{\sigma}} \newcommand{\strain}{\boldsymbol{\varepsilon}} \newcommand{\stressc}{{\sigma}} \newcommand{\strainc}{{\varepsilon}} \newcommand{\I}{\boldsymbol{I}} \newcommand{\T}{\boldsymbol{T}} \newcommand{\dfc}{\alpha} % diffusion coefficient \newcommand{\ii}{\boldsymbol{i}} \newcommand{\jj}{\boldsymbol{j}} \newcommand{\kk}{\boldsymbol{k}} \newcommand{\ir}{\boldsymbol{i}_r} \newcommand{\ith}{\boldsymbol{i}_{\theta}} \newcommand{\iz}{\boldsymbol{i}_z} \newcommand{\Ix}{\mathcal{I}_x} \newcommand{\Iy}{\mathcal{I}_y} \newcommand{\Iz}{\mathcal{I}_z} \newcommand{\It}{\mathcal{I}_t} \newcommand{\If}{\mathcal{I}_s} % for FEM \newcommand{\Ifd}{{I_d}} % for FEM \newcommand{\Ifb}{{I_b}} % for FEM \newcommand{\setb}[1]{#1^0} % set begin \newcommand{\sete}[1]{#1^{-1}} % set end \newcommand{\setl}[1]{#1^-} \newcommand{\setr}[1]{#1^+} \newcommand{\seti}[1]{#1^i} \newcommand{\sequencei}[1]{\left\{ {#1}_i \right\}_{i\in\If}} \newcommand{\basphi}{\varphi} \newcommand{\baspsi}{\psi} \newcommand{\refphi}{\tilde\basphi} \newcommand{\psib}{\boldsymbol{\psi}} \newcommand{\sinL}[1]{\sin\left((#1+1)\pi\frac{x}{L}\right)} \newcommand{\xno}[1]{x_{#1}} \newcommand{\Xno}[1]{X_{(#1)}} \newcommand{\yno}[1]{y_{#1}} \newcommand{\Yno}[1]{Y_{(#1)}} \newcommand{\xdno}[1]{\boldsymbol{x}_{#1}} \newcommand{\dX}{\, \mathrm{d}X} \newcommand{\dx}{\, \mathrm{d}x} \newcommand{\ds}{\, \mathrm{d}s} \newcommand{\Real}{\mathbb{R}} \newcommand{\Integerp}{\mathbb{N}} \newcommand{\Integer}{\mathbb{Z}} $$ previous next

Table of contents

Finite difference methods for waves on a string
      The complete initial-boundary value problem
      Input data in the problem
      Demo of a vibrating string (\( C=0.8 \))
      Demo of a vibrating string (\( C=1.0012 \))
      Step 1: Discretizing the domain
      The discrete solution
      Step 2: Fulfilling the equation at the mesh points
      Step 3: Replacing derivatives by finite differences
      Step 3: Algebraic version of the PDE
      Step 3: Algebraic version of the initial conditions
      Step 4: Formulating a recursive algorithm
      The Courant number
      The finite difference stencil
      The stencil for the first time level
      The algorithm
      Moving finite difference stencil
      Sketch of an implementation (1)
      PDE solvers should save memory
      Sketch of an implementation (2)
Verification
      A slightly generalized model problem
      Discrete model for the generalized model problem
      Modified equation for the first time level
      Using an analytical solution of physical significance
      Manufactured solution: principles
      Manufactured solution: example
      Testing a manufactured solution
      Constructing an exact solution of the discrete equations
      Analytical work with the PDE problem
      Analytical work with the discrete equations (1)
      Analytical work with the discrete equations (1)
      Testing with the exact discrete solution
Implementation
      The algorithm
      What do to with the solution?
      Making a solver function
      Verification: exact quadratic solution
      Visualization: animating \( u(x,t) \)
      Making movie files
      Running a case
      Implementation of the case
      Resulting movie for \( C=0.8 \)
      The benefits of scaling
Vectorization
      Operations on slices of arrays
      Test the understanding
      Vectorization of finite difference schemes (1)
      Vectorization of finite difference schemes (2)
      Vectorized implementation in the solver function
      Verification of the vectorized version
      Efficiency measurements
Generalization: reflecting boundaries
      Neumann boundary condition
      Discretization of derivatives at the boundary (1)
      Discretization of derivatives at the boundary (2)
      Visualization of modified boundary stencil
      Implementation of Neumann conditions
      Moving finite difference stencil
      Index set notation
      Index set notation in code
      Index sets in action (1)
      Index sets in action (2)
      Alternative implementation via ghost cells
      Implementation of ghost cells (1)
      Implementation of ghost cells (2)
Generalization: variable wave velocity
      The model PDE with a variable coefficient
      Discretizing the variable coefficient (1)
      Discretizing the variable coefficient (2)
      Discretizing the variable coefficient (3)
      Computing the coefficient between mesh points
      Discretization of variable-coefficient wave equation in operator notation
      Neumann condition and a variable coefficient
      Implementation of variable coefficients
      A more general model PDE with variable coefficients
      Generalization: damping
Building a general 1D wave equation solver
      Collection of initial conditions
Finite difference methods for 2D and 3D wave equations
      Examples on wave equations written out in 2D/3D
      Boundary and initial conditions
      Example: 2D propagation of Gaussian function
      Mesh
      Discretization
      Special stencil for the first time step
      Variable coefficients (1)
      Variable coefficients (2)
      Neumann boundary condition in 2D
Implementation of 2D/3D problems
      Algorithm
      Scalar computations: mesh
      Scalar computations: arrays
      Scalar computations: initial condition
      Scalar computations: primary stencil
      Vectorized computations: mesh coordinates
      Vectorized computations: stencil
      Verification: quadratic solution (1)
      Verification: quadratic solution (2)
Migrating loops to Cython
      Declaring variables and annotating the code
      Cython version of the functions
      Visual inspection of the C translation
      Building the extension module
      Calling the Cython function from Python
Migrating loops to Fortran
      The Fortran subroutine
      Building the Fortran module with f2py
      How to avoid array copying
      Efficiency of translating to Fortran
Migrating loops to C via Cython
      The C code
      The Cython interface file
      Building the extension module
Migrating loops to C via f2py
      The C code and the Fortran interface file
      Building the extension module
      Migrating loops to C++ via f2py
Analysis of the difference equations
      Properties of the solution of the wave equation
      Demo of the splitting of \( I(x) \) into two waves
      Effect of variable wave velocity
      What happens here?
      Representation of waves as sum of sine/cosine waves
      Analysis of the finite difference scheme
      Preliminary results
      Numerical wave propagation (1)
      Numerical wave propagation (2)
      Numerical wave propagation (3)
      Why \( C\leq 1 \) is a stability criterion
      Numerical dispersion relation
      The special case \( C=1 \)
      Computing the error in wave velocity
      Visualizing the error in wave velocity
      Taylor expanding the error in wave velocity
      Example on effect of wrong wave velocity (1)
      Example on effect of wrong wave velocity (1)
      Extending the analysis to 2D (and 3D)
      Discrete wave components in 2D
      Stability criterion in 2D
      Stability criterion in 3D
      Numerical dispersion relation in 2D (1)
      Numerical dispersion relation in 2D (2)
      Numerical dispersion relation in 2D (3)

previous next