fem1d_model, a Python code which applies the finite element method (FEM) to a 1D linear two point boundary value problem (BVP), using piecewise linear basis functions.
FEM1D_MODEL differs from FEM1D in using a more intuitive approach to assembling the system matrix.
The BVP to be solved is:
-u'' + u = x u(0) = 0.0 u(1) = 0.0
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 = FWe modify the first and last rows of the linear system to enforce the boundary conditions, then solve to determine the values of C.
The computer code and data files described and made available on this web page are distributed under the MIT license
fem1d_model is available in a Python version.
fem1d_bvp_linear, a Python code 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 code 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 code 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 code 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.