Sie sind auf Seite 1von 5

ME2016, Dr.

Ferri Finite-Difference Example

One of the most important types of problems that engineers and scientists need to solve is known as a two-point-boundary-value-problem (TPBVP). A popular solution technique, known as the finite-difference technique, is explored in this problem. (See Section 27.1 of the text) A cooling fin extends from a hot furnace wall as shown below. Assuming that heat flows only in the x-direction, the thermal equilibrium equation leads to the following governing equation:
kA d 2T dx 2 hP(T Ta ) = 0

(1)

where k = thermal conductivity, A = cross-sectional area, h = convection heat transfer coefficient, Ta = surrounding or ambient temperature, P = perimeter, and T(x) = temperature at x. The boundary conditions for this problem are: T (0) = T0 and k
dT ( L) = h (T ( L) Ta ) dx

(2a, b)

For simplicity, let Y = T - Ta, let k/h = A/P = 1, L=1, and let T0- Ta = 10. Then, the equation and boundary conditions are:

d 2Y dx
2

Y = 0 , Y (0) = T0 Ta = 10 and

dY (1) = Y (1) dx

(3a, b, c)

y0
T

y1

y2

yN-1

yN

virtual node

T(0)

Cooling Fin, T(x)

x x0 x1

x x2 L

x xN-1 xN

x xN+1

x L

Now, consider a finite-difference solution to this problem. Divide the fin into N equal segments of length x = L/N. The temperature difference at each node is denoted yi, i = 1, 2, N.

The first and second-derivative at each node can be expressed to order O(x2) using centereddifference expressions (see page 89 of text):
yi = yi +1 yi 1 , 2x

yi =

yi 1 2 yi + yi +1 x 2

(4a, b)

At node 1, substitution of (4b) into (3a) yields: y1 = y1 y 0 2 y1 + y 2 x


2

= y1 (2 + x 2 ) y1 y 2 = y 0

(5)

where y0 = 10. Similarly, at nodes 2, 3, , N-1, we would get:

yi = yi

yi 1 2 yi + yi +1 x
2

= yi yi 1 + (2 + x 2 ) yi yi +1 = 0 , i = 2,,N-1

(6)

The end point requires special treatment because of the convective (or natural) boundary condition at x = L, (3c). Imagine that there was an (N+1)st virtual node, with temperature yN+1. Approximating (3a) at node N yields:
y = y N N y N 1 2 y N + y N +1 x
2

= y N y N 1 + (2 + x 2 ) y N y N +1 = 0

(7)

To get a relation for yN+1, we use the natural boundary condition (3c) at x = L together with the first centered difference expression (4a) :
y = y N N y N +1 y N 1 = y N y N +1 = y N 1 2x y N 2 x

(8)

Equation (8) can be used to eliminate yN+1 from equation (7) above: 2 y N 1 + (2 + 2x + x 2 ) y N = 0 Equation (5), (6) and (9) constitute N linear algebraic equations in N-unknowns. It is known that the exact solution to equation (3a) subject to boundary conditions (3b) and (3c) is Y ( x) = 10 e x . We will compare this answer to finite-difference solutions using N=2 and N=5.
Solution

(9)

The following function implements the Finite-Difference (FD) method for this problem:

function [x,y] = fd_fin(N); L=1; dx=L/N; y0 = 10; x = 0:dx:L; % Initialize A to be all zeros A = zeros(N,N); % Assign nonzero elements of first row: A(1,1)=2+dx^2; A(1,2) = -1; A(2,1) = -1; % Assign nonzero elements of rows 2 through N-1: for k = 2:(N-1); A(k,k-1) = -1; A(k,k) = 2+dx^2; A(k,k+1) = -1; end % Assign nonzero elements of Nth row A(N,N)=2+2*dx+dx^2; A(N,N-1) = -2; % RHS B = zeros(N,1); B(1) = y0; % solve y_1_N=A\B; % Now, append y to the initial temperature, y0 y = [y0; y_1_N];

For N = 5, we obtain the following matrix for A. Note that it is diagonally dominant regardless of N- that means that iterative solution techniques such as Jacobi iteration and Gauss-Seidel iteration are guaranteed to converge! Also note that the matrix is tri-diagonal. There are many efficient routines for solving such systems.
>> A A = 2.0400 -1.0000 0 0 0 -1.0000 2.0400 -1.0000 0 0 0 -1.0000 2.0400 -1.0000 0 0 0 -1.0000 2.0400 -2.0000 0 0 0 -1.0000 2.4400

10 Exact solution N=2 N=5

7 Y 6 5 4 3 0

0.1

0.2

0.3

0.4

0.5 x

0.6

0.7

0.8

0.9

Figure 1. Exact solution vs Finite-Difference solutions using N=2 and N=5 The result is shown in Figure 1. The error between the FD solutions and the exact solution is shown in Figure 2. Note that while both approximate results are fairly good, the N=5 solution is better than the N=2 result.
0.09 0.08 0.07 0.06 0.05 error 0.04 0.03 0.02 0.01 0 N=2 N=5

0.1

0.2

0.3

0.4

0.5 x

0.6

0.7

0.8

0.9

Figure 2. Error between exact solution and FD solution

Since the centered-difference approximations of equation (4) are accurate to order O(x2), the ratio of errors is theoretically predicted to be (0.5)2/(0.2)2 = 6.25. This compares very favorably with what we actually found. The ratio of the maximum error in the N=2 solution to the maximum error in the N=5 solution is found to be 6.1242.

Das könnte Ihnen auch gefallen