Solving PDEs in Python
Hans Petter Langtangen
Computers & Technology
Solving PDEs in Python

This book offers a concise and gentle introduction to finite element programming in Python based on the popular FEniCS software library. Using a series of examples, including the Poisson equation, the equations of linear elasticity, the incompressible Navier–Stokes equations, and systems of nonlinear advection–diffusion–reaction equations, it guides readers through the essential steps to quickly solving a PDE in FEniCS, such as how to define a finite variational problem, how to set boundary conditions, how to solve linear and nonlinear systems, and how to visualize solutions and structure finite element Python programs.

1 Preliminaries
1.1 The FEniCS Project
1.2 What you will learn
1.3 Working with this tutorial
1.4 Obtaining the software
1.4.1 Installation using Docker containers
1.4.2 Installation using Ubuntu packages
1.4.3 Testing your installation
1.6 Background knowledge
1.6.1 Programming in Python
1.6.2 The finite element method
2.1 Mathematical problem formulation
2.1.1 Finite element variational formulation
2.1.2 Abstract finite element variational formulation
2.1.3 Choosing a test problem
3.1 The heat equation
3.1.1 PDE problem
3.1.2 Variational formulation
3.1.3 FEniCS implementation
4.1 Combining Dirichlet and Neumann conditions
4.1.1 PDE problem
4.1.2 Variational formulation
4.1.3 FEniCS implementation
4.3 Defining subdomains for different materials
4.3.1 Using expressions to define subdomains
4.3.2 Using mesh functions to define subdomains
4.3.3 Using C++ code snippets to define subdomains
5.1 Refactoring the Poisson solver
5.1.1 A more general solver function
5.1.2 Writing the solver as a Python module
5.1.3 Verification and unit tests
5.1.4 Parameterizing the number of space dimensions
1.5 Obtaining the tutorial examples
2 Fundamentals: Solving the Poisson equation
2.2 FEniCS implementation
2.2.1 The complete program
2.2.2 Running the program
2.3 Dissection of the program
2.3.1 The important first line
2.3.2 Generating simple meshes
2.3.3 Defining the finite element function space
2.3.4 Defining the trial and test functions
2.3.5 Defining the boundary conditions
2.3.6 Defining the source term
2.3.7 Defining the variational problem
2.3.8 Forming and solving the linear system
2.3.9 Plotting the solution using the plot command
2.3.10 Plotting the solution using ParaView
2.3.11 Computing the error
2.3.12 Examining degrees of freedom and vertex values
2.4 Deflection of a membrane
2.4.1 Scaling the equation
2.4.2 Defining the mesh
2.4.3 Defining the load
2.4.4 Defining the variational problem
2.4.5 Plotting the solution
2.4.6 Making curve plots through the domain
3 A Gallery of finite element solvers
3.2 A nonlinear Poisson equation
3.2.1 PDE problem
3.2.2 Variational formulation
3.2.3 FEniCS implementation
3.3 The equations of linear elasticity
3.3.1 PDE problem
3.3.2 Variational formulation
3.3.3 FEniCS implementation
3.4 The Navier–Stokes equations
3.4.1 PDE problem
3.4.2 Variational formulation
3.4.3 FEniCS implementation
3.5 A system of advection–diffusion–reaction equations
3.5.1 PDE problem
3.5.2 Variational formulation
3.5.3 FEniCS implementation
4 Subdomains and boundary conditions
4.2 Setting multiple Dirichlet conditions
4.4 Setting multiple Dirichlet, Neumann, and Robin conditions
4.4.1 Three types of boundary conditions
4.4.2 PDE problem
4.4.3 Variational formulation
4.4.4 FEniCS implementation
4.4.5 Test problem
4.4.6 Debugging boundary conditions
4.5 Generating meshes with subdomains
4.5.1 PDE problem
4.5.2 Variational formulation
4.5.3 FEniCS implementation
5 Extensions: Improving the Poisson solver
5.2 Working with linear solvers
5.2.1 Choosing a linear solver and preconditioner
5.2.2 Choosing a linear algebra backend
5.2.3 Setting solver parameters
5.2.4 An extended solver function
5.2.5 A remark regarding unit tests
5.2.6 List of linear solver methods and preconditioners
5.3 High-level and low-level solver interfaces
5.3.1 Linear variational problem and solver objects
5.3.2 Explicit assembly and solve
5.3.3 Examining matrix and vector values
5.4 Degrees of freedom and function evaluation
5.4.1 Examining the degrees of freedom
5.4.2 Setting the degrees of freedom
5.4.3 Function evaluation
5.5 Postprocessing computations
5.5.1 Test problem
5.5.2 Flux computations
5.5.3 Computing functionals
5.5.4 Computing convergence rates
5.5.5 Taking advantage of structured mesh data
5.6 Taking the next step
The book hasn't received reviews yet.