INF5620 in a nutshell
The new official six-point course description
More specific description of the contents; part 1
More specific description of the contents; part 2
Philosophy: simplify, understand, generalize
The exam
Required software
Assumed/ideal background
Start-up example for the course
Start-up example
What to learn in the start-up example; standard topics
What to learn in the start-up example; programming topics
What to learn in the start-up example; mathematical analysis
What to learn in the start-up example; generalizations
Finite difference methods
Topics in the first intro to the finite difference method
A basic model for exponential decay
Applications
Continuous problem
Discrete problem
The steps in the finite difference method
Step 1: Discretizing the domain
Step 1: Discretizing the domain
What about a mesh function between the mesh points?
Step 2: Fulfilling the equation at discrete time points
Step 3: Replacing derivatives by finite differences
Step 3: Replacing derivatives by finite differences
Step 4: Formulating a recursive algorithm
Let us apply the scheme
A backward difference
The Backward Euler scheme
A centered difference
The Crank-Nicolson scheme; part 1
The Crank-Nicolson scheme; part 2
The unifying \( \theta \)-rule
Constant time step
Test the understanding!
Compact operator notation for finite differences
Compact operator notation for difference operators
The Backward Euler scheme with operator notation
The Forward Euler scheme with operator notation
The Crank-Nicolson scheme with operator notation
Implementation
Requirements of a program
Tools to learn
Why implement in Python?
Why implement in Python?
Algorithm
Translation to Python function
Integer division
Doc strings
Formatting of numbers
Running the program
Verifying the implementation
Simplest method: run a few algorithmic steps by hand
Comparison with an exact discrete solution
Making a test based on an exact discrete solution
Test the understanding!
Computing the numerical error as a mesh function
Computing the norm of the error
Norms of mesh functions
Implementation of the norm of the error
Comment on array vs scalar computation
Plotting solutions
Decorating a plot
How the plots look like
Plotting with SciTools
Creating user interfaces
Accessing command-line arguments
Reading a sequence of command-line arguments
Implementation
Working with an argument parser
Reading option-values pairs
A graphical user interface
The Parampool package
Making a compute function
The hard part of the compute function: the HTML code
How to embed a PNG plot in HTML code
Generating the user interface
Running the web application
More advanced use
Computing convergence rates
Estimating the convergence rate \( r \)
Implementation
Execution
Debugging via convergence rates
Memory-saving implementation
Memory-saving solver function
Reading computed data from file
Usage of memory-saving code
Software engineering
Making a module
Test block
Prefixing imported functions by the module name
Downside of module prefix notation
Doctests
Running doctests
Unit testing with nose
Basic use of nose
Example on a nose test in the source code
Example on a nose test in a separate file
The habit of writing nose tests
Purpose of a test function: raise AssertionError if failure
Advantages of nose
Demonstrating nose (ideas)
Demonstrating nose (code)
Floats as test results require careful comparison
Test of wrong use
Test of convergence rates
Classical unit testing with unittest
Basic use of unittest
Demonstration of unittest
Implementing simple problem and solver classes
What to learn
The problem class
Improved problem class
The solver class
The visualizer class
Combing the classes
Implementing more advanced problem and solver classes
A generic class for parameters
The problem class
The solver class
The visualizer class
Performing scientific experiments
Model problem and numerical solution method
Plan for the experiments
Typical plot summarizing the results
Script code
Comments to the code
Interpreting output from other programs
Code for grabbing output from another program
Code for interpreting the grabbed output
Making a report
Publishing a complete project
Analysis of finite difference equations
Encouraging numerical solutions
Discouraging numerical solutions; Crank-Nicolson
Discouraging numerical solutions; Forward Euler
Summary of observations
Problem setting
Experimental investigation of oscillatory solutions
Exact numerical solution
Stability
Computation of stability in this problem
Computation of stability in this problem
Explanation of problems with Forward Euler
Explanation of problems with Crank-Nicolson
Summary of stability
Comparing amplification factors
Plot of amplification factors
Series expansion of amplification factors
Error in amplification factors
The fraction of numerical and exact amplification factors
The true/global error at a point
Computing the global error at a point
Convergence
Integrated errors
Truncation error
Computation of the truncation error
The truncation error for other schemes
Consistency, stability, and convergence
Model extensions
Extension to a variable coefficient; Forward and Backward Euler
Extension to a variable coefficient; Crank-Nicolson
Extension to a variable coefficient; \( \theta \)-rule
Extension to a variable coefficient; operator notation
Extension to a source term
Implementation of the generalized model problem
Implementations of variable coefficients; functions
Implementations of variable coefficients; classes
Implementations of variable coefficients; lambda function
Verification via trivial solutions
Verification via trivial solutions; nose test
Verification via manufactured solutions
Linear manufactured solution
Nose test for linear manufactured solution
Extension to systems of ODEs
The Backward Euler method gives a system of algebraic equations
General first-order ODEs
Generic form
The \( \theta \)-rule
Implicit 2-step backward scheme
The Leapfrog scheme
The filtered Leapfrog scheme
2nd-order Runge-Kutta scheme
4th-order Runge-Kutta scheme
2nd-order Adams-Bashforth scheme
3rd-order Adams-Bashforth scheme
The Odespy software
Example: Runge-Kutta methods
Plots from the experiments
Example: Adaptive Runge-Kutta methods