FEM 198 - 1 - Online
FEM 198 - 1 - Online
View Export
Online Citation
Macros in a Spreadsheet
Comput. Phys. (September 1990)
A
spreadsheet program and the finite-element method integrate. If the functions are well behaved and integration
(FEM) are used to explore each other's virtues and by parts is justified, the result is
show their mutual ability to provide efficient and
accurate solutions of boundary-value differential equa-
tions (DEs) . The reason for essaying this article was to re-
duce the author's general innocence of the field and tempt
colleagues to explore the FEM. To friends who have long IXo
+ A Jo guu dx = Jo
r hu dx.
o
(1)
since put the FEM to work and extolled its virtues go
manifold thanks. 1-3
The FEM is this: Use an expansion in certain basis The first term in Eq. (1) brings in the boundary-value
functions to approximate a solution. Take scalar products conditions, while the others express the basic dependences
(integrals) of the equation (s) with a set of test functions of the DE.
to obtain discrete equations, and solve them for the This type of integral equation is the basis of the FEM,
coefficients of expansion. The basis functions used in the as well as the related Rayleigh-Ritz method. Using the
FEM have "limited support"-they are nonzero in a solution itself as a trial function, u = u, yields an equation
limited or finite interval, as suggested in Fig. 1. that can be solved for the Rayleigh quotient
For this article, two examples were explored: a quite
u'ju' dx + ...)
IXo
Jo ugu dx.
article. It was possible, but not trivial, to solve the two-di-
mensional (2-D) problem using a few tens of basis This gives an estimate for a A value that would make
elements-resolution that might be adequate in some given boundary values fully consistent with the integra-
applications. tion interval and the DE. The force term hand boundary-
condition terms are hidden here in the ellipsis. Some
FEM in One Dimension: For a one-dimensional (I-D) readers will remember using Rayleigh quotients to
example, we consider the Sturm-Liouville problem estimate energy levels of an atom from the Schr6dinger
(ju')' + AgU = h on [0, x o]; that is, O,;;;x ,;;;x o' Here, f, g, equation.
and h may be functions of x (and perhaps eigenvalue A). The integral equation is termed a weak statement of
the original problem. Its strong form was the original DE,
that is, the Euler-Lagrange equation for the conservation
law given by the integrals in Eq. (1). The terms "strong"
and "weak" denote convergence properties of a sequence
of approximate solutions: A well-chosen sequence with
increasing resolution may converge at each point in the in-
terval. However, iffunctionsf, g, and h are not sufficiently
FIG. 1. Three sample basis and test functions for the finite-element well behaved, the sequence may converge only in an
method. These are piecewise constant (top hats), piecewise linear (tents), average sense, as in Fourier analysis, with residual
and piecewise quadratics. Other higher-order polynomials, splines, etc., deviations analogous to Gibbs' phenomena.
are often used but are not shown here. Textbooks5 ,6 on the FEM discuss questions of
convergence and error at great length, as well as
Boundary conditions will have the form x' = a at x =
(Neumann) and x = b at x = Xo (Dirichlet). With minor
° alternative choices of the basis and trial functions. A
potential user should consult the texts for a serious
changes, mixtures of these could be accommodated. discussion of convergence and pitfalls.
The FEM is based on integral (conservation-Iaw4 ) For our FEM example, the expansion will be defined
statements of the problem at hand. To establish an integral by one such choice: a discrete grid in the range [0, x o ] and
statement, multiply the DE by a trial function u and a tent-function basis, as in Fig. 1. This basis function
tj (x) has unit value at grid point i; it falls linearly to zero
Robert A. Dory is a research physicist at Oak Ridge National Laboratory, at the next and preceding grid points and is zero
Oak Ridge, TN 37831. elsewhere.
Xi -Xi_I
Figure 2 displays the results of two worksheets for the in u could be reduced by a factor of 2 and more by using
Bessel test. They differ only in the number of intervals tak- grid spacing that varies smoothly by approximately 10%-
en for the grid and therefore form the beginnings of a con- 20%. Contrarily, throwing in a few extra nodes near the
vergence study. The error in u is surprisingly small, origin in the naive hope of providing more resolution near
considering the low resolution used. One reason for that is the singular point led to a large increase in error if the re-
the ease of doing "what-if" studies in a PC-based sulting grid space varied substantially between two
spreadsheet: The main value of P has been tweaked for the adjacent nodes. The textbooks will probably include that
five- and ten-node cases, giving a roughly optimum value in the list of "crimes" sometimes committed against the
of 0.61. FEM method. 5
The point x = 0 is singular, so special care is required A brief study showed that the error decreases as the
for it. Tests and analysis showed that for the first grid in- square of 8 but has a very small multiplier when care is
terval, the integration tuning parameter P should have a taken to optimize values of P and PI'
different value, PI;::::: 3/8, with a small correction for finite For nonuniform grid spacing tests, the value of delx
grid size 8. It turned out that P + PI was just less than uni- was modified by a factor
ty, differing by about 8 2 •
It was somewhat frustrating to have highly accurate {1 + bet(2/1r)tan - I [alph(i - io) n,
solution values and find that the Rayleigh quotient was
still in substantial error because of finite resolution for the giving an adequately smooth variation for an alph of about
quadrature. One could use a convergence study to 1. The maximum error in u or the weighted maximum er-
compensate, optimizing grid-space variation or the choice rors in u and u', or the error in A, could be minimized by a
FIG. 2. The Bessel FEM worksheet gives remarkably good results, despite low resolution and use of simple
linear elements. Cases here have N=5 and 10 expansion coefficients. The Rayleigh estimate A for the eigen-
value and the measures of error showed quadratic convergence in this case of equally spaced nodes, as is
shown by the nearness of LAMBDA to unity and by the value of maximum error for u{x).
ofp, as suggested in Ref. 7, to provide better convergence nonzero value of bet, but each such criterion would give a
of A to its value at high resolution. The resulting different "best" value of variation bet.
integration parameters should remain roughly optimal if The formulas (programming) for the five-node
small changes are made to details of the DE problem. As example are given in Fig. 3.
always, judicious testing is needed to ensure adequate Increasing the resolution for the calculation is fairly
accuracy for the problem at hand. simple. First, save the worksheet-in case a mistake is
Simple tests here showed also that the greatest error made. Select the entirety of row 13 (the row labeled by an i
~ Ref:B
P I~on" p+pl mox I{fu' =SUM(fmp
4 LRP 4: 0.60825 =$1$4-p 0.9829 =MAX("'9S(frr) I(gu =SUM(g*d
6 $olut;on v.ctor
f@
~
a
N
=COUNT
dolx
=08/(N-l
KO
2
x@
mdpts
Soh
(fu')'+c
True val
Formule
f@
x x~
9 i dx x xmp u I-u'(xmp) u true -u' Irue f fmp
=0.5*(010+011 ) -v-I*Gl ~=-(Gl1-Gl0)/C1( -1+xs' =xmp*(0.5+xl·
~
11
0
=Bl0+l
-011-010
=012-011
0
=010+dolx*(1 =0.5*(011+012) =v-I*GI2 =-(GI2-Gl1)/Cl1 =1+xs' =x~*(0.5+xl·
-x
=x
-x+Cl0/2
=x+Cll/2
15 =BI4+1 -017-015 -014+dolx*(1 +I -0.5"(01 5+DI7)II~v a -1 +xs'" -x "(0.5+xv·2*QI=x a
N I 0 p 0 R Y I z
3
4
h'mbda 1
LAMBDA --=($M$
max 1M
=J4/M
alp"
a I~"t
6 err u Bossel Jo(x)
rms factors for
r-J..
a x
g@
xmp
g@
=SQRT(SUI' cOfoffic;.nts
9 Ig !gmp err u la lIb
=(pono/2*(L 1O»)/Cl a ) l=pono/2*(Cl O)*Nl 0+(I-ponf)/4*(Cl 0*01 0)
~ =lambda*x =lamb
11 =lambda"x =lamb
=(u_truo-u
=(u_truo-u =(p02*(L10+L11)+omp*Ml0)/Cl0 =p02*(Cl0+Cl1)*Nl1+omp4*(Cl0*OI0+Cll *011)
15 =lambda"x 10 I 1=(u_Iruo-u~ 1=(p02*(L14+L1 5)+omp*MI4)/CI410
AB AC AD AE AF AG AH
~ 11:02 I~mp l~mp4 prol (p) j'pone) (N)
=pont/p~
~ =p/2 =1-p =(I-p)/4 =$G$4 ~one =$9$8
f6 TriD Eqn. 10 bo solvod is
1-7 Elemenls of Sourc. for", ard ripple
ra
r;-- a
Tridiagonal malr vector
den
vectors
Id Ib Iy II v
1-10 a I~Yl0+Yl1-Z10 1~-YI1-Cl0*omp4*OI0 0 =d I-b/den =y Idon
t-t1 =AD10 =Yll +YI2-Z11 =-YI2-Cll "omp4"011 a =d-a*"'Gl0 =b/den =(y-a*"'Hl0)/don