ABSTRACT

The left end is the essential boundary condition as before while the right end is the natural boundary condition. As seen in Eq. (3.1.2), the boundary condition

with a known value of ~~ contributes to the right-hand side column vector. For example, Eq. (2.4.23) shows how the natural boundary condition is incorporated into the column vector. Because the column vector moves to the right-hand

side of the matrix equation, d~Sl) = 1 is subtracted from the right-hand side column vector. The program list is given below for completeness. Comparing the program to that given in the previous example tells the difference between

% EX3.5.2.m % to solve the ordinary differential equation given as % au" + b u' + c u = 1, 0 < X < 1 % u(O) = 0 and u'(1) = 1 % using 5 or 10 linear elements % % Variable descriptions % k = element matrix % f = element vector % kk = system matrix % ff = system vector % index = a vector containing system dofs associated with each element % bcdof = a vector containing dofs associated with boundary conditions % bcval = a vector containing boundary condition values associated with % the dofs in bcdof %-------------------------------- % %---------------~-

% input data for control parameters %----------------- nel=5; nnel=2; ndof=l; nnode=6; sdof=nnode*ndof;

% number of elements % number of nodes per element

% number of dofs per node % total number of nodes in system

% total system dofs

%elementlength %extractsystemdofsassociated

end % end of loop for total elements % %----------------------- % apply the natural boundary condition at the last node %---------------------- ff(nnode)=ff(nnode)-1; %include u'(l) = 1 in column vector % %--------------- % apply boundary conditions %--------------- [kk,ff] =feaplyc2(kk,ff, bcdof, bcval ); % %-------------- % solve the matrix equation %-------------- fsol=kk \ff; % %------------ % analytical solution %------------ cl =( 1 +0.5*exp(1)) / (2*exp(2 )-exp(1) ); c2=-( 1 +exp(2) )/(2*exp(2)-exp(1) ); for i=1:nnode x=gcoord(i); esol(i)=cl *exp(2*x)+c2*exp(x)+ 1/2; end % %----------------- % print both exact and fern solutions %----------------- n urn= 1:1 :sdof; results=[num' fsol esol'] %------------------_:__ ____________ _

The solutions using 5 elements and 10 elements are shown below, respectively. Comparing the two finite element solutions to the exact solution shows the convergence of the finite element solution as the mesh is refined.