Sie sind auf Seite 1von 10

Numerical Solutions for 1D Conduction using the Finite Volume Method

Aaron Outhwaite
Department of Process Engineering and Applied Sciences, Dalhousie University
Email: aaron.outhwaite@dal.ca

Abstract
The finite volume method is used to solve the general transport equation for 1D conduction in a plane
wall. A good agreement between the FVM using the Gauss-Seidel and TDMA numerical methods, and
the analytical solution to 1D conduction is demonstrated, with a maximum error of 0.803% and
0.807%, respectively, occurring at node 1.

Keywords
Computational Fluid Dynamics; 1D Conduction; Finite Volume Method; Gauss-Seidel; TDMA;
MATLAB

1. Introduction

Computational fluid dynamics (CFD) derives numerical solutions for the analysis of mass,
momentum, and heat transport phenomena, as well as associated phenomena such as reaction
chemistry and thermodynamics. These fluid flow systems are analyzed using the Navier-Stokes
equations, which are mathematical statements of the three fundamental principles of CFD,
including continuity through the conservation of mass, Newtons Law of Motion for the
conservation of momentum, and the conservation of energy (Anderson, 2009).

Because the Navier-Stokes equations for mass, momentum, and heat transport obey a generalized
conservation principle, a generalized transport equation for a dependent variable can be
described and used as the basis for discretization in CFD analysis (Patankar, 1980). The finite
volume method (FVM) is one such method of discretizing the general transport equation that is
widely presented in the literature and commonly used in commercial CFD software (Versteeg +
Malalasekera, 2007).

This paper derives a numerical solution for 1D conduction through a plane wall from the general
transport equation, which is discretized into a system of linear equations using the FVM. This
system of discretized equations is solved using the Gauss-Seidel and TDMA numerical methods, as
implemented in MATLAB. Results from the numerical analysis of 1D conduction are compared with
the analytical solution, with percentage error between the FVM and analytical results reported.

2. Model Description

For a general property , the differential form of the transport equation is:


() + () = ()+ (1)

1
where / () is the transient term describing the rate of change of in the fluid element,
() is the convective term describing net flow of out of the fluid element, () is the rate
of increase of due to diffusion, and is the rate of increase of due to source terms. Here, we
develop the FVM using the simplest transport equation, namely, pure diffusion in steady state. As
such, both the transient and convective terms from Eq. 1 are neglected, leaving:

()+ = 0 (2)

where is the diffusion coefficient. For the steady-state diffusion of property in x-direction (1D),
Eq. 2 becomes:


( ) + = 0 (3)

Using the FVM, the 1D domain is divided into discrete control volumes defined by nodal points.
These nodal points define the space between boundary conditions and , as described in Fig. 1
using general notation.

Fig. 1: FVM applied to 1D conduction through a wall (adapted from Versteeg + Malalasekera, 2007).
.
In Fig. 1, nodes are defined between the boundary temperatures. With the FVM, a general node
is defined at node 1, with node 1 and node 3 the west () and east () nodes of , respectively.
The control volume is bound by west () and east () faces, which are placed at the midpoint
between and , and and , respectively. To implement the FVM, Eq. 3 must be integrated over
the control volume defined at , which gives:


( ) + = ( ) ( ) + (4)

where is the cross-sectional area of the control volume face, is the volume and is the
average value of sources over the control volume. Eq. 4 states that the diffusive flux of leaving
the east face () minus the diffusive flux of entering the west face () is equal to the generation
of . In general, with = + and by using central differencing, Eq. 4 can be approximated
as:

2

+ ( + ) = 0 (5)

Eq. 5 can be rearranged as:


( + ) = ( ) + ( ) + ( ) (6)

By identifying the coefficients of , , and as , , and respectively, Eq. 6 simplifies to:

= + + (7)

The general discretized 1D diffusion equation described by Eq. 7 is used in the following sections to
solve for conduction through a plane wall.

2.1 Model Formulation

Consider the conduction of heat through a wall of thickness , as described in Fig. 2.

Fig. 2: 1D conduction through a wall of thickness (adapted from Versteeg + Malalasekera, 2007).

If the dimensions of the wall in the - and -direction are very large compared to the -direction,
then Eq. 3 becomes:


(k ) + = 0 (8)

where (W m-1 K-1) is the thermal conductivity of the wall, and (kW m-3) is a source term
describing heat generation within the wall. Integrating Eq. 8 across the CV yields:

3

( ) + = ( ) ( ) + = 0 (9)

Using central differencing around node and rearranging, Eq. 9 becomes:


( + ) = ( ) + ( ) + (10)

Eq. 10 is in the general form described by Eq. 7 and is valid for nodes 2 to 1. Assuming a
constant thermal conductivity in the wall and equal node spacing, for 1D thermal conductivity
though a plane wall, Eq. 7 becomes:

= + + (11)

with coefficients described in Table 1.

Table 1: Coefficients for 1D conduction in plane wall for internal CV nodes 2 to 1.




+ 0

To incorporate the boundary conditions at node 1 and , a linear approximation for temperature
between a boundary and the adjacent nodal point is used. Introducing the linear approximation for
temperatures between and yields:


( ) ( ) + = 0 (12)
/2

Similarly, for temperatures between and :


( ) ( ) + = 0 (13)
/2 /2

After rearrangement, Eq. 12 and 13 can be discretize as Eq. 11, with coefficients described in Table
2:

Table 2: Coefficients for 1D conduction in plane wall for boundary CV nodes 1 and .

2 2
+ 0 + ( )

2 2
+ 0 + ( )

4
2.2 Numerical Methodology

To solve the resulting system of discretized equations, an iterative method is required. The Thomas
algorithm, or tri-diagonal matrix algorithm (TDMA), is a commonly used line-by-line solver that is
computationally inexpensive and has minimal storage requirements. The Jacobi and Gauss-Seidel
methods are general-purpose solvers that are quick to implement, but slow to converge when the
tridiagonal system is large. In the present work, both the TDMA and Gauss-Seidel methods are
implemented in MATLAB using the code presented in Appendix A.

2.3 Case Studies

The analytical solution to Eq. 8 is obtained by integrating twice and applying boundary conditions.
This gives:


=[ + ( )] + (14)
2

For the plane wall described in Fig. 2, a thickness is 0.02 m is used. The plane wall has a constant
thermal conductivity of 0.5 W m-1 K-1, and a uniform heat generation of 1000 kW m-3. The boundary
temperatures and are 100 oC and 200 oC, respectively. The numerical method is implemented
in MATLAB using 10 nodes, with node spacing defined as = /

3. Results and Discussion

The results of the FVM for 1D conduction through a plane wall as compared to the analytical
solution are presented in Table 3 for both the Gauss-Seidel and TDMA numerical methods.

Table 3: Comparison between finite volume method and analytical solution for 1D conduction
through a plane wall.
Finite volume method
Node Analytical Gauss-Seidel Error TDMA Error
(m) ( C)
o ( C)
o (%) ( C)
o (%)
1 0.001 124 124.996 0.803 125 0.807
2 0.003 166 166.989 0.596 167 0.602
3 0.005 200 200.984 0.492 201 0.500
4 0.007 226 226.980 0.434 227 0.443
5 0.009 244 244.979 0.401 245 0.410
6 0.011 254 254.980 0.386 255 0.394
7 0.013 256 256.983 0.384 257 0.391
8 0.015 250 250.987 0.395 251 0.400
9 0.017 236 236.992 0.420 237 0.424
10 0.019 214 214.997 0.466 215 0.467

It is clear from Table 3 that the FVM with 10 nodes shows good agreement with the analytical
solution for both the Gauss-Seidel and TDMA numerical methods, with the former numerical
method having a marginally lower percent error. Graphically, the agreement between the FVM and
analytical solution for 1D conduction in a plane wall is demonstrated in Fig. 3.

5
Fig. 3: Comparison between analytical simulation (line) and numerical simulation (dot) for 1D
conduction through a plane wall using the Gauss-Seidel numerical method and = 10 nodes.

Although not demonstrated here, it is noted that these results can be validated by changing the
number of nodes to 5 in the MATLAB code, and comparing the resulting percent error between the
FVM and analytical solutions with Table 4.3 and/or Fig. 4.8 of Versteeg + Malalasekera (2007).

4. Conclusion

In the present work, the finite volume method (FVM) has been used to analyze 1D conductive heat
transfer in a plane wall of thickness . Using both the Gauss-Seidel and TDMA numerical methods,
the FVM shows good agreement with the analytical solution, with an error of less than 1% for each
numerical method considered. These results can be validated using the work of Versteeg +
Malalasekera (2007), and therefore represent a good introduction to the implementation of the
FVM for 1D conduction in MATLAB.

References

Anderson, J.D (2009). Governing Equations of Fluid Dynamics. In Wendt, J (Ed.), Computational
Fluid Dynamics An Introduction (3rd ed., pp 15 - 52). Berlin Heidelberg: Springer-Verlag

Patankar, S. (1980). Numerical heat transfer and fluid flow (Series in computational methods in
mechanics and thermal sciences). Washington: New York: Hemisphere Pub.; McGraw-Hill.

Versteeg, H., and Malalasekera, W. (2007). An introduction to computational fluid dynamics: The
finite volume method (2nd ed.). Harlow, England; New York: Pearson Education

6
Nomenclature

Symbols

Coefficient of FVM (W K-1)


CV boundary Area (m2)
East CV boundary (-)
East FVM node (-)
Thermal conductivity (W m-1 K-1)
Plane wall thickness (m)
Node (-)
Central CV node (-)
Heat generation (kW m-3)
Source term (kW)
Temperature (oC)
Velocity (m s-1)
CV Volume (m3)
West CV boundary (-)
West FVM node (-)
Distance between nodes (m)

Subscripts

A Refers to temperature at boundary node


Refers to temperature at boundary node

Greek Symbols

General dependent variable (-)


Density (kg m-3)
Diffusion coefficient (m2 s-1)

Abbreviations

1D One-dimensional
CFD Computational fluid dynamics
CV Control volume
FVM Finite volume method
TDMA Tri-diagonal matrix algorithm

7
Appendix A: MATLAB code
% computational fluid dynamics
% finite volume method
% one dimensional steady-state diffusion
% aaron outhwaite 2017

clc;
clear;

% variable declaration
TA = 100; % C temperature face A
TB = 200; % C temperature face B
k = 0.5; % W (m K)^-1 thermal conductivity
q = 1e6; % W m^-3 uniform heat generation
L = 0.02; % m plate thickness
A = 1; % m^2 plate area
n = 10; % number of nodes
dx = L/n; % node spacing

% initialize T (temperature) matrix


T = zeros(n);
% initialize S (source) matrix
s = zeros(n,1);
% initialize x (distance) matrix
for i = 1:n+2
if (i == 1)
x(i) = 0;
elseif (i == 2)
x(i) = dx/2;
elseif (i > 2) && (i < n+2)
x(i) = x(i-1)+dx;
elseif (i == n+2)
x(i) = L;
end
end

% solve aP*TP-aW*TW+-aE*TE=Su at each node


for i = 1:n
if (i == 1)
% node 1 boundary
sP = -2*k*A/dx;
aW = 0;
aE = k*A/dx;
aP = aW + aE - sP;
% populate temperature array
T(i,i) = aP;
T(i,i+1) = -aE;
% populate source array
s(i) = q*A*dx+((2*k*A*TA)/dx);

elseif (i > 1) && (i < n)


% node 1 <= i <= n mid slab
sP = 0;
aW = k*A/dx;
aE = k*A/dx;
aP = aW + aE - sP;

8
% populate temperature array
T(i,i-1) = -aW;
T(i,i) = aP;
T(i,i+1) = -aE;
% populate source array
s(i) = q*A*dx;

elseif (i == n)
% node 5 boundary
sP = -2*k*A/dx;
aW = k*A/dx;
aE = 0;
aP = aW + aE - sP;
% populate temperature array
T(i,i-1) = -aW;
T(i,i) = aP;
% populate source array
s(i) = q*A*dx+((2*k*A*TB)/dx);
end
end

% use numerical method to solve temperature at each node


Tguess = zeros(n,1);
relax = 1;
Tfvm = gaussSeidel(T,s,Tguess,relax);
%Tfvm = TDMA(T,s);
% reorder matrix and add boundary conditions
Tfvm = Tfvm';
Tfvm = [TA Tfvm];
Tfvm = [Tfvm TB];

% calculate temperature at each node using exact solution


for i=1:n+2
Tact(i) = (((TB-TA)/L) + (q/(2*k))*(L-x(i)))*x(i) + TA;
end
% calculate percent error between fvm and exact
for i=1:n+2
error(i) = 100*abs(Tact(i)-Tfvm(i))./Tact(i);
end

% plot solution sets


% plot Tact as smooth curve
t = 0:0.001:0.02;
s = spline(x,Tact,t);
plot(t,s,'-k');
% plot Tfvm as solid dot
hold on;
plot(x,Tfvm,'ko','MarkerFaceColor','k');
xlabel('L [m]');
ylabel('T [^oC]');
title('1D Conduction through a Plane Wall');

% Gauss-Seidel algorithm
function [X] = gaussSeidel(A,B,Xguess,relax)
X = Xguess;
Xold = X;

9
n = length(Xguess);
conv = 1;
iter = 0;
while conv > 1e-5
for i = 1:n
X(i) = B(i);
X(i) = X(i) - A(i,1:i-1)*X(1:i-1);
X(i) = X(i) - A(i,i+1:n)*X(i+1:n);
X(i) = X(i)/A(i,i);
end
X = relax*X + (1-relax)*Xold;
test = abs(X-Xold)./(Xold + 1e-8);
conv = max(test(:));
Xold = X;
iter = iter+1;
end

% TDMA algorithm
function [X] = TDMA(A,b)

m = length(b);
X = zeros(m,1);
A(1,2) = A(1,2)./A(1,1);
b(1) = b(1)./A(1,1);

for i = 2:m-1
temp = A(i,i)-A(i,i-1).*A(i-1,i);
A(i,i+1) = A(i,i+1)./temp;
b(i) = (b(i)-A(i,i-1).*b(i-1))./temp;
end

i=m;
X(m) = (b(i)-A(i,i-1).*b(i-1))./(A(i,i)-A(i,i-1).*A(i-1,i));

for i = m-1:-1:1
X(i) = -A(i,i+1).*X(i+1)+b(i);
end
end

10

Das könnte Ihnen auch gefallen