You are on page 1of 15

Java Applet on Computation

of Thermodynamic
Properties of Steam
and R134a Refrigerant
F. L. TAN, PATRICK S. K. CHUA
School of Mechanical and Production Engineering, Nanyang Technological University, 50 Nanyang Avenue,
Singapore 639798

Accepted 7 July 2003

ABSTRACT: This paper describes the application of Java programming on the computa-
tion of thermodynamic properties of steam and the HFC-134a, 1,1,1,2-tetrafluoroethane
(R134a) refrigerant through the Java applets. The Java applets can compute thermodynamic
properties of steam and R134a refrigerant, such as specific volume, internal energy, enthalpy,
and entropy in the phases of saturated mixture, compressed liquid, and superheated vapor.
The calculated values are accurate compared to the standard reference properties tables for
steam and refrigerant. ß2004 Wiley Periodicals, Inc. Comput Appl Eng Educ 11: 211225, 2003; Published
online in Wiley InterScience (www.interscience.wiley.com.); DOI 10.1002/cae.10049

Keywords: Java applet; thermodynamic properties; steam; R134a refrigerant

INTRODUCTION erant. It may exist in more than one phase, like the
water, a mixture of water and water vapor (steam),
The thermodynamic properties of a pure substance solid ice, or a mixture of ice and water. In a ther-
such as temperature, pressure, specific volume, modynamic system, the thermodynamic properties of
enthalpy, entropy, and internal energy are essential the working substances at different phases in the
in the analysis and computation of various thermo- various thermodynamic processes (e.g., compression,
dynamic systems (e.g., steam power plant and vapor expansion, heat addition, etc.) have to be determined
compression refrigeration system). A pure substance before performing calculations on quantities such as
is the one that has a homogeneous and invariable thermal efficiency and power consumption.
chemical composition, for example steam and refrig- Tables of thermodynamic properties of many sub-
stances are available, for example the standard steam
tables. Manual calculations using these property tables
Correspondence to F. L. Tan (mfltan@ntu.edu.sg). and charts have been used by students in solving ther-
ß 2004 Wiley Periodicals Inc. modynamic problems. The use of thermodynamics
211
212 TAN AND CHUA

properties application software can help to reinforce ties have been obtained by many experimental and
the understanding of the properties tables and charts. modeling studies. Various equations of states for
Some of the more reliable and established software R134a has been established by several researchers
include STEAM, STEAMCALC [1], R134aTAB, and [4,5]. A formulation known as the ‘‘International
ALLPROPS. The FORTRAN programming is a Standard Formulation for the Thermodynamic Proper-
commonly used programming language in the devel- ties of 1,1,1,2-Tetrafluoroethane (HFC-134a)’’ was
opment of the application software. Most of these reported by TillnerRoth [6]. This formulation is
computer programs, except for ALLPROPS, are devel- effective for temperatures from 170 K to 445 K and
oped and implemented by the American Society of pressures up to 70 MPa. It is internationally adopted
Mechanical Engineers (ASME). as the basis for the preparation of standard thermo-
With the rapid evolution of Internet, there are dynamic property tables and charts for R134a.
several web sites that provide online computation of This paper describes the development of Java
thermodynamic properties for steam and other pure programs called Java applets for the Internet browsers
substances. The accuracy of the results generated to compute the thermodynamic properties of steam
through the online website is comparable to those and refrigerant 134a. The Sun Microsystems Java 2
generated by the desktop application software. In Development Kit is used to develop two Java applets.
addition, it is also a time-saving process. Hence, One Java applet can generate standard saturated pro-
online thermodynamic computation serves as a con- perties over a specified temperature range. The other
venient way to obtain information on thermodyna- applet can compute thermodynamic properties at a
mic properties, especially when other conventional given single-phase thermodynamic state in the satu-
methods are not available. rated mixture, sub-cooled or compressed liquid, and
Obtaining information from the Internet has superheated vapor regions.
become a trend for most people in the modern day
world. Besides the desktop personal computer (PC),
other devices have been developed to access informa-
COMPUTATION OF
tion via the Internet. These Internet capable devices
THERMODYNAMIC PROPERTIES
include personal digital assistants (PDAs) such as
PalmOS, and wireless application protocol (WAP)
Thermodynamic Properties
compatible devices, which are usually cell phones. As
such, an integration of basic thermodynamic property The pressure-specific volumetemperature relation-
computation with the Internet would be desirable. ship for a substance can be represented by a three-
The equations adopted in the 1967 IFC Formula- dimensional thermodynamic surface with P ¼ P(v, T).
tion for Industrial Use (IFC-67) are used to predict the It shows the regions where only one phase exists such
properties of water and steam over a wide range of as solid, liquid, and vapor, and the regions where
temperature (from 273.16 K to 1073.15 K) and pres- two phases exist simultaneously such as solidliquid
sure (from 0 to 1,000 bar). They form the basis for the (SL), solidvapor (SV), and liquidvapor (LV).
thermodynamic tables and charts in the improved On the P-v-T surface, the triple line is a line of
ASME steam tables [2]. In September 1997, the constant temperature and pressure where all the three
International Association for the Properties of Water phases (liquid, solid, and vapor) coexist. At pressure
and Steam (IAPWS) adopted a new formulation for above the pressure of the critical point, the liquid
the thermodynamic properties of water and steam for substance simply changes to the vapor state without a
industrial use. This new industrial standard is called constant vaporization process. The P-v-T surface may
‘‘IAPWS Industrial Formulation for the Thermo- be projected onto the P-v plane, the T-v plane, and the
dynamic Properties of Water and Steam’’ (IAPWS- P-T plane, thus obtaining the P-v, T-v, and P-T
IF97). The formulation IAPWS-IF97 replaces the diagrams. The triple line on the P-v-T surface appears
previous industrial standard IFC-67. Based on the to be a point, when viewed parallel to the v-axis on the
IAPWS-IF97 formulation, a new steam table, entitled P-T diagram, is called a triple point.
‘‘Properties of Water and Steam’’ by Wagner and A constant pressure line is shown on a T-v
Kruse [3]. This steam table contains a complete diagram as shown in Figure 1 while a constant tem-
description of the equations of IAPWS-IF97 neces- perature line is shown on the P-v diagram. A saturated
sary for using the equations. vapor lies on the saturated vapor line while a saturated
The HFC-134a, 1,1,1,2-tetrafluoroethane, or liquid on the saturated liquid line. The region to the
commonly known as the R134a, is one of the most right of the saturated vapor line is the superheated
promising alternative refrigerants. As such, its proper- vapor region and the region to the left of the saturated
JAVA APPLET ON COMPUTATION OF THERMODYNAMIC PROPERTIES 213

For gases or substance in vapor phase region


that has relatively low density, the pressure, specific
volume, and temperature are governed by the ideal gas
law as follow:
Pv ¼ RT
where R is a constant for a particular gas and is
known as the gas constant. The above equation is
known as the ideal-gas equation of state [7]. Any
gas for which this equation is valid is called an ideal
gas or a perfect gas. The ideal gas law is valid at low
pressure.
The behavior of a gas deviates from its ideal
Figure 1 T-v diagram. gas behavior at higher pressure. The non-ideal gas
behavior occurs when the pressure is relatively high
(>4 MPa for many gases) or when the temperature
liquid line is the compressed liquid region which is
is near the saturation. There are many equations
also known as the sub-cooled liquid region. When the
pressure and temperature are greater than the critical of state that have been recommended for use to
account for such behavior. An example is the van der
values, the substance is in a supercritical state. In the
Waals equation of state [7], which accounts for
region between the saturated liquid line and the
the volume occupied by the gas molecules and
saturated vapor line, the substance is in a saturated
for he attractive forces between the molecules. It is
mixture state. In the LV region, the substance exists
given by
as both the liquid and vapor phases.
In the saturated mixture region, the tempera- RT a
P¼  ð1Þ
ture and pressure are dependent. Hence, specifying ðv  bÞ b2
the pressure and temperature will not establish the
state of a mixture. To establish the state of a mixture, a where a and b are given by the following:
property other than temperature needs to be specified 27R2 Tc2 RTc
if the pressure is specified. Conversely, if the tempera- a¼ ; b¼
64Pc 8Pc
ture is specified, a property other than pressure must
be stated. Other properties that may be used include Pc and Tc are the critical pressure and temperature,
internal energy, enthalpy, and entropy. respectively.
The state of a mixture can also be determined An improved equation is the RedlichKwong
indirectly if the quality of the mixture is known. The equation of state [8], which is
quality is a value that describes the relative composi- RT a
tion of the liquid and vapor phases in a mixture. It is P¼  pffiffiffiffi ð2Þ
ðv  bÞ ½vðv þ bÞ T 
defined as the ratio of the mass of saturated vapor to
the total mass of the mixture and is designated by the where
symbol x. The point 3 on the T-v diagram in Figure 1
represents any state (T, v) between the saturated liquid 0:4275R2 Tc2:5 0:0867RTc
a¼ ; b¼
at point 1 and saturated vapor at point 2, liquid and 64Pc Pc
vapor exist as a mixture in equilibrium vf and vg re-
present the specific volumes of the saturated liquid and Another important equation of state that is used
the saturated vapor, respectively. The specific volume for many substances including steam is the Virial
of the saturated mixture can be found as follows: equation of state [8]. This equation presents the
v ¼ vf þ xðvg  vf Þ product Pv as a series expansion. The most common
v ¼ vf þ xvfg expansion is

Other thermodynamic properties such as enthalpy RT BðTÞ CðTÞ


P¼ þ 2 þ 3 þ  ð3Þ
and entropy can also be found in a similar manner as v v v
follow: The functions B(T), C(T), etc., represent the
h ¼ hf þ xhfg
corrections to the ideal gas law and must be specified
s ¼ sf þ xsfg for the particular gas or substance.
214 TAN AND CHUA

From the First law of Thermodynamics, the Substituting Equation (11) into Equation (10) and
following relation between the specific internal integrating over a path of constant temperature, and
energy (u), pressure (P), specific volume (v), and the using dv ¼  dr/r2, one finds
specific enthalpy of a system can be obtained:
ðT ð r  "   #
0 1 @P
h ¼ u þ Pv ð4Þ u¼ cv ðTÞdT þ 2
PT dr þ u0
T0 0 r @T r
Applying the First law and Second law of
Thermodynamics and Maxwell relations [8], we can ð12Þ
obtain the following relations:
    T0 is a chosen reference temperature. The cons-
@P tant u0 is a term used as a desired datum for u.
du ¼ cv dT þ T  P dv ð5Þ
@T v The entropy is determined from the Gibbs
    equation,
@v
dh ¼ cP dT þ v  T  P dP ð6Þ    
@T P 1 P
c    ds ¼ du þ dv ð13Þ
v @P T T
ds ¼ dT þ dv ð7Þ
T @T v
Using Equations (10) and (11), one finds
where
  c    
@u v 1 @P
cv ¼ ds ¼ dT  dr ð14Þ
@T T r2 @T r
v

As only the changes in internal energy, enthalpy, By adding and subtracting a term Rdr/r from
and entropy are of practical interest, we can arbitrarily Equation (14), and then integrating on the path of
choose the datum state from which to measure h, u, constant temperature, one gets
and s. From Equation (4), we have
ðT 0
h2  h1 ¼ u2  u1 þ P 2 v 2  P1 v 1 ð8Þ cv ðTÞ
s¼ dT  Rlnr
T0 T
Thus, if we have an equation of state where P is a ð r  "   # ð15Þ
function of T and v (i.e., P ¼ f(T,v)), we can find the 1 @P
þ 2
rR  dr þ s0
change of internal energy (u2u1) from Equation (5) 0 r @T r
and the change of enthalpy (h2h1) from Equation (8).
s0 is a constant that can be chosen as a desired datum
for s. Given the analytical expressions for P(r, T) and
Computation of
c(T), together with known constants, the values of P, u,
Thermodynamic Properties
s, and h can be calculated for specified values of T and
The general approach in the computation of thermo- r. There are four basic equations required to compute
dynamic properties of a simple compressible sub- the thermodynamic properties. Given the four basic
stance [9] is illustrated below. Two basic expressions equations and the relevant constants for a substance,
that are required in the computation are the P-r-T the thermodynamic properties for that substance can be
equation and c0v ðTÞ equation, where r is the density of computed. Each substance has a unique set of constants
the substance and c0v is the specific heat of an ideal gas and datum states. The four basic equations for water
at low density. and R134a refrigerant are summarized below:
The general expression for the internal energy of
a simple compressible substance is Basic Equations for Water
u ¼ uðT; vÞ ð9Þ
(i) Saturation pressure equation:
Differentiating Equation (9),    X8
  Psat Tc
@u ln ¼ 1 Fi ½aðT  Tp Þi1 ð16Þ
du ¼ cv dT þ dv ð10Þ Pc T i¼1
@v T
An important thermodynamic relationship is (ii) P-r-T equation:
       
@u @P @Q
¼T P ð11Þ P ¼ rRT 1 þ rQ þ r2 ð17Þ
@v T @T v @r T
JAVA APPLET ON COMPUTATION OF THERMODYNAMIC PROPERTIES 215

(
X
7 Equations for R134a
Q ¼ ðt  t0 Þ ðt  taj Þj2
j¼1
" #) (i) Saturation pressure equation:
X
8 X
10
 Aij ðr  r0 Þi1 þ eEr Aij ri9
i¼1 i¼9 lnðPsat ÞR ¼ TR1 b7:6510ð1  TR Þ
ð18Þ þ 1:8458ð1  TR Þ1:5  0:6821ð1  TR Þ2
where  3:059ð1  TR Þ3 c
Ta Ta Ta ð22Þ
t¼ ; t0 ¼ ; ta1 ¼ tc ¼ ;
T T0 Tc where
taj ¼ 2:5; j>1
Psat T
(iii) Saturated liquid density equation: ðPsat ÞR ¼ ; TR ¼
Pc Tc
"   #
X
8
T 1=3 (ii) P-r-T equation:
rf ¼ rc 1 þ Di 1  ð19Þ
i¼1
Tc
9     
TR rR X ai2 ai3
(iv) Internal energy equation: PR ¼ þ ai1 þ þ
Zc i¼2
TR TR2
    ð23Þ
ðT ai4 ai5
þ 3 þ riR
u¼ c0v ðTÞdT TR TR5
T0
ð r  "   # ð20Þ
1 @P P r T Pc
þ 2
PT dr þ u0 PR ¼ ; rR ¼ ; TR ¼ ; Zc ¼
0 r @T r Pc rc Tc Rrc Tc

(v) Entropy equation: (iii) Saturated liquid density equation:

ðT
c0v ðTÞ rf ¼ rc b1 þ 2:45ð1  TR Þ0:38
s¼ dT  Rlnr ð24Þ
T0 T þ 0:4403ð1  TR Þ1:6 c
ð r  "   # ð21Þ
1 @P
þ 2
rR  dr þ s0 where
0 r @T r
T
The constants in the above equations, a, rc , taj , TR ¼
Aij , Di , Fi , T0 , Ta , Tc are constants in the above Tc
equation, which are obtained from Reference [9]. (iv) Enthalpy equation:

hR ¼ h=T R RZ C
( )
X
9
¼ f R þ TR ½ðai2 =T 2R Þ þ ð2ai3 =T 3R Þ þ ð3ai4 =T 4R Þ þ ð5ai5 =T 6R Þðri1
R =i  1Þ  lnrR =Z C
i¼2
ð25Þ
X
9
þ ½ai1 þðai2 =T R Þ þ ðai3 =T 2R Þ þ ðai4 =T 3R Þ þ ðai5 =T 5R Þri1
R þ T R =Z C þ ðT R =Z C Þ
i¼1

 fðC1  1ÞlnðT R =T 0R Þ þ C 2 ðT R  T 0R Þ þ C 3 ½T 2R  ðT 0R Þ2 =2 þ C4 ½T 3R  ðT 0R Þ3 =3 þ CS g

X
9
fR ¼ ½ai1 þ ðai2 =T R Þ þ ðai3 =T 2R Þ þ ðai4 =T 3R Þ þ ðai5 =T 5R Þðri1
R =i  1Þ
i¼2
ð26Þ
þ T R lnrR =Z C þ ð1=Z C ÞfðC 1  1Þ ½T R  T 0R  T R lnðT R =T 0R Þ  C 2 ðT R  T 0R Þ2 =2
 C 3 ½T 3R  3ðT 0R Þ2 T R þ 2ðT 0R Þ3 =6  C 4 ½T 4R  4ðT 0R Þ3 T R þ 3ðT 0R Þ4 =12  CS ðT R  T 0R Þ  Cf g
216 TAN AND CHUA

(v) Entropy equation: volume at the saturated vapor state (vg) for both
substances is determined by iterations and linear
SR ¼ s=RZ C
interpolation of the data from standard property
X
9
tables. The next saturated property to be computed
¼ ½ðai2 =T 2R Þ þ ð2ai3 =T 3R Þ þ ð3ai4 =T 4R Þ is the specific enthalpy at saturated vapor state (hg).
i¼2
For R134a, this is attained by the application of
þ ð5ai5 =T 6R Þðri1
R =i  1Þ  lnrR =Z C ð27Þ Equations (25) and (26). As for steam, the specific
 ð1=Z C ÞfðC 1  1ÞlnðTR =T 0R Þ internal energy at saturated vapor phase (ug) is first
computed using Equation (20). Then, hg for steam is
 C2 ðT R  T 0R Þ  C 3 ½T 2R  ðT 0R Þ2 =2
calculated using Equation (32). The specific enthalpy
 C4 ½T 3R  ðT 0R Þ3 =3  C S g of vaporization hfg, for each substance is then deter-
mined from Equation (28). Subsequently, the specific
The constants in the above equations, aij , rc , C1 , enthalpy at saturated liquid state hf, for each substance
C2 , C3 ; C4 , C5 , CS , Cf , Pc , R, Tc are constants in the can be found by subtracting hfg from hg.
above equation, which are obtained from Reference [5]. The procedures for determining the saturated
There are other thermodynamic relations that are specific entropies for both substances are similar. The
used in the computation of thermodynamic properties specific entropy at saturated vapor phase (sg) is
for both steam and R134a. The relations are as follow: computed using the respective entropy equation for
each substance (i.e., Equation (21) for steam and
(i) Enthalpy of vaporization equation (from Equation (27) for R134a). Then, the specific entropy
Clapeyron equation): of vaporization (sfg) is found from Equation (30).
  Finally, the specific entropy at saturated liquid phase
dPsat
hfg ¼ Tvfg ð28Þ is determined by subtracting sfg from sg.
dTsat The procedures for generating the thermody-
(ii) Saturated liquid enthalpy equation: namic properties for both steam and refrigerant 134a
(R134a) at a given thermodynamic state are much
hf ¼ hg  hfg ð29Þ more complex and cumbersome. This is because
(iii) Entropy of vaporization equation: seven possible pairs of thermodynamic properties that

hfg
Sfg ¼ ð30Þ
T
(iv) Saturated liquid entropy equation:
sf ¼ sg  sfg ð31Þ
(v) Enthalpy-internal energy relation:

h ¼ u þ Pv ð32Þ

Algorithm for Computing


Thermodynamic Properties
The algorithms for generating saturated thermody-
namic properties for both steam and refrigerant 134a
(R134a) are almost identical. The saturated properties
include pressure, specific volumes, specific enthal-
pies, and specific entropies. The saturated properties
are generated for temperatures within a given tem-
perature range and desired temperature increment.
For each temperature, the saturation pressure Psat
is first determined using the respective saturation pres- Figure 2 GUI components for applet generating
sure equation for each substance. Then, the saturated saturated properties. [Color figure can be viewed in the
liquid density equation is used to compute the specific online issue, which is available at www.interscience.
volume at the saturated liquid state vf. The specific wiley.com.]
JAVA APPLET ON COMPUTATION OF THERMODYNAMIC PROPERTIES 217

Figure 3 Java applet for generating saturated thermodynamic properties. [Color figure
can be viewed in the online issue, which is available at www.interscience.wiley.com.]

Figure 4 Table of saturated thermodynamic properties generated by the applet choice box.
218 TAN AND CHUA

specify the state are considered, and algorithms have separate Java applets were developed. One applet
to be written for the determination of the thermo- generates saturated properties over a temperature
dynamic region corresponding to each possible input range. Another applet calculates the thermodynamic
pair. In addition, procedures have to be devised for properties at a given thermodynamic state.
computing all the properties at the given state in all the
possible thermodynamic regions (sub-cooled, satu- Applet for Generating
rated, and superheated regions). The seven pairs of Saturated Properties
thermodynamic properties that may be used to specify
a thermodynamic state are as follows: The main components required in the applet for
generating saturated thermodynamic properties in-
(a) Pressure & specific volume (P, v), clude the following:
(b) Temperature & specific volume (T, v),
(c) Pressure & enthalpy (P, h), (a) Choice box for indicating the choice of the
(d) Pressure & entropy (P, s), substance (water or R134a),
(e) Pressure & quality (P, x), (b) Textfield for higher temperature limit Th,
(f) Temperature & quality (T, x), and (c) Textfield for lower temperature limit Tl,
(g) Pressure & temperature (P, T ). (d) Textfield for temperature increment dT,
(e) Label for showing warnings or instructions,
When the thermodynamic state is specified by (f) Button for activating all calculations,
choices (a), (b), (c), (d), or (g), a comparison is made (g) Button for clearing the textfields.
between the value of the given property at the point
The layout and functions of the graphical user in-
state and the saturated values in order to determine the
terface (GUI) components for this applet is illustrated
thermodynamic region corresponding to that state. For
example, if T and v are given, the value of v will be
compared to the values of vf and vg which are com-
puted using the methods for the generation of sat-
urated properties. If v is smaller than vf, then the
substance is in the compressed liquid region. If it is
greater than vg, then the substance is in the super-
heated state. If not, the substance is in the saturated
state. When the thermodynamic state is specified by
choices (e) and (f), no comparison between any values
is required as it is understood that the substance is in
the saturated region.
Once the thermodynamic region is determined,
computation for all the thermodynamic properties
(except for given properties) in that region proceeds.
The properties that are generated include P, T, v, u, h,
s, and x (if applicable). If the substance is in the sub-
cooled region, the properties are approximated by that
of saturated liquid. In the saturated region, the quality
x, if not given, is first computed so that the rest of the
properties can be determined. The properties in the super-
heated vapor state can be determined using the given
properties and the equations listed in earlier section.

JAVA APPLETS

Java 2 SDK standard edition version 1.3 is used as a


development environment for building applications,
applets, and components that can be deployed on the Figure 5 GUI components for applet generating
Java platform. It includes tools useful for developing thermodynamic properties at a given state. [Color
and testing programs written in the Java program- figure can be viewed in the online issue, which is
ming language and running on the Java platform. Two available at www.interscience.wiley.com.]
JAVA APPLET ON COMPUTATION OF THERMODYNAMIC PROPERTIES 219

in Figure 2. To begin, the user will have to indicate ‘‘Generate’’ button is pressed, the applet will compute
his/her preference of the substance in the choice box. the thermodynamic properties for the saturated region
This is followed by entering the temperature range and display a window showing the computed proper-
and desired temperature increment in the relevant ties of specific volume, specific enthalpy, and specific
textfields. Once the ‘‘Generate’’ button is pressed, the entropy in a table as shown in Figure 4.
applet will start to scrutinize the inputs before per-
forming the calculations. If the input is found to be Applet for Computing Thermodynamic
invalid (e.g., out of valid temperature range), no Properties at a Given State
computations will be carried out and warnings or
Compared to the previous applet, there are more GUI
instructions for entering valid input will appear in the
components required in the applet for generating
‘‘warning’’ label. For valid input, computations will
thermodynamic properties at a given thermodynamic
be carried out and results will be tabulated in a table
state. They are:
that appears in a separate frame that is generated using
JFrame. To perform another round of calculations, the (a) Choice box for indicating the choice of sub-
‘‘Clear’’ button is pressed to clear all the textfields and stance (water or R134a),
the above-mentioned procedures are repeated. (b) Choice box for indicating the choice of
Figure 3 shows the user interface of the Java diagram (P-h or T-s),
applet for generating saturated thermodynamic prop- (c) Label for indicating the thermodynamic region,
erties over a specified temperature range. The R134a (d) Textfield for temperature T,
substance is selected. A value of 240 K is entered for (e) Textfield for pressure P,
the lower temperature (Tl), and a value of 280 K is (f) Textfield for specific volume v,
entered for the higher temperature (Th). A tempera- (g) Textfield for specific internal energy u,
ture increment (dT ) of 5 K is entered. When the (h) Textfield for specific enthalpy h,

Figure 6 Java applet for computing thermodynamic properties at a given state. [Color figure
can be viewed in the online issue, which is available at www.interscience.wiley.com.]
220 TAN AND CHUA

(i) Textfield for specific entropy s, Another action performed by the ‘‘Calculate’’
(j) Textfield for quality x, button is the generation of a thermodynamic diagram
(k) Canvas for drawing or plotting of diagrams, (either P-h or T-s). The thermodynamic diagram will
(l) Label for showing warnings or instructions, consist of a saturation curve (a plot of saturation
(m) Button for activating all calculations, points) and a red dot that pinpoints the location of the
(n) Button for clearing the textfields. given thermodynamic state. To perform another round
of calculations, the ‘‘Clear’’ button is pressed to clear
The layout and functions of the GUI components
all the textfields and the above-mentioned procedures
for this applet is illustrated in Figure 5. This time, the
are repeated.
user will not only have to indicate his/her preference
Figure 6 shows the Java applet for computing the
of the substance in the choice box (a), he/she also has
thermodynamic properties at a given state. The steam
to choose a diagram to plot from choice box (b). This
with T-s diagram is selected in the choice box. The
is followed by keying in a valid pair of thermo-
user enters a pressure of 1 MPa and a quality of 0.7.
dynamic properties (as specified in earlier section) the
When the ‘‘Calculate’’ button is pressed, the applet
relevant textfields. Once the ‘‘Calculate’’ button is
will compute the saturation temperature, specific vol-
pressed, the applet will start to check the validity of
ume, specific internal energy, specific enthalpy, and
the input before performing any calculation.
entropy. The computed values are shown in the text-
If the input is found to be invalid (e.g., wrong
fields. On the T-s diagram, a black dot shows the given
combination of input), no computation will be
state inside the saturated region.
carried out and warnings or instructions for entering
valid input will appear in the ‘‘warning’’ label. For
valid input, computation for the values of the rest of
Java Classes
the thermodynamic properties will be carried out and
the results will be reflected in the respective textfields. Java classes were written for the equations used in
The thermodynamic region that corresponds to the the computation of the thermodynamic properties for
given thermodynamic state will also be indicated in steam and R134a. The numerical constants for
label (c). these equations are kept in interfaces, which will be

Figure 7 H2OPsat class that contains a method for computing the saturation pressure of steam.
JAVA APPLET ON COMPUTATION OF THERMODYNAMIC PROPERTIES 221

implemented by the classes that contained the ties of R134a for a given temperature range is shown
methods for computing thermodynamic properties. in Figure 8. The properties at each temperature value
Figure 7 shows the H20Psat class that contains a within the desired temperature range are computed
method (lines 718) for computing saturation pres- first (lines 625). Then, the results are added to a
sure of steam based on Equation (16). The classes and property table (lines 2737).
methods that were developed for the equations in There are four important mathematical techni-
earlier section were used in the coding of the algo- ques that are essential in the calculation of the ther-
rithms for computing thermodynamic properties. The modynamic properties of steam and R134a. They are
source code for the computation of saturated proper- numerical iteration, linear interpolation, integration,

Figure 8 Source code on the generation of saturated properties of R134a for a given
temperature range.
222 TAN AND CHUA

and differentiation. These mathematical operations The computation of internal energy, enthalpy, and
were carefully coded as they are crucial in determin- entropy involves some complex mathematical inte-
ing the accuracy of the computed properties. grations and differentiations. The methods by which
Numerical iteration is basically a trial and error these operations are performed have a direct impact
process used to determine a quantity or variable that on the accuracy of the calculated properties. In the
is not represented by any mathematical function or computation of the thermodynamic properties of
expression. This method was used to determine vapor steam and R134a, mathematical differentiations were
temperature and specific volume. Figure 9 shows a carried out based on the fundamental definition of a
sample source code that demonstrates the iterative derivative. This method is illustrated in Figure 11 for
procedures (lines 610) in the computation of vapor the computation of enthalpy at saturated liquid phase
temperature. In this case, a temperature increment of (hf), which is based on Equations (20) and (29). In this
0.01 K (which is small compared to actual vapor case, the derivative ‘dPsat/dTsat’ has to be solved
temperature) was used to ensure that the iterated vapor before hf can be determined. Lines 68 in Figure 11
temperature converge as close as possible to the shows that this is achieved using the definition of
standard value. a derivative with a differential saturation tempera-
Linear interpolation is a mathematical technique ture value of 0.001 K (i.e., dPsat/dTsat & [Psat(Tsat þ
that is used for determining quantity from existing 0.001)  Psat(Tsat)]/0.001).
figures by assuming a linear relationship between The mathematical integration in the computation
the figures. This technique was employed to determine of the thermodynamic properties of steam and R134a
the value of specific volume at saturated vapor phase were performed by using the method of summation of
(i.e., vg). A sample source code written for computing small elements. This method is illustrated in Figure 12
vg of R134a at a given temperature using the method for the calculation of the internal energy (u) of steam,
of linear interpolation is shown in Figure 10. In this based on Equation (20). In this case, the terms
case, the upper and lower integer approximations of ‘[c (T)dT]’ and ‘[(1/r2)(rR  (@P/@T)r)dr]’ have to
the given temperature were first determined (lines 7 be integrated over a given temperature and a given
and 8). Then, the standard values of vg (from standard density range, respectively. The method of summation
property tables) at these temperatures are used to of elements is used to integrate the first term with a
determine vg at the given temperature through linear differential temperature value of 0.01 K (lines 610).
interpolation (lines 1018). The second term is integrated by the same method

Figure 9 Source code on the numerical iterations in the computation of vapor


temperature.
JAVA APPLET ON COMPUTATION OF THERMODYNAMIC PROPERTIES 223

Figure 10 Source code on the determination of vg by linear interpolation.

Figure 11 Source code on mathematical differentiation.


224 TAN AND CHUA

Figure 12 Source code on mathematical integration in the computation of the internal


energy of steam.

with a differential density value of 0.01 m3/kg (lines ACKNOWLEDGMENTS


1220).
The authors gratefully acknowledge the contribution
of Benny B. H. Goh in the development of the Java
CONCLUSION applets for the courseware.

Java applets were developed for the computation of


thermodynamic properties of steam and refrigerant REFERENCES
134a. The performances of the programs were gauged
mainly by the degree of accuracy of the generated [1] L. Haar, J. S. Gallagher, and G. S. Kell, National
properties based on the comparisons made between Standard Reference Data System (U.S.), NBS/NRC
the computed properties and the data from standard steam tables: Thermodynamic and transport properties
property tables. The applet that generates saturated and computer programs for vapor and liquid states of
water in SI units, Washington, [D.C.]: Hemisphere Pub.
properties for a specified temperature was found to be
Corporation, 1984.
successful in achieving 99% accuracy. On the other [2] C. A. Meyer, American Society of Mechanical Engi-
hand, the applet that computes properties at a given neers, ASME Steam Tables: Thermodynamic and
state is less consistent with the values from standard transport properties of steam: comprising tables and
property tables. However, most of the computed charts for steam and water, calculated using the 1967
properties were within 4% error in the sub-cooled, IFC formulation for industrial use in conformity with
saturated, and superheated regions. the 1963 international skeleton tables, as adopted by the
JAVA APPLET ON COMPUTATION OF THERMODYNAMIC PROPERTIES 225

sixth international conference on the properties of Association of Refrigeration; Japan Flon Gas Associa-
steam, New York: American Society of Mechanical tion, 1990.
Engineers, 1993. [6] R. Tillner-Roth, Thermodynamic properties of envir-
[3] W. Wagner and A. Kruse, Properties of water and steam: onmentally acceptable refrigerants, Berlin: Springer
The industrial standard IAPWS-IF97 for the thermo- Verlag, 1995.
dynamic properties and supplementary equations for [7] M. J. Moran and H. N. Shapiro, Fundamentals of
other properties, Berlin: Springer Verlag, 1998. engineering thermodynamics. SI version. Chichester;
[4] C. Piao, H. Sato, and K. Watanabe, Thermodynamic New York: John Wiley, 1998.
charts, tables, and equations for refrigerant HFC-134a. [8] M. C. Potter and C. W. Somerton, Schaum’s outline:
Alternative refrigerants: A collection of papers from the thermodynamics for engineers, USA: McGraw-Hill,
ASHRAE meeting at Indianapolis, Indiana, June 1991, 1995.
Vol. 7, No. 3, pp. 2844. [9] W. C. Reynolds, Thermodynamic properties in SI:
[5] Japanese Association of Refrigeration, Thermophysi- Graphs, tables, and computational equations for forty
cal properties of environmentally acceptable fluorocar- substances. Stanford, CA: Department of Mechanical
bons: HFC-134a and HCFC-123, Tokyo: Japanese Engineering, Stanford University, 1979.

BIOGRAPHIES

Fock-Lai Tan was born in Singapore, in Patrick S. K. Chua was born in Singapore.
1959. He received his BEng in mechanical He worked as an R&D manager prior to
engineering from the National University joining Nanyang Technological Univer-
of Singapore in 1984 and his MSME sity, Singapore. Currently, he is an asso-
degree in mechanical engineering from ciate professor at NTU. His research
Rensselaer Polytechnic Institute, Troy, interests are in the areas of fluid power
New York, in 1992. He is currently an technology, automated assembly, condition
associate professor in the School of monitoring, and biomedical engineering.
Mechanical and Production Engineering He is also actively involved in the devel-
at Nanyang Technological University, opment of e-learning courseware.
Singapore. His primary research interest is in the area of
solidification and melting heat transfer. He has been actively
involved in the development of multimedia courseware for
university teaching and distance learning.

You might also like