Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
28 views5 pages

FEM 198 - 1 - Online

Uploaded by

robliutpg.com.au
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

FEM 198 - 1 - Online

Uploaded by

robliutpg.com.au
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

RESEARCH ARTICLE | MARCH 01 1992

Finite‐Element Method in a Spreadsheet 


Robert A. Dory

Comput. Phys. 6, 198–201 (1992)


https://doi.org/10.1063/1.4823062


View Export
Online Citation

Articles You May Be Interested In

Macros in a Spreadsheet
Comput. Phys. (September 1990)

Contour Plots for Spreadsheets


Comput. Phys. (September 1991)

Fourier Analysis Using A Spreadsheet


Comput. Phys. (November 1988)

09 November 2024 10:58:05


SPREADSHEETS

Finite-Element Method in a Spreadsheet


Robert A. Dory

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

09 November 2024 10:58:05


general Sturm-Liouville boundary-value problem (BVP)
in one dimension and a Laplace equation BVP in a
triangular region. Only the first example is treated in this
A= (I XO

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.

198 COMPUTERS IN PHYSICS VOL. 6. NO.2, MARIAPR 1992


Integration Formulas: We will need to evaluate The last is so written to simplify description of its
integrals having the form counterpart at the Neumann boundary, X = 0, where
some elements for the left side are missing: The entire left
side of the equation should be taken as zero for i = 1. At
(2) the Dirichlet boundary, X = x o, use UN = b as the finite-
element equation.
In the last equation we see terms that would appear in
Some users of the FEM will use any integration a solution of the same problem by a finite-difference
method that is ready to hand, including analytical ones- method (FDM). If p = 0, the first terms on the left and
or a numerical one which may be highly accurate, such as right sides give an FDM form for the (ju/) / in the DE. The
Gaussian quadrature. However, at least one group of remaining terms provide an FDM form for AgU, provided
authors 7 notes that a degree of integration error can be p = 1 and the grid is uniform.
useful to offset finite resolution error, as in the tunable In the discrete equations, one can isolate the terms in
scheme applied here. ui' Ui-I' and Ui + I and write the result in a standard FEM
"Tunable" integration uses a variable combination of form: Kd = F, where K is the N XN stiffness matrix
trapezoidal and midpoint rules: (tridiagonal) and d and F are displacement and force
vectors. The terminology comes from structural engineer-
ing application to bending of beams-one of the earliest
i~~l ¢(x)dx beneficiaries of the FEM.
For the I-D second-order problem, the tridiagonal
= (Xi - Xi _ I ){~p[ ¢(x i ) + ¢(xi _ I)] stiffness matrix can be inverted easily, compactly, and
accurately by the rippling method illustrated in an earlier
+ (1 - p)¢«x i + Xi_I )/2)} , (3)
column. 8 Assume that d i = aidi _ I + {3i' and use the
tridiagonal equations aid i _ I + cidi + bidi + I = Fi to

09 November 2024 10:58:05


where p is a tuning parameter. The value p = 1 gives the find simple recurrence equations for the a i and {3i' Apply
trapezoidal rule; p = 1/3 yields Simpson's rule. the recurrence for a i and{3i from one boundary to the oth-
A roughly optimal value of p will be used for the er, and then apply d i _ I = (d i - {3i )/a i back to the first
FEM problem; the true optimum will vary somewhat, boundary. The rippling forth and back completes the
depending on details of the DE. Bondeson and Fu7 solution. The process is economical and accurate; even a
observe that the error for several model problems has a fairly complicated case can be done rapidly in a
fairly broad minimum near the optimum and that results spreadsheet program on a PC or Macintosh.
are relatively insensitive to errors in choice of p. Many features of equations solved for plasma
problems are found in the Bessel equation. The form
Coefficients for the 1-0 FEM Problem: We choose to factors for the zeroth-order Bessel function Jo are! = x,
approximate the solution u as ~fu/j(x), take the test g = x, and h = 0:
functions v to be the ti themselves (Galerkin method),
and evaluate the integral in Eq. (3). The algebra is (XU/) / ° on
+ AXU = O~<xo.
somewhat tedious, but perhaps not overwhelmingly so.
When i# 1 and i#N, that is, away from the boundaries, Placing grid points at "odd" points of a problem like
the integral is the singular point ° is beneficial to accuracy and
X =
convergence. Such points are those where the form factors
have zeros or jump discontinuities, or where the force
Ui - Ui - I (Xi! dx _ Ui + I - Ui function! has a 0 function singlllarity. The singular point
(Xi -Xi _ I )2 JXi_l (X i + 1 -Xi)2 X = ° for the Bessel problem is at the left end of the inte-
gration integral, so only a little special attention is needed,
i~i+ I! dx = - A i~~+ll guti (x)dx as noted later. If the value of A is not consistent with as-
sumed boundary data, one can use the square root of the
Rayleigh quotient to estimate how much Xo should be
or scaled to make the boundary values consistent.

Xi -Xi_I

COMPUTERS IN PHYSICS, VOL. 6, NO.2, MAR/APR 1992 199


SPREADSHEETS

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

5 Node rEM for Jo


A BI C D E IF G I H J KLIMINIOP o
~ FINITE ELEMENT METHOD 1---'= p.ar.:::am:.::e",teT'rs'---c--:-+,,!:~,,",rr-,-1u=---j ROIjleigh Integrals-Eigenvalue study I lerrl u
~ Ref: Bondeson & Fu p pon. p+pl max I(fu' ,u') 0.5019 l~m""~ 1 max / M

09 November 2024 10:58:05


~ LRP 425/90 CRPP. .6083 .3747 .9829 0.0011 l(gII,u) 0.7465ILAMBDA 1.018 ~
~ grid vectors solution veoctors Form f-letor functions for Jo ~
~ N delx xo x@ Solves: True values: M1S 55 f@ f@ g@ g@ rms
~ 6 0.4 2 mdpts (fu')'+ u=O Formul.e (9.4.1 ...) x xmp x xmp I 7.2.-04
9 i dx x xm~ U -u '(x~ u true -u· true f fmp g QMP err u
f-1o 0 .4000 0 0.200 1.0 0.1 003 1.000 0.0995 0.0 0.2 0.0 0.2 I -0.001
'11 1 .4000 0.400 0.600 0.9610 0.2857 0.9604 0.2867 0.4 0.6 0.4 0.6 -6E-04
~ 2 .4000 0.800 1.000 0.8467 0.4382 0.8463 0.4401 0.8 1.0 0.8 1.0 -5E-04
f-I3 3 .4000 1.200 1.400 0.6715 0.5397 0.6711 0.5419 1 .2 1 .4 1 .2 1 .4 -3E-04
f-14 4 .4000 1.600 1.800 0.4556 0.5792 0.4554 0.5815 1.6 1.8 1.6 1.8 -2E-04
rt5 5 .4000 2.000 2.200 0.2239 -- 0.2239 [.5767] 2.0 -- 2.0 --
===b
F,t 16 I - - I 2.40 I io = 3.1 I est. xo 2.0091 I nom. err. 1.4*M I Imax .rr 0.11*M Imin err O*M I I M=.D101
10 Node FEM for Jo
ABI C D E F G I H 1 I J K LIM I N 10 P 0
~ FINITE ELEMENT METHOD parameters lerrl u Rayleigh Integrals-Eigenvalue study I lerrl u
~ Ref: Bondeson & Fu p pon. p+pl max I(fu',u') 0.5059 lam .... a 1 max / M
~ LRP 425/90 CRPP. .6083 .3747 .9829 0.0004 I(gu u) 0.7608 LAMBDA 1.004 ~
~ grid vfoctors solution vectors Form folctor functions for Jo ~
7 N delx xo x@ Solvos: True values: AMS 55 f@ f@ 9@ 9@ rms
r--a-
:::L 11
i
0.2
dx
2
x
mdpts
xmp
(fu')'+g u=O
u
Formul.e (9.4.1 .. .)
-u'(xmp) u true -u' true
x
f
xmp
fmp
x
g
xmp
gmp
1'·ge-04
~
~ 0 .2000 0 0.100 1.0 0.0:;07 1.000 0.0499 0.0 0.1 0.0 0.1 -4E-04
4 1 .2000 0.200 0.300 0.9903 0.1484 0.9900 0.1483 0.2 0.3 0.2 0.3 -2E-04
12 2 .2000 0.400 0.:;00 0.9606 0.2421 0.9604 0.2423 0.4 0.5 0.4 0.5 -2E-04
13 132000 10600 0.700 10.9122 0.3287 0.9120 0.3290 n.. n7 n (, 07 -2F-04
m 101.20002.0002.100 10.22391 -- 10.2239 [.5767]J 2.0 -- 2.01 -- I ===b
:m 1111 - - I 2.20 lio-3.1 lest.xo 2.0022 I nom. err. 0.3*M I Imaxorr 0.04*Mlminerr O*M I ~

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

200 COMPUTERS IN PHYSICS. VOL. 6. NO.2. MAR/APR 1992


5 Node rEM for Jo - Eq'ns: 1
B C D E G H I J L H
2 FINITE poromotors lorrl u R~l

~ 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

09 November 2024 10:58:05


FIG. 3. Formulas in a I·D FEM solver for a Sturm· Liouville Bessel problem. Some columns containing
nonessential formulas, such as a series approximation for "true" Bessel functions and error-measurement co-
lumns, have been truncated or deleted to save space. The fragment should be adequate to reconstruct the
worksheet-using the labels and some imagination to divine which columns have what names.

value of 3) and use an "insert row" command to add new References


rows as required. Then replicate the entire row 11 1. K. Appert, D. Berger, R. Gruber, F. Troyon, and J. Rappaz, J. Appl.
downward through the next to last row of the main table Math. Phys. (Z. Angew. Math. Phys.) 25 (1974); R. Gruber and J.
(i = N - 2). The resulting formulas for new rows should Rappaz, Finite Element Method in Linear Ideal Magnetohydrodyna-
be checked to see that they follow the patterns shown in mics (Springer-Verlag, New York, 1985).
Fig. 3. 2. T. Takeda and T. Tokuda, J. Comput. Phys. 93, I (1990).
Going Beyond: Besides static problems as illustrated 3. A. J. Glasser, K. Miller, and N. Carlson, "Moving finite elements: A
here, the FEM is used for dynamical modeling. 9 Modern continuously adaptive method for computational fluid dynamics," in
methods provide ways to optimize an underlying multidi- Proceedings of Energy Research Supercomputer Symposium, Gaithers-
mensional grid to the system dynamics by making it "go burg, MD (1991) (U.S. Dept. of Energy, Washington, DC, 1991) (in
press).
with the flow," or as governed by the flow. The grid is ad-
justed dynamically to reduce error and improve stability 4. Given FEM and FDM methods at finite resolution may conserve
while avoiding introduction of excess numerical diffusion. appropriate quantities exactly, but (somewhat to my surprise) this
In one intriguing study,3 the dynamics variational may be an incompletely resolved issue, as suggested by G. Comini and
S. Del Guidice in Int. J. Numer. Methods Eng. 32, 559 (1991).
equations are augmented by variational equations for the
grid motion to define movement of the mesh in a way that 5. G. Strang and G. Fix, An Analysis of the Finite Element Method
keeps resolution concentrated where it is most needed- (Prentice-Hall, Englewood Cliffs, NJ, 1973).
generally in regions of largest curvature of the solution
6. E. Becker, G. Carey, and J. Oden, Finite Elements: An Introduction
functions. (Prentice-Hall, Englewood Cliffs, NJ, 1981).
References 3 and 9 should be useful as initial points in
a search for recent work. 7. A. Bondeson and G. Fu, "Tunable integration scheme for the finite
element method," to be published in Comput. Phys. Commun. The
ACKNOWLEDGMENT concise statement of the FEM in the opening paagraph is based on
words from their article.
This work received partial support from Oak Ridge
National Laboratory, managed by Martin Marietta 8. R. A. Dory, Comput. Phys. 3 (3), 84 (1989).
Energy Systems, Inc., under contract DE-AC05- 9. M. J. Fritts, W. P. Crowley, and H. Trease, The Free-Lagrange
840R21400 with the United States Department of Method, Lecture Notes in Physics, No. 238 (Springer-Verlag, New
Energy.
• York, 1985).

COMPUTERS IN PHYSICS VOL. 6, NO.2, MAR/APR 1992 201

You might also like