Professional Documents
Culture Documents
Computer-Aided Thermofluid Analyses Usin PDF
Computer-Aided Thermofluid Analyses Usin PDF
Computer-Aided Thermofluid Analyses Usin PDF
Mohamed M. El-Awad
Computer-Aided Thermofluid Analyses Using Excel 2
Mohamed M. El-Awad
Associate Professor,
Sohar College of Applied Sciences
Computer-Aided Thermofluid Analyses Using Excel 3
https://www.researchgate.net/publication/334959438_Thermax
Or
https://www.mendeley.com/library/fileproxy?id=04a975bf-59cf-cde5-7abe-
54d5b118d1e6
Computer-Aided Thermofluid Analyses Using Excel 5
Preface
This book shows how Microsoft Excel can be used as an effective educational platform
for thermofluid analyses. Excel provides a rich library of mathematical and statistical
functions and powerful tools for “what-if” type of analyses and data visualisation. The
Solver add-in that comes with it enables the students to perform constrained and multi-
variable optimisation analyses of thermofluid systems. Building on these capabilities, the
Excel-based platform for thermofluid analyses presented in this book also utilises the
Visual Basic for Applications (VBA) programming language that comes with Microsoft
Office. The book shows how VBA can be used for developing additional user-defined
functions (UDFs) for supplementing Excel’s built-in functions and introduces an Excel
add-in, called Thermax, that provides UDFs for determining the thermo-physical
properties of the fluids commonly used in thermofluid systems.
The fluids covered by the Thermax add-in include twelve ideal gases, saturated water and
superheated steam mixtures, six refrigerants, humid air for psychrometric analyses, and
atmospheric air at various temperatures. Property add-ins developed by other academic
and research institutions or individuals can be used to extend the range of thermofluid
analyses that can be performed with the Excel-based platform. In addition to its property
functions, Thermax also provides interpolation function and an internal solver for
nonlinear equations based on the Netwon-Raphson (N-R) method. The interpolation
functions can be used to interpolate tabulated properties of the fluids not covered by the
add-in and the N-R Solver is needed for dealing with iterative solutions and optimisation
analyses that involve a non-linear equation, such as the Colebrook-White equation or the
Soave-Redlich-Kwong (SRK) equation of state.
The principles underlying thermofluid analyses are usually taught to engineering students
in three separate courses: thermodynamics, fluid mechanics, and heat transfer. Rather
than dealing with thermofluid analyses in this segregated manner, the first six chapters
of the book adopt a unified approach that best suits the students who have already studied
the three basic courses. The last five chapters of the book differ in that they deal with
selected topics related to thermodynamics, fluid mechanics, and heat transfer. This
Computer-Aided Thermofluid Analyses Using Excel 6
arrangement makes the book more useful for those students interested in only one
thermofluid subject. The book adopts a learning-by-example approach and most of the
examples considered in it are based on relevant examples given in popular textbooks so
that the solutions obtained with Excel can be verified. Exercises are given at the end of
each chapter to help students sharpen their skills related to that chapter.
The material covered in this book is adequate for a stand-alone course at the intermediate
level on computer-aided thermofluid analyses, but selected chapters or sections from it
can also be used to supplement standard courses on thermodynamics, fluid dynamics, and
heat transfer. It is also hoped that the book can be a useful reference for practicing
engineers in the area of thermofluid and energy systems.
Acknowledgements
The preparation of this book would not have been possible without benefitting from the
efforts of many other people who have made the fruits of their efforts available in the
open literature or the internet. In this respect, my special gratitude goes to the Mechanical
Engineering Department at the University of Alabama (USA) whose initiatives both
inspired and helped me throughout the writing of this book. I am also indebted to the
College of Applied Sciences in Sohar (Oman) who provided the needed financial support
for my work, gave me the chance to teach the three thermofluid subjects, and helped me
to prepare the material covered in the book. I also appreciate the unfailing support
received from my colleagues and students at CAS Sohar and the University of Khartoum
and hope that they find this book a fair repay. Last, but not least, my thanks and gratitude
go to my beloved family for their tolerance and unfailing support desperately needed to
complete the work.
Computer-Aided Thermofluid Analyses Using Excel 7
CONTENTS
Nomenclature 11
1. Introduction 13
1.1. A review of thermofluid subjects 14
1.1.1. Thermodynamics 14
1.1.2. Fluid dynamics 19
1.1.3. Heat transfer 23
1.2. Advantages of computer-aided thermofluid analyses 26
1.3. An Excel-based modelling platform for thermofluid analyses 29
1.4. Closure 30
References 32
2. Excel 35
2.1. Elements of Excel’s user-interface 36
2.2. Excel’s formulae 37
2.3. Use of cell labels 39
2.4. Excel’s built-in functions 42
2.4.1. Logical functions 43
2.4.2. Functions for matrix operations 44
2.5. Solution of linear systems of equations 47
2.6. Iterative solutions with Excel 50
2.6.1. Iterative solutions with Goal-Seek 50
2.6.2. Iterative solutions with circular calculations 53
2.7. Excel’s graphical tools for data presentation and analysis 56
2.8. Closure 58
References 58
Exercises 59
Exercises 178
Appendices 349
A. Properties of air and water at various temperatures 350
B. The fin equation, fin efficiency, and fin effectiveness 352
C. Heat-exchanger analyses 356
D. Property add-ins developed at the University of Alabama 359
E. FD analysis of the heat conduction from a triangular fin 363
F. The functions Fdimplicit and TDMA of the implicit FD method 269
Nomenclature
A Area
C Friction coefficient in Hazen-Williams equation, Equation (1.27)
Cf Friction coefficient, defined by Equation (4.34)
cp Specific heat at constant pressure, kJ/kg·oC
cv Specific heat at constant volume, kJ/kg·oC
D Diameter
E Total energy of the system
E Energy per unit mass of the system
EG Total energy generated in the system
eG Energy generated per unit volulme
f Friction factor
F Correction factor, defined by Equation (C.4)
FD Drag force, defined by Equation (4.34)
g Acceleration of gravity
h Average heat-transfer coefficient
h Enthalpy, kJ/kg
hf Major friction in a pipe system
k Thermal conductivity, W/m·oC
k Isentropic exponent, dimensionless (k=cp /cv)
K Minor losses friction coefficient in a pipe system, defined by Equation (1.28)
L Length
m Mass ˙
m Mass rate of flow
M Molecular weight
P Pressure, usually kPa
Pr Reduced pressure
Pr Relative pressure (for an ideal gas), defined by Equation (4.7)
q Heat-transfer per kg of the working fluid, usually kJ
Q Heat, usually kJ
Q Volume flow rate
Q Rate of heat transfer, W or kW
r Radius or radial distance
R Gas constant, kJ/kg.K
Rth Thermal resistance, usually oC/W
Ru Universal gas constant kJ/kmol.K
s Entropy
T Temperature
Tc Critical temperature
Tr Reduced temperature
u Internal energy
U Overall heat-transfer coefficient of a heat-exchanger
Computer-Aided Thermofluid Analyses Using Excel 12
Greek Characters
α Amortisation rate, defined by Equation (6.24)
δ Thickness (e.g. of insulation)
∆ Difference (e.g. temperature)
ε Roughness of surface material
ε Heat-exchanger effectiveness
εf Flow exergy
η Efficiency
μ Dynamic viscosity, kg/m.s
ν Kinematic viscosity, m2/s
ρ Density, kg/m3
Time, annual operating hours of a system
Finite-difference mesh Fourier number, defined by Equation (11.56)
Subscripts
f Saturated liquid condition
fg Difference in property between saturated liquid and saturated vapour
g Saturated vapour condition
lm Log-mean
s Saturation temperature or pressure
s Evaluated at the surface
∞ Evaluation at free-stream ambient conditions
Computer-Aided Thermofluid Analyses Using Excel 13
Introduction
Computer-Aided Thermofluid Analyses Using Excel 14
Cars, refrigerators, and air-conditioners that have become indispensible belongings for
the individuals and families around the globe require large amounts of energy that mainly
come from burning fossil fuels in power-generation plants. Apart from being non-
renewable sources of energy, large-scale combustion of fossil fuels is the main cause for
global warming and its devastating effects are felt at different parts of the world.
Therefore, proper design and operation of these and other energy-conversion devices is
becoming increasingly important. The principles underlying the designs of these systems
are usually taught to engineering students in three thermofluid subjects; which are
thermodynamics, fluid mechanics, and heat transfer. This chapter reviews these
principles and their application for typical analyses in each subject. Due to the variation
of the working fluids properties with temperature and pressure, the equations involved in
these analyses are usually nonlinear and difficult to solve without introducing many
simplifying assumptions that reduce their accuracy. In this respect, the chapter highlights
the advantages of computer-aided methods and describes the Excel-based modelling
platform for thermofluid analysis used in this book.
1.1.1. Thermodynamics
The principles of engineering thermodynamics allow us to determine the amount of
energy transfer between the system and its surroundings in the form of work or heat and
to determine the effectiveness of energy utilization in the system. Thermodynamics has
four basic laws, the most important of which are the first law and the second law of
thermodynamics. In addition to these two basic laws, thermodynamic analyses use many
relationships that describe the behaviour of the particular system being considered
(closed or open) or the particular fluid involved (a liquid, a liquid-vapour mixture, a gas,
or a gaseous mixture). To illustrate the application of thermodynamic laws and
relationships in a typical analysis, consider the air-compression system shown in Figure
1.1 that has two stages of compression separated by an intercooler. Air enters the system
at a temperature T1 and pressure P1. The first-stage compressor, C1, compresses the air
adiabatically to state 2, after which it enters the intercooler where its temperature is
reduced to T3. The second-stage compressor, C2, then increases the air pressure to P4 and
the temperature to T4.
Computer-Aided Thermofluid Analyses Using Excel 15
T
4 P4
P2
Air 4 2
C1 C2 P1
1
T 3 1
2 Intercooler 3 Intercooling
Cooling
water s
(a) (b)
Figure 1.1. Schematic and T-s diagrams of a two-stage air compressor with inter-stage
intercooling
The total compression work depends on how the total pressure ratio is divided between
the two stages and there is a certain value of the intermediate pressure (Pi) that minimises
the total work. The principles of thermodynamics help us to determine this optimum
intermediate pressure as shown below.
Treating the two compressor stages as steady-flow processes, and neglecting changes in
kinetic and potential energy, the first-law of thermodynamics leads to [1]:
Where q and w are the amounts of heat transfer and work transfer per unit mass flow of
air, respectively, and (ho –hi) is the resulting enthalpy change in the stage. Equation (1.1)
adopts the sign convention that heat into the system is positive, while work into the
system is negative. Assuming the compression processes in both stages to be adiabatic
(q=0) and reversible means that the processes are isentropic as shown in Figure 1.1.b.
Using an average specific heat for air at constant pressure (cp), the compression work per
unit mass flow of air in stage 1 (w1) and in stage 2 (w2) can be determined from Equation
(1.1) as follows:
Therefore, the total compression work in both stages (wtotal) is given by:
T T4 T T4
wtotal c p T1 1 2 1 c p T1 2 2 (1.5)
T1 T3 T1 T3
Since we already assumed the two compression processes to be isentropic and the specific
heats cp and cv for air to be constant, the temperature ratios in Equation (1.5) can be
converted into pressure ratios by using the following relationships:
k 1
T2 P2 k
(1.6)
T1 P1
k 1
T4 P4 k
(1.7)
T3 P3
Where k is the ratio (cp/cv); cv is the specific heat for air at constant volume. Appendix A
gives properties of atmospheric air at different temperatures. Making another assumption
that there is no pressure loss in the intercooler, then P3 = P2= Pi. Substituting from
Equations (1.6) and (1.7) into Equation (1.5), we get:
k 1 k 1
c p T1 2
Pi
k P4
k
wtotal (1.8)
1 pi
P
To see how the total compression work varies with the intermediate pressure Pi, let us
consider the specific case in which T1= 300K, P1=100 kPa, and P4 = 900 kPa. Using
Equation (1.8), the total compression work in the system was calculated for different
values of Pi and the result is shown in Figure 1.2. The figure shows that the value of Pi
at which the total compression work is minimal is around 300 kPa. Increasing or
decreasing Pi from this value will increase the compression work.
310
Total compression work (kJ)
300
290
280
270
260
0 200 400 600 800 1000
Intermediate pressure (kPa)
Figure 1.2. Variation of the total compression work with the intermediate pressure
Computer-Aided Thermofluid Analyses Using Excel 17
The principles of thermodynamics are useful for performance analyses and optimisation
of various types of power-generation and refrigeration systems. For example, consider
the regenerative steam-turbine power plant shown in Figure 1.3. This plant consists of a
boiler house for producing superheated steam, a high-pressure steam turbine (HPT), a
low-pressure steam turbine (LPT), a condenser, an open feed-water heater (FWH) and
two feed-water pumps. A fraction of the steam (y) is extracted after the HPT for
preheating the feed-water before going back to the boiler house.
1 2
HPT LPT
Boiler
House
y
3
1-y
7 FWH
Condenser
5
6
4
Pump 2 Pump 1
Figure 1.3. Schematic diagram of a regenerative steam-turbine power plant
The extracted steam reduces the work output from plant, but it also reduces the amount
of heat added in the boiler and its net effect is to increase the thermal efficiency of the
plant. There is also a certain extraction pressure for the steam at which the plant’s thermal
efficiency attains a maximum value. As shown below, the principles of thermo-dynamics
can also be used to determine this optimum steam-extraction pressure.
The total specific work output from the two turbines (wout) and the total work input to the
two pumps (win) are given by:
Where wHPT and wLPT are the specific work output from the high-pressure turbine and the
low-pressure turbine, respectively, and wP1 and wP2 are the specific work input in pump
1 and pump 2, respectively. Assuming the two turbines and the two pumps to be adiabatic
and neglecting the changes in kinetic and potential energies, the work output or input for
each device can be determined from the enthalpy difference across the device. Per each
kg of steam generated in the boiler, these are given by:
Computer-Aided Thermofluid Analyses Using Excel 18
w P 2 h7 h6 (1.14)
Mass and energy balance over the open feed-water heater gives:
The net specific work output from the plant (wnet) is then given by:
The specific heat input to the boiler (qin) can also be determined from the relevant
enthalpy change as follows:
q in h1 h7 (1.17)
Therefore, the thermal efficiency of the plant (η) can be calculated from:
wnet / q in (1.18)
Both wnet and η depend on the fraction of steam extracted for regeneration (y); which in
turn depends on the extraction pressure (P2). Figure 1.4 shows the variation of y and η
with P2 for an ideal cycle in which P1 = 15 MPa, T1 = 600oC, and P4 = 10 kPa. The figure
shows that the cycle’s efficiency attains a maximum value of 45.55% when P2 is in the
range of 1000 kPa.
It should be mentioned that the working fluid in the above power plant changes phase
from subcooled liquid water to superheated steam in the boiler, to saturated mixture of
water and steam in the low-pressure turbine, and returns to subcooled water in the
condenser. Therefore, appropriate property relationships, tables, or charts are needed in
order to determine the working fluid properties at different states. The principles of
thermodynamics are also applied in the analyses of air-conditioning and combustion
processes as well as the analyses of processes or systems involving chemical reactions.
For such analyses, thermodynamics provides the basic relationships needed to quantify
the effects of fluid mixing and chemical reactions on the properties of working fluid and
on the transfer of energy and effluents to or from the thermofluid system.
Computer-Aided Thermofluid Analyses Using Excel 19
0.456 0.3
L2
D
Q
A
The power needed for the pump ( W ), in W, can be determined from the following power
equation:
W Q h p / (1.19)
Where γ is the specific weight of the transported liquid (N/m3), Q is the volume flow rate
of the liquid (m3/s), hp is the pump head (m) needed to circulate the fluid through the
pipe, and η is the combined efficiency of the pump and the electric motor. For steady
Computer-Aided Thermofluid Analyses Using Excel 20
V B2 V A2
h p h f ,total z B z A (1.20)
2g
Where hf,total is the total head loss through the system due to friction (m), zA and zB are the
elevations (m) at points A and B, respectively, and VA and VB are the corresponding fluid
velocities (m/s).
The total friction head loss hf,total consists of two parts: the major friction loss (hf), which
is the part lost in the pipe itself, and the minor friction head loss (hf,minor), which is the
part lost in other components of the system, i.e., elbows and tees, valves, etc. The major
friction loss can be determined from the following Darcy-Weisbach equation [2]:
L V2
hf f (1.21)
D 2g
Where f is the Dracy friction factor (dimensionless), V the fluid velocity (m/s), L the total
length of the pipe (m), and D the internal diameter of the pipe (m). The value of the
friction factor, which depends on the roughness of the pipe surface and on whether the
flow is laminar or turbulent, can be obtained from a Moody diagram [2] or calculated
from a relevant formula. For laminar flows, f can be calculated from:
Re VD / (1.23)
Where ν is the kinematic viscosity of the flowing fluid (m2/s). For a turbulent flow in
smooth tubes, f can be determined from the first Petukhov equation [2]:
f 0.790 ln Re 1.64
2
104 < Re < 106 (1.24)
For a turbulent flow in rough pipes, f can be obtained from the following Swamee-Jain
equation:
2
5.74
f 0.25 / log 10 0.9 Re > 4000 (1.25)
3.7 D Re
Computer-Aided Thermofluid Analyses Using Excel 21
Chemical engineers usually determine the pipe friction by using the Chezy-Manning
equation instead of the Darcy-Weisbach equation. According to this equation:
L V2
hf 2 f (1.26)
D g
Where f is the Fanning friction factor. Comparison with Equation (1.21) reveals that the
value of the Fanning friction factor used in Equation (1.26) is 4 times the corresponding
value of the Darcy friction factor. Civil engineers determine the friction head loss in
water-transporting pipes by using the following Hazen-Williams equation:
10 .67 LQ 1.852
hf (1.27)
C 1.852 D 4.8704
Where C is a coefficient that depends on the roughness of the pipe. Unlike Equations
(1.21) and (1.26), Equation (1.27) is applicable for both laminar and turbulent flows.
The minor friction loss, hf,minor, can be determined from the following equation:
n
V2
h f ,min or
1
K
2g
(1.28)
Where n is the total number of components in the system and K is a coefficient the value
of which for each component can be found in relevant tables.
The equations described above can be used to determine the required pump power for
specified values of the pipe length, pipe diameter, flow rate, fluid viscosity, and pipe
material. The equations can also be used to determine the minimum diameter of the pipe,
or the maximum flow rate of the fluid to be delivered, such that the friction loss in the
system or the needed pump power does not exceed a specified limit. By also taking into
consideration the initial cost of the pump-pipe system and the cost of electrical energy
needed by the pump, fluid-dynamics equations can be used to determine the pipe diameter
that gives the best economic compromise between the initial cost and the operating cost
of the system over its life-time.
The principles of fluid dynamics also enable us to select the appropriate type and size of
the pump for a given pump-pipe system. This is achieved with the help of characteristic
curves usually provided by the manufacturers such as that shown in Figure 1.6 for a
centrifugal pump. In many practical situations a single pump or a single compressor may
not be adequate to meet the required fluid flow rate or delivery pressure and more than
one pump or compressor have to be used. In this situation, the principles of fluid
dynamics allow us to decide when to arrange the pumps/compressor in parallel or in
Computer-Aided Thermofluid Analyses Using Excel 22
series. Figures 1.7 and 1.8 show the characteristic curves of two different arrangements
of centrifugal pumps.
60
50
40
30
h, m
20
Pump curve
10
System curve
0
0 0.001 0.002 0.003 0.004
Q, m3/s
hp
Q, L, D, ε
Two pumps
One pump B
Q2 Check valves Q1 A
Q
Q
(a) (b)
Figure 1.7. Two centrifugal pumps connected in parallel (adapted from Burmeister [3])
hp
Q, L, D, ε
Two pumps
One pump B
Q
A
Q
Q
(a) (b)
Figure 1.8. Two centrifugal pumps connected in series (adapted from Burmeister [3])
Computer-Aided Thermofluid Analyses Using Excel 23
r3
T∞
r1
Ti r2
The rate of heat transfer ( Q ) to/from the pipe can be calculated from [4]:
1 ln r2 / r1 ln r3 / r2 1
Rth (1.30)
hi A1 2Lk 1 2Lk 2 ho A3
Where hi and A1 are the heat-transfer coefficient and surface area inside the pipe,
respectively, ho and A3 are the heat-transfer coefficient and surface area outside the
insulated pipe, respectively, L is the length of the pipe, and k1 and k2 are the thermal
conductivities of the pipe and the insulation, respectively. To simplify the analysis, it is
usually assumed that ho takes into account the heat-transfer by both convection and
radiation to/from the insulation surface. The thickness of the metal pipe is usually small
Computer-Aided Thermofluid Analyses Using Excel 24
compared to its diameter, while its thermal conductivity is much higher than that of the
insulation material. Therefore, the analysis can be simplified further by neglecting the
second term that gives the thermal resistance due to conduction through the pipe.
The above analytical model can be used to determine the thickness of insulation required
for reducing the rate of heat transfer to a specified limit or for controlling the surface
temperature to a limit that is dictated by safety or other practical considerations. Although
the thicker the insulation, the lower will be the rate heat transfer, the cost of insulation
increases with its thickness and there is a certain thickness beyond which adding more
insulation will be uneconomical. This economical thickness of insulation can be
determined by extending the above heat-transfer model so that the cost of insulation and
that of the saved energy can be calculated and compared.
Figure 1.10 shows a typical arrangement in which circular fins are attached to the surface
of a pipe so as to boost the rate of heat-transfer between the fluid being transported with
the pipe and the surrounding gas, usually air. As shown in Appendix C, the principles of
heat transfer can be used to develop the required mathematical equations that describe
the variation of temperature and rate of heat transfer over the surface of the fin. These
equations can then be used to evaluate the effectiveness and efficiency of the fin.
Hot Cold
out out
Cold Hot
in in
Cross-flow
(unmixed)
Tube-flow
(unmixed)
Three independent physical laws are used to quantify the rate of heat transfer between
the system and its surroundings by conduction (Fourier’s Law), convection (Newton’s
law of cooling), and radiation (Stefan-Boltzmann law). While the physical properties that
determine the rates of heat transfer by conduction and radiation, i.e. the thermal
conductivity (k) and surface emissivity (ε), respectively, are substance-specific, the
convection heat-transfer coefficient (h) depends on both the fluid and the flow. Numerous
analytical relationships and empirical formulae are used for determining h depending on
whether the flow is forced or natural. For forced flows, the formulae also depend on
whether the flow is internal or external to the system being considered. These formulae
usually give the Nusselt number (Nu) from which the heat-transfer coefficient can be
calculated. For example, the following Dittus-Boelter equation is used for determining
Nu inside a fluid-transporting pipe due to forced convection:
Where Re is the Reynolds number, Pr the Prandtl number, and n is a constant that takes
the value of 0.4 when the pipe is being heated and 0.3 when it is being cooled. The heat
transfer coefficient is related to the Nusselt number as follows:
k
h Nu (1.32)
D
Where D is the pipe diameter and k is the thermal conductivity of the transported fluid.
Many other analytical or empirical formulae are used for determining the Nusselt number
for forced or natural flows over single tubes, bank of tubes, plates, etc. [4,5].
Pv~ Ru T (1.33)
~
Where P is the absolute pressure of the gas, v is the molar specific volume, Ru is the
universal gas constant, and T is the absolute temperature of the gas. The ideal gas law
can be used with reasonable accuracy for determining the specific volume of a
superheated vapour, but when the temperature approaches the saturation line, the value
of the specific volume determined by the ideal-gas law departs significantly from the
actual volume. More accurate estimates can be obtained by using the Soave-Redlich-
Kwong (SRK) equation of state [1]:
RT a
P~u ~ ~ (1.34)
v b v ( v b)
Where the constants a, b and are fluid-dependent. Figure 1.13 shows the deviations
from the tabulated values by those obtained from the ideal-gas law and the SRK equation
of state for refrigerant R134a at 0.2 MPa.
7
6 Ideal-gas model
Error in specific volume (%)
SRK model
5
4
3
2
1
0
250 300 350 400
Temperature K
Figure 1.13. Errors in the specific volume of R134a by the ideal-gas law
and the SRK equation of state
The figure shows that the error of the ideal-gas law is more that 2% even at high
temperatures and increases as the temperature approaches the saturation value, but the
accuracy of the SRK equation remained higher than 99% even close to the saturation line.
~
However, since the SRK equation is implicit in v , it cannot be used directly to determine
the specific volume, but has to be solved iteratively. A number of standard iterative
procedures (e.g. Newton-Raphson method) can be used to solve the equation, but they
are not convenient for hand calculations.
Computer-Aided Thermofluid Analyses Using Excel 28
There are many similar situations in thermofluid analyses where a nonlinear equation like
the SRK equation gives advantage to computer-aided numerical methods by enabling
more realistic and accurate estimations. Another important implicit equation for
thermofluid analyses is the Colebrook-White equation (usually referred to as the
Colebrook equation) that determines the friction factor (f) in turbulent pipe flows:
1 / D 2.51
2.0 log 10 (1.35)
f 3.7 Re f
Where Re is the Reynolds number, D is the pipe’s diameter, and ε is the roughness of the
pipe material. Since the equation involves the friction factor f on both sides, it needs to
be solved iteratively. This is why traditional methods prefer to use explicit relationships,
such as the Swamee-Jain formula given by Equation (1.25), even though the Colebrook
equation is more accurate.
Optimisation analyses are needed for determining the best design for a thermofluid
system such as the optimum intermediate pressure for an air-compression system, the
optimum steam-extraction pressure for a regenerative Rankine cycle, and the best
thickness of insulation for a pipe. While simple optimisation analyses that involve a
single design parameter can be performed by means of calculus techniques and graphic
tools, optimisation analyses of complex systems that involve multiple variables require
the use of computer-aided techniques.
Computer-Aided Thermofluid Analyses Using Excel 29
Q2
QA
A
QB
B
Q3
Q4
Another type of thermofluid analyses for which computer-aided numerical methods are
necessary are the analyses of multi-dimensional fluid-flow and heat transfer in complex
geometries. This type of analyses involves coupled and nonlinear partial differential
equations that have to be solved by using computational fluid dynamics (CFD) methods
such as the finite-volume method or the finite-difference method. Many commercial CFD
applications are available nowadays that offer great flexibility and user-friendliness.
Basic for Applications (VBA) that can also be used for developing customised user-
defined functions (UDFs) needed for engineering analyses when such functions are not
provided by Excel. The Developer ribbon also allows the use of macros to remove the
tedium of parametric studies and repetitive calculations.
The main limitation of Excel as modelling platform for thermofluid analyses is the lack
of built-in functions for fluid properties. This problem could be solved by developing
add-ins for this purpose. In this respect, the Mechanical Engineering Department at the
University of Alabama developed a set of add-ins for various thermofluid analyses [13-
15]. Their Thermotable add-in for fluid properties deals with ideal gases, water and
superheated steam, and four refrigerants R134a, R22, R410A, and R407C. They also
developed other add-ins for psychrometric and compressible flow analyses. Goodwin
[16] developed an educational Excel add-in, called TPX (Thermodynamic Properties for
Excel), that determines the thermodynamic properties of selected gases (H2O, H2, O2, N2,
and CH4) and refrigerant R-134a. A number of property add-ins have also been developed
for research applications [17-19]. For industrial applications, the American National
Institute of Standards and Technology (NIST) developed the REFPROP add-in that
provides thermophysical properties of various refrigerants and their mixtures [20]. An
open-source alternative to REFPROP, called CoolProp, was developed by Bell [21] at
the University of Liege, Belgium. A commercial alternative to REFPROP is provided by
Optimized Thermal Systems called XProps [22].
The Excel-based modelling platform used in this book requires, in addition to Excel and
Solver, an educational Excel add-in called Thermax. Thermax provides property
functions for 12 ideal gases (air, N2, O2, H2, CO, CO2, H2O, NO, NO2, S2, SO2, and SO3),
saturated water and superheated steam, 6 refrigerants (R134a, R22, R410A, R717, R718,
and R744), humid air for psychrometric analyses, and air at standard atmospheric
pressure. Thermax also provides two interpolation functions and a Newton-Raphson
solver for nonlinear equations that further enhance the usefulness of the modelling
platform for thermofluid analyses. The nonlinear equations and any additional functions
required by the analyses are developed by using VBA. Table 1.1 summarises the roles of
the four components of the Excel-based modelling platform as used in this book.
1.3. Closure
The following chapters of the book describe the four components of the Excel-based
modelling platform in more details and show how the platform can be used to perform
various types of computer-aided thermofluid analyses. Exercises are given at the end of
each chapter to train the students for using the different components of the modelling
platform in relevant thermofluid analyses. Chapter 2 describes the features and built-in
functions of Excel which are mostly needed for thermofluid analyses and illustrates the
use of Excel’s matrix functions and its two built-in iterative tools; Goal Seek and circular
calculations. Chapter 3 introduces the Solver add-in and shows how its three solution
methods can be used for solving different types of computer-based problems. The chapter
also shows how VBA can be used for developing user-defined functions. Chapter 4
Computer-Aided Thermofluid Analyses Using Excel 31
describes the Thermax add-in that provides user-defined functions for thermofluid
analyses and shows how these functions can be used in Excel’s formulae.
Table 1.1. Roles of the four components of the Excel-based modelling platform
Component Role
Provides the basic functions needed for thermofluid analyses
including general mathematical functions, matrix-operation
Excel (built- functions, and logical-operation functions.
in functions Provides the Goal Seek command for performing unconstrained
and user- iterative solutions involving a single parameter
interface) Allows circular calculations that can be used to solve systems of
linear or non-linear equations iteratively
Provides graphical tools for data charting and trendlining
Allows constrained iterative solutions involving multiple
parameters
Solver
Allows constrained optimisation analyses
Offers three search options that suit different types of problems
Provides the physical properties of ideal gases, water and
superheated steam, six refrigerants (R134a, R22, R410A, R717,
R718, and R744), humid air for psychrometric analyses, and air at
Thermax
atmospheric pressure
add-in
Provides a Newton-Raphson solver for non-linear equations such
as the Colebrook equation and the SRK equation
Provides two interpolation functions for tabulated data
Can be used to develop additional fluid property functions if
needed
Can be used to develop user-defined functions for dealing with
VBA
non-linear equations and large systems of linear equations
involved in iterative solutions or optimisation analyses
Can be used to develop macros for repetitive calculations
Chapters 5 and 6 show how the Excel-based modelling platform can be used to perform
basic types of computer-aided thermofluid analyses. Chapter 5 deals with iterative
solutions and shows how Excel’s Goal Seek command and Solver can be used to solve
problems that require such solutions in the fields of fluid dynamics, heat-transfer, and
thermo-dynamics. Chapter 6 focuses on optimisation analyses of thermofluid systems
and shows how Solver can be used to deal with those involving a single design parameter,
such as the optimum thickness of insulation for a pipe, and those involving multiple
design variables. This chapter also demonstrates the use of the Evolutionary method
instead of the GRG Nonlinear method in optimisation analyses.
References
[1] Y.A. Cengel, and M.A. Boles, Thermodynamics an Engineering Approach,
McGraw-Hill, 7th Edition, 2007
[2] C. T. Crowe, D. F. Elger, B. C. Wiliams, and J. A. Roberson, Engineering Fluid
Mechanics, 9th edition, John Wiley & Sons, Inc., 2009.
[3] L.C. Burmeister, Elements of Thermal-Fluid System Design, Prentice Hall, 1998.
[4] Y.A. Cengel and A.J. Ghajar, Heat and Mass Transfer: Fundamentals and
Applications. 4th edition, McGraw Hill, 2011.
[5] J. P. Holman, Heat Transfer, 10th edition, McGraw-Hill. 2010.
[6] W.W. Pulkrabek, Engineering Fundamentals of the Internal Combustion Engine,
2nd Edition, Pearson Education International, 2004.
[7] C.R. Ferguson, Internal Combustion Engines, John Wiley & Sons, 1986.
[8] A. Rivas, T. Gómez-Acebo, and J. C. Ramos. The application of spreadsheets to
the analysis and optimization of systems and processes in the teaching of hydraulic
and thermal engineering, Computer Applications in Engineering Education, Vol.
14, Issue 4, 2006, pp. 256-268.
[9] D. Brkic, Spreadsheet-Based Pipe Networks Analysis for Teaching and Learning
Purpose, Spreadsheets in Education (eJSiE): Vol. 9: Iss. 2, Article 4, 2016.
Available at: http://epublications.bond.edu.au/ejsie/vol9/iss2/4
[10] A. Karimi, Using Excel for the thermodynamic analyses of air-standard cycles and
combustion processes, ASME 2009 Lake Buena Vista, Florida, USA.
[11] Z. Ahmadi-Brooghani, Using Spreadsheets as a Computational Tool in Teaching
Mechanical Engineering, Proceedings of the 10th WSEAS International Conference
on computers, Vouliagmeni, Athens, Greece, July 1315, 2006, 305-310
[12] S.A. Oke, Spreadsheet Applications in Engineering Education: A Review, Int. J.
Engng Ed. Vol. 20, 2004, No. 6, 893-901
[13] The University of Alabama, Mechanical Engineering, Excel for Mechanical
Engineering project, Internet: http://www.me.ua.edu/excelinme/index.htm (Last
accessed July 11, 2019).
[14] J. Huguet, K. Woodbury, R. Taylor, Development of Excel add-in modules for use
in thermodynamics curriculum: steam and ideal gas properties, American Society
for Engineering Education, 2008, AC 2008-1751.
Computer-Aided Thermofluid Analyses Using Excel 33
Excel
Computer-Aided Thermofluid Analyses Using Excel 36
Excel is the backbone of the modelling platform used in this book for thermofluid
analyses. As a general-purpose application, Excel is equipped with numerous features
and functions that can be utilised by various users for the presentation and analysis of
their data. This chapter focuses on its features that are mostly needed in this book for
building a modelling platform for thermofluid analyses. These include Excel’s user-
interface, its formulae and built-in functions, and its graphical tools and trendline feature.
The chapter highlights the use of cell-labelling instead of the commonly-used referencing
by location and illustrates the use of Excel’s matrix functions for the solution of linear
systems of equations and the use of Goal Seek and circular calculations for the solution
of nonlinear equations. Finally, the section on Excel’s graphical tools demonstrates the
use of the trendline feature for data curve-fitting.
2
3
To allow easy access to the large number of functions tools and commands provided by
Excel, its interface is divided into a number of elements with different purposes. Figure
2.1 shows four of these elements which are:
1. The ribbon
2. The name box
3. The formula bar
4. The workspace
Computer-Aided Thermofluid Analyses Using Excel 37
The Ribbon, which occupies the top part of the sheet, organises the numerous commands
provided by Excel into nine “tabs” including the File, Home, and Insert tabs. Each tab
consists of a number of command-groups that have a common purpose. For example, the
File tab consists of four groups of commands called Clipboard, Font, Alignment, and
Number. The Workspace, which is the main part of the sheet, is divided into a grid of
columns and rows so that the intersections of the rows with columns form separate
“cells”. A cell is referred to by a letter that represents its column followed by a number
that represents its row, e.g. A1, B3, H2, etc. As the figure shows, a cell can contain a
character data, such as “Saeed” and “Salim”, or a numerical data, such as 62.5 and 70. A
cell can also contain a formula for data manipulation using the numerous built-in
functions provided by Excel. The formula in cell H2 calculates the average mark for the
first student in the list; “Saeed”. While the Name box shows the location of the current
cell, the Formula bar shows the formula typed in the cell. The role of the Formula bar
will be explained in more details in the following section.
Formula bar
Now, go to cell A2 and type the formula ”=PI()*A1^2/4”. The function “PI()” is a built-
in function that returns the value of Archimedes’ constant π. The formula also contains a
reference to cell A1 that stores the value of the circle’s radius, the multiplication operator
*, the division operator /, the power operator ^, and the constants 2 and 4. Note that the
formula is shown in the formula bar which can be used to edit the formula. Pressing the
Enter key after typing the formula, the result shown in Figure 2.3 is obtained in cell A2;
which is 19.63495 square meters.
Computer-Aided Thermofluid Analyses Using Excel 38
Figure 2.3. The completed Excel sheet with formula that determines the area of a circle
The following example shows how Excel’s formulae and built-in functions can be used
in a typical thermofluid analysis.
Example 2.1. Determining the error of the ideal-gas law for refrigerant R134a
Develop an Excel sheet that calculates the specific volume (v) of refrigerant R134a from
the ideal-gas law at a pressure of 200 kPa (Tsat = -10.09oC) and temperatures in the range
0oC to 100oC (273 to 373 K). Compare your results with the tabulated data.
Solution
Figure 2.4 shows the Excel sheet prepared for this example. The pressure (P), the gas
constant (R), and the temperature (T) are stored in columns A, B, and C, respectively.
Column D stores the values of v obtained from property tables and column E stores the
corresponding values obtained from the ideal-gas law:
v RT / P (2.1)
where, P and T are the absolute pressure and temperature, respectively, and R is the gas
constant (for R134a R = 0.08149 kJ/kg.K). The percentage error of the ideal-gas law in
estimating the specific volume is given by:
v Ideal vTable
Error 100 (2.2)
vTable
To determine the percentage error at 273K, go to cell F2 and type the following formula
which is equivalent to Equation (2.2):
=(E2 – D2)/D2*100
When you press the Enter key, the number 6.566 will appear in cell F2 as shown in
Figure 2.4.
Computer-Aided Thermofluid Analyses Using Excel 39
Figure 2.4.The sheet developed for determining error in the ideal-gas law for R134a
Note that the formula shown in the formula bar represents Equation (2.2) when the
temperature is 273K. To find the percentage errors at other temperatures, you can simply
copy the formula in cell F2 and paste it on cells F3 to F12. Values of the calculated errors
show that the maximum error occurs at the lowest temperature, which is 273K. The error
decreases gradually as the temperature increases.
For the purpose of illustration, suppose that we want to compare the density of air before
and after an isentropic compression process from an initial condition of P1 = 100 kPa, T1
=300K to a final pressure of P2 = 800 kPA. The two densities can be calculated from the
ideal-gas law as follows:
1 P1 / RT1 (2.3)
2 P2 / RT2 (2.4)
Computer-Aided Thermofluid Analyses Using Excel 40
Where k is the ratio of specific heat at constant pressure (cp) and at constant volume (cv).
For air, k can be taken as 1.4.
Figure 2.5 shows the sheet prepared for this case. Note that respective labels are typed in
the column to the left of the different pressures and temperatures, while the corresponding
units are written in the column to the right of each quantity. This is also done to the other
quantities in the calculations.
Figure 2.5. Excel sheet for calculating the air densities before and after compression
Placing the cursor on cell F4 makes the formula bar reveal the formula used in the
calculation of the temperature T2, which is:
=B4*B7^((B8-1)/B8)
The above formula can be made more understandable by using meaningful labels to refer
to the different cells involved. To do that, select the cells in columns A and B as shown
in Figure 2.6, then go to Formulas and, at the Name Manager, select Create from
Selection. When the form shown in Figure 2.6 appears to you, tick the “Left column”
option. Pressing the “OK” button will make Excel create names for the different values
in the selection box according to the labels written on the left column. The cell F3 that
stores the value of P_2 can also be associated with its corresponding label in cell E3.
Now, type the formula in cell F4 that determines T_2 as:
=T_1*P_r^((k_-1)/k_)
Computer-Aided Thermofluid Analyses Using Excel 41
The formula bar in the sheet shown in Figure 2.7 reveals the formula with the
corresponding labels instead of location references. Labelled formulae are easier to edit
than those using location referencing particularly when intricate formulas are involved.
There are a couple of rules that have to be observed when using cell labels. When naming
your cells, choose suitable representative names for the variables involved, e.g. P_1 and
T_1 for P1 and T1. Note that Excel does not accept “P1” or “T1” as labels since these can
be confused with usual cell references by locations. In this case, Excel automatically
changes the labels to “P1_” and “T1_”. Also note that if you copy a formula that uses the
usual referencing by location in another cell, you will get a different answer, but if you
copy a labelled formula and paste it in any other cell, you will get the same answer. To
reveal or hide all the formulae in the sheet, press the control key (ctrl) with the tilde key
(~). A more detailed discussion of Excel formulae can be found in Walkenbach [1] or the
numerous online help sources.
Computer-Aided Thermofluid Analyses Using Excel 42
The “Math & Trig” group includes the mathematical and trigonometric functions used
in different types of engineering analyses, including thermofluid analyses. Figure 2.10
shows some of the numerous functions in this group. Note that the dialog box gives a
brief explanation of each function. For example, the explanation given to the ABS
function is that it returns the absolute value of a number. The functions ACOS, ASIN,
and ATAN apply the familiar inverse trigonometric functions: cos-1, sin-1, and tan-1,
respectively. By scrolling down the list, you can find many other functions frequently
used in engineering calculations. The following sections focus on two types of functions
that deserve a special attention, which are (a) the logical functions and (b) the functions
for matrix operations.
=IF(logical_test,[value_if_true],value_if_false])
Computer-Aided Thermofluid Analyses Using Excel 44
Note the quotation marks around “Laminar” and “Turbulent or transitional”. However,
the above formula does not tell us whether the flow is turbulent or transitional. The
required general formula can be written by using the following nested IF function:
Figure 2.11 shows an Excel sheet containing the above formula (shown in the formula
bar) and the response of the formula when Re = 500, which is “Laminar”. Excel supports
six other logical functions; AND, FALSE, IFERROR, NOT, OR and TRUE that can be
combined in the same formula so as to handle more intricate choices.
Figure 2.11. A formula using the nested IF function to determine the type of flow
1. After keying in the data of matrix [A] and vector {b} as shown in Figure 2.12,
position the cursor at cell H3 and type the formula: =MMULT(B3:D5;F3:F5).
2. Now press ENTER key and cell H3 will take the value 14, which the result of
multiplying the first row of the matrix with the vector {b} (Figure 2.13).
The other two elements of the result vector will not appear automatically. To view the
complete results vector, do as follows:
1 0 3
[A] = 0 5 6
7 0 5
Solution
The first step is to enter the elements of the matrix as shown in Figure 2.16. After entering
the data, go to cell F2 and type the formula “=MINVERSE(B2:D4)”. When you press
ENTER, this cell will have the value -0.3125, which is the first element of [A]-1 shown
in Figure 2.17. Starting with the formula in cell F2, select the range F2 to H4 as shown
in the figure. Press and release the function key F2 and then simultaneously hold the
CTRL+SHIFT keys and press ENTER. Other elements of the inverse matrix [A]-1 will
then appear as shown in Figure 2.18. You can check the answer by finding the product
of matrix [A] with its inverse by using the MMULT functions. The procedure is
illustrated by Figures 2.19 to 2.21. As should be expected, Figure 2.21 shows that the
resultant matrix is the identity matrix.
Where [A] is the coefficient matrix, {x} the vector of unknowns, and {y} the right-side
or “load” vector.
Computer-Aided Thermofluid Analyses Using Excel 48
Where [A]-1 is the inverse of matrix [A]. The following example illustrates the procedure.
14 14 9 3 5 x1 15
14 52 15 2 32 x 100
2
9 15 36 5 16 x 3 = 106
x 329
3 2 5 47 49
4
5 32 16 49 79 x 5
463
(2.8)
Solution
Note that the system is symmetric; which is typically the case with linear systems that
arise in the solution of heat-conduction problems by the finite-difference method. For
large systems of equations, symmetry of the system can be utilised for reducing the
required computer memory by storing only one half of the coefficient matrix. However,
for small systems, such as the one considered here, it is more convenient to use the matrix
inversion method using Excel functions. Figure 2.22 shows the Excel sheet that stores
both the coefficient matrix [A] and the load vector {y}. The inverse of the coefficient
matrix [A]-1 was obtained by following the procedure described above and stored below
the coefficient matrix as shown in the figure. The inverse matrix [A] -1 is then multiplied
by the load vector {y} and the result stored below the load vector as shown in Figure
2.23. The complete solution is shown in Figure 2.24. The first element is practically zero
and, therefore, the answer is{x} = (0, 1, 2, 3, 4).
Computer-Aided Thermofluid Analyses Using Excel 49
Figure 2.22.The coefficient matrix [A], the load vector {y}, and the inverse matrix [A]-1
Figure 2.23. Multiplying the inverse matrix [A]-1 with the load vector {y}
y = x2 – 2x +1 -1.0 ≤ x ≤ 3 (2.9)
Solution
Using the conventional analytical method, the two values can be found by substituting y
in Equation (2.9) by 1.5. This leads to the following quadratic equation:
x 2 2 x 0.5 0
The two roots of this equation using the standard solution method are:
2 22 4 1 0.5 2 6
x
2 1 2
Or:
x1 = ̶ 0.22474
x2 = 2.2247.
We will now solve the problem by using the Goal Seek command. Figure 2.25 shows the
Excel sheet prepared for this purpose in which y is plotted at various values of x. The
figure shows that the two values of x that yield y = 1.5 are approximately -0.2 and 2.2.
Computer-Aided Thermofluid Analyses Using Excel 51
Figure 2.25. Excel sheet for finding the roots of a nonlinear equation
To solve the problem by using Goal Seek, enter an initial guess for x in cell B2, say 0,
and then enter the following formula that calculates y in cell B3:
= B2^2 – 2*B2 +1
Note that the formula bar reveals the above formula when the cursor is placed at cell B3.
To activate the Goal Seek command, go to the Data tab, select the What-If-Analysis
option in the Data Tools group and then select Goal Seek, as shown in Figure 2.26. The
Goal Seek dialog form shown in Figure 2.27 will ask you to select the “Set cell”, i.e. the
cell that contains the dependent variable, which is B3 in this case.
Figure 2.27. Goal Seek Set-up for finding the root of a nonlinear equation
Computer-Aided Thermofluid Analyses Using Excel 52
You also have to specify the value sought for this cell and then select the adjustable cell
that stores the value of the parameter to be changed. In this case, we seek the value in the
Set Cell B3 to be 1.5 by changing the value of cell B2. Providing this information to Goal
Seek and then pressing the “OK” button, will trigger the tool to iterate by changing the
value in the adjustable cell (B2) until the Set cell (B3) acquires the required value. As
shown in Figure 2.28, the answer obtained by Goal Seek is x = -0.22474 which agrees
with the first root obtained analytically.
Goal Seek determined the first solution and not the second one because it starts the
iterative process with the initially specified value in the changeable cell, which is x = 0.0,
and gives the solution that is closer to it. To determine the second solution, we have to
start with a suitable initial guess. Figure 2.29 shows the same Excel sheet with the initial
value of x changed to 1.0 and the set-up for Goal Seek before the solution. Figure 2.30
shows the new solution found by Goal Seek, which is x = 2.2249.
Note that the second Goal Seek solution deviates slightly from the analytical solution of
x=2.2247. The precision of Goal Seek solution can be improved by adjusting Excel’s
default parameters for iterative solutions. This can be done by selecting Options from
the File tab and then selecting Formulas. You can now increase the allowable maximum
number of iterations from the default value of 100 and reduce the maximum change from
the default value of 0.001.
Computer-Aided Thermofluid Analyses Using Excel 53
Solution
From the defenition of specific heat, the final temperature (T2) is given by:
T2 T1 Q / c~p / M (2.11)
Where T1 is the initial temperature, Q is the amount of heat added, and M is the molar
mass for air, taken as 29. If we ignored the variation of c~p with temperature and
determined the final temperature based on its value at T1 only, the answer would be
T2=399.73K. However, we can be more accurate by determining c~p from Equation (2.10)
by using the average temperature, Tavr = (T1+T2)/2. Figure 2.31 shows the Excel sheet
developed for this method which reveals the formulae inserted in cells F2, F4, and F6.
As soon as we type Equation (2.11) in cell F6, Excel makes the warning message that
there is a circulare refernce as shown in Figure 2.32. The circular reference occurs
because T2 depends on c~p according to Equation (2.11) while c~p itself depends on T2
Computer-Aided Thermofluid Analyses Using Excel 54
according to Equation (2.10). If we press the “OK” button shown in Figure 2.32, the cells
involved in the circular reference whill be identified as shown in Figure 2.33. In this case,
three cells are involved in the circular reference, which are F2, F4, and F6.
Excel can solve this problem and determine the values of both T2 and c~p that satisfy the
relevant equations if allowed to iterate. To allow this option, go to File and select
Options. The Backstage View form shown in Figure 2.34 will appear to you. Select
Formulas, then the form will appear as shown in Figure 2.35. Enable iterative
calculations by ticking the box indicated in the figure √ and press the “OK” button.
Excel can now find the correct values of T2 and cp by iteration. Figure 2.36 shows the
solution found by Excel, which is T2 =398.976K.
Computer-Aided Thermofluid Analyses Using Excel 55
Although most thermofluid analyses that require iterative solutions can be solved more
easily with Goal Seek or the Solver add-in than with circular calculations, the subtle
nature of this feature can be useful in certain situations. This is demonstrated in Chapter
11 that applies the finite-difference method for solving the heat-conduction equation.
Computer-Aided Thermofluid Analyses Using Excel 56
45 60
40
50
Temperature (oC)
35
30 40
Humidity (%)
25
30
20
15 20
10 temperature 10
5 Humidity
0 0
Feb
Aug
Sep
Nov
Dec
Jan
Mar
Apr
May
Jul
Oct
Jun
Month
Excel supports other types of charts that allow the user to select the most appropriate way
to display his/her data in the form of bar, area, or scatter charts. For more information
about the different types of Excel’s charts, the reader can refer to specialised references
such as Walkenbach [2]. A number of tutorials and videos that show how to create
different types of charts can also be found in the internet.
Excel’s graphical tools provide a curve-fitting capability of numerical data by using the
Trendline feature. This particular capability is useful for computer-aided thermofluid
analyses because it can be used to convert tabulated data into analytical equations that
suit computer-based methods better. The trendline feature provides a number of options,
which include exponential, linear, logarithmic, polynomial, and power equations as
shown in Figure 2.38. For example, Table 2.1 shows properties of saturated water in the
range 0.001oC – 60oC. Values of the saturation pressure (Psat) and saturated liquid
enthalpy (hf) are used in psychrometric analyses of air-conditioning applications, but for
computer-based analyses it is useful to convert these data into equations. First, we have
to create line charts for the two properties as shown in Figure 2.39.
Computer-Aided Thermofluid Analyses Using Excel 57
Table 2.1. Properties of saturated water at temperatures in the range 0oC- 60oC taken
from Cengel and Boles [3]
To C Psat vf vg uf ug hf hg sf sg
[kPa] [m3/kg] [m3/kg] [kJ/kg] [kJ/kg] [kJ/kg] [kJ/kg] [kJ/kg.K] [kJ/kg.K]
0.01 0.6117 0.001000 206.00 0.000 2374.9 0.001 2500.9 0.0000 9.1556
5 0.8725 0.001000 147.03 21.019 2381.8 21.020 2510.1 0.0763 9.0249
10 1.2281 0.001000 106.32 42.020 2388.7 42.022 2519.2 0.1511 8.8999
15 1.7057 0.001001 77.885 62.980 2395.5 62.982 2528.3 0.2245 8.7803
20 2.3392 0.001002 57.762 83.913 2402.3 83.915 2537.4 0.2965 8.6661
25 3.1698 0.001003 43.340 104.83 2409.1 104.83 2546.5 0.3672 8.5567
30 4.2469 0.001004 32.879 125.73 2415.9 125.74 2555.6 0.4368 8.4520
35 5.6291 0.001006 25.205 146.63 2422.7 146.64 2564.6 0.5051 8.3517
40 7.3851 0.001008 19.515 167.53 2429.4 167.53 2573.5 0.5724 8.2556
45 9.5953 0.001010 15.251 188.43 2436.1 188.44 2582.4 0.6386 8.1633
50 12.352 0.001012 12.026 209.33 2442.7 209.34 2591.3 0.7038 8.0748
55 15.763 0.001015 9.5639 230.24 2449.3 230.26 2600.1 0.7680 7.9898
60 19.947 0.001017 7.6670 251.16 2455.9 251.18 2608.8 0.8313 7.9082
Computer-Aided Thermofluid Analyses Using Excel 58
25 300
Saturation pressure (kPa)
y = 9E-05x3 - 0.0012x2 + 0.0788x
250
Enthalpy (kJ/kg)
20 + 0.5418
y = 4.184x + 0.146
200
15
150
10
100
5
50
0 0
0 25 50 75 0 25 50 75
Temperature (oC) Temperature (oC)
(a) (b)
Figure 2.39. Fitting trendlines on tabulated data for water of
(a) saturation pressure and (b) saturated liquid enthalpy
Trendlines can then be added on the line charts. Figures 2.39.a and 2.39.b also show the
corresponding trendline equations of the tabulated data as determined by using
polynomial equations. A linear equation is adequate for the hf data since its variation over
the given temperature range is mild (Figure 2.39.b), but a third-order polynomial is
required to represent the variation of Psat with temperature (Figure 2.39.a).
2.8. Closure
This chapter described the main features of Excel needed for thermofluid analyses. The
chapter highlighted the importance of using cell labelling with Excel’s formulae and
illustrated the use of Excel’s general mathematical functions and logical functions. The
chapter also showed how Excel’s functions for matrix operations can be used for solving
linear systems of equations and demonstrated the use of its iterative tools, Goal Seek and
circular calculations. In spite of its simplicity, the Goal Seek command is very useful for
computer-aided thermofluid analyses. As shown in later chapters of this book, it can be
used for solving problems that require iterative solutions such as type-2 and type-3 pipe
flow problems and flow analyses of multi-pipe arrangements and pipe-networks. Finally,
the chapter illustrated the usefulness of Excel’s charting tools for computer-based
thermofluid analyses particularly the trendline feature.
References
1. J. Walkenbach, Excel 2010 Formulas, Wiley Publishing Inc., 2010
Computer-Aided Thermofluid Analyses Using Excel 59
Exercises
1. The following table shows the measured values of the temperature by two different
methods compared to the correct values. Find the average error for each method.
2. Suppose that we have the data shown on the following table for the saturation
pressure of a certain fluid. Use a nested IF statement to develop an interpolation
formula that determines the saturation pressure for any temperature in the range 5oC
≤T ≤ 30oC.
70 1 0 a 636
60 1 1 b 518
40 0 1 c 307
Computer-Aided Thermofluid Analyses Using Excel 60
Solve the system of equations to determine the values of the three unknowns a, b,
and c. This exercise is based on Example 9.11 in Chapra and Canale [4]. The
answer is: a = 8.5941, b=34.4118, and c = 36.7647.
4. The following system of linear equations resulted from a finite-difference solution
of the heat transfer in the triangular fin shown in the following figure.
0 1 2 3 4 5
T4 - 1.008 T5 = -0.209
5. Adopting suitable names in your formulae, prepare an Excel sheet for calculating
the frictional loss (hf) in a circular pipe of diameter D, length L, and roughness ks.
Use your sheet to determine hf in the following cases:
Determine the values of the kinematic viscosity from relevant property tables and
take the transition of flow from laminar to turbulent to occur at Re = 4,000.
6. Using a line chart, plot the variation of sine θ for -180 ≤ θ ≤ 180 in steps of 10othen
add cosine θ on the same chart.
Computer-Aided Thermofluid Analyses Using Excel 61
7. Using the data shown in Table 2.1, make a line chart for vf and vg. Add polynomial
trendlines for both and comment on the trendlines equations.
8. The table below shows some of the thermo-physical properties of air at atmospheric
pressure and different temperatures. Use Excel charts to show the variation of the
properties ρ, β, cp, k, α, μ, ν, and Pr with temperature and use trendline to obtain
suitable equations for these properties.
103 c p 106
T k 106 Pr
(K) (kg/m3) (J/kg.K) (W/m.K) (m2/s)
(1/K) (N S/m2) (m2/s)
273 1.252 3.66 1011 0.0237 19.2 17.456 13.9 0.71
293 1.164 3.41 1012 0.0251 22.0 18.240 15.7 0.71
313 1.092 3.19 1014 0.0265 24.8 19.123 17.6 0.71
333 1.025 3.00 1017 0.0279 27.6 19.907 19.4 0.71
353 0.968 2.83 1019 0.0293 30.6 20.790 21.5 0.71
373 0.916 2.68 1022 0.0307 33.6 21.673 23.6 0.71
473 0.723 2.11 1035 0.0370 49.7 25.693 35.5 0.71
573 0.596 1.75 1047 0.0429 68.9 29.322 49.2 0.71
673 0.508 1.49 1059 0.0485 89.4 32.754 64.6 0.72
773 0.442 1.29 1076 0.0540 113.2 35.794 81.0 0.72
9. Using the Excel sheet developed for Example 2.4, check the accuracy of the solution
obtained by Goal Seek when the spreadsheet iteration parameters are adjusted such
that the maximum number of iterations is increased to 10,000 and the maximum
change is reduced to 0.00001.
10. Solve Example 2.5 by using the Goal Seek command instead of circular calculations.
11. The volume V of liquid in a spherical tank of radius r is related to the depth h of the
liquid by:
V = πh2(3r −h)/3
Using Excel and the Goal Seek command, determine h given r=1 m and V = 0.5 m3.
This exercise is based on Problem 8.9 in Chapra and Canale [4]. Answer: h = 0.431
m.
Computer-Aided Thermofluid Analyses Using Excel 62
Computer-Aided Thermofluid Analyses Using Excel 63
This chapter focuses on two auxiliary components of the Excel-based modelling platform
for thermofluid analyses, which are Solver and VBA. Developed by Frontline Systems
[1], Solver enables Excel to perform iterative solutions and optimisation analyses with
multiple adjustable cells. It offers three solution methods that suit different types of
problems including a deterministic gradient method, a linear-programming method, and
a stochastic evolutionary method. This chapter shows how Solver can be activated and
used for solving single nonlinear equations and systems of linear equations and
performing optimisation analyses. The Chapter describes the settings of Solver’s solution
options and illustrates the use of its GRG Nonlinear method and the Evolutionary method.
Finally, the chapter shows how VBA can be used for developing custom functions not
provided by Excel.
When you click the Solver button from the Data tab, Solver Parameters dialog box
shown in Figure 3.3 will appear to you. This dialog box helps you to specify the required
outcome of a formula in one cell called the objective cell by adjusting the values of a
group of cells, called decision variables or variable cells, which are directly or indirectly
related to the formula in the objective cell. As shown on the parameters dialog box, you
can specify constraints on the values of the decision variables. Compared to the Goal
Seek command, Solver offers the following advantages:
1. While Goal-Seek can only be used for simple problems that involve one decision
variable, Solver can deal with more difficult problems in which the objective cell
is affected by many decision variables.
Computer-Aided Thermofluid Analyses Using Excel 65
2. Goal Seek allows only a required value of the objective cell to be achieved, but
Solver also enables us to perform an optimisation analysis by finding the
maximum or minimum value for the formula in the objective cell.
3. With Solver, we can apply constraints on the solution, which is not possible with
Goal Seek. Constraints are needed for some optimisation analyses and iterative
solutions.
4. Solver is that it allows the user to select the appropriate solving method for his
or her problem from three options.
The version of Solver that comes with Excel 2010 and later editions offers the following
three search methods:
Both the GRG Nonlinear method and the Evolutionary method are used for non-linear
problems, while the Simplex LP method is suitable for linear problems. Solver uses the
GRG Nonlinear method by default. This section shows how the three solution methods
can be used to solve different types of problems.
Set Objective: Type B3, select Value of, and type 1.5 for this
option since want the value of the function in cell
B3 to be 1.5.
By Changing Variable Cells: Type B2, which is the cell that stores the value of the
independent variable x
Subject to the Constraints: Add two constraints that specify the minimum and
maximum values of x, e.g. x ≥ 0 and x ≤ 3
Select a Solving Method: Select the GRG Nonlinear option
Computer-Aided Thermofluid Analyses Using Excel 67
The upper part of the completed parameters dialog box will be as shown in Figure 3.4.
Note that the two constraints imposed on the solution correspond to x ≥ 0 and x ≤ 3. When
you press the Solve button in the dialog box, Solver will iterate to determine the value of
the only variable cell that yield the targeted objective within the limits specified by the
constraints. As Figure 3.5 shows, the solution determined by Solver is x = 2.22474, y =
1.5, which is the second analytical solution found in Example 2.4. To keep this solution,
press the “OK” button in the Solver Results dialog box. Now try to find the first solution
by modifying the two constraints to: x 1 and x 0.
Figure 3.4. The completed Solver dialog box for Example 2.4 with x ≥ 0
insulation requires its total cost to be minimised. The following example illustrates the
use of the GRG Nonlinear method in optimisation analyses.
Solution
Figure 3.6 shows the Excel sheet developed for this example that calculates the values of
f at different values of x. The line chart in Figure 3.6 shows the variation of f with x from
which we can see that the minimum value of f is -2 and occurs at x =1. Note the curser is
placed on cell B6 to reveal the formula fx = B3^2-2*B3−1. We will now use Solver to
determine the minimum value of the function. Figure 3.7 shows the completed Solver’s
parameters dialog box. Press the “Solve” button and Solver will iterate to find the solution
shown in Figure 3.8. As the figure shows, the answer found by Solver, which is x = 1, f
= -2, agrees with the graphical solution shown in Figure 3.6.
Figure 3.6. Excel sheet for determining the local minimum of the quadratic function
Figure 3.7. The completed Solver dialog box for Example 3.1
Computer-Aided Thermofluid Analyses Using Excel 69
Figure 3.9. Excel sheet for solving Example 2.3 with Solver
The top part of the sheet stores the coefficient matrix [A] and the right-hand vector {y}
of the system of linear equations to be solved. The procedure starts with a guessed
solution which is stored in a vector {x0} in cell F9:F13. All the elements of this vector
are given a value of 1 as shown in Figure 3.9. The coefficient matric [A] is then multiplied
with the guessed vector {x0} by using Excel’s ”MMULT” function and the result stored
in cells H9:H13. If this initial guess were correct, the multiplication [A]{x0} would be
the same as the true right-hand side vector, i.e,:
However, Figure 3.9 shows that the vector [A]{x0} is different form the true right-hand
side vector {y} stored in cells H2:H6. Solver can now be used to adjust the variable cells
D9:D13 so that all elements of the vector [A]{x0} become equal to their counterparts in
vector {y}, i.e:
H9 = H2
H10 = H3
H11 = H4
H12 = H5
H13 = H6
Solver set-up for this task is shown in Figure 3.10. Note that the objective cell is left
blank. In this case, Solver will iterate to find the values of the decision variables that
satisfy all the imposed constraints. Also note that the Simplex LP method is selected as
the solution option.
Figure 3.10. Solver set-up for Example 2.3 with the Simplex LP method
The solution found by Solver using the above set-up is shown in Figure 3.11. All the
elements of the [A]{x0} are now equal to their corresponding elements in the vector {y}.
The first element of the solution vector, which is -6.6x10-16, is practically zero. Therefore,
the solution is [0,1,2,3,4], which is the same as that obtained in Example 2.3 by using the
matrix inversion method. You can now try to use the other two solution methods of Solver
to solve this problem. Solver can also be used for solving systems of simultaneous
nonlinear equations (refer to Problem 3.7).
Computer-Aided Thermofluid Analyses Using Excel 71
f x x cos(x) 3 ≤ x ≤ 14 (3.3)
Solution
Figure 3.12 shows the Excel sheet developed for solving this example. The insert shows
that the function has two minima in the specified range of x; one at x ≈ 5 and another at
x ≈ 11. At the initially-specified value ox x = 3, the function has a value of 0.42336. Let
us first try to solve the problem with the GRG Nonlinear method. Figure 3.13 shows the
completed Solver parameters dialog-box with two constraints that specify the upper and
lower limits for x. From Figure 3.14 that shows the solution found by Solver by using the
GRG Nonlinear method it is clear that Solver found the local minimum which is nearer
to the initial guess and not the global minimum. In order to locate the global minimum
by the GRG Nonlinear method, the solution has to be started with an initial guess that is
nearer to the global minimum, e.g., x = 9. The advantage of the Evolutionary method is
that such an arrangement is not required. With this method we may choose to specify
bounds on variables (see Section 3.6). Since the set-up shown in Figure 3.13 already
specifies upper and lower bounds on x, we only need to change the solution method to
“Evolutionary”. Figure 3.15, which shows the solution obtained by this method, shows
that the method produced the global minmum.
Computer-Aided Thermofluid Analyses Using Excel 72
Figure 3.13. Solver set-up for Example 3.2 with GRG Nonlinear method
Figure 3.14. Solver solution for Example 3.2 with the GRG Nonlinear method
Computer-Aided Thermofluid Analyses Using Excel 73
Figure 3.15. Solver solution for Example 3.2 with the Evolutionary method
While the solution with the GRG Nonlinear method took less than a second that of the
Evolutionary method took one minute and 35 seconds on the same computer. As shown
in the following sections, the computer time of the Evolutionary method can be reduced
by adjusting the default options of the method. The method is particularly useful for
optimisation analyses that involve non-smooth and discontinuous functions, which are
difficult to solve with the GRG Nonlinear method. Section 3.6 compares the GRG
Nonlinear method and the Evolutionary method by considering an optimsation analyses
that is more relevant to thermofluid systems.
Figure 3.17. Default Solver options adopted in the analyses for all solution methods
Figures 3.18.a and 3.18.b show the default settings which are particular to the GRG
Nonlinear method and to the Evolutionary method, respectively. Figure 3.18.a shows that
the GRG Nonlinear method uses the forward difference (FD) approximation of
derivatives by default. This option is kept unchanged in all the analyses presented in this
book. A case is considered in the following section in which the GRG Nonlinear method
needed the automatic-scaling option in order to reach the solution.
Computer-Aided Thermofluid Analyses Using Excel 75
(a) (b)
Figure 3.18. The default Solver options specific to: (a) the GRG Nonlinear method and
(b) the Evolutionary method
Figure 3.18.b shows the default settings used by the Evolutionary method. According to
this set-up, the population size is 100, the maximum allowable time without improvement
is 50 seconds, and upper and lower bounds on variables are required. As shown in the
following section, the time required by the Evolutionary method can be reduced by
adjusting the population size or the maximum allowable time. Because of its long
computer time, only few cases in this book used the Evolutionary method.
D2
D1
(a) The cost of pumping the air through the duct (Cp) in $/year is given by:
C p 3 10 6 D15 (3.4)
(b) The cost of heating the air (Ch) in $/year is given by:
9
Ch (3.5)
(c) Due to space limitations, the outside diameter of the insulation D2 cannot exceed
12 cm.
3 10 6 9 3 10 6 9
CT = (3.6)
D15
D15 D2 D1
By imposing the requirement that the maximum diameter D2 should not exceed 0.12 m,
the total cost becomes;
Computer-Aided Thermofluid Analyses Using Excel 77
3 10 6 9
CT (3.7)
D15 0.12 D1
Differentiating Equation (3.7) with respect to D1 and equating the result to zero, Janna
[6] obtained the following solution for D1:
D1 1.67 10 6 0.12 D1
2 1/ 6
(3.8)
The solution Equation (3.8) would give the required value of D1, but it is nonlinear.
Therefore, it requires an iterative solution. By using an iterative method, Janna [6]
determined the optimum diameter as D1 = 0.045 m. Excel can easily perform the iterative
solution of Equation (3.8) with Goal Seek. However, Solver provides an alternative
method for solving the problem by minimising the basic function in Equation (3.6)
without any differentiation.
The diameter that minimises the total cost can be found by using Solver. Figure 3.21
shows Solver Parameters dialog box for finding the values of D1 (in the adjustable cell)
that minimises the total cost (in the target cell). Initial trials with the GRG Nonlinear
method showed that no solution can be obtained by using the default options shown in
Figures 3.17 and 3.18.a (i.e. without automatic scaling) without imposing a lower limit
on D1. Therefore, a lower limit of 1 cm was imposed on D1 as shown in Figure 3.21. The
solution obtained by Solver with this method and setup is shown in Figure 3.22. The
optimum value thus obtained for the inner diameter, which is D1 = 0.045763 m, agrees
well with the value obtained by Janna [6]. The GRG Nonlinear method can solve the
Computer-Aided Thermofluid Analyses Using Excel 78
problem without imposing a lower limit on D1, but by selecting the “Use Automatic
Scaling” option (see Problem 3.6).
Figure 3.21. Solver set-up for the insulated duct optimisation with the GRG Nonlinear
method
Figure 3.22. Optimised solution for Example 3.3 with the GRG Nonlinear method
same solution in less than a second. Chapter 6 gives more examples of using the GRG
Nonlinear method and the Evolutionary method for optimisation analyses of thermofluid
systems.
Figure 3.23. Solver set-up for the insulated duct optimisation with the Evolutionary
method
Figure 3.24. Optimised solution for Example 3.3 with the Evolutionary method
A D 2 / 4 (3.9)
Computer-Aided Thermofluid Analyses Using Excel 80
As shown in Figure 3.25, VBA is found on the left side of the Developer tab. This tab
gives many other development tools. If the Developer tab is not shown in the ribbon of
your Excel sheet, you can make it available by going to File, selecting Options, and then
the Customise Ribbon from the Backstage View shown in Figure 3.26.
In the Main Tabs list, select the Developer check box as shown in the figure, and then
click “OK”. The Developer tab will now be shown in the ribbon of your Excel sheet. To
start writing the UDF, go to Developer tab menu and select Visual Basic. The Visual
Basic editor will appear to you as shown in Figure 3.27. Select Insert → Module and
the blank page shown in Figure 3.28 will be open for you to type the VBA code.
The following VBA code is the required the UDF that determines the circle’s area from
its diameter according to Equation (3.9):
Computer-Aided Thermofluid Analyses Using Excel 82
Function Circ_area(Dia)
Pi = 3.141593
Circ_area = Pi * Dia ^2 / 4
End Function
Note that the first line in the code starts with the word “Function” and then adds a name
for the function and specifies the required input parameters. The name you give to your
new function will be used to call it from Excel UI. Therefore, this name should clearly
indicate the purpose of its use. In the present case, the name given to the function is
“Circ_area” to indicate that it calculates the area of a circle. The function has only one
input parameter, which is the circle’s diameter (Dia). As soon as you type the first line of
the code and press the “Enter” key, the editor will automatically add the End line of the
function. Now, type the rest of the code as shown in Figure 3.29.
Figure 3.29. A UDF for caclcuating the area of a circle with a given diameter
After typing the code correctly, the function can be used via Excel UI just like any built-
in function as shown in Figure 3.30. Note that the formula bar in Figure 3.30 reveals the
formula in cell B2 as:
= Circ_area(10)
Where the number 10 refers to the diameter of the circle. You can now check the output
of your user-defined function, which is 314.1593 square units, by calculating the circle’s
area with a normal Excel formula. Finally, note that VBA does not provide a built-in
function for the constant Pi (π) and, therefore, you have to assign a value for it as shown
in Figure 3.29. Alternatively, you can use the one provided by Excel.
Computer-Aided Thermofluid Analyses Using Excel 83
In thermofluid analyses, VBA is useful for developing UDFs for fluid properties. For
example, the molar specific-heat at constant pressure ( c~p ) for an ideal gas is given by
the following formula [7]:
Where T is the absolute temperature and a0, a1, a2, and a3 are constants that have different
values for different gases. For air, the constants are 28.11, 0.1967x10-2, 0.4802 x10-5, and
-1.966 x10-9 in this order. Figure 3.31 shows the VBA code for the UDF “cp_air” that
determines c~p for air based on Equation (3.10) and the formula bar in Figure 3.32 shows
how the function can be used in an Excel formula to determine c~ for air at 300K. The
p
Figure 3.31. A UDF for caclcuating the molar specific-heat for air
Computer-Aided Thermofluid Analyses Using Excel 84
3.8. Closure
This chapter introduced the Solver add-in that enables Excel to perform constrained
iterative solutions and optimisation analyses involving multiple parameters. The chapter
briefly described the three solution methods provided by solver, which are the GRG
Nonlinear method, the Evolutionary method, and the Simplex LP method, and showed
how these methods can be used for solving nonlinear equations and systems of linear
equation and performing optimisation analyses. The use of Solver for optimisation
analyses of thermofluid systems is demonstrated by considering the case of insulating a
duct that carries hot air for air-conditioning. This analysis showsed that the default set-
up of Solver may have to be adjusted to allow automatic-scalling in order to perform the
analysis by the GRG Nonlinear method or to reduce the population size in the
Evolutionary method in order to reduce the computer time. Solver can also deal with
multi-variable optimisation analyses as shown in later chapters of the book.
The chapter also showed how VBA can be used for developing user-defined functions
not provided by Excel. In thermofluid analyses, this is needed for the development of
custom functions for fluid properties. As an example, a custom function was developed
for determining the specific heat of air from the ideal-gas law. Another situation that
requires the development of user-defined functions with VBA is faced when the
analytical model involves complex equations, implicit nonlinear equations, or a
complicated logical branching. In such cases, Excel formulae which are confined to
separate cells become too restrictive and inconvenient to use. VBA can then be used to
develop a suitable user-defined function that performs the complicated calculations and
passes the outcome to Excel. More information about the VBA language can be found in
specialised references [8-10].
References
1. Frontline Systems, internet: http://www.Solver.com/ (Last accessed November 23,
2015).
2. L.S. Lasdon, R.L. Fox, M.W. Ratner, Nonlinear optimization using the generalized
reduced gradient method, Revue Française d'Automatique, Informatique et
Recherche Opérationnelle, tome 8, V3 (1974), p. 73-103. Available at:
http://www.numdam.org/article/RO_1974__8_3_ 73_0.pdf
Computer-Aided Thermofluid Analyses Using Excel 85
3. https://en.wikipedia.org/wiki/Evolutionary_algorithm
4. Wikkipedia, https://en.wikipedia.org/wiki/Gradient_method
5. Wikkipedia, https://en.wikipedia.org/wiki/Evolutionary_algorithm
6. W.S. Janna, Design of Fluid Thermal Systems, 3rd Edition, CENGAGE Learning,
2011.
7. Y. A. Cengel and M. A. Boles. Thermodynamics an Engineering Approach,
McGraw-Hill, 7th Edition, 2007
8. J. Walkenbach, Excel 2013 Power Programming with VBA, Wiley Publishing, Inc.
2013.
9. J. L. Latham, Programming in Microsoft Excel VBA, An Introduction, 2008.
Internet: http://ies.fsv.cuni.cz/default/file/download/id/21101 (Last accessed
November 29, 2015).
10. http://www.fontstuff.com/vba/vbatut01.htm (Last accessed November 26, 2017).
11. S.C. Chapra and R.P. Canale, Numerical Methods for Engineers, 6th Edition,
McGraw Hill, 2010.
Exercises
1. Draw a line chart with Excel to show the variation of the following function in the
range -5 ≤ x ≤5:
Use Solver with proper bounds to determine the roots of this equation. This exercise
is based on Example 6.2 in Chapra and Canale [11].
2. A system of algebraic equations can be expressed in matrix form as follows:
70 1 0 a 636
60 1 1 b 518
40 0 1 c 307
Solve the system of equations by using Solver to determine the values of the three
unknowns a, b, and c. Based on Example 9.11 in Chapra and Canale [11]. The answer
is: a = 8.5941, b=34.4118, and c = 36.7647.
3. Draw a line chart with Excel to show the variation of the following function in the
range 0 ≤ x ≤4:
Use Solver to find the maximum of the function in the same range. Based on Example
13.1 in Chapra and Canale [11]. The answer is: f(x) = 1.7757 at x =1.4276.
Computer-Aided Thermofluid Analyses Using Excel 86
f e sin2
0
0 100 200 300 400
Function
-5
-10
-15
Angle
Figure P1.4. A composite function
5. Using the Excel sheet developed to solve Example 2.4 by the GRG Nonlinear method,
study the effect of using central-difference approximation of derivatives instead of the
default forward-difference approximation on the solution.
6. Using the Excel sheet developed for the solution of Example 3.3 with the GRG
Nonlinear method, show that the same solution shown in Figure 3.22 can be obtained
without imposing a lower limit on D1 by using automatic scaling.
7. Consider the following set of simultaneous nonlinear equations:
x2 + xy = 10 (A)
y +3xy2 = 57 (B)
Create two cells (B1and B2) to hold initial guesses for x and y. Enter the function
values themselves, u(x, y) and v(x, y) into two other cells (B3 and B4). The initial
Computer-Aided Thermofluid Analyses Using Excel 87
guesses may result in function values of u and v that are far from zero. Determine the
sum of the function squares, i.e. u2 + v2, and store it in cell B5. Use Solver to find the
values of x and y in cells B1 and B2 (the Changing cells) that make the value in cell
B5 (the objective cell) equal to zero. Using this procedure, find the roots of the above
system starting with initial guesses of x =1 and y = 3.5. Based on Example 6.5 in
Chapra and Canale [11]. The correct pair of roots is x=2 and y=3.
8. The pipe shown in Figure 3.19 has an external diameter D1 = 4.6 cm. The pipe is
surrounded by an insulation material with outside diameter D2. The cost of pumping
the fluid through the pipe (Cp) and the cost of heating the fluid (Ch) are given by
Equations (3.5) and (3.6) in Examples 3.3, respectively. The total cost (CT) includes
the cost of the insulation itself, which is given by:
C s 500
Use Solver with the GRG Nonlinear method to determine the optimum thickness of
insulation.
9. Solve Problem 3.8 with the Evolutionary method using lower and upper bounds for
D2 of 5 cm and 30 cm respectively.
10. The volume V of liquid in a spherical tank of radius r is related to the depth h of the
liquid by:
V = πh2(3r −h)/3
Using VBA, develop a user-defined function that determines h at any given values
of r [m] and V [m3]. Check your function at r=1 m and V = 0.5 m3. Answer: h =
0.431 m.Develop user-defined functions with VBA for determining the specific
enthalpy and entropy of superheated steam from its pressure and temperature.
11. Using tabulated data for refrigerant R134a, develop user-defined functions with
VBA for determining properties, e.g., enthalpy and entropy, of saturated
liquid/vapour R134a from its temperature or pressure.
12. Using suitable formulae for superheated refrigerant R134a, develop user-defined
functions with VBA for determining properties, e.g. enthalpy and entropy, of
superheated R134a from its temperature and pressure.
Computer-Aided Thermofluid Analyses Using Excel 88
Computer-Aided Thermofluid Analyses Using Excel 89
Equipped with numerous built-in functions, the Goal Seek command and the Solver add-
in, Excel is a powerful modelling platform for fluid-flow and heat-transfer analyses.
However, for thermodynamic analyses Excel’s capacity is limited by the lack of built-in
functions for fluid properties. Another limitation of Excel for thermofluid analyses even
for fluid-flow and heat-transfer analyses is that Excel’s cell-confined formula becomes
too restrictive for model development when an iterative solution involves a nonlinear
equation like the Colebrook equation. This chapter presents the Thermax add-in that
provides custom functions for the properties of ideal gases, saturated water and
superheated steam, six commonly used refrigerants, humid air for psychrometric
analyses, and air at standard atmospheric pressure. In addition to its property functions,
Thermax provides two interpolation functions for general use and an internal Newton-
Raphson solver for nonlinear equations that can be used to deal with the linear equation
in an iterative solution. The chapter describes the procedure for installing the add-in and
using its functions and numerical tools in Excel’s formulae.
1. The first part indicates the function’s group: “Gas” for ideal gases, “Wat” for
water, “Ref” for refrigerants, and “Air” for air at atmospheric pressure.
2. The second part indicates the function’s output property, e.g. “h” for enthalpy
and “s” for entropy.
3. The third part indicates the function’s input parameters, .e.g. “P” for pressure
and “T” for temperature.
For example, consider the two functions shown in Figure 4.1. The top function,
Wath_Px, determines the enthalpy of saturated water at a pressure of 500 kPa and quality
of 0.8. The first three letters in the function’s name refer to its group (Wat) immediately
followed by the function’s output (h). An underscore precedes the function’s two input
arguments, which are the pressure (P) and quality (x). Similarly, the name of the bottom
function, Refs_PT, tells that it belongs to the refrigerants group and that it determines
the entropy (s) of refrigerant R134a from its pressure (P) and temperature (T). This
function requires three input parameters which are (i) the refrigerant name, (ii) the
pressure, and (iii) the temperature. Table 4.1 shows more examples for the functions with
their intended usage.
Computer-Aided Thermofluid Analyses Using Excel 91
(a)
(b)
Figure 4.1. Examples of Thermax functions
Table 4.1. Examples of Thermax property functions with their output arguments
# Thermax function Output
1 Gash_TK(“Air”,350) Determines the enthalpy (h) for air at 350K
Determines the entropy (s) of saturated water at
2 Wats_Px(300,0.5)
a pressure of 300 kPa and quality of 0.5
Determines the enthalpy of superheated steam at
3 Wath_PT(90,150)
90 kPa and 150oC
Determines the saturation pressure (Psat) for
4 RefPsat_T(“R134a”,-5)
refrigerant R134a at -5oC.
PsyRh_PTSh(101,30, Determines relative humidity (ϕ) of humid air at
5 0.001) 101 kPa, 30oC, and specific humidity (ω) of
0.001 kg/kg
Determines the dynamic viscosity of air at
6 Airdv_T(25)
standard atmospheric pressure and 25oC.
The following points should be noted regarding the name style adopted by Thermax:
1. The output properties in all the functions are represented by one or two letters,
e.g. Gash_TK and GasTK_h, except those for the saturation pressure and
saturation temperature in the WAT and Ref groups and the air density in the Air-
group, which are named WatPsat_T, WatTsat_P, RefPsat_T, RefTsat_P, and
Airrho_T.
2. The Gas-group and the Ref-group require the name of the gas or the refrigerant
fluid as the first input parameter as shown in Figure 4.1.b.
3. The unit for pressure in both the Wat-group and the Ref-group is kPa.
4. To indicate that absolute temperature is used in the Gas-group, the temperature
is represented by “TK”. However, “T” represents temperature in oC in the other
four groups.
Computer-Aided Thermofluid Analyses Using Excel 92
T
~ ~
h h0 c~p (T )dT (4.1)
T0
T 2
u~ u~0 c~v (T )dT u~0 (c~p (T ) Ru )dT (4.2)
T0 1
T ~
~s 0 ~s 0 c p (T ) dT
0 T
T0
(4.3)
~
Where, h , u~ , and ~
0 0 s 0 are pre-specified values at a reference temperature (T0) and Ru is
0
~
the universal gas constant. For h and u~ , the reference temperature is taken as 300K and
~
the corresponding values of h0 and u~0 are those given by Cengel and Boles [1].
However, for ~s 0 the reference temperature is taken as 298K and the corresponding value
of ~
s 00 is the absolute entropy. Rather than the molar properties given above, Thermax
functions return the ideal-gase properties per kg, i.e. h, u and s0, i.e.:
~
hh /M (4.4)
u u~ / M (4.5)
s 0 ~s 0 / M (4.6)
Where M is the molar mass of the gas. The relative pressure (Pr) and relative specific
volume (vr) are then obtained from [1]:
Pr = exp(s°/R) (4.7)
v r T / Pr (4.8)
Note that Pr is a dimensionless quantity but vr is not. Based on the above equations, this
group provides 12 functions that give properties of the 12 ideal gases listed in Table 4.2.
Table 4.3 lists the 12 functions and shows the input and output of each function and their
relevant units.
Computer-Aided Thermofluid Analyses Using Excel 93
The first five functions shown in Table 4.3 determine the molar mass (M), specific heat
(cp), enthalpy (h), internal energy (u), and the part of entropy change due to temperature
change (s0). The following two functions determine the relative pressure (Pr) and relative
volume (vr). The last five functions in Table 4.3 are inversion functions that determine
the temperature of the ideal gas by iteration from its enthalpy (h), internal energy (u),
temperature-dependent entropy change (s0), relative pressure (Pr) or relative specific
volume (vr). Note that the temperature is represented by the letters “TK” in the names of
all the functions in this group. With the exception of the first function, GasM, all the
functions require the absolute temperature as inputs. An auxiliary custom function named
“Gas_data” stores the values of the four coefficients a0, a1, a2, and a3 in Equation (3.10)
for the twelve ideal gases. Values of the coefficients for the different gases were obtained
from Cengel and Boles [1].
Computer-Aided Thermofluid Analyses Using Excel 94
Table 4.5. Property functions for saturated water/steam at a given pressure in kPa
# Function Output/Unit
1 WatTsat_P Ts [oC]
2 Wathf_P hf [kJ/kg]
3 Wathg_P hg [kJ/kg]
4 Wathfg_P hfg [kJ/kg]
5 Watvf_P vf [m3/kg]
6 Watvg_P vg [m3/kg]
7 Watsf_P sf [kJ/kg.K]
8 Watsg_P sg [kJ/kg.K]
functions are the same as those used for superheated refrigerants which will be described
in the following section. These functions also determine properties of compressed liquid
water by calling those of saturated liquid water at the given temperature shown in Table
4.4.
Table 4.6. Properties of superheated steam given the pressure in kPa and another
property
# Function Input/Unit Output/Unit
1 Watv_PT P, T[oC] v [m3/kg]
o
2 Wath_PT P, T[ C] h [kJ/kg]
o
3 Wats_PT P, T[ C] s [kJ/kg.K]
4 WatT_Ph P, h[kJ/kg] T [0C]
5 WatT_Ps P, s[kJ/kg.K] T [0C]
6 Wath_Ps P, s[kJ/kg.K] h [kJ/kg]
7 Wats_Ph P, h[kJ/kg] s [kJ/kg.K]
Table 4.7. Properties of saturated refrigerants at a given pressure in kPa and quality
# Function Input Output Unit
1 RefTsat_P Refrigerant name, P, x Saturation temperature, Tsat [0C]
2 Refv_Px Refrigerant name, P, x Specific volume, v [m3/kg]
3 Refh_Px Refrigerant name, P, x Specific enthalpy, h [kJ/kg]
4 Refs_Px Refrigerant name, P, x Specific entropy, s [kJ/kg.K]
5 Refcp_Px Refrigerant name, P, x Specific heat, cp [kJ/kg.K]
6 Refvs_Px Refrigerant name, P, x Velocity of sound [m/s]
7 Refdv_Px Refrigerant name, P, x Dynamic viscosity [µPa·s]
8 Refk_Px Refrigerant name, P, x Thermal conductivity [mW/(m·K)]
9 Refst_P Refrigerant nam, P Surface tension [mN/m]
Computer-Aided Thermofluid Analyses Using Excel 96
Specific volume
~ ) of a superheated refrigerant is obtained from the Soave-
The molar specific volume ( v
Redlich-Kwong equation of state [1]:
RT a
P= ~u ~ ~ (4.9)
v b v (v b)
where, Ru is the universal gas constant, P is the absolute pressure, and T is the absolute
temperature. The constants a, b and , which depend on the refrigerant’s pressure and
temperature at the critical point, are given by:
b = 0.0867 Ru Tc / Pc (4.11)
1 S 1 Tr
2
(4.12)
where, Tc and Pc are the temperature and pressure at the critical point, Tr =T/Tc is the
reduced temperature, and S is a function of the acentric factor () for the given
refrigerant:
log 10 prsat 1 , at Tr = 0.7 (4.14)
Where Prsat =Psat/Pc is the reduced saturation pressure. Values of Tc, Pc, and for the six
refrigerants supported by Thermax are shown in Table 4.9.
v v~ / M (4.15)
Where M is the molar mass of the refrigerant and its values for the six refrigerants are
shown in Table 4.9. The accuracy of the above relation in determining the specific
volume was demonstrated by El-Awad [4].
h h g Cp *g T T s (4.16)
Where hg and Ts are the enthalpy and temperature of the saturated vapour refrigerant at
the given pressure while Cp *g is the value of its specific heat evaluated at a skewed
pressure (P*) given by:
P* z P (4.17)
Where z is an adjusting factor the value of which can be taken as 0.5 [4,5]. Values of hg,
Ts, and Cp *g are obtained from ASHRAE data for saturated refrigerants.
Entropy
Computer-Aided Thermofluid Analyses Using Excel 98
Tav T Ts / 2 (4.19)
T Ts h h g / Cp *g (4.20)
Where Ts and hg are values of the saturation temperature and enthalpy of saturated
refrigerant vapour at the given pressure, but Cp *g is the value of the specific heat of
saturated refrigerant vapour determined at the reduced pressure P*. Similarly, when the
pressure and entropy of the superheated refrigerant are known and its temperature is to
be determined, the following equation is used:
ssg
T Tg 273 e Cp*g
273 (4.21)
Where Tg and sg are the temperature and entropy of saturated vapour refrigerant at the
given pressure, while Cp *g is the value of the specific heat of saturated refrigerant vapour
determined at the reduced pressure P*. Table 4.10 lists seven functions that apply the
above formulae to deal with superheated vapours of refrigerants.
The first six functions in Table 4.10 use Equations (4.15) to (4.21) to determine property
values. The last function is an inversion function that uses an iterative tool. All the
functions apply for pressures and temperatures not higher than the critical values of the
given refrigerant.
Where, cpa is the specific heat at constant pressure for dry air (cpa =1.005 kJ/kg.K), T is
the temperature in oC, ω is the absolute humidity, and hv is the enthalpy of water vapour
at the air temperature and partial-pressure of the water-vapour (Pv). The absolute
humidity (ω) in Equation (4.22) is determined from:
0.622 Pv
(4.23)
P Pv
Where, P is the total pressure of the air-water-vapour mixture and Pv is the partial
pressure of water-vapour in the air. The partial pressure of water vapour itself is
determined from:
Pv Psat (4.24)
100
Where ϕ is the relative humidity and Psat is the saturation pressure of water at the given
dry-bulb temperature. The enthalpy of saturated liquid water (hv) in Equation (4.22) is
approximated by the enthalpy of saturated water-vapour at the given temperature (hg) and
calculated as follows:
Property functions of this group also use the following relationship between the relative
and specific humidities:
P
(4.26)
0.622 Pg
Table 4.11 lists 14 functions that are included in psychrometry group together with their
input and output arguments. The letters in the function names have the following
Computer-Aided Thermofluid Analyses Using Excel 100
Table 4.11. Function for psychrometry analyses given the pressure in kPa and two other
properties
# Function Input/unit Output/unit
1 Psyv_PDbRh P, Tdb [ C], ϕ [%]
o
v [m3/kg]
2 PsyRh_PDbSh P, Tdb [ C], ω[kg/kg]
o
ϕ [%]
3 PsyRh_PDbWb o o
P, Tdb [ C], Twb [ C] ϕ [%]
4 PsySh_PDbRh P, T [oC], ϕ [%] ω [kg/kg]
5 PsySh_PDbWb o o
P, Tdb [ C], Twb [ C] ω [kg/kg]
6 Psyh_PDbSh P, T [oC], ω[kg/kg] h [kJ/kg]
7 Psyh_PDbRh P, T [ C], ϕ [%]
o
h [kJ/kg]
8 PsyDp_PDbRh P, Tdb [oC], ϕ [%] Tdp [oC]
o o
9 PsyDp_PDbWb P, Tdb [ C], Twb [ C] Tdp [oC]
10 PsyDb_PRhSh P, ϕ [%], ω[kg/kg] Tdb [oC]
11 PsyDb_PhSh P, h [kJ/kg], ω[kg/kg] Tdb [oC]
12 PsyWb_PDbRh P, Tdb [oC], ϕ [%] Twb [oC]
13 PsyWb_PDbSh P, Tdb [ C], ω[kg/kg]
o
Twb [oC]
14 PsyWb_PRhSh P, ϕ [%], ω[kg/kg] Twb [oC]
This group also needs functions that determine certain properties of saturated liquid
water, viz. Psat, Tsat and hl. The group has its own functions that determine these properties
for temperatures in the range 0 – 100oC as met in common air-conditioning practice. The
saturation pressure (Psat) and saturation temperature (Tsat) are obtained from the following
Antoine equations [6]:
B
A
Psat 0.1333 10 C T
(4.27)
P
Tsat B / A log C
0.1333
(4.28)
Where, T is in oC, P in kPa and the three constants A, B, and C, respectively, have values
of 8.07131, 1730.63, 233.426 for 1< T < 100oC and 8.14019, 1810.94, 244.485 for 99
< T < 374oC. Enthalpy of saturated liquid water at a given temperature is obtained from
the following equation which was obtained by curve-fitting the data using Excel’s
trendline feature:
The functions in this group that use Equations (4.27), (2.18) and (4.29) make the group
independent from the water group. Case 5 in Table 4.1 shows how the function
PsyRh_PTSh can be used to determine the relative humidity for air given its pressure,
temperature, and specific humidity.
If for any reason you saved the add-in in a location that is different from the default
folder, then click on Browse and search for it in the destination folder and select it.
Having installed the add-in, its functions can be used in Excel's formulae just like its
built-in functions. Thermax functions are named in a way that helps you to easily identify
the required function via Excel’s user-interface without having to memorise all the names
of the functions and required input. The following sections illustrate two methods for
using the add-in functions in Excel formulae.
Figure 4.3. Finding the add-in user-defined functions in the Function Wizard
Figure 4.4. Thermax functions listed alphabetically in the User Defined category
Computer-Aided Thermofluid Analyses Using Excel 104
Figure 4.5. The Function Arguments box for the “Airk_T” function
Figure 4.5 shows that this function has one input parameter, which is the temperature in
o
C “TempC”, and gives a brief description of its intended use. Let us use the function to
determine the thermal conductivity for air at 25oC. Fill the form by entering thr value of
the temperature, 25, as shown in Figure 4.6. Note that the formula ribbon now shows the
formula in cell B2, which is “=Airk_T(25)”. The form also shows the calculated value of
k, which is 0.02551 W/m.oC. When you press the “OK” button, this value will appear in
the cell B2. Check this value with the tabulated data and try other functions.
Figure 4.6. Using the function “Airk_T” to determine the thermal conductivity of
atmospheric air at 25oC
value. Therefore, we start an Excel formula by typing the equal sign “=” in any cell. As
shown in Figure 4.7, as soon as we type the prefix "Gas" after the equal sign, the user-
interface will display all Thermax functions in the ideal-gases group for us to select from.
Since the property we want to find is the temperature, which the Gas-group functions
require in absolute degree, we continue the name of the function by adding the letters
“TK” immediately after the three-letter prefix "Gas" followed by an underscore. As
shown in Figure 4.8, the user-interface then lists only the five functions in Table 4.3 that
determine the gas temperature given h, Pr, s0, u, or vr.
Figure 4.8. UI showing only the five functions that determine the temperature of an
ideal gas from known values of h, pr, s0, u, or vr
Since we want to find the temperature from a known value of enthalpy, we have to select
the “GasTK_h” function. This function requires as input the name of the gas, which is
“CO2”, and the value of enthalpy, which is 750 kJ/kg, as shown in Figure 4.9. Pressing
the “Enter” key after entering the required data, the function will calculate the
corresponding temperature. As shown in Figure 4.10, the answer is 817.5544K.
Computer-Aided Thermofluid Analyses Using Excel 106
The following example shows how property functions in the Gas-group can be used for
applying the exact, variable specific-heat method in thermodynamic analyses.
Air
T1 = 330K
P1 = 100 kPa
V1 = 0.1 m3
Heat 50 kJ
Figure 4.11. Schematic for Example 4.1
Solution
Computer-Aided Thermofluid Analyses Using Excel 107
Using the approximate constant specific heat method, the final temperature is determined
from:
Q
T2 T1 (4.30)
m cp
Where m is the mass of air in the piston-cylinder device, cp is the the specific heat at
constant pressure, and Q is the amount of heat added. The mass of air is calculated from
the ideal-gas law:
P1V1
m (4.31)
R T1
Where R is the gas constant for air, R = 0.287 kJ/kg.K. Substituting for P1, V1, R and T1
in Equation (4.31), leads to m = 0.105585 kg and substituting for m in Equation (4.30)
gives T2 = 801.194K.
To apply the exact method by using the add-in functions in the Gas group, we first
determine the final enthalpy, h2, by applying the first law of thermodynamics to the closed
system:
h2 h1 Q / m (4.32)
Once h2 is found, the final temperature, T2, can be determined by using the function
GasTK_h in the Gas group.
Figure 4.12 shows the Excel sheet developed for this example. The given data are inserted
at the left-hand side of the sheet together with the gas constant (R_) and specific heat (cp)
for air. The calculations part is divided into two parts that determine the final temperature
according to the approximate method and the exact method using the corresponding
equations given above.
Figure 4.12 also reveals the formulae typed in these calculations. As the figure shows,
the answer found by the approximate method for T2 is 801.2K, while the exact method
determines the final temperature as 781.6K. Thus, the approximate constant specific-heat
method results in an error of 2.5%.
Both Interpol1 and Interpol2 require four input arguments referred to as: X, XX, YY,
and Ndata. Their meanings are as follows:
Computer-Aided Thermofluid Analyses Using Excel 109
- X passes the value of the independent property (i.e. temperature) at which the
value of the dependent property (i.e. viscosity) is to be determined.
- XX and YY are vectors that store the tabulated data (in this case, the temperature,
B5:B13, and viscosity values, E5:E13,).
- Ndata passes the number of entries in the tabulated data. For the tabulated data
shown in Figure 4.13, Ndata = 9.
The formula bar in Figure 4.13 reveals the formula in which the linear interpolation
function Interpol1 is used to determine the viscosity at 90oC. Both the linear and
quadratic interpolation functions return the warning message “Given data is out of
range” if the temperature lies outside the tabulated range. The following example shows
how the interpolation functions can be used in a thermofluid analysis.
Example 4.2. Effect of oil temperature on the drag force over a flat plate
Engine oil at 20°C flows over the upper surface of a 5-m-long flat plate as shown in
Figure 4.14. If the oil velocity is 2 m/s, determine the total drag force (FD) per unit width
of the entire plate. Also, plot the variation of FD with oil temperatures in the range 40 -
150oC.
T∞ = 40 – 150oC
V = 2 m/s
Oil FD
A Ts = 20oC
L=5m
Figure 4.14. Schematic for Example 4.2 (adapted from Cengel and Ghajar [7])
FD C f AV 2 / 2 (4.34)
Where Cf is the friction coefficient (not to be confused with the friction factor f), A is the
surface area of the plate, and ρ and V are the density and velocity of oil, respectively. The
value of the friction coefficient depends on whether is flow is laminar or turbulent as
indicated by the Reynolds number (ReL). For the flow over a flat plate, the critical
Reynolds number above which the flow becomes turbulent is about 5x105. For laminar
flows, the friction coefficient is given by:
Computer-Aided Thermofluid Analyses Using Excel 110
Note that fluid properties are evaluated at the average temperature (Ts+T∞)/2. For
example, if the oil temperature is 60oC, the oil viscosity and density are evaluated at 40oC.
The friction coefficient is calculated depending on the value of the Reynolds number by
using the following nested-If formula in cell F7:
Cf=IF(Re<500000,1.328*Re^-0.5,0.074*Re^-0.2)
The above formula determines whether to use Equation (4.35) or Equation (4.36) to
calculate the friction coefficient depending on whether the flow is laminar or turbulent.
Figure 4.15 shows the calculations at an oil temperature of 40oC, which is the initial oil
temperature in the required range. At the average temperature, which is 30oC, the sheet
uses the linear interpolation function Iinterpol1 to determine the values of the oil density
and viscosity. At this temperature the calculated drag force, F_D, is 88.445 N. By
Computer-Aided Thermofluid Analyses Using Excel 111
inserting a different value for the oil temperature, say 50oC, the sheet automatically
updates its calculations. Figure 4.16 shows a plot of the drag force determined at different
oil temperatures in the range 40oC to 150oC. The figure shows that the drag force drops
exponentially with temperature, approaching a value of about 20 N.
100
80
Drag force (N)
60
40
20
0
0 50 100 150 200
Oil temperature (oC)
Figure 4.16. Variation of the drag force with oil temperature
The usefulness of the linear and quadratic interpolation functions in thermofluid analyses
goes beyond that of determining fluid properties since these functions are also useful for
interpolation of other types of tabulated data that is required by such analyses. Table 4.12
shows the cost per meter of galvanised-steel air-conditioning ducts for different diameters
of the duct. In this case, the interpolation functions permit automatic determination of the
duct diameter from the tabulated data, which is useful for optimisation analyses that
involve the duct diameter.
1 / D 2.51
2.0 log 10 (1.35)
f
3 .7 Re f
Where D is the pipe’s diameter, ε is the roughness of the pipe material, and Re is the
Reynolds number. Since the equation involves f on both sides, it needs to be solved
iteratively. Determining f from Equation (1.35) will be inconvenient particularly when
dealing with type-2 or type-3 pipe-flow problems, which themselves require iterative
solutions, since we have to deal with two nested iterations; an inner iteration to determine
f and an outer iteration to determine the pipe’s diameter or the flow rate.
Another nonlinear equation that is even more difficult to fit in an Excel formula is the
following Benedict-Webb-Rubin (BWR) equation of state [1]:
Where Ru is the universal gas constant, P is the absolute pressure, T is the absolute
temperature, and v~ is the molar specific volume. The BWR equation, which is one of
the most accurate equations of state, is implicit in v~ and, therefore, cannot be used
directly in an Excel formula to determine the molar specific volume.
Thermax provides a third VBA function for solving nonlinear equations such as the
Colebrook equation and the BWR equation. The function, called NRM, requires four
input arguments: fun$, x0, Var1, and Var2. The first argument, fun$, passes the name of
the user-defined function developed separately for the particular nonlinear equation to be
solved; e.g. the SRK equation or the BWR equation. The second argument, x0, is an
~ in
initial guess for the dependent variable in the equation; i.e. f in Equation (1.35) and v
Equation (4.37). The third and fourth arguments, Var1 and Var2, are values of two
independent variables in the nonlinear equation; i.e. ε/D and Re in Equation (1.35) and P
and T in Equation (4.37). To illustrate the use of the NRM function, let us use it to
compare the specific volumes of carbon dioxide (CO2) as determined by the ideal-gas
law and the BWR equation of state at different temperatures. The following VBA
function is that for the BWR equation of state taking the different constants in the
equation as those of carbon dioxide (CO2):
Function BWR(x, P, T)
Dim Ru, a, A0, b, B0, c, C0, alfa, gama
Computer-Aided Thermofluid Analyses Using Excel 113
Figure 4.17 shows an Excel sheet that determines the specific volume of carbon dioxide
at 0.2 MPa and temperatures in the range 273 – 373K by using the ideal gas law and by
using the BWR equation of state and Table 4.13 reveals the formulae used in the sheet.
Figure 4.17. Excel sheet for determining the specific volume by the ideal-gas law
compared to the BWR equation of state
The formula bar in Figure 4.17 reveals the following Excel formula in cell F3 that uses
~ at 273K:
the NRM solver to calculate v
D4=NRM("BWR",E3,P,D3)
Computer-Aided Thermofluid Analyses Using Excel 114
Note that the first argument passed to the NRM function is the name of the UDF written
for the nonlinear equation, which in this case is the BWR function. Also, note that the
value determined by the ideal-gas law in cell E3 is used as an initial guess for the BWR
equation. Figure 4.18 shows how the error of the ideal-gas law in estimating the specific
volume increases at the low temperatures.
Table 4.13. The formulae used in the Excel sheet using the NRM solver
T v_ideal v_BWR error_v_ideal
273 =Ru*D3/P =NRM("BWR",E3,P,D3) =ABS(F3-E3)/F3*100
283 =Ru*D4/P =NRM("BWR",E4,P,D4) =ABS(F4-E4)/F4*100
293 =Ru*D5/P =NRM("BWR",E5,P,D5) =ABS(F5-E5)/F5*100
303 =Ru*D6/P =NRM("BWR",E6,P,D6) =ABS(F6-E6)/F6*100
313 =Ru*D7/P =NRM("BWR",E7,P,D7) =ABS(F7-E7)/F7*100
323 =Ru*D8/P =NRM("BWR",E8,P,D8) =ABS(F8-E8)/F8*100
333 =Ru*D9/P =NRM("BWR",E9,P,D9) =ABS(F9-E9)/F9*100
343 =Ru*D10/P =NRM("BWR",E10,P,D10) =ABS(F10-E10)/F10*100
353 =Ru*D11/P =NRM("BWR",E11,P,D11) =ABS(F11-E11)/F11*100
363 =Ru*D12/P =NRM("BWR",E12,P,D12) =ABS(F12-E12)/F12*100
373 =Ru*D13/P =NRM("BWR",E13,P,D13) =ABS(F13-E13)/F13*100
0.50
Error of the ideal gas law(%)
0.45
0.40
0.35
0.30
250 300 350 400
Temperature (K)
Figure 4.18. Errors in the specific volume estimations by the ideal-gas law compared to
the BWR equation of state
4.4. Closure
The chapter introduced the Thermax add-in that provides property functions for 12 ideal
gases, saturated water and superheated steam, the six refrigerants R134a, R22, R410A,
R717, R718, and R744, humid air for psychrometric analyses, and air at atmospheric
Computer-Aided Thermofluid Analyses Using Excel 115
pressure. Thermax property functions are named in a way that makes it easy to find the
appropriate function via Excel’s user-interface without having to memorise the names of
all the functions. Thermax also provides two custom functions for data interpolation and
a solver for nonlinear equations based on the Newton-Raphson method. While the
interpolation functions are useful for including additional fluid properties or other
tabulated data in a thermofluid analysis, the Newton-Raphson solver removes the
restriction of Excel’s formula when an optimisation analysis or an iterative solution
involves a nonlinear equation.
References
[1] Y. A. Cengel and M. A. Boles. Thermodynamics an Engineering Approach,
McGraw-Hill, 7th Edition, 2007.
[2] American Society of Heating, Refrigeration and Air-Conditioning Engineers,
(ASHRAE), Handbook of fundamentals, Atlanta, 2017.
[3] Wikipedia contributors, “Accentric factor”, Wikipedia, The Free Incyclopedia,
internet: https://en.wikipedia.org/wiki/Acentric_factor, (last acessed November 30,
2015.
[4] M.M. El-Awad, An Excel Add-In for Refrigerants Properties and its Use for
optimising Multi-Stage Compression Refrigeration Cycles, the Electronic Journal of
Spreadsheets in Education (eJSiE), Vol. 12, Iss. 1, Article 3, 2019.
[5] M.M. El-Awad, M.S. Al Nabhani, K.S. Al Hinai, A. Younis, Development and
Validation of an Excel Add-In for determining the Properties of Various
Refrigerants, Proceedings of the 1st National Conference on Applied Science,
Engineering & Technology 2019, CASET – 2K19, 11th June 2019, Ibri, Oman.
[6] Wikipedia contributors, “Antoine equation”, Wikipedia, The Free Incyclopedia,
internet, https://en.wikipedia.org/wiki/Antoine_equation (Last accessed November
23, 2015).
[7] Y. A. Cengel and A. J. Ghajar. Heat and Mass Transfer: Fundamentals and
Applications. McGraw Hill, 2011.
Exercises
1. Complete the following table by specifying the usage of the given Thermax function
according to its name:
3. Using Thermax functions, determine the following fluid properties: Also, determine
the same properties by using the appropriate property tables and compare their values
with those determined previously by using Thermax functions.
RT a
P~u ~ ~ (1.39)
v b v ( v b)
Where the constants a, b and are fluid-dependent. Following the method described
in Section 4.5.2, develop a user-defined function that can be used with the Newton-
Raphson Solver to calculate the specific volume for refrigerant R-12 from the SRK
equation of state at a pressure of 200 kPa and temperatures in the range 0 - 50oC. On
a suitable chart, compare values of the specific volume thus obtained by those
calculated by the ideal-gas equation of state.
Computer-Aided Thermofluid Analyses Using Excel 117
6. Develop a user-defined function with VBA to determine the friction factor from the
Colebrook equation, Equation (1.35), and use it with the NRM solver to determine
the frictional losses (hf) in a circular pipe in the following case:
7. Using the data for properties of air at atmospheric pressure, develop a user-defined
function that can be used for determining the kinematic viscosity of air at any given
temperature in the range 200 – 1000K.
Iterative solutions
Computer-Aided Thermofluid Analyses Using Excel 120
L V2
hf f (1.21)
D 2g
where f is the Darcy friction factor, L the length of the pipe, D its diameter, V the fluid
velocity, and g the gravitational acceleration constant. The friction factor can be obtained
from Equation (1.22) if the flow is laminar and from Equation (1.24) or (1.25) if it is
turbulent.
1. Type-1 problem - requires the determination of hf when both the pipe’s diameter
and fluid velocity (or flow rate) are known.
2. Type-2 problem - requires the flow rate for a specified hf and pipe diameter to be
determined.
3. Type 3 problem - requires the pipe diameter to be determined for a given hf and
flow rate.
iterative solutions because the Reynolds number and, therefore, the friction factor cannot
be determined in advance. In the case of type-2 problems (i.e. unknown velocity), the
iterative procedure can be avoided by using extended Moody diagrams that require the
determination of the following dimensionless parameter [2]:
0.5
D1.5 2 gh f
Re f 0.5
. (5.1)
L
Apart from the inaccuracy of visual chart interpolation, the procedure is difficult to adopt
in optimisation or parametric analyses. By using the Goal Seek command, both type-2
and type-3 problems can be solved more easily and accurately. The following example,
which is based on Example 8.4 in Cengel and Cimbala [1], demonstrates this method by
solving a type-3 problem.
0.35 m3/s
air D
150 m
Figure 5.1. Schematic for Example 5.1 (adapted from Cengel and Cimbala [1])
Solution:
The problem can be solved by calculating the friction head loss at different diameters of
the duct and then selecting the diameter that gives the required head loss of 20 m. The
iterative solution proceeds as follows:
Figure 5.2 shows the Excel sheet developed for this example which is divided into three
parts: (i) problem data (ii) calculations, and (iii) results. The data part shows the
Computer-Aided Thermofluid Analyses Using Excel 122
information given in the question. The value of the kinematic viscosity of air at 35°C (ν
= 1.655x10-5 m2/s) was obtained from Cengel and Cimbala [1] and fixed throughout the
calculations. Cell-labelling is applied in the formulae and Figure 5.2 reveals the formulae
used in each cell of the calculations part.
Figure 5.2. Excel sheet and Goal Seek set-up for Example 5.1
As Figure 5.2 shows, for an assumed duct diameter of 0.1 m the friction head loss exceeds
2761 m. Figure 5.2 also shows the completed Goal Seek dialog box that requires Goal
Seek to change the diameter in cell F2 and iterate until the friction head loss in cell J2
attains the required value of 20 m. Figure 5.3 shows the answer found by Goal Seek,
which is D ≥ 0.27 m. This answer agrees with that given by Cengel and Cimbala [1]. A
similar procedure can be used to solve type-2 flow problems by iterating over the flow
rate instead of the diameter.
common simplificationan in these analyses is the use of constant specific heats for gases.
Example 4.1 showed how the property function provided by Thermax enable the exact
method of analysis with variable specific heats to be used instead of the approximate
method. Another commonly used approximation in thermodynamic analyses is to treat
air as a pure gas even though it is mainly a mixture of nitrogen and oxygen gases.
Computer-aided analyses with property functions enable a more realistic approximation
to be used by treating air as a mixture of gases instead of a single gas. However, this
method involves an iterative solution when the temperature of the gas mixture is not
known but has to be determined. The following example shows how the method can be
applied by using the Goal Seek command.
O2 21%, N2 79%
T1 = 330K
P1 = 100 kPa
V1 = 0.1 m3
Heat 50 kJ
Figure 5.4. Schematic diagram for Example 5.2
Solution
This problem is basically the same as that given in Example 4.1, but the air is now treated
as a mixture of O2 and N2 and not as a single pure gas. The solution procedure also applies
the first-law of thermodynamics, but the law is now applied as follows:
Q mO 2 h2 _ O 2 h1 _ O 2 m N 2 h2 _ N 2 h1 _ N 2
(5.2)
Where Q is the amount of heat added, mO2 and mN2 are the masses of oxygen and nitrogen
in the device, h1_O2 and h2_O2 are enthalpies of oxygen at the initial and final temperatures,
respectively, and h1_N2 and h2_N2 are the corresponding enthalpies for nitrogen. The
enthalpies of O2 and N2 in Equation (5.2) can be determined by using the relevant
Computer-Aided Thermofluid Analyses Using Excel 124
Thermax function, Gash_TK, and the masses mO2 and mN2 can be obtained from the
ideal-gas law using the corresponding partial pressures as follows:
0.21P1V1
mO 2 (5.3)
RO 2T1
0.79 P1V1
mN 2 (5.4)
R N 2T1
Where RO2 and RN2 are the gas constants for oxygen and nitrogen, which are 0.2598
kJ/kg.K and 0.2968 kJ/kg.K, respectively. The correct value of the final temperature is
that at which the amount of heat added (Q) is the same as the given value, which is 50
kJ. This can be determined by using Goal Seek.
Figure 5.5 shows the Excel sheet developed for this example. The data part includes the
initial pressure, temperature, and volume of the gas mixture together with the mole
fractions and gas constants of oxygen and nitrogen. The initial partial pressures of oxygen
and nitrogen, P1_O2 and P1_N2, are calculated from the total initial pressure (P_1) and
the respective volume fractions, y_O2 and y_N2, as shown in cells E2 and E3,
respectively. The sheet then determines the masses of the two gases in the mixture (m_O2
and m_N2) in cells E5 and E6, respectively, and the total mass (m_total) in cell E8. Note
that the value of the total mass, 0.1052 kg, is slightly different from that obtained in
Example 4.1, which is 0.106 kg.
Figure 5.5. The Excel sheet developed for Example 5.2 by using Thermax functions
The calculations start with a guessed value for the final temperature, T_2g, which is
500K. Equation (5.2) is then used to determine the total amount heat added in the process
(Q_g). The initial and final enthalpies of oxygen and nitrogen are determined by using
the function Gash_TK at the corresponding temperatures. Note that the sheet determines
the total amout of heat as 18.4 kJ, which is less than the actual values of 50 kJ. To find
the appropriate final temperature, the guessed temperature T_2g has to be adjusted by
Goal Seek so that the value of Q_2g equals 50 kJ. Figure 5.5 shows the required Goal
Seek set-up and Figure 5.6 shows the solution obtained by Goal Seek, which is 780.444
K. The value determined in Example 4.1 for T2 by using the exact method was 781.6K,
Computer-Aided Thermofluid Analyses Using Excel 125
while the value determined by using the approximate method was 801.2K. Although
these results confirm the the accuracy of treating air as a single pure gas and using the
exact method of analysis, the deviation from the present model and that of Exampe 4.1
is expected to increase as the amout of heating increases.
Figure 5.6. Goal Seek solution for Exampe 6.2 by using Thermax functions
Properties of water at 98oC are: ρ = 960 kg/m3, μ = 2.82 x 10-4 kg/m.s, k = 0.68 W/m.oC,
Pr = 1.76. For a 2-in schedule 40 pipe, Di = 5.25 cm and Do = 6.033 cm.
o
Air, 20 C, ho
Water
98oC
V = 25 cm/s
hi
Where Tw and T∞ are the water temperature and air-temperature, respectively, and Rth is
the total thermal resistance to heat-transfer that consists of the thermal resistances due to
heat-transfer by convection inside the pipe (Ri), by conduction through the steel pipe (Rp),
and by convection from outside the pipe (Ro). The three resistances are given by:
1
Ri (5.6)
Al hi
ln Di / Do
Rp (5.7)
2k
1
Ro (5.8)
Ao ho
Where Ai and Ao are the inside and outside areas of the pipe and hi and ho are the
corresponding heat-transfer coefficiens. The internal heat-transfer coefficien hi is
determined from the corresponding Nusselt number (Nu):
kw
hi Nu (5.9)
Di
Where, kw is the thermal conductivity of water. The Nusselt number is determined from
emprirical equations depending on the type of the flow, i.e. natural or forced, laminar or
turbulent. For the turbulent forced internal flow (to be confirmed later), Nu is obtained
from the Dittus-Boelter equation, Equation (1.31), with n = 0.4 following Holman [3]:
Where, Re and Pr are the Reynolds number and Prandtl number, respectively.
For the external flow, Holman [3] used the following simplified equation for free laminar
convection from a horizontal pipe to air at atmospheric pressure:
Computer-Aided Thermofluid Analyses Using Excel 127
1/ 4
T
1/ 4
T T
ho 1.32 1.32 o (5.11)
D Do
Both Ri and Rp can be determined directly from the given data, but Ro depends on ho
which cannot be determined directly because To is not known. Therefore, the problem
has to be solved by adopting an iterative approach. A value for To is assumed based on
which ho is determined and, consequently, Q. The value of Q thus obtained can be used
to calculate corresponding values for Ti and To from:
Ti Tw Q.Ri (5.12)
To Ti Q.R p (5.13)
If the guessed value for To is correct, it will be the same as that obtained from Equation
(5.13). Otherwise, a new guess for To has to be made repeatedly until this condition is
met. Once this is achieved, the overall heat-transfer coefficient (Uo) based on the outside
area (Ao) can be obtained from:
1
Uo
Ao Ri Ro R p (5.14)
As Figure 5.8 shows, the value of T_o calculated from Equation (5.13) is 97.876oC, which
is different from the initially guessed value (T_og = 50oC). The formula bar reveals the
formula entered in cell H12 that calculates the difference between the calculated exit
temperature (T_o) and the guessd value (T_og) as a fraction of T_og. The exit
temperature that makes the difference vanishes can be found by using the Goal Seek
command and Figure 5.8 shows the required set-up. The solution found by Goal Seek is
shown in Figure 5.9. Table 5.1 that comapres the presents results with those given by
Holman [3] confirms the accuracy of the iterative solution with Goal Seek.
Computer-Aided Thermofluid Analyses Using Excel 128
Table 5.1. Comparison of the presnt solution with that given by Holman [3]
Present solution Holman [3]
Ti 97.64 97.65
To 97.59 97.6
hi 1960.56 1961.0
ho 7.90 7.91
Uo 7.86 7.87
second example demonstrates the usefulness of Solver for a constrained iterative solution
of Example 5.4 given by Cengel and Boles [5].
Example 5.4. Determining the maximum water flow rate to avoid cavitation
Water at 20oC (γ = 9810 N/m3 and ν =1.006x10-6 m2/s) is to be pumped from a large
reservoir via a pump-pipe system as shown in Figure 5.10. The pump is positioned
vertically at a level which is 9 m above the surface of the reservoir and horizontally at 1
m from the vertical section of the pipe. The pipe is made of commercial steel pipe (ε =
0.046 mm) and has a 2″ nominal diameter.
1m
Q
2
Determine the maximum allowable water flow rate (Q) that satisfies the following
restrictions:
1. To avoid cavitation, the pressure at the pump inlet must be greater than the saturation
pressure of water at 20oC, which is 2.338 kPa.
2. For economic considerations, the water velocity (V) is to be in the range 1.4-2.8 m.
p1 V12 p2 V22
z1 z2 hf
2g 2g (5.15)
Where γ stands for the specific weight of water, z for the elevation, V for the water
velocity, g for the gravitational acceleration, and hf for the friction loss in the pipe. For
Computer-Aided Thermofluid Analyses Using Excel 130
suction from a large reservoir V1 = 0. Taking point 1 as a reference, i.e. z1 = 0, and noting
that the water velocity in the pipe is uniform, i.e. V2 = V, the energy equation becomes:
p V2
p2 1 z 2 h f
2g (5.16)
The velocity V is related to the pipe diameter (D) and water flow rate (Q) as follows:
V 4Q / D 2 (5.17)
Neglecting minor losses, the friction loss can be calculated from the Darcy-Weisbach
equation which needs an auxiliary formula to determine the friction factor (f) as described
in Chapter 1 for both laminar and turbulent flows.
The right side of the sheet contains the single cell I2 that determines the flow rate (Q).
The formula in this cell is shown in the formula bar. Based on the assumed water velocity
of 1.0 m/s, the calculated values of hf and P_2 are 0.2295 m and 8.958 kPa, respectively.
Since the pressure at point 2 is higher than the minimum design level of 2.338 kPa, while
the water velocity (V) is less than the minimum economic value of 1.4 m, there is room
Computer-Aided Thermofluid Analyses Using Excel 131
to increase the flow rate. The task can be left to Solver and Figure 5.12 shows the required
set-up.
The above set-up requires Solver to maximise the value of the flow rate Q while satisfying
the three constraints shown in the figure. The first constraint on the iterative solution
requires the value of P_2 in cell E7 to be higher than or equal to the specified value of
2.338 kPa, which is the minimum pressure level required to prevent cavitation. The two
other constraints are to satisfy the limits on the water velocity imposed by economic
limits, i.e. 1.4 m ≤ V ≤ 2.8 m. Pressing the “Solve” button will trigger Solver to search
for the solution. The solution found by Solver using the GRG Nonlinear method is shown
in Figure 5.13.
The value determined by Solver for the water velocity is 1.90 m/s. Note that this velocity
lies within the limits imposed by the economic constraint. The corresponding flow rate,
which is 0.00413 m3/s, is the maximum flow rate to be recommended.
Computer-Aided Thermofluid Analyses Using Excel 132
T1 = 317 k
P1 = 200 kPa
V1 = 0.05 m3
Heat 72.7 kJ
Figure 5.14. Schematic and pressure-volume diagrams for Example 5.5 (adopted from
Cengel and Boles [5])
If the cross-sectional area of the piston is 0.25 m2, determine the final volume, pressure,
and temperature of the air inside the cylinder. Air can be treated as an ideal gas with a
specific heat at constant volume (cv) that varies linearly with the temperature according
to the formula:
cv = 0.645+0.0002T (5.18)
Solution
Unlike the present example, Cengel and Boles [5] specified the final volume to be 0.1 m3
instead of the amount of heat added. When the final volume (or final pressure) is given,
the problem can be solved in a straightforward manner without iteration by using the
ideal-gas law. However, in the present example T2, V2, and P2 at the final state all depend
on the amount of heat added. The specific value of 72.7 kJ given in this example has been
chosen so that the final volume will be 0.1 m3 as specified by Cengel and Boles [5].
Therefore, the final pressure on the piston and the total work should be the same as those
obtained by Cengel and Boles [5] even though the formulations of the two examples are
different.
Example 5.2, the variation of the specific heat with temperature makes it necessary to
adopt an iterative solution approach. Since the iterative process here involves not only
the temperature but also the volume (or pressure), the Goal Seek command is inadequate.
Therefore, this example requires Solver since it allows the iterative procedure to start by
* *
assumed values for both the final temperature ( T2 ) and the final volume ( V2 ). The final
pressure P2 is given by:
kx
P2 P1 (5.19)
A
Where A is the base area of the piston and Δx is the reduction in the spring’s length given
by:
V2* V1
x (5.20)
A
The total work (W), i.e. the summation of the air expansion work and the work done
against the spring, can now be obtained from:
P1 P2
W V2* V1 (5.21)
2
Where Q is the amount of heat added, u is the internal energy, m is the mass of air inside
the cylinder, and c v is the average specific heat of air at constant volume. The mass and
specific heat of air can be obtained from:
cv 0.6 0.0002 T1 T2* / 2 (5.24)
Q W
T2 T1 (5.25)
mcv
Computer-Aided Thermofluid Analyses Using Excel 134
Using the values obtained for T2 and P2, the final volume V2 can be determined from the
ideal-gas law:
V 2 mRT 2 / P2 (5.26)
* *
If the initially guessed volumes of T2 and V2 are correct, then they will be the same as
T2 and V2 obtained from Equation (5.23) and Equation (5.25), respectively. Otherwise,
* *
new values for T2 and V2 have to be used until the difference between the calculated
and guessed values becomes negligibly small.
Figure 5.16 shows the set-up that requires Solver to change the values of T_2g and V_2g
in cells F2 and F3, respectively, until two constraints are satisfied: (i) T_2 = T_2g and
(ii) V_2=V_2g. Note that the “Set Objective” option has been left blank. The “Changing
Variable Cells” are F2 and F3. Figure 5.17 shows the solution obtained by the GRG
Nonlinear method of Solver, which is T_2g = 1014.864K and V_2g = 0.1 m3. At this
state, the final pressure on the piston is 320.0 kPa and the total work is 13.0 kJ. These
Computer-Aided Thermofluid Analyses Using Excel 135
values agree with their corresponding values given by Cengel and Boles [5] whose
analysis also gave P2 = 320 kPa and W = 13 kJ.
1 / D 2.51
2.0 log (1.35)
f 3. 7 Re f
Computer-Aided Thermofluid Analyses Using Excel 136
Since the Colebrook equation involves the friction factor f in both sides, it needs to be
solved iteratively in order to determine f. Therefore, for type-2 and type-3 flow problems
using the Colebrook equation to determine the friction factor would involve two nested
iterations; an inside iteration to determine f and an outside iteration to determine the
pipe’s diameter or flow rate. This situation also occurs in optimisation analyses that use
the Colebrook equation.
Chapter 4 illustrated the use of the NRM solver provided by Thermax by considering the
Benedict-Webb-Rubin equation. The NRM solver can also be used to solve the
Colebrook equation with type-2 and type-3 problems. For illustration, let us reconsider
Example 5.1 and solve it by the using the Colebrook equation to determine f instead of
the Swamee-Jain equation. As mentioned in Chapter 4, the NRM solver requires the
intended nonlinear equation to be written as a separate user-defined VBA function. The
needed VBA function for the Colebrook equation is listed below:
Note that, unlike in an Excel formula, in VBA syntax the term “log” is used for the natural
logarithm “ln”. Figure 5.18 shows the Excel sheet developed for solving Example 5.1
with the Colebrook equation.
Figure 5.18. Excel sheet for Example 5.1 using the Colebrook equation
The only difference between this sheet shown in Figure 5.2 is the content of the cell F9
that calculates friction factor. As Figure 5.18 shows, the formula typed in this cell now
reads:
The first input to the NRM function, “colebrook”, refers to the function that contains the
Colebrook equation while the second input, 0.004, is an initial guess for f. The last two
arguments, ε_by_D and Re, respectively, are labels for the cells that hold values of the
roughness-diameter ratio (ε/D) and the Reynolds number (Re) at which f is to be
determined. Figure 5.18, which shows the calculations for a selected diameter of 0.1 m,
shows that the value of the friction factor obtained by the Colebrook equation is
0.018075. The diameter that keeps the losses below 20 m can be determined by using
Goal Seek as in Example 5.1. Figure 5.18 also shows Goal Seek set-up for finding the
value of D that makes the friction head loss equal to 20 m. As Figure 5.19 shows, the
answer found by Goal Seek is D ≥ 0.27 m, which is the same answer obtained earlier in
Example 5.1.
Figure 5.19. Goal Seek solution for Example 5.1 using the Colebrook equation
5.4. Closure
This chapter dealt with thermofluid analyses that require iterative solutions and showed
how Excel’s Goal Seek command and Solver can be used for solving typical problems
from the areas of fluid dynamics, thermodynamics, and heat-transfer. The cases
considered include a type-3 flow problem, expansion of an oxygen-nitrogen ideal-gas
mixture in a closed system, and a convective heat-transfer analysis of a pipe heat-
exchanger. Because of its simplicity, Goal Seek should be the first option to consider for
an iterative solution that involves a single parameter. Solver can be used to solve more
difficult problems because it can handle multiple changeable cells and allows constraints
to be applied to the iterative process. The chapter also showed how the Newton-Raphson
solver provided by Thermax can be used to deal with the analyses that involve nonlinear
equations such as the Colebrook equation.
References
[1] Y. A. Cengel and J. M. Cimbala, Fluid Mechanics Fundamentals and Applications,
3rd edition, McGraw-Hill, 2006.
[2] C. T. Crowe, D. F. Elger, B. C. Williams, and J. A. Roberson, Engineering Fluid
Mechanics, 9th edition, John Wiley, 2009.
Computer-Aided Thermofluid Analyses Using Excel 138
Exercises
1. Consider the problem in Example 5.1. Suppose that the only available pipe diameter
is 20 m and we want to maintain the same maximum limit on the friction head loss
of 20 m by reducing the water flow rate. Using the Excel sheet developed for this
example, determine the water flow rate that gives the required result. Answer: 0.157
m3.
2. Using the two Excel sheets developed for Example 5.2, determine the final
temperature for air by the two methods when the amount of heat added is 50, 100,
150, and 200 kJ. Also calculate the final temperature from Equation (5.4) by using
a constant specific heat (cp) of 1.043 kJ/kg.K. Plot the values obtained for the final
temperature (T2) with the amount of heat added by the three methods and comment
on the result.
3. A gas mixture consisting of O2 and CO2 with mole fractions 0.2 and 0.8,
respectively, expands isentropically and at steady state through a nozzle from 700
K, 500 kPa to an exit pressure of 100 kPa as shown in the figure. Determine the
temperature at the nozzle exit, in K.
P1 = 500 kPa
P2 = 100
T1 = 700K
kPa
This exercise is based on Example 12.4 in Moran and Shapiro [6]. Using the
approximate constant-specific heat method, the exit temperature (T2) can be
determined from:
Computer-Aided Thermofluid Analyses Using Excel 139
k 1
T2 T1 P2 / P1 k (A)
Where k is the ratio of the specific heats for the mixture. Using k = 1.304, the
resulting exit temperature is 480.9K. Using the exact variable specific heat method,
T2 is determined by requiring that the total entropy change is zero, i.e:
P 0 P2
y O 2 s O0 2 T2 s O0 2 T1 RO 2 ln 2 y CO2 s CO 2 T2 s CO 2 T1 RCO 2 ln
0
0
P1 P1
(B)
Where yO2 and yCO2 are the volume fractions of O2 and CO2, respectively, and RO2
and RCO2 are the molar masses for O2 and CO2, respectively. The values of s O0 2 and
0
s CO 2 can be determined by using the relevant function provided by Thermax.
Equation (B), that requires an iterative solution, can be solved by using the Goal
Seek command. Answer: T2 = 514.05K.
4. Steam is be condensed at 30°C on the shell side of the multi-pass shell-and-tube heat
exchanger shown in Figure P5.4. The condenser has 8-tube-passes with 50 tubes in
each pass. Its overall heat transfer coefficient is 1000 W/m2·°C. Cooling water (Cp
= 4180 J/kg·°C) enters the tubes at 15°C at a rate of 55,000 kg/h. The tubes are thin-
walled, and have a diameter of 1.5 cm and length of 2 m per pass. Develp and Excel
shhet to determine the outlet temperature of the cooling water by using Goal Seek
and the LMTD method instead of the ε-NTU method [7].
Hot
Cold
5. Reconsider the problem in Example 5.5. Show that an alternative solution of this
problem that also takes into consideration the variation of specific heat for air with
temperature can be obtained by using the ideal-gas property functions provided by
Thermax instead of Equation (5.18). Show that this solution can be obtained by
using the Goal Seek command instead or Solver and compare your solution with that
given in Example 5.5.
6. Consider the semi-infinite slab shown in the figure that is suddenly exposed to
convection environment at T∞. The temperature (T) at a depth x from the surface at
any time is given by [3]:
T Ti hx h 2 h
1 erf X exp 2 1 erf X
(A)
T Ti
k k k
Where and k are the diffusivity and thermal conductivity of the slap material,
respectively, and:
X 2
Ti = initial temperature of solid
T∞ = environmental temperature
= elapsed time in seconds
T∞
h T1
x
Figure P5.6. Semi-infinite slab with convection heat-transfer
Equation (A) requires an iterative procedure because the time (τ) appears in both
terms on the right-hand side of the equation.
This problem is based on Example 4-5 in Holman [3]. His answer is approximately
3000 seconds.
7. Water at 60oC enters a tube of 3-cm diameter at a mean flow velocity of 1.2 cm/s. If
the tube is 3.0 m long and the wall temperature is constant at 80oC, what will be the
exit water temperature?
Use Goal Seek to perform the iterative solution of this problem. To determine the
viscosity of water at any temperature, develop a user-defined function based on the
data shown in Table A.2. in Appendix A. This exercise is based on Example 5.2 in
Holman [3]. Answer: 73.0oC.
Computer-Aided Thermofluid Analyses Using Excel 142
Computer-Aided Thermofluid Analyses Using Excel 143
Optimisation analyses
Computer-Aided Thermofluid Analyses Using Excel 144
The cost of energy constitutes a major part of the total lifetime costs of thermofluid
systems. Therefore, a compromise must be made between the lifetime savings in energy
cost that result from improving the efficiency of these systems and the additional costs
of such improvements. Optimisation analyses of thermofluid systems aim to determine
the most desirable design or operating conditions for these systems. This chapter shows
how the Excel-based platform described in this book can be used for optimisation
analyses of thermofluid systems. Initially, the chapter highlights the advantages of the
Excel-aided optimisation method over the traditional analytical method by considering a
two-stage air-compression system. The optimisation method with Excel is then applied
to selected thermofluid systems that involve single and multiple design variables. Finally,
the chapter demonstrates the use of the Evolutionary method in thermofluid optimisation
analyses by solving two examples previously solved by the GRG Nonlinear method and
comparing the results and computer time.
k 1 k 1
c p T1 2
Pi
k P4
k
wtotal (6.1)
1 Pi
P
Where k is the ratio of the specific heat for air at constant pressure (cp) to that at constant
volume (cv). Equation (6.1) is the objective function for optimisation and we are required
to determine the intermediate pressure (Pi) that minimises the total compression work.
Designating the pressure ratio in the first and second compressor stages by rp1 and rp2,
respectively, and the ratio (k-1)/k by α, Equation (6.1) can be put in the following simpler
form:
Computer-Aided Thermofluid Analyses Using Excel 145
wtotal c p T1 2 rp1 rp2 (6.2)
The pressure ratio in the second stage rp2 can be replaced by the total pressure ratio (rp)
and the pressure ratio in the first stage (rp1) as follows:
P4 P4 P1 r p
rp 2 (6.3)
Pi P1 Pi r p1
rp
wtotal c p T1 2 r p1
(6.4)
r p1
dwtotal
0 (6.5)
drp1
For convenience, let us replace rp1 in Equation (6.4) by x. Then, Equation (6.5) leads to:
d rp
c p T1 2 x 0 (6.6)
dx x
0 x 1
rp ( ) x 1 0 (6.7)
x 1 rp x 1 (6.8)
x 2 rp , or x rp (6.9)
rp1 rp 2 rp (6.10)
This solution indicates that, in order to minimise the total compression work, the overall
pressure ratio should be divided equally between the two compression stages. For
example, consider a two-stage air compression system designed to receive air at 100 kPa,
300K and discharge it at 900 kPa. Using Equation (6.10), the optimum pressure ratios rp1
and rp2 are such that:
rp1 rp 2 9 3
The total compression work (w) can be determined from rom Equation (6.1). Taking cp
for air as 1.005 kJ/kg.K and k as 1.4, gives:
1.41
wtotal 1.005 300 2 23 1.4 = -222.35 kJ
These simplifications and idealisations can undermine the accuracy of the results
obtained. The following example demonstrates how the Excel-based platform enables a
more realistic method for solving the optimisation problem by avoiding all the four
simplifying assumptions mentioned above.
Unlike the analytical model, we don’t take the compression process to be ideal, but allow
for the actual friction losses in the process by using ηc = 85%. We also allow for the
imperfections of the intercooler by accounting for its pressure losses and heat-transfer
effectiveness. By using Thermax functions for ideal gases, we also don’t have to use the
approximate method that assumes constant specific heats for air.
Computer-Aided Thermofluid Analyses Using Excel 147
T
P4
Px
4 2
2s
4s P1
T3
T1 3 1
Intercooling
s
Figure 6.1. T-s diagram for the two-stage air compressor with
inter-stage intercooling
The relative pressure at state 2s (Pr2s) can then be calculated from the following
relationship [1]:
Px
Pr 2 s Pr1 (6.11)
P1
Having determined the value of Pr2s, the ideal isentropic temperature after the first
compression stage T2s can be determined by using the add-in function GasTK_Pr.
Enthalpy values at states 1and 2s can be calculated by using the Gash_TK function.
Enthalpy at the actual temperature (T2) can now be determined as follows:
h2 h1 h2 s h1 / c
(6.12)
Where ηc is the adiabatic efficiency of the compressor. Therefore, the compression work
in the first stage (wc1) is given by:
wc1 h2 h1
(6.13)
The temperature and pressure before the second compressor stage are given by:
Computer-Aided Thermofluid Analyses Using Excel 148
P3 P2 PIC (6.15)
The compression work in the second stage can also be calculated by using the exact
method to determine the ideal exit temperature T4s and actual exit enthalpy h4:
P4 s
Pr 4 s Pr 3
P3 (6.16)
h4 h3 h4 s h3 / c
(6.17)
wc 2 h4 h3
(6.18)
The total compression work (wtotal) is the summation of the work in the two stages:
310
Total compression work (kJ)
300
290
280
270
260
0 200 400 600 800 1000
Intermediate pressure (kPa)
Figure 6.3.Variation of the total compression work with the intermediate pressure
Figure 6.3 indicates that the total work has a minimum value of about 310 kPa. The exact
value of the intermediate pressure that minimises the total work can be determined by
using Solver. Figure 6.4 shows Solver Parameters set-up that requires Solver to minimise
the total compression work calculated in cell L2 by adjusting the value of the intermediate
pressure (P_i). Figure 6.5 shows the solution found by Solver with this set-up using the
GRG Nonlinear method.
As shown in Figure 6.5, the solution found by solver is 316.88 kPa at which the total
compression work is 270.75 kJ. These values of the optimum intermediate pressure and
the corresponding compression work are higher than the corresponding values of 300 kPa
and 222.35 kJ given by the analytical method.
This example demonstrates three advantages for the computer-aided optimisation over
the analytical method. Firstly, the computer-aided method is easier to use because it is
applied to the basic objective function without differentiation. Secondly, it leads to more
realistic results because it can take into consideration the pressure and heat-transfer losses
in the compressors and the intercooler. Thirdly, accounting for the variation of the
specific heat with temperature makes the computer-aided method more accurate than the
analytical method that uses a constant specific heat. Optimisation analyses of thermofluid
systems may also involve one or more of the following complications that make the
analytical method practically impossible to apply:
1. The model may involve discrete-valued variables, such as the cost of material or
equipment, which are difficult to handle using analytical methods.
2. The model may involve too many details that require the lengthy manipulations.
This makes analytical optimisation both tedious and inaccurate.
3. The analytical method cannot deal with complex systems that involve multiple
parameters in the objective function.
As the following sections illustrate, with these complications the computer-aided method
becomes the only viable method for optimisation.
performed by using the GRG Nonlinear method of Solver and the default settings shown
in Figures 3.17 and 3.18.a.
Determine the most economic thickness of insulation based on the following data:
Ts T
Q
Rth
W/m (6.20)
Where Rth is the total thermal resistance to heat transfer by conduction through the pipe
and the insulation and by convection and radiation to the surrounding air.
Computer-Aided Thermofluid Analyses Using Excel 152
D2
D1
Neglecting the thermal resistance to heat transfer by conduction through the pipe and by
radiation from the outer insulation surface, the total thermal resistance becomes that due
to heat transfer by conduction through the insulation and by convection from the surface
of insulation casing to the surrounding air, i.e.:
ln D2 / D1 1
Rth
2k hoD2
(m.K/W) (6.21)
D2 D1 2 (m)
(6.22)
The total annualised cost (CT) is the summation of the annual heating cost and the
annualised cost of insulation given by:
CT C i C h (6.23)
Where Ci is the cost of insulation per meter length of the pipe and α is the amortisation
rate, which can be approximated by the following relationship:
1/ N (6.24)
Where N is the lifetime of insulation or period after which capital cost is written off. The
annual cost of heat lost to the surrounding (Ch) is given by:
C h Q / 10 6 c g t 3600 /
(p/m) (6.25)
Computer-Aided Thermofluid Analyses Using Excel 153
Although the objective function for optimisation in this case, which is Equation (6.23),
is a simple one, it is easier to handle the discrete data for the cost of insulation by using
the computer-aided method of optimisation than by using the analytical method.
The rate of heat loss (Q) is calculated as 111.3 W, which results in an annual cost
(C_total) of 450.9 p per metre length of the pipe. Adding the annualised cost of insulation
of 107.9 p, the total cost becomes 558.8 p. To allow the sheet to determine the cost of
insulation automatically for other values of δ, the following polynomial was obtained by
using Excel trendline feature to curve-fit the price data given above:
As shown in Figure 6.7, the above formula is entered in cell H3 that calculates the initial
cost (ci_ins). Figure 6.8 shows the variation of the cost of the annualised insulation cost
(C_ins), annual heat-loss (C_heat), and the total annualised cost (C_total) with the
thickness of insulation (δ) as obtained by changing the insulation thickness from 0 to 60
mm. It can be seen from the figure that the total cost has a minimum value at an insulation
thickness which is slightly greater than 40 mm. From a graph similar to that shown in
Figure 6.8, Eastop and Croft selected 50-mm as the optimum thickness of insulation. The
optimum insulation thickness can be determined more accurately by using Solver. Figure
6.9 shows the set-up for Solver Parameters dialog box to find the optimum value of δ (in
Computer-Aided Thermofluid Analyses Using Excel 154
the adjustable cell) by minimising the total annualised cost C_total (in the target cell).
Based on the given data, two constraints have been added to limit the thickness of
insulation within the range 19 ≤ δ ≤ 60 mm. The solution determined by Solver is shown
in Figure 6.10.
1600
1400 Insulation cost
1200 Fuel cost
Annual cost (p)
Figure 6.10 shows that Solver determined the optimum thickness of insulation as 42.8
mm. Since this thickness is not available in the given data, the nearest larger thickness
should be selected; which is 50-mm. The thicker insulation is selected so as to allow for
any possible increase in fuel cost in the future.
U = 613 W/m2.K
F = 0.817
cw = $1.32/m3
co = $215/(m2 .yr)
τ = 7800 hr/yr,
Where U and F are the overall heat exchanger coefficient and correction factor in
Equation (1.36), respectively, cw is the unit cost of producing the cooling water, and co is
unit cost of operating the heat-exchanger. Take the density of cold water ( c ) and its
specific heat (Cpc) as 994 kg/m3 and 4179 J/kg.K, respectively.
CT C AW C AO (6.27)
m
C AW 3600 c w (6.28)
Where cw is the cost of water per m3, τ is the total number of operation per year, and the
mass flow rate of cooling water ( m ) is in kg/s. Taking the time-value of money in
consideration, the annual cost of operating the exchanger is given by:
C AO Aco (6.29)
Where co is the annual cost of operating the exchanger per m2 of its area.
Both CAW and CAO depend on the cooling water exit temperature (To). Starting the iterative
optimisation process by an assumed value of this temperature, the mass flow rate of the
cold water ( m c ) can be obtained from the following equation:
Q / C pc Tco Tci
m (6.30)
Where cp, Tci, and Tco are the specific heat and inlet and exit temperatures of the cold
water, respectively. From Equation (C.4), the surface area (A) of the heat-exchanger is:
A Q / UFTlm (6.31)
The above analytical model indicates that, for a given rate of heat rejection to the cooling
water, the water outlet temperature depends on the water flow rate and the area of the
heat-exchanger. Increasing the water flow rate will increase the cost of cooling water, but
reduce the heat-exchanger area and the resulting annual operation cost. The optimum
water outlet temperature is that at which the total cost is minimal.
cells. Based on the assumed outlet temperature of the cold water, Figure 6.11 shows that
the annual cost of water is $61,453.36, the annual cost of operating the exchanger is
$14,317.57, and the resulting total annual cost is $75,770.93.
The sheet was used to calculate the heat-exchanger costs at different values of the
cooling-water outlet temperature and the results are shown in Figure 6.12. The figure
shows that, as the water temperature increases, the annual cost of water decreases but the
annual cost of operating the exchanger increases. The total annual cost initially decreases
as the water outlet temperature is increased but then increases. From the figure, it can be
seen that the optimum water outlet temperature is in the range 45 to 60oC. A more
accurate estimation of the optimum cooling-water outlet temperature can be determined
by using Solver. Figure 6.13 shows the required set-up in which two constraints have
been imposed on the optimisation process to ensure a physically meaningful result.
Figure 6.14 shows sheet with the solution found by Solver. The figure shows that the
optimum cooling-water outlet temperature is 53.27oC at which the total annual cost is
$26,666.4.
Computer-Aided Thermofluid Analyses Using Excel 158
80000
70000 C_AW
Annualised costs ($/yr) C_HX
60000
C_T
50000
40000
30000
20000
10000
0
20 40 60 80 100
Cold water exit temperrature (oC)
Figure 6.12. The variation of the total cost with the cooling water outlet temperature
Ts,hp Ts,1p
Two Tx Twi
Water
HP heater LP heater
Ts,h Ts,1
Saturated liquid water
Where Ci is the annual initial cost ($/year) and Cs is the annual steam cost ($/year) and
the subscripts hp and lp refer to the high-pressure heater and the low-pressure heater,
respectively. For a given heat exchanger, the steam cost is determined from the heat
transfer rate in the heater, which is also the amount of heat transferred to the water. Using
the notation shown in Figure 6.15, the rates of heat transfer in the two heaters can be
expressed as:
C p Tx Twi
Q lp m (6.33)
C p Two Tx
Q hp m (6.34)
Where m is the water mass flow rate. The annual steam costs for both heaters are:
C s ,hp a hp Q hp . (6.36)
Where a is the steam cost in $/kJ and τ is the operating hours per year. To determine the
annual initial cost of the two heaters, we must calculate their heat-transfer surface areas.
Using the log-mean temperature difference (LMTD) method described in Appendix C,
the surface of the low-pressure heater (Alp) is given by:
Alp Q lp / U lp Tlm,lp (6.37)
Where ΔTlm is the log-mean temperature difference which for the low-pressure heater is
defined as:
Tlp,1 Tlp, 2
Tlm,lp
lnTlp,1 / Tlp, 2 (6.38)
,
Where,
Tlp,1 Tslp Tx
(6.39)
,
Computer-Aided Thermofluid Analyses Using Excel 161
The relative cost of the low-pressure heater is simply the product of the heat transfer
surface area (Aip) and the unit cost per square meter (blp). If we apply the annual fixed
charge rate, the annual relative cost becomes:
Where β is the annual fixed charge rate. Combining Equations (6.37) and (6.41) gives:
C i ,lp
blp . .Q lp ln Tlp,1 / Tlp, 2 (6.42)
U lp Tlp,1 Tlp, 2
Similarly, the annual relative cost for the high-pressure heater is given by:
C i ,hp
bhp . .Q hp ln Thp ,1 / Thp , 2 (6.43)
U hp Thp ,1 Thp , 2
Where,
Equation (6.32), which is the objective function for optimisation, requires lengthy
calculations in order to determine the initial costs and the steam costs for both heaters.
Since the total cost depends on the intermediate temperature Tx, trying to obtain the
optimum value of Tx by the analytical method is bound to be a tedious and most likely
inaccurate procedure. The following numerical example illustrates the application of the
computer-aided method of optimisation with Excel and Solver.
Low-pressure High-pressure
heater heater
Steam pressure [kPa] 350 550
Steam cost [$/106 kJ] 5.7 5.72
Heater surface cost [$/m2] 108.7 109.8
Computer-Aided Thermofluid Analyses Using Excel 162
Excel implementation
Figure 6.16 shows the Excel sheet developed for this case. The top-left part of the sheet
shows the data provided above. The bottom-right part of the sheet shows calculations of
the steam and relative initial cost for the two heaters and their total for each heater. The
figure shows the calculations and total relative cost of the system at the top right-hand
side of the sheet for an intermediate temperature Tx = 125oC. We can determine the
optimal sizes of the two heaters by varying the intermediate temperature Tx and finding
the value at which the annual relative cost is minimal. Table 6.2 shows the heat load
distributions and surface areas of the two heaters for Tx in the range 65-135oC. It is seen
from the table that the heat load supported by the low-pressure heater increases as the
intermediate temperature Tx increases. Because of its large temperature differences,
however, the high-pressure heater always has the advantage over the low pressure heater
in terms of heat transfer surface area required. For instance, at Tx = 65oC, i.e. when the
heat load is solely supported by the high-pressure heater, the heater surface area is
approximately 207.41 m2. At Tx = 135oC, i.e. when supported mostly by the low-pressure,
the total surface area becomes 217.95+97.51 = 315.46 m2.
65 0 17850 0 207.41
75 2100 15750 10.76 198.74
85 4200 13650 23.35 188.93
95 6300 11550 38.54 177.61
105 8400 9450 57.67 164.24
115 10500 7350 83.54 147.91
125 12600 5250 123.67 126.93
135 14700 3150 217.95 97.51
Figure 6.17 shows the variation with Tx of the combined initial cost (C_initial), the
combined steam cost (C_steam), and the total combined cost (C_total). The figure shows
that the minimum combined initial cost is obtained at Tx = 65oC, while the minimum
combined steam cost is obtained at Tx =135oC. If only the initial cost is considered, then
a single high-pressure heater would be preferred for the hot water production. On the
other hand, if only steam cost is considered, then only a single low-pressure heater is to
be selected. However, the variation of the total relative cost with Tx indicates that the
minimum total cost occurs at an intermediate temperature which is around 115oC. At this
temperature, the figures in Table 6.2 indicate that the high-pressure heater will take one-
third of the total heat load while the low-pressure heater will supply the remaining two-
thirds. To precisely determine the optimum value of Tx, we can use Solver. Figure 6.18
shows the prepared Solver Parameters dialog box for the determination of the temperature
Tx that minimises the total cost. Two constraints have been inserted which are:
741000 8000
7000
739000
Initial and total cots ($)
6000
Steam cost ($)
737000 5000
4000
735000 3000
C_total 2000
733000 C_steam
1000
C_initial
731000 0
50 70 90 110 130 150
Intermediate temperature (Tx) oC
Figure 6.17. Variation of the systems costs with the intermediate temperature Tx
Computer-Aided Thermofluid Analyses Using Excel 164
Figure 6.18. Solver parameters dialog box for determining the optimum intermediate
temperature for two heat-exchangers in series
T x Ts , l
Tx Tw,in
Pressing the Solve button at the bottom of the dialog box will trigger Solver to iterate and
search for the value of Tx that makes the total cost assume its minimum value. Figure
6.19 shows the solution found by Solver, which is Tx=116.5oC. At the optimum
temperature, the surface area of the LP heater is 88.428 m2 while that of the HP heater is
145.07 m2. The relative cost of the LP heater is 446,004.8$ and that of the HP heater is
292,679.7$, giving a total relative cost of 738,684.4$. This result shows that steam cost
is an important variable in the optimisation of the hot-water production system. When
the steam cost for low-pressure heater is substantially lower than that for high-pressure
heater, it will definitely favour the use of a low-pressure heater. This is particularly true
when the hot water system is operated on a continuous basis.
Computer-Aided Thermofluid Analyses Using Excel 165
Analytical model
Using the definition of fin efficiency ( ηfin) introduced in Appendix B, the rate of heat
transfer from a fin ( Q fin ) can be determined from:
Computer-Aided Thermofluid Analyses Using Excel 166
T∞
Tb
Where Q max is the maximum possible rate of heat-transfer from the fin as given by:
Using the notation of Figure 6.20, the area of the fin Afin is given by:
For a rectangular fin with convection boundary condition at the tip the fin efficiency can
be obtained from:
tanh( mL c )
fin (6.51)
mL c
m 2h / kt (6.52)
Lc L t / 2 (6.53)
Where, k is the thermal conductivity of the fin’s material. The coefficient of heat transfer
h depends on the type of air-flow over the fin, which is established by calculating the
Reynolds number ( Re U L / ). For a laminar flow, h is calculated from [6]:
Computer-Aided Thermofluid Analyses Using Excel 167
k air 1/ 2 1/ 3
h 0.664 Re Pr (6.54)
w
Where, kair and Pr are the thermal conductivity and Prandtl number of air, respectively.
Excel implementation
Figure 6.21 shows the Excel sheet prepared for the solution of this example. The given
data are entered on the left-side column of the sheet. The mass of the fin is specified as 1
g of aluminium. The thickness of the fin (thickness) is initially assumed and given the
value of 2 mm. For this initial guess, the sheet calculates the Reynolds number (Re), heat-
transfer coefficient (h) and volume of the fin (Vol). The figure shows the formulae used
in the calculations.
V 0.001
L (6.55)
wt al wt
Where, ρal is the mass density of aluminium. The fin efficiency (ηfin) and maximum rate
of heat-transfer from the fin (Qmax) are determined from Equations (6.51) and (6.49),
respectively. As shown in Figure 6.21, the resulting rate of heat transfer is 0.037 W.
Solver can now be used to find the combination of t and L that gives the maximum
possible rate of heat transfer from the fin. Figure 6.22 shows the setting up for Solver
Parameters dialog box for the determination of the thickness that maximises the rate of
heat transfer from the fin. No constraints have been inserted for this case. Pressing the
Solve button at the bottom of the dialog box will trigger Solver to iterate and search for
the value of t that maximise the fin’s heat transfer rate. Figure 6.23 shows that the
required thicnkness is t=0.00036 m or 0.36 mm. The corresponding length is 0.046 m or
4.6 cm and the resulting heat transfer rate is 0.044 W.
Computer-Aided Thermofluid Analyses Using Excel 168
natural types. Since the cost of the cooling system constitutes a major fraction of the total
installation cost, the optimisation of its components is important for the economic
feasibility of the whole plant. Example 6.3 considered earlier dealt with the optimisation
of the heat-exchanger that transfers the rejected heat from the power plant condenser to
the cooling water. The following example focuses on the cooling tower and illustrates
the use of Excel for its optimisation. The example is based on Problem 11.7 given by
Stoecker [7].
Cooling
Tower QR
Turbine
Condenser Tc
The three components of the total cost are estimated by the following formulae:
C 2 0.0005 m 3 (6.57)
C 3 270 Tc (6.58)
Where A is the cooling-tower area in m2, m is the flow rate of cooling water in kg/s, and
Tc is the temperature of water entering the condenser in oC. The rate of heat rejection (QR)
is also known to be related to the three factors by the following empirical formula:
Computer-Aided Thermofluid Analyses Using Excel 170
It is required to determine the values of the three design variables A, m , and Tc, that
minimise the total cost of the cooling system (CT) given by:
CT C1 C 2 C 3 (6.60)
Solution
The objective function for optimisation in this case is Equation (6.60). Although three
variables are involved in the optimisation process, which are A, m , and Tc, Equation
(6.59) can be used to reduce the number to two variables only, e,g. A and m . Figure 6.25
shows the Excel sheet developed for this example. The only data in this problem is the
rate of heat rejection (Qcooling) which is assigned the given value of 14 MW. The
intermediate calculations start with initially assumed values for the water flow rate
(m_w=500 kg/s) and the area of the cooling tower (A=150 m2). Based on these assumed
values, Equation (6.59) is used to calculate the cooling-water temperature (T_cw) and
then the three costs given by Equations (6.56) - (6.60). Figure 6.25 reveals the formulae
used in these calculations. As Figure 6.25 shows, the cooling-water turned out to be about
14.56oC and the resulting total lifetime cost (C_T) is $82,601.68. The values of m_w and
A that minimise the total cost C_T can be found by using Solver and Figure 6.26 shows
the required set-up for Solver Parameters dialog box.
The set-up in Figure 6.26 requires Solver to minimise the total cost (C_T) by adjusting
the values of the two parameters, m_w and A. Although no constraints have been
specified, a better practice would be to apply reasonable upper and lower limits on the
two optimisation variables. The solution found by Solver is shown in Figure 6.27. As the
figure shows, the optimum mass flow rate for the cooling water is 202.52 kg/s and the
optimum area of the cooling tower is 167.95 m2. The value obtained for the water mass
flow rate agrees well with that given by Stoecker [7], which is 202.6 kg/s. Stoecker [7]
did not give the optimum value for the heat-exchanger area.
Computer-Aided Thermofluid Analyses Using Excel 171
Figure 6.26. Set-up of Solver Parameters dialog box for Example 6.6
is discharged at a point 16 m downstream of the duct entrance. The remaining part (Q2 =
0.4 m3/s) is discharged at the end. Ambient temperature (T∞2) is 15oC and the outside
heat-transfer coefficient h2 is 30 W/m2.oC. The air duct is to be assembled from 1-m-long
prefabricated units made of 3-mm galvanized sheet metal and, to minimise heat losses to
the surroundings, it is decided to insulate the duct with fiberglass.
L1 L2
Q1 Q2
D1 D2
Q3
It is required to determine the diameters of the two duct sections (D1 and D2) and the
thicknesses of insulation (δ1 and δ2) that minimise the total owning cost based on the data
provided below.
Duct data:
Thermal conductivity (kd) = 18 W/m.oC
Duct roughness (ε) = 0.045mm
Cost of 1-m unit (cd) is as shown in Table 6.3.
Operation data:
365 days per year 24 hours per day
Energy costs:
Cost of electricity (cE): 0.12 $/kWh
Cost of fuel (cF): 0.5 $/therm (1 therm = 105500 kJ)
Capital recovery factor (i) = 0.15
Computer-Aided Thermofluid Analyses Using Excel 173
The idea of this example stemmed from a case given by Janna [3] which could be solved
analytically. The addition of insulation to the duct in the present example makes the
optimisation process involves four parameters instead of two as in the case considered by
Janna [3] and, therefore, the example is difficult to solve analytically.
Where:
How the three components of the total cost are evaluated is explained below.
a) Initial cost
The initial cost (CI) has two parts: (1) the cost of the duct itself (Cduct) and (2) the cost of
insulation (Cins). The two parts are given by:
Where:
Where W fan is the power consumed by the air-circulation fan and cE is the electricity tariff
in $/kW.hr. The power of the circulation fan depends on the friction head losses (hf) in
both sections of the duct which are given by the Darcy-Weisbach equation, Equation
(1.21). The friction factor ( f ) in each section of the duct, which depends on the Reynolds
number in the section, is obtained from the Swamee-Jain equation (Equation 1.25). The
total power consumed by the air-circulation fan ( W fan ) is then determined as follows:
air g h f ,1Q1 h f , 2 Q2
W fan (kW) (6.65)
1000
Q Total [W ] t[hr]
CF cF
1000 105500 ($) (6.66)
Where cF is the cost of fuel in $/therm and t is the total number of operation hours in a
year. The total heat loss ( Q ) is the sum of the heat loss in both sections, i.e. Q
Total = Total
Q1 + Q 2 , where the heat loss ( Q ) in each section is calculated according to the formula:
Where T∞1 and T∞2 are the inside and outside air temperatures and Rth is the total thermal
resistance of the series resistances shown in Figure 6.29.
r2 T∞2
r1
r3
T∞1
T1
T2
T3
T1 T2 T3
T∞1 T∞2
Ri R1 R2 Ro
1 ln r2 / r1 ln r3 / r2 1
Rth (m.K/W) (6.68)
2r1 h1 L 2k d L 2k s L 2r3 h2 L
Where r1, r2 and r3 are the radii shown in Figure 6.29. Note that the value of the outside
heat-transfer coefficient (h2) is constant, but the inside heat-transfer coefficient (h1),
which depends on the air velocity, changes with the inside diameter of the duct and
therefore, has to be determined from the Nusselt number (Nu). For fully developed
turbulent flow in tubes, the Nusselt number is calculated from the Dittus–Boelter
equation, Equation (1.31), with n = 0.3 [6]:
k air
h1 Nu (W/m2.oC) (6.70)
D1
Excel sheet
Figure 6.30 shows the Excel sheet developed for this example. The problem data are
shown in the two columns at the left side of the sheet. The calculations part has two
columns for the two sections of the duct. The calculations stat by guessed values for the
two diameters (D_1 and D_2) and two insulation thicknesses (δ_1 and δ_2) in both
sections of the duct. The results part determines the total friction loss (hf_total), the fan
power (Power), and the different costs involved. The formula bar shows how the annual
cost of electricity is determined. The sheet determines the total annual cost (C_total) for
the guessed values of D_1=0.3m, D_2=0.2m, δ_1=0.1m and δ_2=0.1m.
To allow Excel to automatically calculate the cost of duct unit (cd) when the two duct
diameters are changed, the following equation for cd was obtained by using Excel’s
trendline feature from the data shown in Table 6.3:
Solver can now be used to find the optimum values of D_1, D_2, δ_1 and δ_2. As shown
in Figure 6.31, the set-up box for Solver requires it to minimise the total cost (C_total),
which is the target cell, by changing the values of the two diameters (D_1 and D_2) and
the two insulation thicknesses (δ_1 and δ_2), which are the adjustable cells. Figure 6.32
shows the Excel sheet with the solution found by Solver. The optimised dimensions found
by Solver are shown in Table 6.4 which also shows the different cost involved. The
nearest dimeters are D_1=0.4 m and D_2=0.3 m. Both insulation thicknesses are ≈ 0.3
m. The total annual cost sums up to 479.7 $.
Computer-Aided Thermofluid Analyses Using Excel 176
D2 Q3 / Q1 D1 (6.72)
Equation (6.72) allows us to solve the optimisation problem with only three variables,
which are D1, δ1 and δ2. The solution determined by Solver with D1, δ1 and δ2 as adjustable
cells is also shown in Table 6.4. Comparison with the solution obtained without Equation
Computer-Aided Thermofluid Analyses Using Excel 177
(6.72) indicates that the rule-of-thump leads to a larger D1 and a smaller D2. Although
the insulation thicknesses on the two section are only marginally affected, the figures in
the table show that the total cost (486.2$) has increased due to increases in the initial cost
of the duct (132.1$) as well as the annual cost of electricity (186.4$). By suitably
adjusting the given data, the Excel sheet can be used to study the effects of electricity
cost, fuel cost, or capital recovery factor on the opimised solution.
Figure 6.33. Solver solution for Example 6.3 with the Evolutionary method
Figure 6.34. Solver solution for Example 6.7 with the Evolutionary method
Both solutions were obtained with the default set-up shown in Figure 3.17 and Figure
3.18.b. As Figures 7.29 and 7.30 show, the two solutions are identical to those obtained
earlier with the GRG Nonlinear method shown in Figures 7.14 and 7.35, respectively.
Computer-Aided Thermofluid Analyses Using Excel 179
With the default options of the Evolutionary method shown in Figure 3.18.b, Solver took
more than 100 seconds to solve Example 6.3 which required less than one second with
the GRG Nonlinear method. Example 6.7 required more than 110 seconds with the
Evolutionary method. As mentioned in Chapter 3, the computational time of the
Evolutionary method can be reduced by adjusting the default set-up for the method shown
in Figure 3.18.b to reduce the population size from 100 to 10. With this adjustment, the
Evolutionary method took about one second to solve Example 6.3, but took about 24
seconds to solve Example 6.7 that involved four parameters.
6.5. Closure
This chapter showed how the Excel-based platform can be utilised for optimisation
analyses of thermofluid systems. The chapter initially highlighted the limitations of
traditional optimisation methods that apply calculus techniques and the advantages of the
computer-aided optimisation method. Four examples were then considered that dealt with
optimisation analyses involving a single design parameter, but the computer-aided
optimisation method was indispensable because the mathematical model either involved
lengthy calculations, nonlinear equations, or discrete-valued variables. The advantage of
the computer-aided optimisation method becomes more appreciable when the
optimisation process involves multiple parameters. In this respect, the chapter showed
how Solver can be used to handle optimisation analyses of insulating an air-conditioning
duct consisting of two sections with different diameters. Finally, the chapter considered
using the Evolutionary method instead of the GRG Nonlinear method. It was shown that
the computer time of the Evolutionary method can be reduced by suitable adjustment to
the default values of its options.
References
[1] Y.A. Cengel and M.A. Boles, Thermodynamics an Engineering Approach,
McGraw-Hill, 7th Edition, 2007
[2] T.D. Eastop and D.R. Croft, Energy Efficiency for Engineers and Technologists,
Longman Scientific & Technical, 1990.
[3] W.S. Janna, Design of Fluid Thermal Systems, 3rd Edition, CENGAGE Learning,
2011.
[4] K.W. Li and A.P. Priddy, Power Plant System Design, John Wiley and Sons, 1985.
[5] A. Bejan, G. Tsatsaronis, M. Moran, Thermal Design & Optimisation, John Wiley
& Sons, 1996.
[6] Y.A. Cengel, and A.J. Ghajar, Heat and Mass Transfer: Fundamentals and
Applications. McGraw-Hill, 2011.
[7] W. Stoecker, Design of Thermal Systems, McGraw-Hill, 1989.
[8] The duct shop, https://www.theductshop.com/shop/catalog-galvanized-sheet-metal-
duct-c-1_3.html, last accessed 24/12/2015.
Exercises
Computer-Aided Thermofluid Analyses Using Excel 180
1. Using the analytical optimisation procedure, show that the compression ratios that
minimise the total work input for in a multi-stage compression systems with n
compression stages and a maximum compression ratio rp,max are given by:
r p1 r p 2 .... r p ,n 1 r p ,n n r p , max
2. An air compressor with three stages of compression takes atmospheric air at 300K
and 100 kPa and delivers it at a final pressure of 900 kPa. The adiabatic efficiency
of the three compressors (ηc) is 85%. Each one of the intercoolers that cool the air
after the first and second stages causes a pressure drop of 5 kPa and has effectiveness
(ε) of 85%. By suitably extending the Excel sheet developed for Example 6.1,
determine the exit pressures of the first and second stages, Px and Py, respectively,
that minimise the total compression work.
3. Air, initially at a pressure of 175 kPa and a temperature of 50oC, is to be compressed
to a final pressure of 17,500 kPa by means of a two-stage compression system that
consists of a centrifugal compressor in series with a reciprocating compressor as
shown in Figure P6.3.
P2 = 17,500
kPa
Intercooler
T1 = 50oC
Reciprocating
Compressor
Centrifugal
Compressor
Po = 175 kPa
To= 50oC
Qo= 15 m3/s
Figure P6.3. The air compression system with centrifugal and reciprocating
compressors in series
The advantage of this arrangement is that centrifugal compressors can handle high-
volume flow rates but develop only low pressure ratios while reciprocating
compressors are suited to low-volume flow rates but can develop high pressure
ratios. The initial flow rate of air is 15 m3/s and its temperature after the intercooler
can be taken as the same as the inlet temperature of 50oC.
The first costs of the centrifugal and reciprocating compressors can be represented
by the following formulae:
Computer-Aided Thermofluid Analyses Using Excel 181
P1
C c 70Qo 1600 ($) (A)
P0
P
C r 200 Q1 800 2 ($) (B)
P1
Where Cc and Cr are the first costs of the centrifugal and reciprocating compressors,
respectively, and Q0 and Q1 are the corresponding volume flow rates.
(a) Treating air as a perfect gas, develop the relevant analytical model and objective
function for optimisation in terms of the pressures and flow rates appearing in
Equations (A) and (B).
(b) Use Solver to determine the optimum intermediate pressures and the
corresponding total initial cost of the system.
This exercise is based on Problem 8.5 in Stoecker [7], p 178, Answer: minimum cost
= $24,100
4. A gas turbine operates on a regenerative Brayton cycle with air entering the
compressor at 100 kPa, 300 K. As shown in Figure P6.4, the hot exhaust gas is used
to preheat the compressed air before the combustion chamber. The combustion gases
leave the combustion chamber (CC) at 1400 K. Take the regenerator effectiveness
as 80% and the isentropic efficiency of both compressor and turbine as 75%.
Pressure losses can be neglected.
Regenerator
T6, P6
CC
T3, P3 T4, P4 T5, P5
T2, P2
T1, P1
(a) Treating the working fluid (air) as an ideal gas and using the exact method of
analysis and the functions provided Thermax for ideal gases, develop a model
that determines the thermal efficiency of the regenerative gas-turbine cycle.
(b) By varying the pressure ratio from 2 to 16, study the effect of pressure ratio on
the thermal efficiency of the plant.
Computer-Aided Thermofluid Analyses Using Excel 182
(c) Use Solver to determine the pressure ratio that maximizes thermal efficiency.
5. Consider the steam power plant that operates with one closed feedwater heater as
shown in Figure P6.5. Steam enters the high-pressure turbine at 15 MPa and 600°C
where it expands to a pressure of 700 kPa after which it is returned to the steam
generator house for reheating to a temperature of 550oC. The steam then expands in
the low-pressure turbine and then condensed in the condenser at a pressure of 10
kPa. A fraction y of the steam leaves the low-pressure turbine at an intermediate
pressure Pi which is passed to the closed feedwater heater.
3 HP LP
Turbine Turbine
4
y 6
Steam
Generator 5
8 Condenser
11 7 2
1
10 Pump I
9
Pump II
Using reasonable upper and lower limits on the value of Pi, develop an Excel-
Thermax sheet to determine the value of Pi that maximises the thermal efficiency of
the cycle and determine the corresponding fraction y of steam extracted from the
turbine.
6. Two identical pumps operate in parallel as shown in Figure P6.6 to deliver a total of
0.01 m3/s of water at 15oC. The head losses hL1, hL2 in the lines depend upon
volumetric flow rates Q1, Q2 according to the following formulae:
Where Q1 and Q2 are the respective flow rates in cubic meters per second.
Computer-Aided Thermofluid Analyses Using Excel 183
(a) Develop the mathematical model for determining the flow rates delivered by the
two pumps that minimize the total pumping power.
(b) Develop the Excel sheet with appropriate water properties and use Solver to
determine the optimum values for the pumps flows.
0.01 m3/s
Q Q
1
This exercise is based on Problem 8.3 in Stoecker [7], p. 177. Answer: Q1=0.00567
m3/s, Q2=0.00433 m3/s.
Hint:
7. Figure P6.7 shows a circular air duct system is to be design based on the following
data:
16 m 12 m 20 m
Q1 Q4
D1 D2
D3 B
A Q2 Q3
Figure P6.7. The air duct system
Computer-Aided Thermofluid Analyses Using Excel 184
It is required to determine the values of the three diameters D1, D2 and D3 that
minimize the drop in static pressure between points A and B.
(a) Set up the objective function and constraints in terms of D1, D2 and D3.
(b) Using Excel and Solver, determine the optimal diameters and the minimum total
head loss.
This exercise is based on Problem 8.9 in Stoecker [7], p 182. Answer: D1,= 0.468 m
D2 = 0.426m and D3.= 0.325 m. hf = 17.203 m.