Vous êtes sur la page 1sur 23

Teaching computational fluid dynamics using

spreadsheets
G. Tabor
School of Engineering and Computer Science, Department of Engineering, University of
Exeter, North Park Road, Exeter EX4 4QF, UK
E-mail: g.r.tabor@ex.ac.uk
Abstract The use of spreadsheet programs in teaching the numerical aspects of computational fluid
dynamics is explored. Spreadsheets allow the student to investigate important features of numerical
algorithms without having to invest the time required to code in a traditional programming language.
Thus they represent a short cut to the experiential part of the learning cycle. Four examples are
presented with detailed methodology and learning outcomes, including solutions to the basic partial
differential equations for fluid flow and iterative techniques for matrix inversion.
Keywords computational fluid dynamics, applied numerical methods, spreadsheets

Introduction
Outline of CFD
Computational fluid dynamics (CFD) is the use of computers to solve fluid flow
problems. Although the term can be used to describe simple methodologies such as
computational approaches involving Bernoullis equation or potential functions, in
most cases it refers to the solution of the NavierStokes equations, together with
additional modelling to describe features of the flow such as turbulence, combustion and multi-phase flow. The NavierStokes equations are a complex set of linked
partial differential equations. For the simplest case of non-reacting, incompressible
flows, they consist of four equations for the pressure, p, and the three components
of velocity, u. In vector notation these can be written as:
u = 0

(1)

1 p
u x
+ v 2 u x
+ (u u x ) = t
r x
u y
1 p
+ (u u y ) = + v 2 u y
t
r y
1 p
uz
+ (u uz ) = + v 2 uz
r z
t

(2)

The first of these equations represents conservation of mass, and is referred to as


the continuity equation. The remaining equations form a vector equation (three equations, one for each component) which represents conservation of momentum, and
so is usually referred to as the momentum equation. While this system contains four
unknowns and four equations, and is thus technically soluble, the arrangement of
unknowns causes problems: the momentum equation links all components of the
International Journal of Mechanical Engineering Education 32/1

32

G. Tabor

velocity and the pressure, while the continuity equation represents a constraint on
the velocity. In addition, the set of equations is also non-linear (the . (u ux) term).
Thus CFD represents a complex numerical challenge. The approach conventionally used is referred to as the finite volume (FV) approach. In this, the domain of
interest is divided into a set of small, non-overlapping cells or control volumes, and
the NavierStokes equations (1,2) are integrated over each cell. Gauss theorem is
used to convert the divergence term in the equations into the sum of fluxes over the
cell faces. This converts equations (1,2) into a set of difference equations for the
values of p and u at the chosen points in the domain (conventionally the values are
associated with the cell centres). The set of difference equations so produced are
usually solved sequentially and iteratively, using approximate matrix inversion techniques, to produce the solution. This is a very brief summary of an enormous area,
and for more details the reader is advised to consult one of the many textbooks on
the subject [1, 2, 3].
With the ever-decreasing cost of computer power, CFD is becoming more and
more valuable as a tool in engineering [4, 5]. It provides the ability to investigate
fluid flows without the cost of experimentation, for example allowing many different geometries of an aircraft to be investigated quickly and cheaply. It also provides
the user with a much wider range of information about the flow. For instance, it is
relatively easy to determine experimentally the velocity at a predetermined point in
a flow, but much more difficult to measure the shear stress at all points on the surface
of an airfoil, or the turbulence level throughout an internal combustion engine cylinder. CFD provides easy access to a wide diversity of such information. Thus it is
becoming an important area for undergraduate teaching.
Use of a CFD code requires the completion of three basic tasks: problem definition (meshing, selection of models, physical constants, boundary conditions),
problem solution (matrix inversion to solve the difference equations, iterated or
repeated until the desired result has been achieved) and post-processing of the resulting data to extract the required information. Much of this is becoming an exercise
in manipulation of commercial codes. Commercial codes such as Fluent and STARCD are typically hundreds of thousands of lines in length and are the result of
substantial effort in software development. It is unnecessary for undergraduate engineering students to learn enough to be able to actually write such a code. Undergraduate study modules in this area are best structured around an engineering case
study or set of case studies, with the student gaining enough understanding of CFD
to be able to use a commercial code to simulate the cases critically and intelligently.
This is the structure adopted here at Exeter in third- and fourth-year computational engineering modules, and elsewhere [6, 7]. The emphasis, however, should
be on the critical and intelligent use of the software, and to make this possible the
students have to understand what is going on if they are to make meaningful use of
the code. For example, the issues relating to solution convergence and what represents a correct solution are undeniably complex but impact significantly on the use
of the code [8, 9]. Factors affecting the quality of the solution include modelling
errors (incorrect mathematical models for the physical situation being investigated),
discretisation errors (incorrect or incomplete conversion of the modelled partial difInternational Journal of Mechanical Engineering Education 32/1

Teaching CFD using spreadsheets

33

ferential equations to difference equations, leading to effects such as numerical viscosity) and solution errors (incorrect or incomplete solution of the resulting matrix
equations). Understanding these issues does require some understanding of what
is often referred to as numerics numerical issues relating to the solution of the
model equations.
A selection (not exhaustive) of important numerical issues includes:
derivation of a difference equation from a partial differential equation, and solution via timestepping;
implicit and explicit algorithms for timestepping, stability issues and criteria;
effect of different differencing schemes on the nature of the solution;
iterative matrix inversion techniques for sparse matrices.
Navaz et al. [7] discuss in some detail the structure of a full CFD course, and declare
that Students learning objectives of the course are to learn numerical techniques
and algorithms commonly used by CFD codes. Quoted homework examples from
their course include analysis of implicit and explicit schemes and the discretisation
of governing partial differential equations in fluid flow and heat conduction, and
mention is made of ADI (alternating direction implicit) methods for matrix inversion. However, the approach by which the students learn this material is not specified, and it is the impact of computer methods on this, specifically the application
of spreadsheet analysis on this, that the present paper addresses.
Numerical aspects and spreadsheets
Kolb [10] suggested that learning is a cyclic process involving experiencing, reflecting, thinking and planning stages. The implication here is that the student should
experience all phases of the cycle (often several times) to complete his/her education in a topic. Generally in technical subjects such as engineering, the tradition is
to start with the thinking stage, presented in the form of traditional lectures, and
to progress from there; often other critical stages are neglected or left to the students
themselves. This is a case in point. In terms of teaching numerics for CFD, providing the thinking stage is easy. A simple case might involve the heat transfer equation in one dimension:
T
2 T
=k 2
t
x

(3)

where T is the temperature. One can show in a lecture that this equation can be discretised using straightforward finite difference (FD) techniques on a uniform grid,
providing a difference equation, and thus an algorithm:
Tjn +1 = Tjn +

aDt n
(Tj -1 - 2Tjn + Tjn+1 )
Dx 2

where Dt is the timestep and Dx the grid spacing. The concepts required for getting
this far Taylors expansion and algebraic manipulation are straightforward and
well within the grasp of engineering undergraduates.
International Journal of Mechanical Engineering Education 32/1

34

G. Tabor

However, closing the Kolb cycle by providing the experiential part of the learning cycle is more challenging. The resulting algorithm can be applied by hand to a
dataset, but the resulting calculation is long and tedious for any reasonable size
dataset, and this will tend to obscure the important issues. At the opposite extreme,
students could be required to write a program implementing this algorithm in a highlevel language such as Java or Fortran. However, only a minority of engineering
students have the competency necessary to write code easily, and a significant proportion of student effort is expended in trying to make sense of coding issues rather
than understanding the numerical issues. In addition, in writing high-level code like
this, the student must cope with issues of data storage and manipulation that are
more relevant to computing courses than to understanding the numerical algorithm.
As an example, in the language C, the student will first have to work out how to
store the information for the mesh as an array or by using pointers, both of which
are complex tasks. Higher-level languages such as Matlab may make this easier, but
there is still the challenge of teaching the student a large and complex programming
language. What we need is a computer package that makes the tasks of allocating
data storage and manipulating arrays of data as simple as possible, potentially even
intuitive, so as to be able to abstract out the issues relating to the numerical algorithm and focus on these.
Spreadsheet programs provide this facility. A spreadsheet provides instant data
storage in the form of an extendable two-dimensional array of cells, each of which
can be used to store any type of data, and which has a simple mechanism for referencing in terms of rows and columns. Algebraic and mathematical operations can
be applied to the elements of the spreadsheet, and the operations can be repeated,
either interactively or by creating macros. Additionally, matrix operations are also
available, although this use of spreadsheets is not as well known. For instance, a 6
6 matrix can be created in the spreadsheet and inverted using an internal algorithm
(Gaussian elimination). Spreadsheet programs also contain graphing facilities,
allowing results to be easily displayed. Thus spreadsheet programs fulfil all the necessary requirements for teaching numerics as part of a course in CFD. The most
commonly available spreadsheet is Microsofts Excel; for Unix or Linux, Sun
StarOffice (or Open Office) provides a functional equivalent that has been used for
the examples given here. Virtually all engineering undergraduates have ready access
to a PC both at home and at university [11], and many will already be familiar with
office products such as spreadsheets [12].
The use of spreadsheet programs for mathematical simulation is well known
in business and finance, and they have been used before in teaching engineering.
Halawa [13] has demonstrated the use of Excel spreadsheets to simulate simple engineering systems such as pumps and heat exchangers. This provides the student with
an opportunity to model complex and realistic systems using simple equations, reinforcing the basics of the subject, and to do this without the need for specific
competencies in computer programming. A number of specific engineering problems have been analysed by Fraser and Thorpe [14], including ideal fluid flow, twodimensional heat transfer, plate bending and torsion of non-circular section beams.
All these cases are field problems involving the solution of the Laplace or Poisson
International Journal of Mechanical Engineering Education 32/1

Teaching CFD using spreadsheets

35

equation using FD techniques on a regular grid, although they do also indicate that,
since spreadsheets also provide Boolean operators, digital logic circuits can also be
simulated, and include a worked example of this as well. The authors suggest a time
saving of around 75% over writing conventional code in setting up these problems.
Schumack [15] looks at five automotive-related problems that can be simulated using
spreadsheets (principally heat transfer problems). Student reaction to these computational assignments was very encouraging, with the students reporting increased
confidence and greater understanding of the issues. Also concentrating on heat conduction, Mokheimer and Antar [16, 17] provide detailed instructions on how to set
up calculations in one, two and three dimensions, both steady state and transient.
Use of spreadsheets specifically for fluid flow is less common. Both Fraser and
Thorpe [14] and Morishita et al. [18] demonstrate the simulation of ideal flow using
spreadsheets. Morishita et al. also solve several other types of fluid flow problems,
including boundary layer problems using RungeKutta, Panel methods, potential
methods for transonic flow, Euler flow via the method of characteristics, and, impressively, full solution of the incompressible NavierStokes equations using FD
techniques.
The intention in the present paper is somewhat different from these previous
examples. In the work cited above, spreadsheets were used to solve specific engineering problems, either with the student being unaware of the details going into the
solution, or as an exercise in applying simple concepts that the student is aware of
(Bernoullis equation, digital logic) to model much more complex problems. My
intention here is to discuss the use of spreadsheets as an approach to teaching the
details of the numerical analysis. The advantages of this are the detachment of the
numerics from programming issues, and the versatility that spreadsheets provide
for the student to investigate the effects of various changes, such as to the value of
parameters.
Case studies
Four case studies are presented, covering the full range of numerical issues, algorithm development, differencing and matrix inversion. The mathematical and coding
issues involved in each case are explained, as are the intended learning outcomes
of the case and how these relate to the spreadsheet. The specific cases investigated
are summarised in Table 1. Illustrative exerts from the spreadsheets are included
in the Appendix. In addition, the spreadsheets are available from the website
www.ex.ac.uk/fluidflow/ComputationalFluidDynamics/IJMEE/IJMEEpaper.html,
in StarOffice and Microsoft Excel formats.
One-dimensional heat conduction
Although FD methods are not often used outright in CFD, they are the easiest to
explain and can be used to illustrate a number of important issues in algorithm development, stability and so on. A suitable starting point for students is to create a FD
scheme to solve the one-dimensional heat equation (3). The spatial derivatives can
be discretised to give:
International Journal of Mechanical Engineering Education 32/1

36

G. Tabor

TABLE 1
Case

Summary descriptions of the four case studies presented

Sheet

Description

1
2
1

Heat conduction across kiln wall, explicit one-dimensional algorithm


Same problem, steady state, implicit algorithm
Pollutant transport through constant cross-section pipe, explicit algorithm,
showing effects of upwind/central differencing
Pollutant transport through pipe of varying cross-section
Fluid flow in square duct, implicit algorithm
Solution of linear equation set from Duct2D, using successive over-relaxation
method

Heat1D
Transport

2
Duct2D
SOR

(Tjn-1 - 2Tjn + Tjn+1 )


T
=k
t
Dx 2
Fully explicit, fully implicit and mixed (e.g. CrankNicolson) schemes can all be
derived from this. If we evaluate the spatial derivative at time n, then we can derive
the fully explicit scheme stated above:
Tjn +1 = Tjn + s(Tjn-1 - 2Tjn + Tjn+1 ), s =

kDt
Dx 2

Fixed-value boundary conditions can be implemented by placing the first and last
grid points on the boundaries and setting these to be constant; grid points in between
can be constructed using the above scheme. As an example, spreadsheet 1 sheet 1
(see Appendix) solves the problem of the temperature profile through a 50 cm kiln
wall, one side at room temperature (25 C) and the other at 800 C. We note in
passing that there are stability problems with this, which restrict the timestep so that
s 0.5 (this can be proved using the von Neumann stability analysis, c.f. Fletcher
[1]). This problem has been solved in spreadsheet Heat1D sheet 1.
As time progresses, the solution should approach a steady state: a linear profile
between 800 C and 25 C. This could be derived from the first spreadsheet by carrying the iteration forwards for a considerable time. We could also get this result by
solving the implicit time-independent heat equation:
k

2 T
=0
x2

Discretising this:
k
(Tj -1 - 2Tj + Tj +1 ) = 0
Dx 2
International Journal of Mechanical Engineering Education 32/1

Teaching CFD using spreadsheets

37

This can be written as a matrix equation:


-2 s1
s1

0
0

s1
-2 s1
s1
0
0
0

0
s1
-2 s1
s1
0
0

0
0
s1
-2 s1
s1
0

0
0
0
s1
-2 s1
0

0
0

0
0

s1

-2 s1

T1 0
M 0


Tj -1 M
Tj = M


M 0


TN -1 0

That is
MT = Y with s1 =

k
Dx 2

This can be inverted as T = M-1Y. Of course, as it stands at the moment, inverting


this system will give an incorrect result, as the boundary conditions have not been
introduced as yet. These can be introduced by manipulating the source vector, Y.
For instance, in the explicit scheme, T0 = 25 C. For the implicit scheme, we solve
for nodes 1 . . . N - 1, and so the scheme for node 1 becomes:
k
k
(-2T1 + T2 ) = - 2 T0 = -25s1
2
Dx
Dx
The first and last terms in the source term are therefore -s1T0 and -s1TN, respectively.
The matrix has been set up in spreadsheet Heat1d sheet 2 (see Appendix). The
diagonals are constructed first, and then other entries in the matrix (19 19 in this
case) are filled with zeros. A section of spreadsheet large enough to accommodate
the resulting vector must be marked off first: the matrix system inverted using the
spreadsheet functions MINVERSE and MMULT, and the matrix function entry concluded with the key sequence ctrl shift return. Results for the steady-state case
have been plotted and, as expected, show a straight line between inside and outside.
Using this as an exercise, students should be able to achieve the following learning outcomes:
formulate a difference equation from a simple partial differential equation;
construct an algorithm to solve a set of difference equations at different points
on a mesh;
implement and justify fixed-value boundary conditions;
contrast implicit and explicit algorithms, and time marching, to solve a problem;
discuss stability restrictions for explicit algorithms;
contrast the computational expense of implicit and explicit algorithms.
Since constructing the spreadsheet is relatively fast, students are able to investigate
the effect of changing various parameters. For example, many students do not realise
the importance of the stability restrictions for explicit algorithms until they come to
code the explicit scheme and discover that the timestep they have chosen is too large.
They are also able to investigate the effect of changing the spatial discretisation, and
compare analytical solutions to heat transfer problems in one dimension.
International Journal of Mechanical Engineering Education 32/1

38

G. Tabor

One-dimensional transport equation


Probably the single most important partial differential equation in CFD is the transport equation. In one dimension, this takes the form:
q qu x
q
+ Sq
G
+
=t
x
x x

(4)

for some physical quantity q. The left-hand side of the equation represents fluid
transport of q, via the flow velocity, ux. The right-hand side contains two terms, the
first being the diffusive effect of viscosity, and the second any source terms in the
flow. q can represent any one of a number of physical properties of the flow, such
as temperature of pollutant concentration. Most significantly, each component of the
momentum equation (2) is a (three-dimensional) transport equation, for example for
the x component:
u x
1 p
+ u x u = vu x t
r x
with q = ux. Thus this equation demonstrates many issues which become important
in advanced CFD.
Solution of equation (4) requires a knowledge of ux. In one dimension and for
incompressible flows, this is straightforward, the velocity being inversely dependent
on the cross-sectional area. In the more general case, the velocity would be worked
out as part of the solution step, and for the momentum equation this term generates
the non-linearity which is a feature of CFD. For now, we will keep the problem
simple, and analyse the transport of a contaminant q along a pipe. The problem
geometry is outlined in Fig. 1: a fluid flows through the pipe from left to right at a
particular flow rate, and at time t = 0 a contaminant is introduced at the inlet (q = 1
at t = 0, x = 0). If the change in area is gradual, then this will be a one-dimensional
flow in the x direction, and the domain can be divided into cells, as shown. A regular
mesh can be used, with cells of width dx and volume 12 (A1 + A2) dx.
To apply the FV method we integrate (4) over each cell. Each integral can be
manipulated separately. For instance the transport term becomes:

qu x
qu x
Adx = [qu x A]2 - [qu x A]1
dxdA =
x
x

In the more general case, this conversion from a derivative to a flux term would be
accomplished via Gauss theorem. In the one-dimensional case, as here, the essence
of the conversion is clear even to those students with more limited mathematical
skills. Discretising the whole equation we have:

(q n+1 - q n )
dt

q
q
dV + [qu x ]2 A2 - [qu x ]1 A1 = G A2 - G A1

x
x 1
2

where the brackets contain terms which are being evaluated on the cell faces A1 and
A2. Evaluation of these terms is via interpolation from the cell centre values, which
can either be a centred interpolation, giving a second-order scheme, or an upwind
International Journal of Mechanical Engineering Education 32/1

Teaching CFD using spreadsheets

39

Fig. 1 Flow geometry for case study 2: transport of a contaminant along a pipe. The pipe
varies in area along its length (top view). A typical FV computational cell is shown below.

interpolation, giving a first-order scheme. The classic problem to analyse here is the
propagation of a step profile for the concentration, for which the upwind scheme
smoothes the step by introducing numerical viscosity errors, while the centred
scheme produces an oscillatory effect on either side of the step. This problem is
analysed on page 1 of spreadsheet Transport (p. 47), for a pipe of constant crosssection. Sheet 2 of spreadsheet Transport (p. 48) analyses the transport problem in
a uniformly converging pipe, and generates plots of both pollutant concentration and
velocity (see Appendix). The geometry of the pipe could easily be altered to analyse
flaring pipes for instance, which would be difficult in a FD formulation.
By way of learning outcomes, students should be able to:
indicate the importance of the transport equation in CFD as a description of
pollutant transport and as the basis for solving the momentum equation;
solve the transport equation using FV techniques;
understand the conversion from volumetric quantities in a cell to flux through
cell faces (without needing an in-depth understanding of Gauss theorem);
summarise the different effects of upwind and central differencing (interpolation)
on the propagation of a step function profile (numerical viscosity and phase errors).
Two-dimensional flow in a square duct
The previous examples are of one-dimensional problems, selected to illustrate
numerical issues of importance to CFD. Two-dimensional problems can also be
International Journal of Mechanical Engineering Education 32/1

40

G. Tabor

solved. As an example, we look at the problem of pressure-driven flow in a square


duct. This is an excellent exercise for the student, as it shows how the CFD calculation relates to the governing NavierStokes equation. In this case the driving pressure force in the z direction is balanced by viscous forces in the x and y directions,
and the momentum equation reduces to:
0=-

1 p 2 uz 2 uz
+ v 2 + 2
x
r z
y

If we write the driving term

(5)

1 p
= - K , then this becomes:
rv z

2 uz 2 uz
+
+K =0
x 2 y2
Since the problem is symmetrical, we can solve on a quarter of the duct with
symmetry planes for two boundaries, as shown in Fig. 2. A typical cell is also
shown together with its neighbours. In accordance with convention in the subject,
the neighbouring cells are marked N, S, W, E, and the cell faces marked n, s, w, e,
respectively.
To apply the FV technique, we integrate (5) over this cell, of side dx = dy and
volume (i.e. area) dV = dx dy.
2 uz
2 uz
d
x
d
y
+
x 2
y 2 dxdy + Kdxdy
=
=

uz
x

dy +
w

uz
dx + KdV
y s

uz (E) - uz (C) uz (C) - uz (W )


dy

dx
dx
uz (N ) - uz (C) uz (C) - uz (S)
+
dx + KdV

dy
dy

Since dx = dy, we can rewrite this as:


4uC - uE - uW - u N - uS = KdV
(dropping the subscript z on the velocity). This provides an implicit scheme:
Mu = K
where the matrix M is now a pentadiagonal sparse matrix, with 4 on the leading
diagonal and -1 on four other diagonals. This can be set up in the spreadsheet as
before. The process of construction serves to illustrate a number of issues, including the regular nature of the matrix for a structured grid and its sparse nature (see
Appendix). The boundary conditions are also included. In this case, the boundary
conditions are:
International Journal of Mechanical Engineering Education 32/1

Teaching CFD using spreadsheets

41

Fig. 2

Domain for duct flow calculation. Due the to symmetry of the problem only a
u
quarter of the domain needs to be simulated, with
on the symmetry planes. A typical
n
cell is shown together with its neighbours, labeled N, S, W, E, and shared faces n, s, w, e.

u = 0 on the walls
u

on the symmetry planes (n is normal direction to the plane, x or y as


n
appropriate).
Both can be dealt with by manipulation of the source term K, although the first consists of adding 0 to elements of this term. Finally, the problem can be solved as
before by inverting M. The data can be examined directly, rewriting the elements in
an n n grid (5 5 in the spreadsheet Duct2D) or plotting the data on a graph.
Students should be able to achieve the following learning outcomes:
derive implicit algorithms for fluid dynamical systems, and in particular relate
the analytical approach to fluid dynamics via the NavierStokes equation to the
numerical approximation;
explain the sparse nature of CFD matrices, and why in practice they would be
stored as one-dimensional arrays rather than two-dimensional matrices;
implement and justify various types of boundary conditions.
Sparse matrix inversion
All implicit methods generate a matrix equation of the form:
Mu = Y
This is solved by finding M-1 and multiplying through. This has been done in spreadsheet Duct2D, for example (see Appendix), using the built-in matrix inversion
International Journal of Mechanical Engineering Education 32/1

42

G. Tabor

methods provided in StarOffice Base. The methodology used to invert matrices and
to solve these systems of linear equations is an area of active research in CFD,
looking for more sophisticated, robust and/or efficient algorithms. Undergraduate
engineering students do not necessarily need to understand all the details; however,
as emphasised before, some familiarity with the basic approaches is desirable. Once
again, spreadsheets cab be utilised to assist student learning by providing a straightforward framework for manipulating arrays of numbers.
In practice, rather than separately inverting M and them multiplying the source
vector Y by the result, numerical algorithms are designed to return the solution u
for a given M and Y. These algorithms are iterative and also provide an estimate of
the error at any iteration, referred to as a residual. As an example, the Jacobi method
provides a revised estimate for u, un+1 as:
uin +1 =

(Yi - S Nj i Mij u nj )
Mii

However, this is much too slow to be of any practical use. In addition, as the algorithm sweeps through the matrix, the updated values of uIn+1 must be stored separately: they cannot replace the values of uIn until all the updated values have been
calculated. An immediate improvement would be to replace the old value of u with
the new one in the vector as soon as it is available. As it happens, as well as reducing storage, this also speeds up the convergence of the algorithm. Such an algorithm,
using updated values of u as they become available, gives a revised u as:
Yi - S ij==10 Mij u*j - S Nj =i +1 Mij u nj
ui* =
Mii

If un+1 = u*, then we have the GaussSeidel method. A further improvement is to


blend in a proportion of the previous values, introducing a relaxation parameter, w:
u n +1 + wu* + (1 - w)u n
This is the successive over-relaxation algorithm, or SOR. w can take values
between 0 and 2, and the speed of convergence is dependent on the exact value.
Finding this exact value for a particular case is itself quite challenging [1].
As an example (see Appendix), spreadsheet SOR solves the linear system generated from the previous case, that of flow in the square duct. The system is first written
out in full, as a 25 25 matrix, M, and source term, Y. The various elements of the
matrix are then broken down into the five diagonals, ae, as follows:
c
e a
b e a
c

b e a

M =
b e a

b e a
d

d
b e
International Journal of Mechanical Engineering Education 32/1

Teaching CFD using spreadsheets

43

(zero elements elsewhere), and copied out, together with the source term and an
initial guess for u. Storage for this is now 113 cells as against 650, a significant
saving demonstrated by the layout of the spreadsheet (see Appendix). constructing
the algorithm requires some care to provide the neatest spreadsheet. In spreadsheet
SOR, the various arrays have been offset so the cells and their coefficients are all in
same column. Also, blank space surrounds the computational area. Each individual
cell update in this case involves the operation:
Yj - bu j -1 - du j -6 - au j +1 - cu j +6
u*j =
e
When working with cell j = 0, this would normally need to be modified, since there
is no cell j = -6. By introducing appropriate blank spaces, the same iterative formula
can be used in the spreadsheet implementation, since the value in cell u-6 is zero
anyway. The residual is evaluated afterwards, and the algorithm iterated until the
residual is below 10-4.
This is possibly a more complex spreadsheet to set up, and might be more relevant for demonstration rather than as a student exercise. However, there are valuable learning outcomes from this. The student should be able to:
indicate the importance of storing sparse matrices in the most appropriate
manner;
explain the relevance of the residual of signal convergence to a result;
evaluate convergence rates using different schemes (and in this case, different
values of the relaxation parameter, w).
Conclusions
The objective of this paper was to demonstrate the value of spreadsheets in promoting student understanding of CFD numerics. Although it is possible to use commercial CFD codes without any understanding of the numerical techniques being
utilised, this is not recommended: a competent CFD analyst should have some grasp
of algorithmic complexities, differencing schemes, and matrix inversion techniques
in order to understand their characteristics and limitations. The difficulty with this
is that coding many of these techniques in a conventional programming language
is a challenging task, and requires competencies in an array of issues not directly
related to the numerical issues that the students are supposed to be investigating.
These challenges can easily obscure the concepts that the student is supposed to be
learning, and are irrelevant to the use of the code itself. At the other extreme, a purely
theoretical approach to these issues, for instance the theoretical treatment of the stability of an explicit algorithm, means that the student misses out on the experiential
and reflective aspects of the learning cycle, and can seem remote and academic to
the student. What is needed is a package in which the student can experiment with
the manipulation of numerical information in a way that is intuitive and which insulates him/her from the less important details. Spreadsheets are an ideal tool for this.
They provide an environment designed for manipulating numbers, and arrays of
International Journal of Mechanical Engineering Education 32/1

44

G. Tabor

numbers, and for iterating calculations, without the user being concerned with the
details of numerical storage or program compilation. They are intuitive and easy to
use; indeed, students are often already proficient in their use. Most importantly, they
are easily available. The range of programming languages taught to engineering students is wide, and there is no guarantee of a sufficient level of competence in a given
language, and certainly no guarantee that students will have access to the appropriate compilers, outside of a specialist programming module. Access to a spreadsheet
such as Excel or StarOffice Base, on the other hand, is virtually certain, and even if
students have not used spreadsheets before, they can usually pick up enough understanding in a couple of hours to be able to solve simple numerical problems.
Within this paper, four examples of spreadsheet numerics have been presented,
covering the full range of algorithm construction, stability, differencing and matrix
inversion. Spreadsheet Heat1D illustrates the concepts of explicit and implicit algorithms and stability issues associated with each. Spreadsheets Transport and Duct2D
illustrate the FV methodology for discretisation of the governing partial differential
equations; Transport also demonstrates the effects of upwind and central differencing on the solution for a propagating step profile. Finally, spreadsheet SOR implements the successive over-relaxation algorithm, one of the simpler algorithms used
for solving linear sets of equations. All of these are spreadsheets that could be set
up by an undergraduate student and they provide valuable experience of the issues
concerned. The student can investigate the properties of the algorithms on realistic
meshes, and can quickly and easily investigate the effect of altering specific parameters. In conclusion, spreadsheets provide a valuable tool for teaching numerical
aspects of CFD at undergraduate level.
Appendix
All four applications are available for download from www.ex.ac.uk/fluidflow/
ComputationalFluidDynamics/IJMEE/IJMEEpaper.html in StarOffice and Microsoft Excel formats. Some of these spreadsheets are quite large and this is the most
convenient way of accessing the data. However, websites are an impermanent record
of the work, and for this reason representative sections of the spreadsheets have been
provided here in text form. Spreadsheets Head1D sheet 1 and SOR iterate several
hundred times: these are not provided in full, while the spreadsheet Transport is
reproduced at a very small scale. Spreadsheet Heat1D sheet 2 compares the steadystate solution for the heat equation with the transient solution obtained from sheet
1 after 245 s.

International Journal of Mechanical Engineering Education 32/1

800
800

25

800
800
800
800

25

25

25
25

800
800
800
800
800
800
800

25
25

25

25

25

25

25

800

25

800
800

800

25

25

800

25

800

800
800

800

800

800
800

25
25

25
25
25

25
25

800
800

800
800

25
25

25
25
25
25

800
800
800

25
25
25

Heart1D sheet 1: Spreadsheet to solve heat transfer problem in one dimension Explicit version

Teaching CFD using spreadsheets


45

International Journal of Mechanical Engineering Education 32/1

G. Tabor

Heat1d sheet 2: Implicit version

46

International Journal of Mechanical Engineering Education 32/1

47

Transport: Pollutant transport through pipe of varying Cross-section

Teaching CFD using spreadsheets

International Journal of Mechanical Engineering Education 32/1

48

International Journal of Mechanical Engineering Education 32/1

G. Tabor

49

Duct2D: Two-dimensional flow in a square duct

Teaching CFD using spreadsheets

International Journal of Mechanical Engineering Education 32/1

50

International Journal of Mechanical Engineering Education 32/1

G. Tabor

51

SOR: Solution of linear equations via SOR method

Teaching CFD using spreadsheets

International Journal of Mechanical Engineering Education 32/1

52

International Journal of Mechanical Engineering Education 32/1

G. Tabor

Teaching CFD using spreadsheets

53

References
[1] C. A. J. Fletcher, Computational Techniques for Fluid Dynamics, 2nd edn (volume I & II of the
Springer Series in Computational Physics) (Springer, 1991).
[2] H. K. Versteeg and W. Malalasekera, An Introduction to Computational Fluid Dynamics: The Finite
Volume Method (Longman, 1995).
[3] J. H. Ferziger and M. Peric, Computational Methods for Fluid Dynamics (Springer, 1996).
[4] A. D. Gosman, Developments in industrial computational fluid dynamics, Chem. Eng. Res. Des.,
76(A2) (1998), 153161.
[5] R. Agarwal, Computational fluid dynamics of whole-body aircraft, Ann. Rev. Fluid Mech., 31
(1999), 125169.
[6] D. Wilkinson, Introducing cfd to undergraduate chemical engineers, Int. J. Mech. Enging. Educ.,
26 (1998), 126132.
[7] M. K. Navaz, B. S. Henderson, R. M. Berg and S. M. A. Nekcoei, A new approach to teaching
undergraduate thermal/fluid sciences courses in applied computational fluid dynamics and compressible flow, Int. J. Mech. Enging. Educ., 30 (2002), 3549.
[8] Is my simulation converged?, Fluent News (winter 2001). http://www.fluent.com/about/news/
newsletters/01v10i2/a20.htm.
[9] P. J. Roache, Quantification of uncertainty in computational fluid dynamics, Ann. Rev. Fluid.
Mech., 29 (1997), 123160.
[10] D. Kolb, Experiential Learning: Experience as the Source of Learning and Development (PrenticeHall, 1984).
[11] S. Palmer, On- and off-campus computer usage in engineering education, Computers & Education, 34 (2000), 141154.
[12] P. Newhouse and L. Rennie, A longitudinal study of the use of student-owned portable computers
in a secondary school, Computers & Education, 36 (2001), 223243.
[13] E. E. H. Halawa, Simulation worksheet (lks) for development of steady-state simulation system of
equations, Int. J. Mech. Enging. Educ., 29 (2001), 19.
[14] C. J. Fraser and J. R. Thorpe, Spreadsheet applications for modelling and analysis, Int. J. Mech.
Enging. Educ., 24 (1996), 124136.
[15] M. R. Schumack, Teaching heat transfer using automative-related case studies with a spreadsheet
analysis package, Int. J. Mech. Enging. Educ., 25 (1997), 177196.
[16] E. M. A. Mokheimer and M. A. Antar, On the use of spreadsheets in heat conduction analysis, Int.
J. Mech. Enging. Educ., 28 (2000), 113139.
[17] M. A. Antar and E. M. Mokheimer, Spreadsheet modelling of transient three-dimensional heat conduction with various standard boundary conditions, Int. J. Mech. Enging. Educ., 30 (2002), 1734.
[18] E. Morishita, Y. Iwata, K. Yuki and H. Yoshida, Spreadsheet Fluid Dynamics, Technical report
2000-0804 (AIAA, 2000).

International Journal of Mechanical Engineering Education 32/1

Vous aimerez peut-être aussi