Professional Documents
Culture Documents
Daniel Cook
Abstract
When dessigning a reacctor, chemical engineers co ommonly usee an idealized d design. In almost all casees, the
predicted concentration at any point
p in the tank can bee modeled b
by a second‐‐order differrential
equation. To solve this differen
ntial equation two methhods are com mmonly emp ployed; the Finite
Elemental method and d the Finite Diifference metthod.
Introduction
In the fielld of chemicaal engineeringg reactor dessign holds greeat importancce. A reactorr is a vessel tthat is
used to co ontain chemiical reactionss. Reactors are frequentlyy being redesigned in ordeer to maximizze the
chemical yield. One of
o the factors influencing yield is conccentration off the reactingg chemicals iin the
However problems arise w
reactor. H when determining concenttration as it ccommonly vaaries with time and
position within the reactor.
r Du
ue to this, engineers
e usee an idealizeed design too help determine
concentraation. In the idealized model the reacto or is rectanguular with onee entrance and one exit, an nd it’s
well mixeed in both the
t vertical and horizonttal direction s. With theese assumptions in place the
concentraation can be modeled with a second‐o order differenntial equation n with boundary equation ns. To
solve this differential eequation two o numerical m methods can be used, the finite differeence and the finite
elemental methods.
Physical Analysis
First the sshape and dessign of the idealized reacto
or should be noted:
Here the reactor is re
ectangular with one entraance at x=0 and one exitt at x=L. For this reactor, the
conservattion of mass law reads [1]:
(1)
Where c is the concentration of the chemical in moles per meter cubed, D is the diffusion coefficient in
meters squared per hour, and k is the decay coefficient in units per hour. Equation (1) is based on Fick’s
law describing how flux goes from high to low concentrations. Fick’s law is:
This problem assumes that the diffusion‐reaction equation given in (1) is steady state, thus reducing
equation (1) to:
0 (2)
The assumption of an internal source of chemicals in the reactor is also taken. With this assumption in
place equation (2) is transformed to [1]:
(3)
Equation (3) is defined by the following Dirichlet boundary equations:
0 0 (4)
0
So the concentration at both the entrance and exit of the reactor is zero. The following equations and
values help define the rest of the problem [1]:
1
sin 3 ,
3
0.01 sin 3 ,
3
sin 3 ,
9 sin 3 3
0.01 sin 3 ,
3
For comparison purposes the exact analytical solution to this problem is:
sin 3 ,
(5)
0.01 sin 3 ,
Numerical Analysis
Finite Difference Method
The finite difference method is a numerical method that can be used to solve differential equations
using the finite difference equations. These equations break‐up the solution domain into a set of
discrete points. From here the partial differential equation is written for each node, and the derivatives
are replaced by a finite difference. A finite difference is an equation with the form [2]:
(6)
Equation (6) can be used to model the first and second derivatives in a function. From equation (6), the
first derivative takes the form of [3]:
(7)
And the second derivative takes the form [3]:
(8)
Where h is the distance between incremental concentration points in the reactor. Using equations (7)
and (8), the finite difference approximation to equation (3) at any point “i” in the reactor is:
∗ ∗ 1 ∗ ∗
(9)
From this we can solve this linear equation by setting up a coefficients matrix and a vector matrix for the
terms on the right hand side of equation (9). From these matrices we can solve for the concentration
through use of the equation [3]:
∗
Where A is the coefficient matrix, c is the concentration values at each point, and RHS is the vector
defining the right side of the equation.
Finite Element Method
The finite elemental method is another numerical method used to solve partial differential equations
and integral equations. This method is preferred over the finite difference method when the system has
irregular geometry or heterogeneous composition. The finite element method breaks‐up the solution
domain into simple shapes, or elements. The partial differential equation is then studied and solved for
in each element. The individual solutions for each element are then pieced together to form the
solution for the entire system.
The first step in finite elemental analysis is to divide the solution domain into finite elements. Where
these elements meet is known as a node. Once the solution is broken up into elements, equations must
be used to approximate the solution for each element. For the simplest analysis first order polynomials
are commonly chosen for the approximation function. This equation takes the form [2]:
(10)
Where u represents the dependent variable, x is the independent variable, and the a’s are constants.
Because this equation must pass through the endpoints of each node, equation (10) takes the form:
Solving for these equations through Cramer’s rule we obtain an equation with the form:
(11)
Where
(12)
And
(13)
Now by taking the derivative of equation (11), equation (12) and equation (13) we can solve for the
derivative of u [2]:
(14)
Upon integration of equation (14), the equation yields:
(15)
Looking at equation (15) it become apparent that it is the same form as the trapezoid rule for
integration. Equation (15) becomes the governing equation for the interpolation function.
The final step in finite elemental analysis is to find an equation that describes the behavior of the
element being modeled. What this essentially means is the interpolation function must be fit to the
function defining the differential equation. This elemental equation will take the form of [2]:
(16)
Where [k] is the stiffness matrix, {u} is a vector of unknown variables, and [F] is the vector describing any
external influences. Equation (16) describes the behavior of one element, so the last step is to assemble
the results of each element together in a continuous manner. This is done by making unknowns at the
boundary match the unknowns at abutting elements. The overall system composed of all the elements
takes the form of [2]:
(17)
Where [K] is the assemblage property matrix and {u’} and {F’} are the same vector described in equation
(16) adjusted to contain the vectors of each individual element. Equation (17) can then be solved
through any matrix manipulation technique.
Results
We can now examine the results of solving equation (3) through the finite elemental and finite
difference methods, and compare them to the results obtained by using the exact analytical equation.
For both methods, the reactor was split into twenty and one hundred steps.
Finite Elemental
Figure 1: FE
EM results with 2
20 steps
Figure 2: FE
EM error with 20
0 steps
Figure 3: FE
EM results with 1
100 steps
Figure 4: FE
EM error with 10
00 steps
Finite Diff
fference
Figure 5: FD
DM results with 20 steps
Figure 6: FE
EM error with 20
0 steps
Figure 7: FD
DM results with 100 steps
Figure 8: FD
DM error with 10
00 steps
Discussiion
By visually inspecting aand comparin ng the eight ggraphs in thee results section, several cconclusions ccan be
drawn. First,
F more steps
s and the erefore smaller step sizee results in m
more accuratte results. TThis is
confirmed d with a smaller global errror in the one e hundred steep size graphss. This is mosst likely due tto less
propagate ed error. Smaller step size es cause the error in eachh step to decrrease, thus deecreasing thee total
error.
The next conclusion th hat can be drrawn is the finite elementtal method p provides moree accurate reesults.
When comparing the maximum error e betwee en similar steep sizes of the finite diffference and finite
elemental, the elemental method always has less error. This is probaably due to the nature o of the
elemental method. The
T difference e method bre eaks the systtem up into small squarees, some of wwhose
boundarie es may lie ou
utside the syystem. The elemental
e m ethod breakss the system m up into arb
bitrary
shapes whose sides do o not need to o be square. This results in a better fit to the systeem, reducing error
over the ddifference me ethod.
Figure 9: Co
omparison of the
e FDM and FEM
M break‐up meth
hods [4]
For most professionall applicationss the elemen ntal method would be prreferred. It has the ability to
handle ve a it has le ss error wheen compared to the diffeerence
ery complex geometries, it is faster, and
method. The only real advantage tthat the diffe erence methood holds is that it is simpleer to implemeent in
code.
References
[1] Drapaca, Corina. Project 3: Numerical Analysis of the Swinging Simple Pendulum. Pennsylvania State
University, 2010. Print.
[2] Chapra, Steven C., and Raymond P. Canale. Numerical methods for engineers . 6th ed. Boston:
Mcgraw‐Hill Higher Education, 2010. Print.
[3] "The Finite Difference Method for Boundary Value Problems." Cal State Fullerton Web. Web. 09 Dec.
2010. <http://math.fullerton.edu/mathews/n2003/FiniteDifferenceMod.html>.
[4] "Simtec ‐ Software." Simtec Inc. Web. 09 Dec. 2010. <http://www.simtec‐inc.com/fem_vs_fdm.htm>.
Appendix A: Finite Elemental Method [1]
function [u,utrue] = fem1d()
%
% program to solve the equation
%
% -d/dx(p(x)du/dx) + q(x)u = f
%
% with boundary conditions
%
% u(0) = u(pi) = 0
%
% using the finite element method with piecewise linear
% approximation functions. Uses functions p, q, and f
% to evaluate coefficients and right-hand side.
%
% User is asked for the number of subintervals n.
% Routine plots the true and computed solutions and their
% difference. Returns the computed solution u, and the true
% solution utrue.
%
% Stiffness matrix is stored as a dense matrix and solved
% using MATLAB operator "\".
%
A = zeros(n-1,n-1); b=zeros(n-1,1);
for i=1:n,
xim1 = (i-1)*h;
xi = i*h;
pt1 = (xi+xim1)/2 - h/(2*sqrt(3)); % pt1 and pt2 are the points used
pt2 = (xi+xim1)/2 + h/(2*sqrt(3)); % in 2-point Gauss quadrature for
% evaluating integrals
% Stiffness matrix
pint = .5*(p(pt1)+p(pt2))*h;
qiint = .5*(q(pt1)*(pt1-xim1)^2 + q(pt2)*(pt2-xim1)^2)*h;
qim1int = .5*(q(pt1)*(xi-pt1)^2 + q(pt2)*(xi-pt2)^2)*h;
if i < n, A(i,i) = A(i,i) + pint/h^2 + qiint/h^2; end;
if i > 1,
A(i-1,i-1) = A(i-1,i-1) + pint/h^2 + qim1int/h^2;
qiim1 = .5*h*(q(pt1)*(xi-pt1)*(pt1-xim1) + q(pt2)*(xi-pt2)*(pt2-xim1));
if i < n,
A(i-1,i) = -pint/h^2 + qiim1/h^2;
A(i,i-1) = A(i-1,i);
end;
end;
% Right-hand side
fiint = .5*(f(pt1)*(pt1-xim1) + f(pt2)*(pt2-xim1))*h;
fim1int = .5*(f(pt1)*(xi-pt1) + f(pt2)*(xi-pt2))*h;
if i < n, b(i) = b(i) + fiint/h; end;
if i > 1, b(i-1) = b(i-1) + fim1int/h; end;
end;
u = A\b;
for i=1:n-1,
xi = i*h;
if xi <= pi/3, utrue(i,1) = sin(3*xi); end;
if xi > pi/3, utrue(i,1) = .01*sin(3*xi); end;
end;
plot([h:h:pi-h]',u,'--', [h:h:pi-h]',utrue,'-')
xlabel('x')
ylabel('u(x)')
title('True solution (solid) and approximate solution (dashed)')
pause(5),
figure, plot([h:h:pi-h]',utrue-u,'-')
xlabel('x')
ylabel('error')
title('Difference between true and computed solution')
n=100
a=0
b=pi
ua=0
ub=0
k=1
dx = ( b - a ) / ( n - 1 );
x = ( a : dx : b );
A = sparse ( n, n );
A(1,1) = 1.0;
rhs(1,1) = ua;
for i = 2 : n - 1
A(i,i-1) = - p(x(i)-0.5*dx) / dx / dx
A(i,i) = (( p(x(i)-0.5*dx) + p(x(i)+0.5*dx) ) / dx / dx)+1
A(i,i+1) = - p(x(i)+0.5*dx) / dx / dx
rhs(i,1) = f(x(i));
end
A(n,n) = 1.0;
rhs(n,1) = ub;
u = A \ rhs;