Finite element methods (FEM) are used to solve a vast array of problems in all disciplines, it is essential to learn these methods if you really want to use the computer to solve real-world problems. I will illustrate some of the commonly used methods, but this is a large discipline of itself, so you will want to get a good book on the subject and read it through.
A one-dimensional differential equation
Lets solve the problem of simple cooling of a body
Break up the domain into a mesh of points. These do not need to be equally spaced. For example let the entire time domain be (so a series solution could be convergent), and so that everything can be numerical let and . We will break up the interior domain into , , .
Construct a trial solution that obeys the boundary condition using some basis functions , here we use powers of
which we truncate so that we have as many undetermined constants as we do interior mesh points
Construct the residual function which measures how close the trial is to the actual solution;
Find the coefficients that minimize the residual. Note the similarity to least squares.
It may be possible to actually force the residual to vanish (collocation method). This will happen when we have a set of linear equations in the coefficients to solve.
For a collocation solution, we obtain a system of equations using our mesh of -values:
(1)
Solving these we obtain
which is not in good agreement with the exact solution .
Let’s write a REDUCE program (REDUCE is great for prototyping because it is not strongly typed) and try to get better accuracy
operator a,eqs;
trial:=10.0+for n:=1:8 sum a(n)*x^n;
mesh:={0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.85};
R:=df(trial, x)+2.0*trial;
for n:=1:8 do eqs(n):=sub(x=part(mesh,n),R);
solve(for n:=1:8 collect eqs(n), for n:=1:8 collect a(n));
now we get
which is much better (obviously a finer mesh will give better results).
Approximating the solution with a polynomial using powers of or as a basis creates a problem; fitting a function to a polynomial at a set of discrete points results in oscillation of the polynomial between the discrete set of points used to fit the curve. FEM techniques are designed to cure this problem.
Galerkin method
Instead of demanding the vanishing of the residual, which may not even be possible,we demand that its weighted average value computed over sub-domains vanishes;
and the weight function used in the Galerkin method is the trial function itself. This gives the method a very quantum mechanical flavor, since we will want our basis functions that we expand the trial solution in to be square-integrable, and independent.
The full Galerkin treatment for a one-dimensional problem then is as follows:
Find a set of basis functions and a function that obeys the boundary conditions, and construct the trial solution
(lets assume we are working with functions of for ). Compute the residual , and then obtain your system of equations
and solve the system for your solution.
The most commonly used basis functions for simple demonstrations of the Galerkin method are piecewise continuous localized simplexes in one dimension, with compact support (the subset of upon which the function is non-zero)
for the simple reason that
and
although localized, compactly supported quadratic and cubic functions are also used. Note that these basis functions are very good for enforcing Neumann boundary conditions since they have constant slopes, and the “overlap integrals” are easy to compute
Next: We solve the one-dimensional Dirichlet problem by the Galerkin method.