FEM1D
Piecewise Linear Finite Element Method for 1D problem.


FEM1D is a Python program which applies the finite element method (FEM) to a 1D linear two point boundary value problem (BVP), using piecewise linear basis functions.

The BVP to be solved is:

        -u'' = x * ( x + 3 ) * exp ( x )  over the interval 0 < x < 1
        u(0) = 0.0
        u(1) = 0.0
      

The exact solution is:

        u(x) = x * ( 1 - x ) * exp ( x )
      

A version of the finite element method is used. Six equally spaced nodes are defined, from 0.0 to 1.0, dividing the interval into 5 elements. At node I, we associate a "hat" function, or piecewise linear basis function, PSI(I)(X), which has the value 1 at that node, is 0 at all other nodes.

We look for an approximate solution to our problem of the form

        UH(X) = sum ( 1 <= I <= 6 ) C(I) * PSI(I,X)
      
so that now the problem becomes the determination of the unknown coefficients C.

We take the original BVP, multiply by test function PSI(J,X), integrate over the region, and apply integration by parts, to obtain a linear system of the form

        A * C = F
      
We modify the first and last rows of the linear system to enforce the boundary conditions, then solve to determine the values of C.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

FEM1D is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

FEM1D_BVP_LINEAR, a Python program which applies the finite element method (FEM), with piecewise linear elements, to a two point boundary value problem (BVP) in one spatial dimension, and compares the computed and exact solutions with the L2 and seminorm errors.

FD1D_HEAT_EXPLICIT, a Python library which uses the finite difference method (FDM) and explicit time stepping to solve the time dependent heat equation in 1D.

FEM1D, a data directory which contains examples of 1D FEM files, three text files that describe a 1D finite element model;

FEM1D_BVP_QUADRATIC, a Python program which applies the finite element method (FEM), with piecewise quadratic elements, to a two point boundary value problem (BVP) in one spatial dimension.

FEM1D_CLASSES, a Python library which defines classes useful for solving a boundary value problem (BVP) of the form u''+2u'+u=f in 1 spatial dimension, using the finite element method (FEM), by Mike Sussman.

Reference:

  1. Gilbert Strang, George Fix,
    An Analysis of the Finite Element Method,
    Cambridge, 1973,
    ISBN: 096140888X,
    LC: TA335.S77.

Source Code:

FEM1D solves -u''=x*(1-x)*exp(x).

FEM1D_MODEL solves -u'' + u = x. It differs from FEM1D in using a more intuitive approach to assembling the system matrix.

You can go up one level to the Python source codes.


Last revised on 23 September 2014.