有限元解偏微分方程的工具FEniCS, 阅读材料
FEniCS: a user-friendly tool for solving partial differential equations (PDEs)
Fundamentals
FEniCS is a user-friendly tool for solving partial differential equations (PDEs). The goal of this tutorial is to get you started with FEniCS through a series of simple examples that demonstrate
how to define the PDE problem in terms of a variational problem,
how to define simple domains,
how to deal with Dirichlet, Neumann, and Robin conditions,
how to deal with variable coefficients,
how to deal with domains built of several materials (subdomains),
how to compute derived quantities like the flux vector field or a functional of the solution,
how to quickly visualize the mesh, the solution, the flux, etc.,
how to solve nonlinear PDEs in various ways,
how to deal with time-dependent PDEs,
how to set parameters governing solution methods for linear systems,
how to create domains of more complex shape.
The mathematics of the illustrations is kept simple to better focus on FEniCS functionality and syntax. This means that we mostly use the Poisson equation and the time-dependent diffusion equation as model problems, often with input data adjusted such that we get a very simple solution that can be exactly reproduced by any standard finite element method over a uniform, structured mesh. This latter property greatly simplifies the verification of the implementations. Occasionally we insert a physically more relevant example to remind the reader that changing the PDE and boundary conditions to something more real might often be a trivial task.
FEniCS may seem to require a thorough understanding of the abstract mathematical version of the finite element method as well as familiarity with the Python programming language. Nevertheless, it turns out that many are able to pick up the fundamentals of finite elements and Python programming as they go along with this tutorial. Simply keep on reading and try out the examples. You will be amazed of how easy it is to solve PDEs with FEniCS!
Reading this tutorial obviously requires access to a machine where the FEniCS software is installed. The section Installing FEniCS explains briefly how to install the necessary tools.
All the examples discussed in the following are available as executable Python source code files in a directory tree.
The Poisson equation
Our first example regards the Poisson problem
以下省略