Software for the Automatic and Efficient Solution of Differential Equations

FENICS is a collection of free software for the automatic and efficient solution of differential equations with the finite element method.

FENICS provides a simple, abstract language in which the user can describe the computational region, the mesh, the finite element test and trial spaces, the boundary and initial conditions, and the solution procedure. The user may also easily request plots of the solution and mesh, or have the solution data written to a file for later visualization or analysis.

The problem description takes place using the Python language. This procedure is fairly simple and stereotypical, so that a user who can learn from examples need not first try to master Python.

Once FENICS has determined the user's desires, the actual calculation is done using an extensive C++ library, which, depending on the installation, can include parallel execution under MPI, with access to powerful software libraries such as CHOLMOD, MTL4, PETSC, TRILINOS/Epetra, and UMFPACK.

Although FENICS can display plots interactively, it is also able to write solution data to a file in a Visual Toolkit (VTK) format that can be read in by such standard visualization packages as ParaView and VisIt.


The software developed by the FEniCS Project is free for all to use and modify (licensed under the GNU (L)GPL)

Related Data and Programs:

DEALII, examples which illustrate the use of DEAL.II, a finite element Differential Equations Analysis Library (DEAL).

DOLFIN-CONVERT, a Python program which can convert a mesh file from a given format to an XML format suitable for use by DOLFIN or FENICS, by Anders Logg.

DOLFIN_XML, a data directory which contains examples of XML files that describe 3D finite element meshes as used by DOLFIN and FENICS.

FEM_TO_XML, a C program which reads FEM files defining a 1D, 2D or 3D mesh, namely a file of node coordinates and a file of elements defined by node indices, and creates a corresponding XML file for input to DOLFIN or FENICS.

FEM2D_MESH_DISPLAY, a MATLAB program which reads the FEM model of a 2D mesh, consisting of polygonal elements of any uniform order, and displays an image of the elements and nodes, with optional numbering.

FEM2D_SCALAR_DISPLAY, a MATLAB program which reads information about nodes, elements and nodal values for a 2D finite element method (FEM) and creates a surface plot of U(X,Y), using the MATLAB graphics system.

FEM2D_SCALAR_DISPLAY_GPL, a MATLAB program which reads information about nodes, elements and nodal values for a 2D finite element method (FEM) and creates a GPL file describing a surface plot of U(X,Y), which can be displayed by gnuplot.

FENICS_GLACIER, a FENICS input file that sets up the 2D steady Stokes equations to model the movement of a glacier, by William Mitchell.

FENICS_TO_FEM, examples which illustrate how a mesh or scalar function computed by the FENICS program can be written to FEM files, which can then be used to create images, or as input to meshing programs or other analysis tools.

FREEFEM++, examples which illustrate the use of the FREEFEM++ package, a high-level integrated development environment for the numerical solution of nonlinear multiphysics partial differential equations in 2D and 3D.

GMSH, examples which illustrate the use of the gmsh program, a 3D mesh generator for the finite element method (FEM).

IFISS, examples which illustrate the use of IFISS, the MATLAB-based flow-solver.

MESH2D, a MATLAB library which can automatically create a triangular mesh for a given polygonal region, by Darren Engwirda.

MESHLAB, examples which illustrate the use of the meshlab program, an advanced mesh processing system for automatic or user-assisted editing, cleaning, filtering, converting and rendering of large unstructured 3D triangular meshes. MESHLAB can read and write 3DS, OBJ, OFF, PLY, and STL graphics files.

MITCHELL_FENICS, examples which illustrate the implementation of the Mitchell elliptic test problems using FENICS.

PARAVIEW, examples which illustrate the use of the paraview interactive visualization program.

TETGEN, examples which illustrate the use of TETGEN, a program which can compute the convex hull and Delaunay tetrahedralization of a set of 3D points, or can start with a 3D region defined by its boundaries, and construct a boundary-constrained conforming quality Delaunay mesh, by Hang Si.

UMFPACK, C++ programs which illustrate how to solve a sparse linear system by calling the C library UMFPACK, by Timothy Davis.

VISIT, examples which illustrate the use of the visit interactive graphics program.

VTK, a data directory which contains examples of legacy VTK files, a file format used by the Visual Toolkit, and which can be displayed by programs such as paraview and visit;

XML, a data directory which contains examples of XML files, a standard, general datafile format.

XML_TO_FEM, a Python program which reads an XML file created by FENICS or DOLFIN, describing a mesh in 1D, 2D, or 3D, and creates corresponding FEM files, namely, a file of node coordinates, and a file of element connectivities.


  1. Anders Logg, Kent-Andre Mardal, Garth Wells,
    Automated Solution of Differential Equations by the Finite Element Method: The FEniCS Book,
    Lecture Notes in Computational Science and Engineering,
    Springer, 2011,
    ISBN13: 978-3642230981.
  2. Anders Logg, Garth Wells,
    DOLFIN: Automated finite element computing,
    ACM Transactions on Mathematical Software,
    Volume 37, Number 2, Article 20, April 2010.
  3. Martin Sandve Alnaes, Johan Hake, Robert Kirby, Hans Petter Langtangen, Anders Logg, Garth Wells,
    The FEniCS Manual,
  4. Hans Petter Langtangen,
    A FEniCS Tutorial,

Examples and Tests:

The only reason I can allow you to access and download these python scripts is because I have a hidden file called ".htaccess" which reads RemoveHandler .py thus instructing the Apache fileserver not to try to pre-emptively interpret the files as instructions to its good self.

BURGERS_STEADY solves the steady Burgers equation in 1D. This requires the formulation and solution of a nonlinear equation.

BVP_01 solves -u''+u=x on 0 < x < 1, u(0)=u(1)=0, with piecewise linear basis functions.

BVP_02 solves -u''+u=x on 0 < x < 1, u(0)=u(1)=0, again. computing a table of values, the L1 and H1 errors, and the average value of the solution.

BVP_03 solves -u''=f(x) on -8 < x < 8, with right hand side and boundary conditions set so that the exact solution is u(x) = arctangent(x). The point of this example is that the mesh will be read in from a file. Moreover, the solution has regions of strong curvature, so a sequence of meshes is supplied to try to supply more information there. The meshes were created by taking the mesh file output from BVP_01, examining it, and making new versions by hand.

BVP_04 solves the same problem as bvp_01; however, as a preparation for example bvp_05, we write out explicitly the Dirichlet boundary conditions at the left and right endpoints.

BVP_05 solves the same problem as bvp_05, except that it applies a Neumann boundary condition on the right end point.

BVP_06 solves a 2D problem on the unit square with zero Dirichet boundary conditions.

BVP_07 solves a 2D problem on the L-shaped region with zero Dirichet boundary conditions, and a nonnegative right hand side.

CIRCLE models the deflection of an elastic circular membrane subject to a perpendicular pressure modeled as a Gaussian function over a circular domain whose mesh is read from a file.

D1_P2D defines a version of the Poisson equation in the 2D unit square, with Dirichlet boundary conditions. On our system, I can execute this example with the command "python < d1_p2D.py".

DOMAIN shows how an interesting region can be created by "subtracting" some subregions. In this example, we start with a circle, and subtract a smaller rectangle and circle, creating holes. If only there was usable Fenics documentation to list more clearly the options for such geometric primitives!

EX01 demonstrates how, given a mesh, one can specify values at the nodes, so that a finite element mesh interpolant can be defined.

HEAT_01 solves the steady heat equation in a 2D rectangle with Dirichlet boundary conditions.

HEAT_02 shows how to set up a simple version of the heat equation (rectangular domain, zero Dirichlet boundary conditions) which is modified by adding a point source to the right hand side. We can do this by converting the bilinear and linear forms to matrices, and then "applying" the point load.

HEAT_03 sets up a problem in a rectangular region in which the thermal diffusivity is a function of y.

HEAT_04 sets up a problem in which the thermal diffusivity abruptly changes spatially from 5.0 to 1.0 along a rectangular channel, with Dirichlet boundary conditions at the endpoints. The resulting solution is piecewise linear.

HEAT_EXPLICIT_01 sets up a time dependent heat problem in a square "minus" a circle, and uses an explicit time stepping scheme. I have had a lot of difficulty figuring out how to use FENICS to get this relatively simply procedure to work.

HEAT_EXPLICIT_02 an alternative version of heat_explicit_01, kindly put together by Mike Sussman, which uses the meshr package to create the mesh.

HEAT_IMPLICIT_01 sets up a time dependent heat problem in a square "minus" a circle, and uses an implicit time stepping scheme.

MEMBRANE1 models the deflection of an elastic circular membrane subject to a perpendicular pressure modeled as a Gaussian function.

MESHES displays an example of each of the simple built-in mesh types that FENICS provides: UnitIntervalMesh(), IntervalMesh(), UnitSquareMesh(), RectangleMesh(), UnitCubeMesh() and BoxMesh().

NONLINEAR_POISSON solves the nonlinear Poisson equation in a 2D square, with a diffusitivity coefficient of 1+U**2.

STOKES solves the steady Stokes equations for fluid flow in a 3D region (the unit cube). The unknowns are the velocity vector U and scalar pressure field P. The example shows how to declare the appropriate function space, boundary conditions, and the variational problem. Because of the nature of the Stokes equations and the size of the linear system, a particular linear iterative solver is required, and preconditioning is also needed.

You can go up one level to the Examples directory.

Last revised on 19 November 2014.