The finite element method (FEM) is probably the most widely used numerical approximation technique for solving electrostatic problems. This is true, as well as magnetostatic, general electromagnetic, structural (elastic body), and other physical system analyses.
The finite element method is similar to the FD method for electrostatics in that the space where the electric field exists is discretized (meshed, or “zoned up”) and the electrodes, with applied voltages, are the boundary conditions. It is similar to the MoM in that it is readily amenable to complex geometries.
Because of its abilities to handle complex geometries and boundary conditions, the FEM is uniquely suited to structural analysis (airplane wings, bridges, vibrating structures, etc.). Historically, much of the formal development of the FEM occurred in the mechanical engineering community.1 While electrostatics problems typically have fairly simple boundary conditions, they can have very complex structures, so the applicability and popularity of the FEM is well deserved.
The FEM formalizes and expands several topics that were foreshadowed in previous chapters:
The body of FEM literature is enormous. The breadth and depth of the subject also is enormous. The application of the FEM to electrostatics requires dealing only with a small subset of overall technique. The material below is not intended as a general introduction to FEM analysis; it only treats what is necessary in order to proceed to computer programs for problem setup and solving of Laplace’s equation.
Introducing the FEM method in one dimension allows us to minimize the calculation detail that might obscure the concepts involved. On the other hand, one-dimensional (1d) electrostatic (Laplace’s equation) problems can usually be solved analytically in the first place, so there really is no need for a numerical technique. Also, the matrix equations that result from 1dimensional FEM analysis using linear approximation functions are the same matrix equations that resulted from the FD analysis. This can be frustrating to the student because it appears to entail a lot of work which leads nowhere new. On balance, however, the simplicity that 1d derivations bring outweigh the delay their treatment brings in getting to useful results because of the stage setting they make possible.
We are looking for an approximate solution to Laplace’s equation in one dimension
in the region a ≤ x ≤ b where V(a) = Va , V(b) = Vb are the specified boundary conditions.
Begin by approximating V(x) with the function
where ε is a number and μ(x) is a twice-differentiable function satisfying μ(a) = μ(b) = 0.
For ε small, φ(x) approximates V(x) and at all times φ(x) satisfies the same boundary conditions as V(x).
Define F(V) as
Except for the proper dimensional scaling factor, F is the energy stored in the electric field in the region a ≤ x ≤ b.
If we replace V in equation (12.3) with φ, then, of course, F will change and we may write its new value as
Expanding equation (12.4), we have
The second term on the right is
because μ(a) = μ(b) = 0.
This leaves us with
Equation (12.7) shows several things:
There is much more information on this topic than has been presented here. Kwon and Bang give a detailed discussion of the various techniques for minimizing residual errors in approximate solutions to partial differential equations.2 Although not explicitly discussed above, equations (12.1)–(12.7) provide a simple example of a variational calculation. Chari and Salon devote several chapters to variational methods and finite element formulation.3 Both of these references derive the full multidimensional extension of this simple calculation.
As explained above, one-dimensional (1d) calculations and examples are a good way to introduce the FEM. The solution to Laplace’s equation in 1d rectangular coordinates, with fixed voltages at the endpoints (boundaries), is a straight line, so developing approximate solutions is a comic exercise.
Instead, we will work with Laplace’s equation in 1d cylindrical (i.e., circular) coordinates. We can still (and, indeed, will) find the exact solution, but now this exact solution is useful for evaluating approximate solution characteristics.
Figure 12.1 details the structure being considered.
The two concentric circles shown, in Figure 12.1, including the cross sections of two long concentric cylinders, have inner and outer radii a and b. These circles are conductors that are set at Va and Vb , respectively. The space between these conductions, a < r < b, is filled with a uniform dielectric (possibly air).
Using Gauss’s law, the charge on the inner circle is
where a < r < b, ε is the dielectric constant of the region, and E r is the electric field in the region.
The electric field is then
The voltage is
Evaluating the first boundary condition, we obtain
and substituting this back, we have
Evaluating the second boundary condition, we obtain
and therefore
which results in
From equation (12.14), we have
Redoing the above calculation with respect to the stored energy, we calculate the electric field using equation (12.15), specifically
from which
and finally
Equations (12.16) and (12.19), of course, agree; both derivations are shown for completeness.
The first approximation to examine is the simplest approximation that can satisfy the boundary conditions, a straight line connecting the two boundaries:
Figure 12.2 shows V(r) and φ(r) results for a = 1, b = 100, Va = 1, and Vb = 2. The simple approximation for V(r) doesn't appear to be a very realistic approximation at all.
Equation 12.20 could have been factored and/or expanded and then presented in any of several different but equivalent forms. The form chosen will prove to be very useful going forward. In this example ϕ(r), the approximation to V(r), extends over the entire region of the structure, a ≤ r ≤ b. It is expressed in terms of the voltages at the ends of the region (nodes), which in this example happen to be the boundary conditions. Each node voltage (Va and Vb ) is multiplied by basis functions, Ha (r) and Hb (r), respectively. In this example these basis functions are simple linear equations; it will soon be shown that this is not a necessary condition. The basis functions have several properties:
Continuing, we have
and then
and
Both the exact capacitance [equation (12.19)] and this approximate capacitance are functions only of the ratio b/a. The ratio of the approximate to the exact capacitance varies from 1.001 at b/a = 1.1 to 2.3 at b/a = 100, as shown in Figure 12.3.
The approximation is fairly accurate for the former case, but poor for the latter case. In this latter case, inspection of Figure 12.2 shows the root of the problem, the actual V(r) function just doesn't look like a straight line!
As a first attempt to try to improve the approximation, pick a point c midway between a and b, at a voltage Vc . Now, V(x) will be approximated by two lines, the first from a to b and the second from b to c. Specifically, we have
Region 1: a ≤ r ≤ c = (a + b)/2:
Region 2: c ≤ r ≤ b:
This approximation function is shown in Figure 12.4. Note that for the purpose of this figure, V c has been chosen arbitrarily.
Each of these approximations are written using basis functions that have the same characteristics as described in the previous example. Each region has its own basis functions.
The electric field and the stored energy in each region are found as in equations (12.21) and (12.22). The total stored energy is simply the sum of the energies in each region:
At this point, Vc is still an arbitrary variable. We give it a value by invoking the principle that we want to choose Vc so as to minimize the approximate energy U:
and therefore
Figure 12.5 is a repeat of Figure 12.2 with the two-line approximate voltage added. While it’s more like the exact V(r) than is the single-line approximation, it’s still not a very good approximation.
Figure 12.6 is a repeat of Figure 12.3 with the capacitance ratios for the two-line approximation added. While the results still are not very impressive for the larger values of b, the two-line approximation is significantly better than is the single-line approximation.
The next step in the process of improving the approximate solution to the concentric circle problem is to break the region down into a large number of line segments. Mathematically this is a direct extension of the procedure used in Section 12.4. To circumvent the need to write many sets of equations explicitly and also to allow for an arbitrary number of line segments, it is necessary to introduce some structured notation into the process.
Figure 12.7 shows the notation for the setup of this problem. In a 1d problem correlating the node number and the node location is relatively easy — this won't be the case in unstructured 2d and 3d problems.
Node 1 is at location r 1 = a. Node n is at location rn = b. In general, node j is at location rj . Region (element) j extends from rj to r j+1, rj ≤ r ≤ r j+1 and the size (length) of element j is hj = r j+1 - rj .
For element j it is convenient to define a local coordinate system u, namely, 0 ≤ u ≤ h j. In this region, then
Since we are in cylindrical coordinates, we must return to the global system before we integrate (12.31) to get the stored energy in this element. Since (12.31) is a constant expression, we have
The total energy in the system is the sum of all of the element energies:
To minimize this energy, we set the derivatives to each node voltage equal to zero:
This leads directly to the full set of linear equations:
Before this can be solved, the boundary conditions V 1 = Va , Vn = Vb must be inserted:
Figure 12.8 shows the results of solving equation (12.37), the uniformly spaced nodes curve (a = 1, b = 100). A higher number of nodes, meaning improved resolution, definitely produces better results with the ratio of the calculated to exact capacitance = 1.18 at n = 12.
This calculation was performed by MATLAB program fem1d1.m
.
% fem1d1.m Repeat of the previous problem but using an organized system
% to create linear 1d elements
close
eps0 = 8.854;
n = 2; % Starting number of nodes
a = 1; b = 100;
ri = linspace(a, b, n);
h = ri(2:n) - ri(1:n-1);
Va = 0; Vb = 1;
% top of loop for adding regions
max_iters = 11; % Number of subdivision cycles
for iter = 1 : max_iters
array = spalloc (n, n, 3);
f = zeros(n,1);
% coefficient array
array(1, 1) = (ri(1) + ri(2))/h(1); array(n,n) = (ri(n-1) + ri(n))/h(n-1);
for i = 2 : n-1
array(i,i) = (ri(i-1) + ri(i))/h(i-1) + (ri(i) + ri(i + 1))/h(i);
end
for i = 1 : n-1
array(i,i + 1) = -(ri(i) + ri(i + 1))/h(i);
end
for i = 2 : n
array(i,i-1) = -(ri(i-1) + ri(i))/h(i-1);
end
% bcs
array(1,:) = 0; array(1, 1) = 1; f(n) = Va;
array(n,:) = 0; array(n,n) = 1; f(n) = Vb;
% solve the equation set
V = arrayf;
% calculate the capacitance
Utot = 0;
for i = 1 : n-1
Utot = Utot + (V(i + 1) - V(i))^ 2*(ri(i + 1) + ri(i))/h(i);
end
C = pi*eps0*Utot;
C_exact = 2*pi*eps0/log(b/a);
C/C_exact;
fprintf (' %d %f %f %f
', n, C, C_exact, C/C_exact)
% Show the voltages
if iter == max_iters-1
V_exact = log(ri/a)/log(b/a);
plot(ri, V, 'kx', ri, V_exact, 'k')
xlabel ('r')
ylabel ('V(r)')
end
% Find the element with the largest voltage change
dV = zeros(1,n-1);
dV = (V(2:n) - V(1:n-1)); % ./h';
[dVmax,index] = max(dV);
%subdivide the region - modify h and ri
h = [h(1:index-1), h(index)/2, h(index)/2, h(index + 1:end)];
n = n + 1;
ri = [a];
for i = 1 : n-1
ri = [ri, ri(end) + h(i)];
end
end
MATLAB program fem1d1.m
has one additional capability, the results of which are also shown in Figure 12.8: the self-calculated nodes curve. Starting with some number of nodes (n in the program), the program solves the equation set and then examines the resulting voltage vector (V), looking for the two nodes with the greatest voltage difference between them. It then subdivides the element divided by these two nodes into two equally spaced elements. This is repeated max_iters
times. The program could have been more efficiently written by having it subdivide, say, half of the existing elements — selecting those elements with the largest voltage step, at each iteration. The program as it is written, however, clearly emphasizes the point that higher resolution where the voltage is changing rapidly produces better results (for the same total number of nodes) than does equal-size elements.
Figure 12.9 shows the voltage profile produced by fed1d1.m
for n = 12, using the self-calculated nodes. The calculated voltages at the nodes are superimposed on the exact solution evaluated at the node locations. The agreement is excellent.
In order to compare this 1d FEM calculation to the earlier FD calculation, look at any one of the (non-boundary-condition) lines in equation (12.37). For example, we have
Substituting the values of the coefficients and solving for V 3, we obtain
If all hi are the same (= h), then r 4 = r 3 + h and r 2 = r3 – h, and therefore
which is exactly the result presented in the FD derivation.
As predicted at the beginning of this chapter, 1d FEM derivations using linear elements yield interesting insights but no new results.
One attribute of the FEM equation organization is the ease with which mixed dielectric regions are handled; the only caveat is that the dielectric is uniform in each element (region).
In going from equation (12.33) to equations (12.34) and (12.35), the factor ε/2 that appears in each term was simply dropped because the sum was set = 0. If each region is characterized by a dielectric constant
then equations (12.34) and (12.35) become
The full matrix set [equation (12.36)], does not change if we simply update the definition of the aij terms to
In Section 12.3 we used a straight line connecting the boundaries r = a and r = b as the approximate voltage function. In Section 12.4 this approximation was improved by splitting the line into two lines at an interior point c, specifically, a < c < b, and then adjusting Vc to minimize the total energy stored in the electric field. Another approach to finding an improved voltage approximation is to define a function that itself has one or more adjustable parameters, over the full region a ≤ r ≤ b .
Consider, for example, the function
This function has three parameters, so we will need to satisfy three conditions in order to fully specify it: V(a) = Va , V(b) = Vb, and V(c) = Vc , where c again is an interior point, say, the middle of the region.
Once again we would like to express the approximate voltage function in terms of the node voltages and basis functions
where
subject to
Inserting the appropriate three boundary conditions into each of the three equations, we obtain
Solving these three sets of equations for a = 1, b = 100 and putting the results back into equation (12.47), we get the (three) basis functions shown in Figure 12.10.
These functions have the same properties as the previous basis functions; namely, they each equal one at their “home” nodes and zero at all other nodes, and the sum of all (three) functions is equal to one everywhere.
The steps to complete this solution follow the steps of the previous solution, but the details of the arithmetic are much more tedious.
First we find the electric field
then
and
We find Vc
in terms of Va
, Vb
, and the geometry and substitute this back into equation (12.46) for the voltage, equation (12.53) for the energy, and then the capacitance. The details of these calculations are shown in program fem1d2.m
— quadratic element solution of the concentric circle problem:
% playing #3. Repeat of the previous problem but using an organized system
% to create 1 quadratic element
close
eps0 = 8.854;
a = 1; b = 100; c = (a + b)/2;
Va = 0; Vb = 1;
ar = ones(3, 3);
ar(1, 2) = a; ar(1, 3) = a*a;
ar(2, 2) = b; ar(2, 3) = b*b;
ar(3, 2) = c; ar(3, 3) = c*c;
f = [1;0;0]; pa = arf
f = [0;1;0]; pb = arf
f = [0;0;1]; pc = arf
r_plt = a : (b-a)/50 : b;
fa_plt = pa(1) + pa(2)*r_plt + pa(3)*r_plt.^ 2;
fb_plt = pb(1) + pb(2)*r_plt + pb(3)*r_plt.^ 2;
fc_plt = pc(1) + pc(2)*r_plt + pc(3)*r_plt.^ 2;
figure (1)
plot(r_plt, fa_plt, 'k', r_plt, fb_plt, 'k', r_plt, fc_plt, 'k')
xlabel ('r')
ylabel ('Basis Functions')
text (10, .8, 'fa')
text (50, 1.05, 'fb')
text (88, .8, 'fc')
% the first 3 terms will be needed for finding Vc
k1 = pc(2)^ 2*(b^ 2-a^ 2)/2 + 4/3*pc(2)*pc(3)*(b^ 3-a^ 3) + pc(3)^ 2*(b^ 4-a*4);
k2 = pa(2)*pc(2)*(b^ 2-a^ 2)/2 + (pa(2)*pc(3) + pc(2)*pa(3))*(b^ 3-a^ 3)*2/3 ⋯
+ pa(3)*pc(3)*(b^ 4-a^ 4);
k3 = pb(2)*pc(2)*(b^ 2-a^ 2)/2 + (pb(2)*pc(3) + pc(2)*pb(3))*(b^ 3-a^ 3)*2/3 ⋯
+ pb(3)*pc(3)*(b^ 4-a^ 4);
Vc = -(k2*Va + k3*Vb)/k1
k4 = pa(2)^ 2*(b^ 2-a^ 2)/2 + 4/3*pa(2)*pa(3)*(b^ 3-a^ 3) + pa(3)^ 2*(b^ 4-a*4);
k5 = pb(2)^ 2*(b^ 2-a^ 2)/2 + 4/3*pb(2)*pb(3)*(b^ 3-a^ 3) + pb(3)^ 2*(b^ 4-a*4);
k6 = pa(2)*pb(2)*(b^ 2-a^ 2)/2 + (pa(2)*pb(3) + pb(2)*pa(3))*(b^ 3-a^ 3)*2/3 ⋯
+ pa(3)*pb(3)*(b^ 4-a^ 4);
Utot = k1*Vc^ 2 + 2*k2*Va*Vc + 2*k3*Vb*Vc + k4*Va^ 2 + k5*Vb^ 2 + 2*k6*Va*Vb;
V_plt = Va*fa_plt + Vb*fb_plt + Vc*fc_plt;
figure (2)
plot(r_plt, V_plt)
C = 2*pi*eps0*Utot;
C_exact = 2*pi*eps0/log(b/a);
C/C_exact;
fprintf (' %d %f %f %f
', n, C, C_exact, C/C_exact)
This program calculates a capacitance ratio of 1.60. This is better (lower) than the linear calculation for three nodes but not quite as good as the linear node calculation for four nodes.
One attribute of the FEM method is that it is possible to mix and match approximations as desired. In other words, some of the elements in a problem can be linear, some can be quadratic, and so forth. In 2d and 3d problems different-shape elements can also be mixed together, along with different approximation functions attached to different elements. The bookkeeping required to track this is significant, but computers do this kind of thing very well.
A 2d FEM program based on rectangles in a uniform grid doesn't add any new capabilities to what has already been presented. It is, however, a good learning tool because all of the steps necessary to create the FEM coefficient matrix are present. On a uniform grid there is a logical, simple way to number the nodes to make it easier to keep track of the node locations (the corners of the rectangles). The get_ijk.m
function presented in Chapter 8 handles this job readily. This convenience disappears when different element shapes and orientations are allowed and/or the system becomes unstructured.
In one dimension, a linear approximation function FEM analysis generated the same coefficient matrix as did the 1d FD analysis. This will not repeat in two dimensions, as will be shown shortly.
Figure 12.11 shows a section of a square grid.
Consider the element shown shaded in Figure 12.11. Each such element in the grid will be referred to by the (i,j) value of its lower left corner, and the node numbers of the four vertices will be labeled according to the convention used in Chapter 8 (and also in the get_ijk.m
function). Rectangle (i,j) has an X-dimension of 1 and a Y-dimension of 1. The four nodes (vertices) shown are labeled V
1 = V(x,y), and so on, as shown, for convenience.
Consider a local coordinate system aligned with the grid and with its origin at point (i,j). In this coordinate system, the voltage V(x,y) in the gray (shaded) rectangle is approximated by
The procedure at this point is straightforward:
Calculate the stored energy in the electric field:
Calculate the (four) partial derivatives of the energy with respect to the node voltages:
MATLAB program femrect.m
—a simple 2d structured FEM program—is a rewrite of fd2.m
, replacing the FD coefficient terms lines with the preceding lines:
%fmrect.m A simple FEM example to show assembly procedure
clear
ns = 3; % scaling factor for resolution studies
Imin = -20*ns; Imax = -Imin ; Jmin = -4*ns; Jmax = -Jmin; % definition of array
Ic1 = -2*ns; Ic2 = -Ic1; Jc = 0; % inner conductor
[i,j,Kmax] = get_ijk(Imin,Imax,Jmin, Imax,Jmax,0); % number of variables
a = spalloc(Kmax,Kmax,9*Kmax); % allocate the coefficient array
b = zeros(Kmax,1); % allocate the bcs array
% initialize a as if every variable is free
for j = Jmin: Jmax
for i = Imin : Imax
[i,j,k0] = get_ijk(Imin,Imax,Jmin, i,j,0);
% first equation
[i,j,n1] = get_ijk(Imin,Imax,Jmin, i,j,0);
n2 = n1 + 1;
n3 = n2 + (Imax - Imin) + 1;
n4 = n3 - 1;
a(n1,n1) = a(n1,n1) + 4;
if i < Imax, a(n1,n2) = a(n1,n2) - 1; end;
if i < Imax & j < Jmax, a(n1,n3) = a(n1,n3) -2; end;
if j < Jmax, a(n1,n4) = a(n1,n4) -1; end;
% second equation
[i,j,n2] = get_ijk(Imin,Imax,Jmin, i,j,0);
n1 = n2 - 1;
n3 = n2 + (Imax - Imin) + 1;
n4 = n3 - 1;
a(n2,n2) = a(n2,n2) + 4;
if i > Imin, a(n2,n1) = a(n2,n1) - 1; end;
if i < Imax & j < Jmax, a(n2,n3) = a(n2,n3) -1; end;
if j < Jmax, a(n2,n4) = a(n2,n4) -2; end;
% third equation
[i,j,n3] = get_ijk(Imin,Imax,Jmin, i,j,0);
n4 = n3 - 1;
n1 = n4 - (Imax - Imin) - 1;
n2 = n1 + 1;
a(n3,n3) = a(n3,n3) + 4;
if i > Imin & j > Jmin, a(n3,n1) = a(n3,n1) - 2; end;
if j > Jmin, a(n3,n2) = a(n3,n2) -1; end;
if i > Imin, a(n3,n4) = a(n3,n4) -1; end;
% fourth equation
[i,j,n4] = get_ijk(Imin,Imax,Jmin, i,j,0);
n3 = n4 + 1;
n1 = n4 - (Imax - Imin) - 1;
n2 = n1 + 1;
a(n4,n4) = a(n4,n4) + 4;
if j > Jmin , a(n4,n1) = a(n4,n1) - 1; end;
if i < Imax & j > Jmin, a(n4,n2) = a(n4,n2) -2; end;
if i > Imin & j < Jmax, a(n4,n3) = a(n4,n3) -1; end;
end
end
% Perimeter (v = 0) bcs
% clean out the appropriate row, replace it w/ 1 on diagonal
for i = Imin : Imax
[i,j,k] = get_ijk(Imin,Imax,Jmin, i,Jmin,0);
a(k,:) = 0; a(k,k) = 1;
[i,j,k] = get_ijk(Imin,Imax,Jmin, i,Jmax,0);
a(k,:) = 0; a(k,k) = 1;
end
for j = Jmin + 1 : Jmax - 1
[i,j,k] = get_ijk(Imin,Imax,Jmin, Imin,j,0);
a(k,:) = 0; a(k,k) = 1;
[i,j,k] = get_ijk(Imin,Imax,Jmin, Imax,j,0);
a(k,:) = 0; a(k,k) = 1;
end
% inner strip (v = 1) bcs
% clean out the appropriate row, replace it w/ 1 on diagonal
% put 1 in b array
for i = Ic1 : Ic2
[i,j,k] = get_ijk(Imin,Imax,Jmin, i,Jc,0);
a(k,:) = 0;
a(k,k) = 1;
b(k) = 1;
end
% solve for voltages
v = a;
% list non-zero voltages by row, column, & variable nrs
fprintf (' i j k Volts
')
for k = 1 : Kmax
volts = v(k);
if volts > 0
[i,j,k] = get_ijk(Imin,Imax,Jmin, 0,0,k);
fprintf (' %3d %3d %3d %8.3f
', i, j, k, volts)
end
end
% We'll need an xy voltage array for ongoing calcs
Sx = Imax - Imin + 1; Sy = Jmax - Jmin + 1;
Volts = zeros(Sx,Sy);
for ii = Imin:Imax
i = ii - Imin + 1;
for jj = Jmin:Jmax
j = jj - Jmin + 1;
[ii,jj,k] = get_ijk(Imin,Imax,Jmin, ii,jj,0);
Volts(i,j) = v(k);
end
end
C = C_Energy(Volts)
The difference in the results between programs fd2.m
and femrect.m
is not striking. The FEM calculation is better, that is, the capacitance is lower for all levels of resolution (ns). However, the improvement is only tenths of a percent. While fd2.m
is a useful exercise in that in demonstrates taking local element results and assembling the coefficient matrix from it, it offers no real value in the quality of the results when a FD calculation can be easily written.
On the other hand, the 1d FEM formation yielded exactly the same results (and the same coefficient matrix) as did the FD formulation. In this 2d case, the fact that there is a small difference in results means that the coefficient matrices are not the same. This is obvious in that the FEM coefficient matrix has nine nonzero entries per (non-boundary-condition) rows, while the FD coefficient matrix has five.
Taking any of the non-boundary-condition rows of the coefficient matrix and rewriting it so that the references are to (i,j) coordinates rather than row numbers, we get (see Figure 12.12 for notation)
This equation tells us that, for a square grid, the FEM result is that the voltage at a node is calculated by averaging the voltages at the eight nearest nodes. This, according to the simple example above, yields slightly better results than does the FD calculation, which were that the voltage at a node is the average of the voltages at the four nearest nodes. If this is all it had to offer, the FEM calculation would not be worth the trouble.
In Chapter 13 we begin a discussion of unstructured systems and triangular element shapes. The value of the FEM calculations will soon become apparent.
3.145.186.83