Você está na página 1de 175

This report is the property of AGA and is part of its process for developing new

documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
1
AGA Report No. 10
Speed of Sound in Natural Gas and
Other Related Hydrocarbon Gases
November 15, 2002 Post-Ballot Draft
Prepared by
Transmission Measurement Committee
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
2
Table Of Contents
Forward
1 Introduction
1.1 Scope
1.2 Background
1.3 Field of Application
1.4 Types of Properties
1.5 Types of Gases
1.6 Types of Conditions
2 Uncertainty
3 Calculations
3.1 Symbols
3.2 Overview of Calculation Method and Sequence
3.3 Compliance
3.4 Equations for Speed of Sound
3.5 Critical Flow Factor Determination
4 Characteristics of Typical Gases
5 References
6 Computation Flow Charts
7 Calculation Output for Program Verification
7.1 Detailed Output Results for Program Development
7.1.1 Detailed Output Result #1
7.1.2 Detailed Output Result #2
7.1.3 Detailed Output Result #3
7.2 Tabled Results for Compliance Checking and Program Development
APPENDIX A C++ Language Example Implementation
1.0 Overview of Computer Code
1.1 File Group 1 Calculation Library
1.2 File Group 2 Example Windows Application
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
3
1. Introduction
1.1 Scope
This document contains information for precise computation of sound speed in
natural gas and other related hydrocarbon gases. Procedures are included for
computation of several related gas properties, including heat capacity, enthalpy,
entropy and the critical flow coefficient, C*.
The methods in this document are extensions to Compressibility Factors for
Natural Gas and Other Hydrocarbon Gases, AGA Transmission Measurement
Committee Report No. 8, 2
nd
Edition, 2
nd
Printing (1994). This document contains
excerpts from Report No. 8, but intentionally does not reproduce the full report.
Similarly, the methods for computing the critical flow coefficient, C*, are based on
the information in appendix E of ASME/ANSI MFC-7M-1987. Users are referred
to this source for background and pertinent references.
Procedures for computing other natural gas properties such as volumetric
heating value and relative density fall outside of the scope of this report and are
not included.
1.2 Background
This is the first AGA document on speed of sound. It is based on a large
database of high accuracy basic physical property research data obtained
through research sponsored by the Gas Research Institute in cooperation with
the American Gas Association, the American Petroleum Institute and Groupe
Europeen de Recherches Gazieres (GERG).
The methods presented in this AGA document utilize high accuracy calculation
procedures and related equations of state already implemented by AGA, API and
ISO.
For continuity and ease of application, the original AGA Report No. 8 solution
methods have been carried forward with little change. Computer code
development for Report No. 10 will be modest and incremental to most existing
AGA Report No. 8 implementations.
1.3 Field of Application
High accuracy sound speed information is needed in a variety of gas flow
measurement applications, such as ultrasonic meters and critical flow nozzles, as
well as analytical applications such as transducers and densitometers.
This report provides the information needed to compute the speed of sound in
natural gas and related hydrocarbon gases. The equations utilized are consistent
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
4
with AGA Report No. 8, API MPMS Chapter 14.2 and ISO Standard 12213 Part
2.
1.4 Types of Properties
The methods in this document may be used to compute a number of gas
properties including speed of sound, enthalpy, entropy, heat capacity and critical
flow coefficient.
In conjunction with the methods in AGA Report No. 8, procedures can be
developed to support a variety of applications including sonic nozzles,
compressor efficiency, and heat exchanger calculations.
1.5 Types of Gases
This report is intended for natural gases and other related hydrocarbon gases.
Table 1 identifies the ranges of gas characteristics for which this report can be
used. The normal range column gives the range of gas characteristics for which
the average expected uncertainty corresponds to the uncertainties identified in
Figure 1. The expanded range of gas characteristics has an uncertainty, which is
expected to be higher, especially outside of region 1 of Figure 1. The use of this
report for computations of the physical properties of gases with component mole
percentages outside the ranges given in Table 1 is not recommended.
An accepted database for water, heavy hydrocarbons and hydrogen sulfide in
natural gases is not presently available for determinations of uncertainties of
calculated gas properties. Therefore, as a practical matter, the only limitation is
that the calculation is for the gas phase. Thus, the limits are the water dew point
for mole percent water, the hydrocarbon dew point for mole percent heavy
hydrocarbons, and pure hydrogen sulfide. The presentation of methods for
calculations using the various heavy hydrocarbon fraction characterization
methods used in the hydrocarbon industry is beyond the scope of this report.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
5
Table 1 Range of Gas Mixture Characteristics Consistent with this Report
Quantity Normal Range Expanded Range
Relative Density * 0.554 to 0.87 0.07 to 1.52
Gross Heating Value ** 477 to 1150 Btu/scf 0 to 1800 Btu/scf
Gross Heating Value *** 18.7 to 45.1 MJ/m
3
0 to 66 MJ/m
3
Mole Percent Methane 45.0 to 100.0 0 to 100.0
Mole Percent Nitrogen 0 to 50.0 0 to 100.0
Mole Percent Carbon Dioxide 0 to 30.0 0 to 100.0
Mole Percent Ethane 0 to 10.0 0 to 100.0
Mole Percent Propane 0 to 4.0 0 to 12.0
Mole Percent Total Butanes 0 to 1.0 0 to 6.0
Mole Percent Total Pentanes 0 to 0.3 0 to 4.0
Mole Percent Hexanes Plus 0 to 0.2 0 to Dew Point
Mole Percent Helium 0 to 0.2 0 to 3.0
Mole Percent Hydrogen 0 to 10.0 0 to 100.0
Mole Percent Carbon Monoxide 0 to 3.0 0 to 3.0
Mole Percent Argon # 0 to 1.0
Mole Percent Oxygen # 0 to 21.0
Mole Percent Water 0 to 0.05 0 to Dew Point
Mole Percent Hydrogen Sulfide 0 to 0.02 0 to 100.0
* Reference Conditions: Relative Density at 60 F, 14.73 psia.
** Reference Conditions: Combustion at 60 F, 14.73 psia; density at 60 F, 14.73 psia.
*** Reference Conditions: Combustion at 25 C, 0.101325 MPa; density at 0 C, 0.101325 MPa.
# The normal range is considered to be zero for these compounds.
1.6 Types of Conditions
This report is only valid for the gas phase. The methods can be applied for
temperatures from -130 C to 200 C (-200 F to 400 F) at pressures up to 138
MPa (20,000 psia). Application at extreme conditions should be verified by other
means (e.g., experimental verification). Use of the calculation method is not
recommended within the vicinity of the critical point. For pipeline quality gas, this
is usually not a constraint because operating conditions near the critical point
generally are not encountered.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
6
Temperature, C
-130 -60 -8 62 120 200
20000 140
Region 4 1.0%
10000 70
Region 3 0.5%
P
r
e
s
s
u
r
e
,

p
s
i
a
P
r
e
s
s
u
r
e
,

M
P
a
2500 0.3% 17
Region 2
1750 0.1% 12
Region 1
-200 -80 17 143 250 400
Temperature, F
Figure 1 Targeted Uncertainty for Natural Gas Speed of Sound Using the AGA Report No.
10 Method
2.0 Uncertainty
The uncertainty of calculated speed of sound depends on natural gas
temperature, pressure and composition. The uncertainties of speed of sound
methods were evaluated by comparing calculated values to experimentally
measured speed of sound from NIST Monograph 178 [7].
Calculations were compared with experimental measured values for 17
gravimetrically prepared natural gas mixtures, listed in Table 2, over the range
250 K and 350 K (-10 F and 165 F) and pressures up to 17 MPa (2500 psia).
Some of the gas mixtures included in the uncertainty analysis are outside of the
range of Table 1.
The measurements conducted demonstrate that the uncertainty in the speed of
sound is within 0.1% for Gulf Coast, Amarillo and Ekofisk gases for pressures up
to 12 MPa (1750 psia) and temperatures between 250 K and 350 K (-10 F and
165 F).
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
7
The uncertainty in the speed of sound is also within 0.1% for other gas mixtures
whose characteristics fall within the normal range of Table 1. Higher levels of
uncertainty are indicated for gases outside of the normal range of Table 1.
Statistical analyses of the differences between calculated and experimental
values were performed to evaluate the uncertainties in the calculated speed of
sound values. Statistics were calculated using the following equations where N is
the number of data points:
100
exp
exp
x
W
W W
W
calc
diff

(2.1)

N
i
i diff
W
N
BIAS
1
,
1
(2.2)
( ) [ ]

N
i
i diff
W
N
AAD
1
2
1
2
,
1
(2.3)
( )
2
1
1
2
,
1
1
. .
1
]
1

N
i
i diff
BIAS W
N
Dev Std
(2.4)
Where:
W
diff
= relative percentage difference between calculated and experimental speed of sound
W
diff,i
= W
diff
for i
th
data point
W
calc
= calculated speed of sound
W
exp
= experimental speed of sound
AAD = average absolute deviation
BIAS = bias
Std.Dev. = Standard deviation
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
8
Table 2 Gas Mixture Characteristics Included In Statistical Analysis
Gas
No.
Methane Nitrogen Carbon
Dioxide
Ethane Propane Isobutane Normal
Butane
Isopentane Normal
Pentane
Normal
Hexane
2 0.94985 0 0 0.05015 0 0 0 0 0 0
3 0.84992 0 0 0.15008 0 0 0 0 0 0
4 0.68526 0 0 0.31474 0 0 0 0 0 0
5 0.50217 0 0 0.49783 0 0 0 0 0 0
6 0.34524 0 0 0.65476 0 0 0 0 0 0
7 0.90016 0 0 0 0.09984 0 0 0 0 0
8 0.95114 0.04886 0 0 0 0 0 0 0 0
9 0.8513 0.1487 0 0 0 0 0 0 0 0
10 0.71373 0.28627 0 0 0 0 0 0 0 0
11 0.94979 0 0.05021 0 0 0 0 0 0 0
12 0.85026 0 0.14974 0 0 0 0 0 0 0
13 0.69944 0 0.30056 0 0 0 0 0 0 0
14 0 0.49593 0.50407 0 0 0 0 0 0 0
15 0.96561 0.00262 0.00597 0.01829 0.0041 0.00098 0.00098 0.00046 0.00032 0.00067
16 0.90708 0.03113 0.005 0.04491 0.00815 0.00106 0.00141 0.00065 0.00027 0.00034
17 0.8398 0.00718 0.00756 0.13475 0.00943 0.0004 0.00067 0.00013 0.00008 0
18 0.74348 0.00537 0.01028 0.12005 0.08251 0 0.03026 0 0.00575 0.0023
Table 3 Statistical Analysis of the Differences between Calculated and
Experimental Speed of Sound Values for 17 Natural Gas Mixtures
Gas No. No. Points AAD % Bias % Std Dev %
2 80 0.021 -0.026 0.026
3 67 0.079 0.016 0.133
4 95 0.600 0.317 1.094
5 78 0.418 0.103 0.803
6 72 0.086 -0.011 0.127
7 76 0.327 0.144 0.721
8 81 0.021 -0.037 0.026
9 87 0.024 -0.036 0.029
10 97 0.025 -0.023 0.033
11 80 0.026 -0.053 0.038
12 71 0.024 -0.041 0.039
13 90 0.096 -0.009 0.184
14 65 0.148 0.230 0.205
15 83 0.030 -0.045 0.040
16 82 0.031 -0.026 0.051
17 91 0.094 0.001 0.153
18 44 0.148 0.068 0.224
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
9
3.0 Calculations
3.1 Symbols
T B First partial derivative of B wrt T
2 2
T B
Second partial derivative of B wrt T
Z T
First partial derivative of Z wrt T
2 2
T Z
Second partial derivative of Z wrt T
Z
First partial derivative of Z wrt

Molar density
Isentropic exponent
B Second virial coefficient
Cp Constant pressure heat capacity (real gas)
Cp
o
Constant pressure heat capacity (ideal gas)
Cv Constant volume heat capacity (real gas)
H Enthalpy (real gas)
H
o
Enthalpy (ideal gas)
M
r
Molar mass
P Absolute pressure
R Universal gas constant
S Entropy (real gas)
S
o
Entropy (ideal gas)
T Temperature
W Speed of sound
X
i
Mole fraction of ith component
Z Compressibility Factor
3.2 Overview of Calculation Method and Sequence
The speed of sound is related to the compressibility of a gas and can be
computed from its fundamental physical property relationships. The information
contained in this report, in combination with the information provided in AGA
Report No. 8, is needed to implement the AGA speed of sound calculation.
The method used in this report utilizes a detail characterization of the gas
composition, i.e., a representative gas analysis. As such, implementation is
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
10
limited to methods provided in the AGA Report No. 8 Detail Characterization
Method.
The reliability of calculation results is dependent on the reliability of the gas
composition data, temperature data and, to a lesser extent, pressure data.
Except where noted, all computations are performed in metric units. For
conversions to other unit systems, users are referred to applicable documents
by NIST[10] and the Canadian Standards Association[11].
Pure fluid ideal gas heat capacities, enthalpies and entropies are computed from
equations given by Aly and Lee[3], with the additions given by McFall[2]. The
originally published constants and units of measure have been preserved for this
set of equations, necessitating conversion from thermochemical calories to
joules. In this document, all references to the Btu refer to the International Table
Btu (Btu
(IT)
).
In the appendix to this report, real gas heat capacity, enthalpy and entropy are
solved through numerical integration, applying gaussian quadrature. Alternative
solution methods are feasible but users are advised to carefully evaluate the
potential impact on accuracy and robustness.
Several partial derivatives are solved during computation. Three of these ( Z T ,
2 2
T Z , Z ) are solved using the approach given in AGA Report No. 8 for
subroutine ZDETAIL. Two other derivatives, T B and
2 2
T B are solved as
minor additions to subroutine B, also given in AGA Report No. 8.
The general procedure for computing speed of sound at the flowing or operating
condition of interest is:
1. Input the operating temperature (T), operating pressure (P) and gas analysis.
2. Calculate the molar mass of the mixture.
3. Calculate the compressibility and density of the fluid at the conditions of
interest.
4. Calculate the ideal gas constant pressure heat capacity at the operating
temperature.
5. Calculate the real gas constant volume heat capacity at the operating
conditions.
6. Calculate the real gas constant pressure heat capacity at the operating
conditions.
7. Calculate the ratio of heat capacities, C
p
/C
v
, at the operating conditions.
8. Calculate the speed of sound, based on the results of the preceding steps.
9. Calculate the isentropic exponent, .
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
11
3.3 Compliance
To be compliant with this AGA Report, a computational solution by this or any
other method must demonstrate agreement within 50 parts per million of the
sound speeds given in Section 7.2, Table 6a (English units) or Table 6b (Metric
units).
Other tables of computed values are given in Section 7 for computational checks
but a compliance level is not specified.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
12
3.4 Equations for Speed of Sound
The speed of sound is derived from thermodynamic relationships[1-9]. The
relationships include the compressibility factor, density, ratio of specific heats,
molar mass and the partial derivative of the compressibility factor with respect to
the density at a constant temperature. The basic speed of sound relation can be
expressed as:
5 . 0
1
1
]
1

,
_

,
_

,
_

,
_

T r v
p
Z
Z
M
RT
c
c
W

(3.1)
The isentropic exponent may be expressed in terms of its relationship to the
speed of sound:
ZRT
M
W
r 2

(3.2)
The quantities Cv and Cp are the constant volume and constant pressure heat
capacities of the gas.

'

1
1
]
1

,
_

,
_

d
T
Z
T
Z T
T R c c
o
P v
0
2
2
2
1
(3.3)
1
1
]
1

,
_

1
1
]
1

,
_

,
_

+
T
v p
P
T
P
T
c c

2
2
(3.4a)
or, expressed in terms of compressibility,
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
13
1
1
]
1

,
_

+
1
1
]
1

,
_

+
+
T
v p
Z
Z
T
Z
T Z
R c c

2
(3.4b)
Note that the ideal gas specific heat ratio,
o
v
o
p
C
C
, real gas specific heat ratio,
v
p
C
C
,
and the isentropic exponent, , are related but separate quantities. In certain gas
industry applications, the ratio of ideal gas specific heats is assumed to be
synonymous with the isentropic exponent.
The pure fluid constant pressure ideal gas heat capacity is computed as:
( )
2 2 2 2
) / cosh(
/
) / sinh(
/
) / cosh(
/
/ sinh
/
1
]
1

+
1
]
1

+
1
]
1

+
1
]
1

+
T J
T J
I
T H
T H
G
T F
T F
E
T D
T D
C B C
o
P
(3.5)
The pure fluid ideal gas enthalpy is computed as:
( ) ) / tanh( ) / coth( ) / tanh( / coth T J IJ T H GH T F EF T D CD BT A H
o
+ + +
(3.6)
Evaluate the change in enthalpy :
( )
1
1
]
1

,
_

0
1
T
Z T
Z RT H H
o
(3.7)
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
14
The pure fluid ideal gas entropy is computed as:
[ ]
[ ]
[ ]
[ ] )) / ln(cosh( ) / tanh( ) / (
)) / ln(sinh( ) / coth( ) / (
)) / ln(cosh( ) / tanh( ) / (
)) / ln(sinh( ) / coth( ) / ( ) ln(
T J T J T J I
T H T H T H G
T F T F T F E
T D T D T D C T B K S
o

+

+ +
(3.8)
Evaluate the change in entropy:
( )
( )
i i o
o
X RX
T
Z T Z
R
ZP
P
R S S ln
1
) ln(
0

,
_

,
_


(3.9)
where P
o
= 0.101325 MPa
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
15
The coefficients for computing the ideal gas constant pressure heat capacity,
enthalpy and entropy are given in Table 4. In this table, the unit of measure for
energy is the thermochemical calorie (1 cal
(th)
= 4.184 J).
Table 4 Calculation Coefficients for Heat Capacity, Enthalpy and Entropy
Component A
(cal/mol)
B
(cal/mol-K)
C
(cal/mol-
K)
D
(K)
E
(cal/mol-K)
F
(K)
G
(cal/mol-
K)
H
(K)
I
(cal/mol-
K)
J
(K)
K
(cal/mol-K)
Methane -29776.4 7.95454 43.9417 1037.09 1.56373 813.205 -24.9027 1019.98 -10.1601 1070.14 -20.0615
Nitrogen -3495.34 6.95587 0.272892 662.738 -0.291318 -680.562 1.78980 1740.06 0 100 4.49823
Carbon
Dioxide
20.7307 6.96237 2.68645 500.371 -2.56429 -530.443 3.91921 500.198 2.13290 2197.22 5.81381
Ethane -37524.4 7.98139 24.3668 752.320 3.53990 272.846 8.44724 1020.13 -13.2732 869.510 -22.4010
Propane -56072.1 8.14319 37.0629 735.402 9.38159 247.190 13.4556 1454.78 -11.7342 984.518 -24.0426
Water -13773.1 7.97183 6.27078 2572.63 2.05010 1156.72 0 100 0 100 -3.24989
Hydrogen
Sulfide
-10085.4 7.94680 -0.0838 433.801 2.85539 843.792 6.31595 1481.43 -2.88457 1102.23 -0.51551
Hydrogen -5565.6 6.66789 2.33458 2584.98 0.749019 559.656 0 100 0 100 -7.94821
Carbon
Monoxide
-2753.49 6.95854 2.02441 1541.22 0.096774 3674.81 0 100 0 100 6.23387
Oxygen -3497.45 6.96302 2.40013 2522.05 2.21752 1154.15 0 100 0 100 9.19749
Isobutane -72387 17.8143 58.2062 1787.39 40.7621 808.645 0 100 0 100 -44.1341
Normal
Butane
-72674.8 18.6383 57.4178 1792.73 38.6599 814.151 0 100 0 100 -46.1938
Isopentane -91505.5 21.3861 74.3410 1701.58 47.0587 775.899 0 100 0 100 -60.2474
Normal
Pentane
-83845.2 22.5012 69.5789 1719.58 46.2164 802.174 0 100 0 100 -62.2197
Normal
Hexane
-94982.5 26.6225 80.3819 1718.49 55.6598 802.069 0 100 0 100 -77.5366
Normal
Heptane
-103353 30.4029 90.6941 1669.32 63.2028 786.001 0 100 0 100 -92.0164
Normal
Octane
-109674 34.0847 100.253 1611.55 69.7675 768.847 0 100 0 100 -106.149
Normal
Nonane
-122599 38.5014 111.446 1646.48 80.5015 781.588 0 100 0 100 -122.444
Normal
Decane
-133564 42.7143 122.173 1654.85 90.2255 785.564 0 100 0 100 -138.006
Helium 0.0 4.968 100 0 100 0 0 100 0 100 0.0
Argon 0.0 4.968 100 0 100 0 0 100 0 100 0.0
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
16
The basic equation for the compressibility factor, from AGA Report No. 8, is:
( ) ( )



+ +
18
13
58
13
* *
3
exp 1
n n
k
n
b k
n n n
u
n
u
n
n n n n n
D c D D k c b T C T C D
K
DB
Z
(3.10)
where
( )
*
1 1
18
1
2
3
nij j i
u
ij j
N
i
N
j
i
n
u
n
B K K E x x T a B
n n

(3.11)
The first partial derivative of Z with respect to T is:
( )
( )
( ) ( )

+

+
,
_


,
_

58
13
1 *
18
13
1 *
3
exp
n
k
n
b k
n n n
u
n n
n
u
n n
d d
n n n n
n
D c D D k c b T C u
T C u D
T
B
K
D
T
Z

(3.12)
where
( )
( )
*
1 1
18
1
1
2
3
nij j i
u
ij j
N
i
N
j
i
n
u
n n
d
B K K E x x T a u
T
B
n n


+

,
_

(3.13)
The second partial derivative of Z with respect to T is:
( )
( )
( )
( )
( ) ( )

+
+ +
+

,
_

,
_

58
13
2 *
18
13
2 *
2
2
3 2
2
exp 1
1
n
k
n
b k
n n n
u
n n n
n
u
n n n
d d
n n n n
n
D c D D k c b T C u u
T C u u D
T
B
K
D
T
Z

(3.14)
where
( )
( )
( )
*
1 1
18
1
2
2
2
2
3
1
nij j i
u
ij j
N
i
N
j
i
n
u
n n n
d
B K K E x x T a u u
T
B
n n


+
+

,
_

(3.15)
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
17
The first partial derivative of Z with respect to is:
( )
( ) ( )
( )
( )
( )
( )
( )
( ) ( )


+
+

'

1
]
1

,
_

58
13
1 *
58
13
1 *
58
13
1 2 *
18
13
*
3
3
exp
exp
exp
n
k
n
k
n n
b k
n n n
u
n
n
k
n
b
n
k
n n n
u
n
n
k
n
b k
n n
u
n
n
u
n
T
n n n n n
n n n n
n n n n n
D c D k c D D k c b T C
D c D b D k c b T C
D c D D k c T C T C
K
B
K
Z

(3.17)
4 Critical Flow Factor Determination
The critical flow factor can be determined from an iterative procedure whereby
the energy and entropy balances are solved around a converging nozzle with a
throat velocity that is sonic.
Applying procedures listed in the appendix of ASME standard MFC-7M [5],
thermodynamic changes are predicted for the acceleration of gas from the
plenum to the throat of a critical flow nozzle. An assumption is made of one-
dimensional flow, isentropic and adiabatic. The method may be implemented to
account for non-zero gas velocity in the plenum.
5 Characteristics of Typical Gases
This section contains graphical representations of thermodynamic properties
relevant to this document. The graphs are intended as an aid to familiarity with
concepts, not as a substitute for the equations given elsewhere in this report.
Five different gas mixtures are explored, in terms of speed of sound, critical flow
coefficient and isentropic exponent. Each characteristic is mapped, as a function
of pressure and/or temperature.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
18
The gas mixtures below match the examples given in AGA Report No. 8, Second
Edition. The Amarillo, Gulf Coast, Ekofisk, High N2 and High CO2 mixtures
represent a range of commercial quality natural gases found throughout the
industry.
Component Gulf Coast Amarillo Ekofisk High N2 High CO2
Methane 96.5222 90.6724 85.9063 81.4410 81.2110
Nitrogen 0.2595 3.1284 1.0068 13.4650 5.7020
Carbon
Dioxide
0.5956 0.4676 1.4954 0.9850 7.5850
Ethane 1.8186 4.5279 8.4919 3.3000 4.3030
Propane 0.4596 0.8280 2.3015 0.6050 0.8950
Isobutane 0.0977 0.1037 0.3486 0.1000 0.1510
Normal
Butane
0.1007 0.1563 0.3506 0.1040 0.1520
Isopentane 0.0473 0.0321 0.0509 0.0000 0.0000
Normal
Pentane
0.0324 0.0443 0.0480 0.0000 0.0000
Normal
Hexane
0.0664 0.0393 0.000 0.0000 0.0000
Table 5 Composition of Typical Gases
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
19
1150
1200
1250
1300
1350
1400
1450
1500
30 50 70 90 110 130
temperature (degrees F)
s
o
u
n
d

s
p
e
e
d

(
f
t
/
s
)
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 2a Sound Speed at 1200 psia as a Function of Temperature
360
370
380
390
400
410
420
430
440
450
460
0.0 10.0 20.0 30.0 40.0 50.0
temperature (degrees C)
s
o
u
n
d

s
p
e
e
d

(
m
/
s
)
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 2b Sound Speed at 8.27 MPa as a Function of Temperature
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
20
1150
1200
1250
1300
1350
1400
0 200 400 600 800 1000 1200
absolute pressure (psia)
s
o
u
n
d

s
p
e
e
d

(
f
t
/
s
)
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 3a Sound Speed at 32 F as a Function of Pressure
350
360
370
380
390
400
410
420
430
0 1 2 3 4 5 6 7 8 9
absolute pressure (MPa)
s
o
u
n
d

s
p
e
e
d

(
m
/
s
)
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 3b Sound Speed at 0 C as a Function of Pressure
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
21
0.69
0.7
0.71
0.72
0.73
0.74
0.75
0.76
0.77
0.78
30 50 70 90 110 130
temperature (degrees F)
C
*
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 4a Critical Flow Coefficent, C*, at 1000 psia as a Function of Stagnation Temperature
0.690
0.700
0.710
0.720
0.730
0.740
0.750
0.760
0.770
0.780
0.0 10.0 20.0 30.0 40.0 50.0 60.0
temperature (degrees C)
C
*
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 4b Critical Flow Coefficent, C*, at 6.9 MPa as a Function of StagnationTemperature
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
22
1.25
1.3
1.35
1.4
1.45
1.5
0.00 200.00 400.00 600.00 800.00 1000.00 1200.00
absolute pressure (psia)
i
s
e
n
t
r
o
p
i
c

e
x
p
o
n
e
n
t
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 5a Isentropic Exponent at 32 F as a Function of Pressure
1.25
1.30
1.35
1.40
1.45
1.50
0.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00
absolute pressure (MPa)
i
s
e
n
t
r
o
p
i
c

e
x
p
o
n
e
n
t
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2
Figure 5b Isentropic Exponent at 0 C as a Function of Pressure
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
23
5 References
[1] K.E. Starling and J.L. Savidge, Compressibility Factors of Natural Gas and Other
Related Hydrocarbon Gases, A.G.A. Transmission Measurement Committee Report No.
8, Second Edition, Second Printing, July, 1994.
[2] R. L. McFall, Sonic Nozzle Flow Calculations for Natural Gas Using A
Generalized Equation of State, M.S. Thesis, The University Of Oklahoma Graduate
College, 1984.
[3] F.A. Aly and L.L. Lee, Self-Consistent Equations for Calculating the Ideal Gas
Heat Capacity, Enthalpy and Entropy, Fluid Phase Equilibria, 6 (1981) 169-179.
[4] L.M. Ryan, Sonic Nozzle Mass Flow Calculations, Kaybob South No. 3 Meter
Prover, Internal Document, Nova Corporation, August 1994.
[5] The American Society of Mechanical Engineers, ASME/ANSI MFC-7M-1987,
1987.
[6] J.L. Savidge, S.W. Beyerlein, and E.W. Lemmon, Technical Reference
Document for the 2
nd
Edition of AGA Report No. 8, GRI-93/0181 (1993).
[7] B.A. Younglove, N.V. Frederick and R.D. McCarty, Speed of Sound Data and
Related Models for Mixtures of Natural Gas Constituents, NIST Monograph 178 (1993).
[8] B. A. Younglove and McLinden, M.O., An International Standard Equation of
State for the Thermodynamic Properties of Refrigerant 123, J. Phys. Chem. Ref. Data,
23(5), 731 (1994).
[9] B.E. Gammon. and D.R. Douslin, The Velocity of Sound and Heat Capacity in
Methane from Near-Critical to Subcritical Conditions, and Equation of State
Implications, Bartlesville Energy Research Center ERDA, Bartlesville, OK; J. Chem.
Phys, 64(1), 203 (1976).
[10] B.N. Taylor, Guide for the Use of the International System of Units (SI), NIST
Special Publication No. 811, (Supersedes 1991 Edition), National Institute of Standards
and Technology (NIST) (1995).
[11] Canadian Standards Association, Canadian Standards Association Metric
Practice Guide, 2000: Z234.1-00.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
24
6 Computation Flow Charts
Extending the calculation process of AGA Report No. 8, the method for
calculating speed of sound, enthalpy and entropy can be summarized by the
following flowchart.
initialize tables of
constants
AGA8 function
chardl
AGA8 function
paramdl
AGA8 function
temp
AGA8 function
ddetail
AGA8 function
zdetail
AGA8 function
relative density
modified AGA8
function bvir
AGA8 function
braket
AGA8 function
pdetail
begin
AGA8 function
zdetail
AGA8 function
pdetail
new AGA8
function
dZdD
end
AGA8 function
zdetail
new AGA8
function
dZdT
new AGA8
function
d2ZdT2
new function for
Cp (ideal gas)
new function
Cp, H, S
(real gas)
new function for
S (ideal gas)
new function for
H (ideal gas)
new functions for
Cv, k, c, W
original AGA 8
algorithm
new algorithm
new or modified
AGA8 algorithm
process endpoint
color codes
Figure 6 Flowchart of Sound Speed Calculation Procedure
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
25
The calculation sequence for the critical flow function C* is an extension of the
algorithms for sound speed, enthalpy and entropy.
compute enthalpy,
entropy and sound
speed at plenum
compute enthalpy
and sound speed
at throat
compute
temperature and
pressure, given
new enthalpy and
constant entropy
end
find a pressure
which satisfies a
given entropy and
temperature
find a temperature
which satisfies a
given enthalpy and
pressure
begin
convergence
tolerance met?
convergence
tolerance met?
convergence
tolerance met?
no
yes
yes
no
no
yes
Figure 7 Diagram of Critical Flow Function Calculation
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
26
7 Calculation Output for Program Verification
7.1 Detailed Output Results for Program Development
The following three calculation scenarios provide detailed intermediate and
output data for specific sets of input conditions. The purpose of this data set is to
facilitate computer program development.
7.1.1 Detailed Output Result #1
Input
Composition : Pure Methane
Pressure : 8.000 MPa (1160.3019 psia)
Temperature : 20.0 C (68.0 F)
Output
Molar Density : 3.79174963 moles/dm3
Molar Mass : 16.0430000 kg/kg-mol
Compressibility Factor : 0.865613011
Z T
: 0.001370797803
2 2
T Z
: -1.08884683127e-005
Z
: -0.02602812374
T B : 0.000396764069
2 2
T B : -3.34719916156e-006
Cp (ideal gas) : 2.21437395 kJ/kg-K
Cp (real gas) : 2.86910318 kJ/kg-K
Cv (real gas) : 1.78350108 kJ/kg-K
Isentropic exponent : 1.42527799
Sound Speed : 432.944437 m/s
Specific Enthalpy : 528.977205 kJ/kg
Specific Entropy : 9.09475139 kJ/kg-K
C* : 0.732987437
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
27
7.1.2 Detailed Output Result #2
Input
Composition : Amarillo
Pressure : 4.000 MPa (580.15095 psia)
Temperature : 10.0 C (50 F)
Output
Molar Density : 1.87396178 moles/dm3
Molar Mass : 17.5955109 kg/kg-mol
Compressibility Factor : 0.90666330
Z T
: 0.00084934112
2 2
T Z
: -7.3766250161e-6
Z
: -0.0442939010
T B : 0.00047962844
2 2
T B : -4.2808097391e-006
Cp (ideal gas) : 2.06018714 kJ/kg-K
Cp (real gas) : 2.40008811 kJ/kg-K
Cv (real gas) : 1.64511520 kJ/kg-K
Isentropic exponent : 1.32535394
Sound Speed : 400.972536 m/s
Specific Enthalpy : 499.296977 kJ/kg
Specific Entropy : 8.82412494 kJ/kg-K
C* : 0.704302274
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
28
7.1.3 Detailed Output Result #3
Input
Composition : Hypothetical 21 Component Mixture
Methane 86.29
Nitrogen 2.0
Carbon Dioxide 0.50
Ethane 5.0
Propane 3.0
Water 0.01
Hydrogen Sulfide 0.1
Hydrogen 0.01
Carbon Monoxide 0.01
Oxygen 0.02
i-Butane 1.10
n-Butane 0.90
i-Pentane 0.35
n-Pentane 0.25
n-Hexane 0.20
n-Heptane 0.10
n-Octane 0.05
n-Nonane 0.02
n-Decane 0.01
Helium 0.04
Argon 0.04
Pressure : 6.000 MPa (870.2264 psia)
Temperature : 40.0 C (104.0 F)
Output
Molar Density : 2.62533592 moles/dm3
Molar Mass : 19.4780144 kg/kg-mol
Compressibility Factor : 0.877763047
Z T
: 0.00110251388
2 2
T Z
: -8.7236464045e-006
Z
: -0.0375423163
T B : 0.0004594320
2 2
T B : -3.776948019e-006
Cp (ideal gas) : 2.08298699 kJ/kg-K
Cp (real gas) : 2.55641833 kJ/kg-K
Cv (real gas) : 1.73699984 kJ/kg-K
Isentropic exponent : 1.30648621
Sound Speed : 391.528389 m/s
Specific Enthalpy : 508.00420 kJ/kg
Specific Entropy : 8.23840377 kJ/kg-K
C* : 0.710708883
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
29
7.2 Tabled Results for Compliance Checking and Program Development
The following tables were generated with the alogrithms described in this report.
The numerical resolution provided is suitable for compliance checking but does
not reflect the uncertainties inherent in the solution method itself.
The compliance criteria given in section 3.2 of this document refer only to the
results given below in Tables 6a and 6b.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
30
Speed of Sound (W)
English units
Temperature Pressure Speed of Sound (ft/s)
F psia Gulf Coast Amarillo Ekofisk High N2 High CO2
32 14.73 1376.597 1342.938 1292.325 1310.350 1265.813
32 100 1366.745 1332.778 1279.700 1302.556 1255.856
32 200 1355.642 1321.304 1265.215 1293.922 1244.570
32 400 1335.321 1300.228 1237.817 1278.667 1223.691
32 600 1318.413 1282.605 1213.748 1266.847 1205.990
32 800 1306.276 1269.889 1195.063 1259.523 1192.885
32 1000 1300.594 1263.899 1184.617 1257.912 1186.169
32 1200 1303.310 1266.743 1186.056 1263.309 1187.957
50 14.73 1399.778 1365.493 1313.880 1332.486 1287.058
50 100 1391.213 1356.638 1302.733 1325.815 1278.371
50 200 1381.650 1346.728 1290.049 1318.509 1268.612
50 400 1364.443 1328.825 1266.410 1305.883 1250.851
50 600 1350.531 1314.261 1246.097 1296.509 1236.186
50 800 1340.972 1304.165 1230.700 1291.207 1225.721
50 1000 1337.006 1299.870 1222.250 1290.879 1220.765
50 1200 1339.995 1302.842 1223.155 1296.448 1222.771
100 14.73 1460.830 1424.940 1370.746 1390.875 1343.132
100 100 1455.126 1418.987 1362.902 1386.697 1337.269
100 200 1448.935 1412.505 1354.172 1382.301 1330.855
100 400 1438.390 1401.389 1338.541 1375.317 1319.748
100 600 1430.716 1393.186 1325.949 1371.076 1311.372
100 800 1426.462 1388.482 1317.221 1369.996 1306.299
100 1000 1426.212 1387.900 1313.273 1372.500 1305.135
100 1200 1430.551 1392.061 1315.055 1378.986 1308.491
130 14.73 1495.370 1458.605 1403.004 1423.961 1374.940
130 100 1490.996 1454.003 1396.704 1420.941 1370.392
130 200 1486.351 1449.093 1389.791 1417.877 1365.511
130 400 1478.794 1441.021 1377.738 1413.428 1357.384
130 600 1473.848 1435.600 1368.490 1411.448 1351.750
130 800 1471.893 1433.233 1362.617 1412.219 1349.001
130 1000 1473.315 1434.333 1360.724 1416.016 1349.538
130 1200 1478.487 1439.294 1363.406 1423.092 1353.747
Table 6a
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
31
Speed of Sound (W)
Metric units
Temperature Pressure Speed of Sound (m/s)
C MPa Gulf Coast Amarillo Ekofisk High N2 High CO2
0 0.101560 419.5867 409.3274 393.9008 399.3948 385.8198
0 0.689476 416.5839 406.2307 390.0524 397.0190 382.7850
0 1.378951 413.1998 402.7334 385.6374 394.3874 379.3451
0 2.757903 407.0058 396.3094 377.2867 389.7378 372.9809
0 4.136854 401.8523 390.9379 369.9503 386.1351 367.5856
0 5.515806 398.1531 387.0622 364.2551 383.9027 363.5914
0 6.894757 396.4209 385.2363 361.0712 383.4116 361.5444
0 8.273709 397.2489 386.1033 361.5100 385.0567 362.0892
10 0.101560 426.6523 416.2024 400.4707 406.1417 392.2953
10 0.689476 424.0418 413.5034 397.0729 404.1083 389.6475
10 1.378951 421.1270 410.4828 393.2070 401.8816 386.6731
10 2.757903 415.8822 405.0260 386.0018 398.0332 381.2593
10 4.136854 411.6419 400.5867 379.8104 395.1759 376.7896
10 5.515806 408.7283 397.5095 375.1172 393.5599 373.5999
10 6.894757 407.5195 396.2005 372.5418 393.4601 372.0890
10 8.273709 408.4305 397.1062 372.8175 395.1572 372.7007
37.77778 0.101560 445.2610 434.3217 417.8034 423.9387 409.3866
37.77778 0.689476 443.5224 432.5074 415.4124 422.6653 407.5996
37.77778 1.378951 441.6354 430.5315 412.7517 421.3253 405.6445
37.77778 2.757903 438.4214 427.1435 407.9873 419.1965 402.2592
37.77778 4.136854 436.0821 424.6432 404.1493 417.9039 399.7063
37.77778 5.515806 434.7855 423.2094 401.4891 417.5749 398.1599
37.77778 6.894757 434.7095 423.0320 400.2857 418.3379 397.8052
37.77778 8.273709 436.0321 424.3002 400.8288 420.3148 398.8279
54.44444 0.101560 455.7889 444.5827 427.6358 434.0233 419.0817
54.44444 0.689476 454.4556 443.1802 425.7152 433.1027 417.6954
54.44444 1.378951 453.0398 441.6836 423.6082 432.1689 416.2077
54.44444 2.757903 450.7364 439.2233 419.9346 430.8128 413.7308
54.44444 4.136854 449.2290 437.5708 417.1157 430.2093 412.0134
54.44444 5.515806 448.6331 436.8495 415.3258 430.4443 411.1754
54.44444 6.894757 449.0665 437.1847 414.7486 431.6017 411.3391
54.44444 8.273709 450.6429 438.6969 415.5661 433.7584 412.6220
Table 6b
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
32
Critical Flow Coefficient (C*)
English Units
Temperature Pressure C*
F psia Gulf Coast Amarillo Ekofisk High N2 High CO2
32 14.73 0.670417 0.669863 0.667375 0.671600 0.670255
32 100 0.675541 0.675065 0.673485 0.676352 0.675744
32 200 0.681844 0.681589 0.681097 0.682164 0.682419
32 400 0.695500 0.695774 0.697897 0.694621 0.697193
32 600 0.710734 0.711681 0.717468 0.708285 0.713849
32 800 0.727755 0.729555 0.740770 0.723243 0.732690
32 1000 0.746747 0.749611 0.767156 0.739544 0.753948
32 1200 0.767596 0.771751 0.798146 0.756775 0.777601
50 14.73 0.669873 0.669189 0.666598 0.670993 0.669556
50 100 0.674358 0.673917 0.672034 0.675235 0.674450
50 200 0.679953 0.679608 0.678754 0.680394 0.680355
50 400 0.691938 0.692034 0.693445 0.691341 0.693279
50 600 0.705083 0.705721 0.709959 0.703174 0.707576
50 800 0.719491 0.720788 0.729277 0.715923 0.723392
50 1000 0.735236 0.737325 0.750218 0.729588 0.740840
50 1200 0.751996 0.755020 0.774151 0.743905 0.759633
100 14.73 0.667905 0.667144 0.663869 0.669223 0.667476
100 100 0.671300 0.670641 0.668316 0.672365 0.671094
100 200 0.675397 0.674866 0.673183 0.676043 0.675470
100 400 0.683874 0.683630 0.683511 0.683878 0.684666
100 600 0.692961 0.693044 0.694685 0.692103 0.694475
100 800 0.702570 0.703021 0.706747 0.700698 0.704905
100 1000 0.712829 0.713688 0.719707 0.709787 0.715930
100 1200 0.723242 0.724557 0.733378 0.718835 0.727355
130 14.73 0.666606 0.665350 0.662451 0.667998 0.665680
130 100 0.669465 0.668756 0.665798 0.670639 0.669192
130 200 0.672895 0.672289 0.670296 0.673795 0.672851
130 400 0.680003 0.679624 0.678807 0.680297 0.680458
130 600 0.687336 0.687314 0.687851 0.686925 0.688452
130 800 0.695076 0.695346 0.697432 0.693870 0.696821
130 1000 0.703241 0.703692 0.707531 0.701146 0.705538
130 1200 0.711526 0.712298 0.718088 0.708427 0.714547
Table 7a
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
33
Critical Flow Coefficient (C*)
Metric Units
Temperature Pressure C*
C MPa Gulf Coast Amarillo Ekofisk High N2 High CO2
0 0.101560 0.670417 0.669863 0.667375 0.671600 0.670255
0 0.689476 0.675541 0.675065 0.673485 0.676352 0.675744
0 1.378951 0.681844 0.681589 0.681097 0.682164 0.682419
0 2.757903 0.695500 0.695774 0.697897 0.694621 0.697193
0 4.136854 0.710734 0.711681 0.717468 0.708285 0.713849
0 5.515806 0.727755 0.729555 0.740770 0.723243 0.732690
0 6.894757 0.746747 0.749611 0.767156 0.739544 0.753948
0 8.273709 0.767596 0.771751 0.798146 0.756775 0.777601
10 0.101560 0.669873 0.669189 0.666598 0.670993 0.669556
10 0.689476 0.674358 0.673917 0.672034 0.675235 0.674450
10 1.378951 0.679953 0.679608 0.678754 0.680394 0.680355
10 2.757903 0.691938 0.692034 0.693445 0.691341 0.693279
10 4.136854 0.705083 0.705721 0.709959 0.703174 0.707576
10 5.515806 0.719491 0.720788 0.729277 0.715923 0.723392
10 6.894757 0.735236 0.737325 0.750218 0.729588 0.740840
10 8.273709 0.751996 0.755020 0.774151 0.743905 0.759633
37.77778 0.101560 0.667905 0.667144 0.663869 0.669223 0.667476
37.77778 0.689476 0.671300 0.670641 0.668316 0.672365 0.671094
37.77778 1.378951 0.675397 0.674866 0.673183 0.676043 0.675470
37.77778 2.757903 0.683874 0.683630 0.683511 0.683878 0.684666
37.77778 4.136854 0.692961 0.693044 0.694685 0.692103 0.694475
37.77778 5.515806 0.702570 0.703021 0.706747 0.700698 0.704905
37.77778 6.894757 0.712829 0.713688 0.719707 0.709787 0.715930
37.77778 8.273709 0.723242 0.724557 0.733378 0.718835 0.727355
54.44444 0.101560 0.666606 0.665350 0.662451 0.667998 0.665680
54.44444 0.689476 0.669465 0.668756 0.665798 0.670639 0.669192
54.44444 1.378951 0.672895 0.672289 0.670296 0.673795 0.672851
54.44444 2.757903 0.680003 0.679624 0.678807 0.680297 0.680458
54.44444 4.136854 0.687336 0.687314 0.687851 0.686925 0.688452
54.44444 5.515806 0.695076 0.695346 0.697432 0.693870 0.696821
54.44444 6.894757 0.703241 0.703692 0.707531 0.701146 0.705538
54.44444 8.273709 0.711526 0.712298 0.718088 0.708427 0.714547
Table 7b
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
34
Isentropic Exponent ()
English Units
Temperature Pressure Isentropic Exponent
F psia Gulf Coast Amarillo Ekofisk High N2 High CO2
32 14.73 1.305655 1.301604 1.286355 1.312895 1.303308
32 100 1.306753 1.302437 1.285530 1.315093 1.304100
32 200 1.309207 1.304616 1.285824 1.318859 1.306240
32 400 1.318742 1.313783 1.291748 1.330968 1.315401
32 600 1.336248 1.331335 1.307683 1.350659 1.333142
32 800 1.364448 1.360274 1.338425 1.380034 1.362646
32 1000 1.406731 1.404366 1.390576 1.421522 1.407936
32 1200 1.467046 1.468004 1.472470 1.477732 1.473756
50 14.73 1.301927 1.297762 1.282196 1.309313 1.299415
50 100 1.303386 1.298975 1.281857 1.311802 1.300595
50 200 1.306168 1.301500 1.282621 1.315805 1.303089
50 400 1.315861 1.310837 1.288893 1.327887 1.312423
50 600 1.332420 1.327375 1.303641 1.346517 1.329108
50 800 1.357804 1.353264 1.330207 1.373215 1.355410
50 1000 1.394331 1.391058 1.372867 1.409667 1.394037
50 1200 1.444570 1.443593 1.436681 1.457613 1.448015
100 14.73 1.290446 1.286086 1.269898 1.298338 1.287777
100 100 1.292600 1.288045 1.270578 1.301364 1.289724
100 200 1.295972 1.291213 1.272307 1.305760 1.292886
100 400 1.305799 1.300745 1.279297 1.317578 1.302444
100 600 1.320395 1.315252 1.292024 1.333960 1.317060
100 800 1.340624 1.335680 1.311904 1.355575 1.337718
100 1000 1.367416 1.363040 1.340524 1.383107 1.365478
100 1200 1.401707 1.398353 1.379548 1.417209 1.401410
130 14.73 1.283014 1.278619 1.262233 1.291253 1.280429
130 100 1.285431 1.280867 1.263345 1.294468 1.282679
130 200 1.289002 1.284263 1.265466 1.298971 1.286084
130 400 1.298767 1.293772 1.272716 1.310547 1.295641
130 600 1.312465 1.307379 1.284661 1.325890 1.309355
130 800 1.330650 1.325687 1.302202 1.345425 1.327855
130 1000 1.353891 1.349315 1.326299 1.369567 1.351784
130 1200 1.382745 1.378866 1.357915 1.398701 1.381773
Table 8a
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
35
Isentropic Exponent ()
Metric Units
Temperature Pressure Isentropic Exponent
C MPa Gulf Coast Amarillo Ekofisk High N2 High CO2
0 0.101560 1.305655 1.301604 1.286355 1.312895 1.303308
0 0.689476 1.306753 1.302437 1.285530 1.315093 1.304100
0 1.378951 1.309207 1.304616 1.285824 1.318859 1.306240
0 2.757903 1.318742 1.313783 1.291748 1.330968 1.315401
0 4.136854 1.336248 1.331335 1.307683 1.350659 1.333142
0 5.515806 1.364448 1.360274 1.338425 1.380034 1.362646
0 6.894757 1.406731 1.404366 1.390576 1.421522 1.407936
0 8.273709 1.467046 1.468004 1.472470 1.477732 1.473756
10 0.101560 1.301927 1.297762 1.282196 1.309313 1.299415
10 0.689476 1.303386 1.298975 1.281857 1.311802 1.300595
10 1.378951 1.306168 1.301500 1.282621 1.315805 1.303089
10 2.757903 1.315861 1.310837 1.288893 1.327887 1.312423
10 4.136854 1.332420 1.327375 1.303641 1.346517 1.329108
10 5.515806 1.357804 1.353264 1.330207 1.373215 1.355410
10 6.894757 1.394331 1.391058 1.372867 1.409667 1.394037
10 8.273709 1.444570 1.443593 1.436681 1.457613 1.448015
37.77778 0.101560 1.290446 1.286086 1.269898 1.298338 1.287777
37.77778 0.689476 1.292600 1.288045 1.270578 1.301364 1.289724
37.77778 1.378951 1.295972 1.291213 1.272307 1.305760 1.292886
37.77778 2.757903 1.305799 1.300745 1.279297 1.317578 1.302444
37.77778 4.136854 1.320395 1.315252 1.292024 1.333960 1.317060
37.77778 5.515806 1.340624 1.335680 1.311904 1.355575 1.337718
37.77778 6.894757 1.367416 1.363040 1.340524 1.383107 1.365478
37.77778 8.273709 1.401707 1.398353 1.379548 1.417209 1.401410
54.44444 0.101560 1.283014 1.278619 1.262233 1.291253 1.280429
54.44444 0.689476 1.285431 1.280867 1.263345 1.294468 1.282679
54.44444 1.378951 1.289002 1.284263 1.265466 1.298971 1.286084
54.44444 2.757903 1.298767 1.293772 1.272716 1.310547 1.295641
54.44444 4.136854 1.312465 1.307379 1.284661 1.325890 1.309355
54.44444 5.515806 1.330650 1.325687 1.302202 1.345425 1.327855
54.44444 6.894757 1.353891 1.349315 1.326299 1.369567 1.351784
54.44444 8.273709 1.382745 1.378866 1.357915 1.398701 1.381773
Table 8b
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
36
Constant Pressure Heat Capacity (Cp)
English Units
Temperature Pressure Heat Capacity (BTU/Lbm-F)
F Psia Gulf Coast Amarillo Ekofisk High N2 High CO2
32 14.73 0.506950 0.488994 0.477059 0.448710 0.432120
32 100 0.518114 0.500128 0.489423 0.458100 0.442493
32 200 0.532186 0.514205 0.505335 0.469826 0.455646
32 400 0.563920 0.546124 0.542691 0.495794 0.485648
32 600 0.601144 0.583864 0.589308 0.525400 0.521447
32 800 0.644486 0.628144 0.647377 0.558743 0.563887
32 1000 0.693897 0.678904 0.717702 0.595435 0.613040
32 1200 0.747987 0.734493 0.796947 0.634328 0.667301
50 14.73 0.511648 0.493747 0.482430 0.452580 0.436334
50 100 0.521749 0.503814 0.493600 0.461077 0.445689
50 200 0.534357 0.516412 0.507791 0.471596 0.457424
50 400 0.562282 0.544440 0.540281 0.494533 0.483658
50 600 0.594169 0.576644 0.579264 0.520103 0.514021
50 800 0.630235 0.613283 0.625738 0.548245 0.548845
50 1000 0.670243 0.654098 0.679782 0.578580 0.587951
50 1200 0.713203 0.697959 0.739439 0.610298 0.630260
100 14.73 0.526964 0.509059 0.499361 0.465094 0.449703
100 100 0.534780 0.516831 0.507931 0.471676 0.456882
100 200 0.544344 0.526357 0.518543 0.479681 0.465695
100 400 0.564789 0.546775 0.541706 0.496606 0.484641
100 600 0.586982 0.569016 0.567593 0.514686 0.505364
100 800 0.610810 0.592965 0.596203 0.533765 0.527779
100 1000 0.635996 0.618330 0.627234 0.553580 0.551626
100 1200 0.662074 0.644607 0.659951 0.573759 0.576432
130 14.73 0.537585 0.519568 0.510761 0.473714 0.458758
130 100 0.544378 0.526314 0.518166 0.479439 0.464972
130 200 0.552620 0.534509 0.527238 0.486349 0.472531
130 400 0.569986 0.551812 0.546667 0.500775 0.488524
130 600 0.588468 0.570272 0.567808 0.515928 0.505642
130 800 0.607928 0.589748 0.590549 0.531665 0.523762
130 1000 0.628141 0.610004 0.614615 0.547787 0.542670
130 1200 0.648786 0.630697 0.639530 0.564040 0.562046
Table 9a
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
37
Constant Pressure Heat Capacity (Cp)
Metric Units
Temperature Pressure Heat Capacity (kJ/kg-K)
C MPa Gulf Coast Amarillo Ekofisk High N2 High CO2
0 0.10156 2.12250 2.04732 1.99735 1.87866 1.80920
0 0.68948 2.16924 2.09394 2.04912 1.91797 1.85263
0 1.37895 2.22816 2.15287 2.11574 1.96707 1.90770
0 2.75790 2.36102 2.28651 2.27214 2.07579 2.03331
0 4.13685 2.51687 2.44452 2.46732 2.19974 2.18319
0 5.51581 2.69833 2.62991 2.71044 2.33935 2.36088
0 6.89476 2.90521 2.84243 3.00487 2.49297 2.56667
0 8.27371 3.13167 3.07517 3.33666 2.65581 2.79386
10 0.10156 2.14217 2.06722 2.01984 1.89486 1.82684
10 0.68948 2.18446 2.10937 2.06660 1.93044 1.86601
10 1.37895 2.23725 2.16212 2.12602 1.97448 1.91514
10 2.75790 2.35416 2.27946 2.26205 2.07051 2.02498
10 4.13685 2.48767 2.41429 2.42526 2.17757 2.15210
10 5.51581 2.63867 2.56769 2.61984 2.29539 2.29790
10 6.89476 2.80617 2.73858 2.84611 2.42240 2.46163
10 8.27371 2.98604 2.92222 3.09588 2.55520 2.63877
37.77778 0.10156 2.20629 2.13133 2.09073 1.94726 1.88282
37.77778 0.68948 2.23902 2.16387 2.12661 1.97481 1.91287
37.77778 1.37895 2.27906 2.20375 2.17104 2.00833 1.94977
37.77778 2.75790 2.36466 2.28924 2.26802 2.07919 2.02909
37.77778 4.13685 2.45758 2.38236 2.37640 2.15489 2.11586
37.77778 5.51581 2.55734 2.48262 2.49618 2.23477 2.20971
37.77778 6.89476 2.66279 2.58883 2.62610 2.31773 2.30955
37.77778 8.27371 2.77197 2.69884 2.76308 2.40221 2.41340
54.44444 0.10156 2.25076 2.17533 2.13845 1.98334 1.92073
54.44444 0.68948 2.27920 2.20357 2.16946 2.00732 1.94674
54.44444 1.37895 2.31371 2.23788 2.20744 2.03625 1.97839
54.44444 2.75790 2.38642 2.31033 2.28879 2.09665 2.04535
54.44444 4.13685 2.46380 2.38761 2.37730 2.16009 2.11702
54.44444 5.51581 2.54527 2.46916 2.47251 2.22598 2.19289
54.44444 6.89476 2.62990 2.55396 2.57327 2.29347 2.27205
54.44444 8.27371 2.71634 2.64060 2.67758 2.36152 2.35317
Table 9b
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
38
Constant Volume Heat Capacity (Cv)
English Units
Temperature Pressure Heat Capacity (BTU/Lbm-F)
F psia Gulf Coast Amarillo Ekofisk High N2 High CO2
32 14.73 0.387265 0.374671 0.369665 0.340975 0.330630
32 100 0.389480 0.376927 0.372301 0.342837 0.332836
32 200 0.392083 0.379584 0.375442 0.345015 0.335446
32 400 0.397320 0.384949 0.381940 0.349356 0.340756
32 600 0.402606 0.390400 0.388807 0.353668 0.346213
32 800 0.407916 0.395913 0.396052 0.357921 0.351802
32 1000 0.413161 0.401382 0.403474 0.362048 0.357415
32 1200 0.418161 0.406590 0.410529 0.365939 0.362807
50 14.73 0.392092 0.379553 0.375178 0.344953 0.334963
50 100 0.394071 0.381570 0.377553 0.346614 0.336924
50 200 0.396389 0.383934 0.380363 0.348551 0.339230
50 400 0.401011 0.388666 0.386095 0.352385 0.343873
50 600 0.405612 0.393398 0.392009 0.356154 0.348560
50 800 0.410166 0.398106 0.398091 0.359831 0.353270
50 1000 0.414611 0.402719 0.404216 0.363370 0.357930
50 1200 0.418844 0.407113 0.410094 0.366705 0.362403
100 14.73 0.407690 0.395145 0.392419 0.357706 0.348592
100 100 0.409168 0.396646 0.394186 0.358944 0.350029
100 200 0.410885 0.398393 0.396254 0.360380 0.351705
100 400 0.414267 0.401835 0.400370 0.363195 0.355018
100 600 0.417562 0.405197 0.404454 0.365920 0.358268
100 800 0.420752 0.408458 0.408481 0.368537 0.361437
100 1000 0.423811 0.411588 0.412407 0.371029 0.364494
100 1200 0.426708 0.414554 0.416161 0.373373 0.367403
130 14.73 0.418440 0.405783 0.403959 0.366435 0.357766
130 100 0.419699 0.407059 0.405451 0.367490 0.358978
130 200 0.421160 0.408539 0.407189 0.368713 0.360386
130 400 0.424025 0.411444 0.410622 0.371104 0.363155
130 600 0.426802 0.414263 0.413987 0.373410 0.365849
130 800 0.429476 0.416979 0.417263 0.375619 0.368454
130 1000 0.432029 0.419574 0.420423 0.377718 0.370949
130 1200 0.434446 0.422028 0.423430 0.379695 0.373315
Table 10a
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
39
Constant Volume Heat Capacity (Cv)
Metric Units
Temperature Pressure Heat Capacity (kJ/kg-K)
C MPa Gulf Coast Amarillo Ekofisk High N2 High CO2
0 0.10156 1.62140 1.56867 1.54772 1.42760 1.38428
0 0.68948 1.63067 1.57812 1.55875 1.43539 1.39352
0 1.37895 1.64157 1.58924 1.57190 1.44451 1.40444
0 2.75790 1.66350 1.61171 1.59911 1.46268 1.42668
0 4.13685 1.68563 1.63453 1.62786 1.48074 1.44953
0 5.51581 1.70786 1.65761 1.65819 1.49854 1.47293
0 6.89476 1.72982 1.68050 1.68926 1.51582 1.49642
0 8.27371 1.75076 1.70231 1.71880 1.53212 1.51900
10 0.10156 1.64161 1.58911 1.57079 1.44425 1.40243
10 0.68948 1.64990 1.59756 1.58074 1.45120 1.41063
10 1.37895 1.65960 1.60746 1.59250 1.45931 1.42029
10 2.75790 1.67895 1.62727 1.61650 1.47537 1.43973
10 4.13685 1.69822 1.64708 1.64126 1.49115 1.45935
10 5.51581 1.71728 1.66679 1.66673 1.50654 1.47907
10 6.89476 1.73589 1.68611 1.69237 1.52136 1.49858
10 8.27371 1.75362 1.70450 1.71698 1.53532 1.51731
37.77778 0.10156 1.70692 1.65440 1.64298 1.49764 1.45948
37.77778 0.68948 1.71310 1.66068 1.65038 1.50283 1.46550
37.77778 1.37895 1.72029 1.66799 1.65904 1.50884 1.47252
37.77778 2.75790 1.73445 1.68240 1.67627 1.52062 1.48639
37.77778 4.13685 1.74825 1.69648 1.69337 1.53203 1.50000
37.77778 5.51581 1.76161 1.71013 1.71023 1.54299 1.51326
37.77778 6.89476 1.77441 1.72324 1.72667 1.55342 1.52606
37.77778 8.27371 1.78654 1.73566 1.74238 1.56324 1.53824
54.44444 0.10156 1.75193 1.69893 1.69130 1.53419 1.49790
54.44444 0.68948 1.75720 1.70427 1.69754 1.53861 1.50297
54.44444 1.37895 1.76331 1.71047 1.70482 1.54373 1.50886
54.44444 2.75790 1.77531 1.72264 1.71919 1.55374 1.52046
54.44444 4.13685 1.78693 1.73444 1.73328 1.56339 1.53174
54.44444 5.51581 1.79813 1.74581 1.74700 1.57264 1.54264
54.44444 6.89476 1.80882 1.75667 1.76023 1.58143 1.55309
54.44444 8.27371 1.81894 1.76695 1.77282 1.58971 1.56300
Table 10b
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
40
Specific Enthalpy (H)
English Units
Temperature Pressure Specific Enthalpy (BTU/Lbm)
F psia Gulf Coast Amarillo Ekofisk High N2 High CO2
32 14.73 235.100 224.943 214.460 208.312 197.589
32 100 232.112 221.980 211.209 205.820 194.867
32 200 228.542 218.437 207.298 202.855 191.610
32 400 221.187 211.127 199.136 196.788 184.873
32 600 213.549 203.517 190.486 190.553 177.837
32 800 205.649 195.628 181.334 184.182 170.514
32 1000 197.538 187.514 171.728 177.726 162.952
32 1200 189.316 179.284 161.838 171.266 155.254
50 14.73 244.267 233.787 223.095 216.423 205.405
50 100 241.470 231.014 220.055 214.092 202.860
50 200 238.139 227.711 216.415 211.327 199.826
50 400 231.321 220.940 208.879 205.699 193.594
50 600 224.303 213.957 200.996 199.960 187.151
50 800 217.113 206.792 192.779 194.139 180.520
50 1000 209.802 199.497 184.282 188.284 173.747
50 1200 202.448 192.156 175.629 182.455 166.911
100 14.73 270.219 258.845 247.628 239.354 227.546
100 100 267.866 256.515 245.078 237.398 225.411
100 200 265.085 253.759 242.051 235.091 222.886
100 400 259.460 248.183 235.887 230.448 217.768
100 600 253.770 242.537 229.589 225.782 212.577
100 800 248.043 236.849 223.188 221.118 207.338
100 1000 242.313 231.156 216.730 216.485 202.086
100 1200 236.626 225.506 210.277 211.917 196.864
130 14.73 286.185 274.272 262.777 253.435 241.171
130 100 284.050 272.159 260.467 251.662 239.237
130 200 281.535 269.669 257.735 249.579 236.956
130 400 276.476 264.656 252.206 245.404 232.360
130 600 271.393 259.617 246.610 241.235 227.734
130 800 266.311 254.577 240.974 237.090 223.100
130 1000 261.259 249.564 235.335 232.993 218.484
130 1200 256.267 244.613 229.737 228.968 213.919
Table 11a
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
41
Specific Enthalpy (H)
Metric Units
Temperature Pressure Specific Enthalpy (kJ/kg)
C MPa Gulf Coast Amarillo Ekofisk High N2 High CO2
0 0.101560 546.844 523.217 498.833 484.533 459.592
0 0.689476 539.892 516.325 491.272 478.738 453.262
0 1.378951 531.588 508.084 482.175 471.841 445.684
0 2.757903 514.481 491.081 463.189 457.729 430.014
0 4.136854 496.716 473.381 443.069 443.227 413.648
0 5.515806 478.339 455.030 421.782 428.407 396.615
0 6.894757 459.473 436.157 399.440 413.391 379.027
0 8.273709 440.350 417.015 376.436 398.364 361.122
10 0.101560 568.165 543.788 518.918 503.399 477.771
10 0.689476 561.658 537.339 511.849 497.978 471.853
10 1.378951 553.912 529.657 503.381 491.546 464.795
10 2.757903 538.051 513.906 485.854 478.456 450.300
10 4.136854 521.728 497.665 467.518 465.106 435.314
10 5.515806 505.006 480.999 448.404 451.568 419.889
10 6.894757 488.000 464.030 428.640 437.948 404.135
10 8.273709 470.894 446.955 408.514 424.391 388.235
37.77778 0.101560 628.530 602.072 575.982 556.738 529.272
37.77778 0.689476 623.056 596.653 570.051 552.187 524.307
37.77778 1.378951 616.587 590.244 563.012 546.822 518.432
37.77778 2.757903 603.503 577.273 548.672 536.022 506.527
37.77778 4.136854 590.269 564.140 534.024 525.169 494.453
37.77778 5.515806 576.947 550.910 519.136 514.319 482.269
37.77778 6.894757 563.621 537.670 504.114 503.543 470.053
37.77778 8.273709 550.392 524.527 489.105 492.919 457.906
54.44444 0.101560 665.666 637.956 611.220 589.489 560.964
54.44444 0.689476 660.701 633.042 605.845 585.366 556.465
54.44444 1.378951 654.851 627.249 599.490 580.520 551.160
54.44444 2.757903 643.082 615.590 586.631 570.810 540.470
54.44444 4.136854 631.261 603.870 573.614 561.111 529.709
54.44444 5.515806 619.440 592.146 560.505 551.471 518.930
54.44444 6.894757 607.687 580.487 547.388 541.941 508.195
54.44444 8.273709 596.077 568.970 534.369 532.579 497.576
Table 11b
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
42
Specific Entropy (S) - English
Units
Temperature Pressure Specific Entropy (BTU/Lbm.F)
F psia Gulf Coast Amarillo Ekofisk High N2 High CO2
32 14.73 2.62900 2.53174 2.41752 2.38655 2.27015
32 100 2.39829 2.31131 2.21022 2.17896 2.07442
32 200 2.31118 2.22795 2.13126 2.10080 2.00028
32 400 2.21846 2.13901 2.04602 2.01801 1.92099
32 600 2.15918 2.08194 1.99027 1.96548 1.86991
32 800 2.11328 2.03758 1.94599 1.92519 1.83004
32 1000 2.07453 2.00001 1.90762 1.89154 1.79613
32 1200 2.04033 1.96674 1.87295 1.86216 1.76598
50 14.73 2.64731 2.54941 2.43476 2.40275 2.28576
50 100 2.41698 2.32936 2.22789 2.19548 2.09038
50 200 2.33035 2.24648 2.14947 2.11772 2.01669
50 400 2.23871 2.15861 2.06548 2.03581 1.93841
50 600 2.18066 2.10279 2.01127 1.98427 1.88852
50 800 2.13618 2.05988 1.96886 1.94508 1.85003
50 1000 2.09903 2.02395 1.93270 1.91263 1.81770
50 1200 2.06656 1.99246 1.90051 1.88451 1.78927
100 14.73 2.69587 2.59630 2.48067 2.44566 2.32719
100 100 2.46638 2.37708 2.27472 2.23910 2.13258
100 200 2.38077 2.29522 2.19745 2.16220 2.05985
100 400 2.29137 2.20960 2.11603 2.08213 1.98365
100 600 2.23582 2.15629 2.06479 2.03261 1.93611
100 800 2.19408 2.11615 2.02579 1.99559 1.90024
100 1000 2.15991 2.08323 1.99347 1.96543 1.87076
100 1200 2.13057 2.05492 1.96541 1.93968 1.84537
130 14.73 2.72366 2.62314 2.50703 2.47017 2.35090
130 100 2.49454 2.40431 2.30150 2.26392 2.15665
130 200 2.40940 2.32291 2.22474 2.18741 2.08434
130 400 2.32099 2.23827 2.14443 2.10816 2.00905
130 600 2.26650 2.18602 2.09442 2.05950 1.96249
130 800 2.22588 2.14701 2.05675 2.02339 1.92768
130 1000 2.19289 2.11527 2.02586 1.99417 1.89931
130 1200 2.16476 2.08818 1.99929 1.96936 1.87505
Table 12a
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
43
Specific Entropy (S) - Metric
Units
Temperature Pressure Specific Entropy (kJ/kg.K)
C Mpa Gulf Coast Amarillo Ekofisk High N2 High CO2
0 0.10156 11.00709 10.59989 10.12165 9.99200 9.50466
0 0.68948 10.04115 9.67701 9.25376 9.12287 8.68517
0 1.37895 9.67643 9.32799 8.92315 8.79563 8.37477
0 2.75790 9.28826 8.95562 8.56627 8.44898 8.04279
0 4.13685 9.04006 8.71666 8.33286 8.22908 7.82894
0 5.51581 8.84786 8.53092 8.14747 8.06038 7.66202
0 6.89476 8.68566 8.37362 7.98683 7.91951 7.52003
0 8.27371 8.54244 8.23437 7.84168 7.79649 7.39379
10 0.10156 11.08375 10.67385 10.19386 10.05983 9.57002
10 0.68948 10.11941 9.75256 9.32774 9.19205 8.75202
10 1.37895 9.75670 9.40555 8.99940 8.86648 8.44349
10 2.75790 9.37301 9.03769 8.64776 8.52351 8.11573
10 4.13685 9.13000 8.80397 8.42077 8.30775 7.90685
10 5.51581 8.94375 8.62430 8.24320 8.14366 7.74571
10 6.89476 8.78824 8.47385 8.09184 8.00782 7.61033
10 8.27371 8.65228 8.34203 7.95704 7.89008 7.49130
37.77778 0.10156 11.28707 10.87017 10.38606 10.23949 9.74348
37.77778 0.68948 10.32622 9.95235 9.52379 9.37465 8.92870
37.77778 1.37895 9.96782 9.60964 9.20026 9.05268 8.62416
37.77778 2.75790 9.59351 9.25117 8.85939 8.71744 8.30516
37.77778 4.13685 9.36094 9.02795 8.64486 8.51012 8.10611
37.77778 5.51581 9.18618 8.85989 8.48159 8.35512 7.95594
37.77778 6.89476 9.04311 8.72205 8.34627 8.22888 7.83251
37.77778 8.27371 8.92027 8.60354 8.22879 8.12106 7.72618
54.44444 0.10156 11.40341 10.98258 10.49645 10.34209 9.84276
54.44444 0.68948 10.44415 10.06635 9.63592 9.47859 9.02944
54.44444 1.37895 10.08769 9.72557 9.31454 9.15825 8.72669
54.44444 2.75790 9.71751 9.37121 8.97831 8.82643 8.41150
54.44444 4.13685 9.48936 9.15242 8.76890 8.62273 8.21657
54.44444 5.51581 9.31931 8.98908 8.61120 8.47151 8.07080
54.44444 6.89476 9.18117 8.85620 8.48185 8.34918 7.95202
54.44444 8.27371 9.06341 8.74279 8.37062 8.24532 7.85048
Table 12b
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
44
APPENDIX A C++ Language Example Implementation
1.0 Overview of Computer Code
Two groups of computer code are included in Appendix A.
The first group of computer files demonstrates a C++ implementation of the AGA speed
of sound calculation method. The primary goals of this implementation are clarity and
compatibility with AGA Report No. 8. Consideration has also been given to secondary
objectives of speed and efficiency.
The second group of files may be used to create a Windows-based example application
for testing or demonstrating.
1.1 File Group 1 Calculation Library
File Group 1 is limited to mathematical calculations. No user interface is provided at this
level but, recognizing the large community of Windows developers, support has been
included for the creation of a Win32 DLL (dynamic link library).
The C++ implementation in this report is derived from an implementation in the
FORTRAN programming language, as it appeared in the 1994 printing of AGA Report
No. 8. Much of the original program structure and nomenclature was preserved for
traceability and ease of conversion. Differences exist due to the syntax and grammar
associated with each programming language but the code is not strongly idiomatic to
the C++ language. Conversion to ANSI C or other computer languages is feasible.
Files included in Group 1 are:
aga10.h header file for aga 10 data structures, macros and prototypes
aga10.cpp c++ source code for overall execution control
detail.h header file for detail class
detail.cpp detail class implementation
therm.h header file for therm class
therm.cpp therm class implementation
entry.cpp Windows DLL entry code
script1.rc Windows resource script; version information
As implemented, external processes communicate with the library through a single
function call. The calling function supplies a pointer argument to a custom structure
(defined in aga10.h) containing input as well as output data.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
45
Overview of Classes and Key Functions
In the C++ programming language, data and functions are typically grouped in
structures called classes. Two classes were created for this implementation. The Detail
class is responsible for density-related computations. The Therm class is designed for
additional thermodynamic calculations, including speed of sound.
The Detail and Therm classes are designed for efficient repeated operation. Any
number of calculations can be executed between the creation and deletion of these
objects.
Detail Class
The Detail class contains all the data and methods required to compute gas
compressibility and density related parameters.
Those familiar with AGA Report No. 8 will note strong resemblance between this code
and the original FORTRAN Detail Characterization Method. Several important design
features were carried over to the C++ version, including the density search procedure.
Extending the original functionality, the Detail class contains the new functions for
solving the partial derivatives of Z and the second virial coefficient, B.
Therm Class
The Therm class contains data and functions for calculating heat capacity, enthalpy,
entropy and the speed of sound.
In typical calculations involving the speed of sound, the user provides the process
pressure, temperature and gas composition. For other calculations, such as those for
critical flow nozzles, the Therm class supports a method of estimating pressure and
temperature from enthalpy and entropy.
In the course of its execution, the Therm class calls the Detail class to perform density-
related work.
Function SOS()
Function, SOS() is responsible for basic execution and memory management. It creates
an object of each required class, launches calculations supported by the classes, and
then removes the objects from memory.
Function Crit()
Function Crit() provides the same basic services of SOS(), but also estimates the critical
flow function, C*, an important parameter for critical flow calculations.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
46
Crit() relies on support function HS_Mode() to predict gas pressure and temperature
from enthalpy and entropy. HS_Mode() uses a nested algorithm and Newtons Method
to converge upon pressures and temperatures which satisfy given enthalpy and entropy
states.
Crit() imposes a significantly larger computing burden than SOS() and is recommended
only for situations where C* is required.
As implented in this Appendix, function Crit() will accept gas velocity at the plenum as
an optional input. The gas velocity is used to refine the estimate of enthalpy at the
plenum.
1.2 File Group 2 Example Windows Application
The second set of code examples is intended as an example of applying a calculation
DLL in an application with a graphical user interface.
A simple Win32 application can be created with this code. The application requires
basic Win32 support, supported widely by vendors of software development systems.
This implementation was created with Microsoft Visual C++, version 6 (SP5).
The interface consists of one non-modal dialog box and basic file operations, tested
under the following Windows operating systems:
Windows 95, 98, NT 4.0 (SP6), Windows XP.
Through a conventional dialog-based interface, the user may:
collect user-defined inputs (keyed directly or loaded from file)
requests a calculation to be performed
observe and/or save the calculation output
File operations consist of reading and writing AGA10STRUCT structures in binary
format. Standard Windows and C++ run-time library process are used for file access.
This report is the property of AGA and is part of its process for developing new
documents. This report or any of its part shall not be copied, disseminated, cited
in literature, presentations or discussions without prior approval from AGA.
AGA Report No. 10, Speed of Sound in Natural Gas
47
The application interacts with aga10.dll in the following ways:
initialization via DLL function AGA10_Init()
de-initialization via DLL function AGA10_UnInit()
creation of an AGA10STRUCT structure for exchanging data
launching calculations by calling DLL function Crit() or SOS()
The files included in this group are:
aga10win.h header file for application
aga10win.cpp main source code for Windows application
dlghlp.cpp utility functions supporting dialog box operations
file.cpp functions supporting file input/output
aga10win.rc Windows resource template
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
49
File Group #1 - Calculation Code
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
50
/*************************************************************************
* File: aga10.h
* Description: function prototypes and defines for aga10.cpp
* Version: ver 1.7 2002.11.17
* Author: W.B. Peterson
* Revisions:
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#ifndef _AGA10_H
#define _AGA10_H
/* Windows-specific export macro and header #include */
#if WIN32
#define DllExport __declspec (dllexport)
#include <windows.h>
#else
#define DllExport
#endif
/* other includes */
#include <strstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
/* status codes */
#define NORMAL 9000
#define AGA10_INITIALIZED 9001
#define MEMORY_ALLOCATION_ERROR 9002
#define GENERAL_CALCULATION_FAILURE 9003
#define MAX_NUM_OF_ITERATIONS_EXCEEDED 9004
#define NEGATIVE_DENSITY_DERIVATIVE 9005
#define MAX_DENSITY_IN_BRAKET_EXCEEDED 9006
/* number of components */
#define NUMBEROFCOMPONENTS 21
/* maximum number of tries within search routines */
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
51
#define MAX_NUM_OF_ITERATIONS 100
/* default tolerance limits */
#define P_CHG_TOL 0.001 /* 0.001 Pa */
#define T_CHG_TOL 0.001 /* 0.001 of a Kelvin */
/* maximum allowable P & T */
const double P_MAX = 1.379e8 ; // maximum pressure (Pa) ~= 20,000 psi
const double P_MIN = 0.0 ; // maximum pressure = 0
const double T_MAX = 473.15 ; // maximum temperature (K) ~= 392 F
const double T_MIN = 143.0 ; // maximum temperature (K) ~= -200 F
/* universal gas constant, in two configurations */
#define RGASKJ 8.314510e-3 /* in kJ mol^-1 K^-1 */
#define RGAS 8.314510 /* in J mol^-1 K^-1 */
/* the main data structure used by this library */
typedef struct tagAGA10STRUCT
{
/* corresponds to the control group in meter classes */
long lStatus ; /* calculation status */
bool bForceUpdate; /* signal to perform full calculation */
double adMixture[NUMBEROFCOMPONENTS] ; /* Composition in mole fraction */
double dPb ; /* Contract base Pressure (Pa) */
double dTb ; /* Contract base temperature (K) */
double dPf ; /* Absolute Pressure (Pa) */
double dTf ; /* Flowing temperature (K) */
// basic output from AGA 8 Detail method
double dMrx ; /* mixture molar mass */
double dZb ; /* compressibility at contract base condition */
double dZf ; /* compressibility at flowing condition */
double dFpv ; /* supercompressibility */
double dDb ; /* molar density at contract base conditions (moles/dm3) */
double dDf ; /* molar density at flowing conditions (moles/dm3) */
double dRhob ; /* mass density at contract base conditions (kg/m3) */
double dRhof ; /* mass density at flowing conditions (kg/m3) */
double dRD_Ideal ; /* ideal gas relative density */
double dRD_Real ; /* real gas relative density */
// additional output
double dHo ; /* ideal gas specific enthalpy */
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
52
double dH ; /* real gas specific enthalpy (J/kg) */
double dS ; /* real gas specific entropy (J/kg-mol.K)*/
double dCpi ; /* ideal gas constant pressure heat capacity (J/kg-mol.K)*/
double dCp ; /* real gas constant pressure heat capacity (J/kg-mol.K)*/
double dCv ; /* real gas constant volume heat capacity (J/kg-mol.K)*/
double dk ; /* ratio of specific heats */
double dKappa ; /* isentropic exponent, denoted with Greek letter kappa */
double dSOS ; /* speed of sound (m/s) */
double dCstar ; /* critical flow factor C* */
} AGA10STRUCT ;
/* enumerations for tracking gas components */
enum gascomp{ XiC1=0, XiN2, XiCO2, XiC2, XiC3,
XiH2O, XiH2S, XiH2, XiCO, XiO2,
XiIC4, XiNC4, XiIC5, XiNC5, XiNC6,
XiNC7, XiNC8, XiNC9, XiNC10, XiHe,
XiAr } ;
/* FUNCTION PROTOTYPES */
/* prototypes for initialization */
DllExport int AGA10_Init(void) ; /* initialize library */
DllExport int AGA10_UnInit(void) ; /* un-initialize library */
/* function prototype for basic VOS calculation */
DllExport double SOS(AGA10STRUCT *) ;
/* function prototype for a C* calculation */
DllExport double Crit(AGA10STRUCT *, double) ;
#endif
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
53
/*************************************************************************
* File: aga10.cpp
* Description: Manages overall process of calculating speed of sound
* or C*; creates and uses objects based on Detail and Therm classes
* Contains the following functions:
* AGA10_Init(), AGA10_UnInit(), SOS(), Crit(), Cperf(), CRi()
* Version: ver 1.7 2002.11.17
* Author: W.B. Peterson
* Revisions:
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#include "aga10.h"
#include "therm.h"
#include "detail.h"
// Create file-scope pointers to objects we will need; one of Therm class
// and one of Detail class.
static Therm *ptTherm ;
static Detail *ptDetail ;
/**************************************************************************
* Function : AGA10_Init()
* Arguments : void
* Returns : int
* Purpose : Initializes library; creates required objects
* Revisions :
**************************************************************************/
DllExport int AGA10_Init(void)
{
// create object for calculating density
if (NULL == (ptDetail = new Detail))
{
return MEMORY_ALLOCATION_ERROR ;
}
// create object for calculating thermodynamic properties
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
54
if (NULL == (ptTherm = new Therm))
{
return MEMORY_ALLOCATION_ERROR ;
}
return AGA10_INITIALIZED ;
} // AGA10_Init
/**************************************************************************
* Function : AGA10_UnInit()
* Arguments : void
* Returns : int
* Purpose : Un-initializes library; deletes objects
* Revisions :
**************************************************************************/
DllExport int AGA10_UnInit(void)
{
// delete the objects (if they exist)
if (ptDetail) delete ptDetail ;
if (ptTherm) delete ptTherm ;
return 0 ;
} // AGA10_UnInit
/**************************************************************************
* Function : SOS()
* Arguments : Pointers to external AGA10 data struct
* Returns : double
* Purpose : calculates speed of sound and other parameters
* Revisions :
**************************************************************************/
DllExport double SOS(AGA10STRUCT *ptAGA10)
{
// check if library is ready; initialize if necessary
if (NULL == ptDetail || NULL == ptTherm)
{
AGA10_UnInit() ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
55
AGA10_Init() ;
}
// Call function to calculate densities and thermodynamic properties
ptTherm->Run(ptAGA10, ptDetail) ;
// the basic sound speed calculation doesn't calculate C*; initialize to zero
ptAGA10->dCstar = 0.0 ;
// return the speed of sound to caller
return ptAGA10->dSOS ;
} // VOS()
/**************************************************************************
* Function : Crit()
* Arguments : Pointers to external AGA10 data struct, Detail and Therm
* objects and a double precision float (gas velocity in plenum)
* Returns : double
* Purpose : calculates C*
* Revisions :
**************************************************************************/
DllExport double Crit(AGA10STRUCT *ptAGA10, double dPlenumVelocity)
{
// variables local to function
double DH, DDH, S, H;
double tolerance = 1.0 ;
double R, P, T, Z ;
int i ;
// check objects for readiness; try to initialize if not
if (NULL == ptDetail || NULL == ptTherm)
{
AGA10_UnInit() ;
if (AGA10_INITIALIZED != AGA10_Init())
{
ptAGA10->lStatus = MEMORY_ALLOCATION_ERROR ;
return 0.0 ;
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
56
}
// begin by calculating densities and thermodynamic properties
ptTherm->Run(ptAGA10, ptDetail) ;
// DH is enthalpy change from plenum to throat; this is our initial guess
DH = (ptAGA10->dSOS * ptAGA10->dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0 ;
// trap plenum conditions before we alter the data stucture's contents
S = ptAGA10->dS ;
H = ptAGA10->dH ;
R = ptAGA10->dRhof ;
P = ptAGA10->dPf ;
Z = ptAGA10->dZf ;
T = ptAGA10->dTf ;
// initialize delta of DH to an arbitrary value outside of
// convergence tolerance
DDH = 10.0 ;
// Via simple repetition, search for a pressure, temperature and sound speed
// at a nozzle throat which provide constant enthalpy, given the entropy known
// at the plenum. Abort if loop executes more than 100 times without convergence.
for (i = 1; i < MAX_NUM_OF_ITERATIONS; i++)
{
// calculate P and T to satisfy H and S
ptTherm->HS_Mode(ptAGA10, ptDetail, H - DH, S, true) ;
// calculate new thermo, including SOS
ptTherm->Run(ptAGA10, ptDetail) ;
// hold DH for tolerance check
DDH = DH ;
// recalculate DH
DH = (ptAGA10->dSOS * ptAGA10->dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0 ;
// end loop if tolerance reached
if (fabs(DDH - DH) < tolerance) break ;
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
57
// C* is the real gas critical flow constant (not to be confused with Cperf or CRi)
ptAGA10->dCstar = (ptAGA10->dRhof * ptAGA10->dSOS) / sqrt(R * P * Z) ;
// put the original plenum pressure and temperature back
ptAGA10->dPf = P ;
ptAGA10->dTf = T ;
// restore fluid props to plenum conditions
ptTherm->Run(ptAGA10, ptDetail) ;
// return the critical flow function to caller
return ptAGA10->dCstar ;
} // Crit()
/**************************************************************************
* Function : Cperf()
* Arguments : pointer to external AGA10 data struct
* Returns : double
* Purpose : calculates isentropic perfect gas critical flow function
* Revisions :
**************************************************************************/
double Cperf(AGA10STRUCT *ptAGA10)
{
double k, root, exponent ;
k = ptAGA10->dKappa ;
root = 2.0 / (k + 1.0) ;
exponent = (k + 1.0) / (k - 1.0) ;
// isentropic perfect gas critical flow function C*i
return(sqrt(k * pow(root, exponent))) ;
} // Cperf
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
58
/**************************************************************************
* Function : CRi()
* Arguments : pointer to external AGA10 data struct
* Returns : double
* Purpose : calculates isentropic real gas critical flow function CRi
* Revisions :
**************************************************************************/
double CRi(AGA10STRUCT *ptAGA10)
{
return (Cperf(ptAGA10) / sqrt(ptAGA10->dZf)) ;
} // CRi()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
59
/*************************************************************************
* File : detail.h
* Description: Header file for the 'Detail' class
* See 'detail.cpp' for the implementation.
* Version : ver 1.7 2002.11.17
* Author : W.B. Peterson
* Revisions:
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#ifndef _DETAIL_H
#define _DETAIL_H
#include "aga10.h"
class Detail
{
private:
// member data
int iNCC ; // number of components
int aiCID[21] ; // component IDs
// five history variables are used to improve efficiency during repeated calculations
double dOldMixID ; // mixture ID from previous calc
double dOldPb ; // Pb from previous calc
double dOldTb ; // Tb from previous calc
double dOldPf ; // Pf from previous calc
double dOldTf ; // Tf from previous calc
// EOS parameters from table 4, column 1
double adAn[58] ;
double adUn[58] ;
// characterization parameters from table 5
double dMri[21] ; // molecular weight of ith component
double dEi[21] ; // characteristic energy parameter for ith component
double dKi[21] ; // size parameter for ith component - m^3/kg-mol ^1/3
double dGi[21] ; // orientation parameter
double dQi[21] ; // quadrupole parameter
double dFi[21] ; // high temperature parameter
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
60
double dSi[21] ; // dipole parameter
double dWi[21] ; // association parameter
double dEij[21][21] ; // virial coefficient energy binary interaction parm
double dUij[21][21] ; // binary interaction parameter for conformal energy
double dKij[21][21] ; // binary interaction parameter for size
double dGij[21][21] ; // binary interaction parameter for orientation
double adTable6Eij[21][21] ; // Table 6 constants
double adTable6Uij[21][21] ; // Table 6 constants
double adTable6Kij[21][21] ; // Table 6 constants
double adTable6Gij[21][21] ; // Table 6 constants
double adTable5Qi[21] ; // table 5 constants
double adTable5Fi[21] ; // table 5 constants
double adTable5Si[21] ; // table 5 constants
double adTable5Wi[21] ; // table 5 constants
double dXi[21] ; // mole fraction of component i
double dPCalc ; // pressure calculated by pdetail()
double dT ; // current temperature
double dP ; // current pressure
double dRhoTP ; // molar density at T & P
double dB ; // 2nd virial coefficient, B
double adBcoef[18] ; // 18 coefficients to calculate B
double adFn[58] ; // function for coefficients of density
double fx[58] ; // modified coefficients used for 3 derivs
double dU ; // mixture energy parameter
double dKp3 ; // mixture size parameter ^3
double dW ; // mixture orientation parameter
double dQp2 ; // mixture quadrupole parameter ^2
double dF ; // high temperature parameter
double dRho ; // molar density
double dRhoL ; // low density used in braket function
double dRhoH ; // high density used in braket function
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
61
double dPRhoL ; // low pressure used in braket function
double dPRhoH ; // high pressure used in braket function
// private class methods
bool compositionchange(AGA10STRUCT *) ; // compares new composition to old
void table() ; // sets up Table 4 and 6 characterization parms
void paramdl() ; // Table 5 and binary interaction parms
void chardl(AGA10STRUCT *) ; // calculates composition dependent quantities
void bvir() ; // calculates the 2nd virial coefficient
void temp() ; // calculates temperature dependent quantities
void braket(AGA10STRUCT *) ; // brackets density solutions
void pdetail(double) ; // calculates pressure as a function of P and T
void ddetail(AGA10STRUCT *) ; // calculates a density, given pressure & temperature
void relativedensity(AGA10STRUCT *) ; // calculates mass density
protected:
public:
Detail(void) ; // default constructor
~Detail() ; // default destructor
// public functions to support advanced fluid property calculations
double zdetail(double) ; // calculates compressibility factor
double dZdT(double) ; // calculates 1st partial derivative of Z wrt T
double d2ZdT2(double) ; // calculates 2st partial derivative of Z wrt T
double dZdD(double) ; // calculates 1st partial derivative of Z wrt D
// public variables also used for advanced fluid property calculations
double dZ ; // current compressibility
double ddZdT ; // first partial derivative of Z wrt T
double dd2ZdT2 ; // second partial derivative of Z wrt T
double ddZdD ; // first partial derivative of Z wrt molar density
double ddBdT ; // first partial derivative of B wrt T
double dd2BdT2 ; // second partial derivative of B wrt T
// the Run() command launches a full calculation sequence
void Run(AGA10STRUCT *) ;
} ;
#endif
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
62
/*************************************************************************
* File : detail.cpp
* Description: This file contains functions implementing
* AGA Report No.8 1994 - Detail Method, plus new features
* required for AGA Report No. 10
* Contains the functions:
* Detail(), ~Detail(), compositionchange(), Run(), table(),
* paramdl(), chardl(), braket(), bvir(), temp(), ddetail(),
* pdetail(), zdetail(), relativedensity(), dZdT(), d2ZdT2(),
* dZdD()
* Version : ver 1.7 2002.11.17
* Author : W.B. Peterson
* Revisions:
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#include "aga10.h"
#include "detail.h"
#include <math.h>
/**************************************************************************
* Function : Detail::Detail()
* Arguments : void
* Returns :
* Purpose : default constructor; includes initialization of
* history-sensitive variables & data tables 4 and 6
* Revisions :
**************************************************************************/
Detail::Detail(void)
{
// initialize history-sensitive variables
dOldMixID = 0.0 ; // mixture ID from previous calc
dOldPb = 0.0 ; // base pressure from previous calc
dOldTb = 0.0 ; // base temperature from previous calc
dOldPf = 0.0 ; // flowing pressure from previous calc
dOldTf = 0.0 ; // flowing temperature from previous calc
// initialize gas component array used within this class
for (int i=0 ;i<NUMBEROFCOMPONENTS ;i++) dXi[i] = 0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
63
// function table() populates tables of static constants
table() ;
} // Detail::Detail()
/**************************************************************************
* Function : Detail::~Detail()
* Arguments :
* Returns :
* Purpose : default destructor
* Revisions :
**************************************************************************/
Detail::~Detail()
{
} // Detail::~Detail()
/**************************************************************************
* Function : Detail::compositionchange()
* Arguments : AGA10STRUCT *
* Returns : void
* Purpose : Compares new composition to old by creating a semi-unique
* numerical ID. It is possible but very unlikely that 2
* sequential & different compositions will produce the same ID
* Revisions :
**************************************************************************/
bool Detail::compositionchange(AGA10STRUCT *ptAGA10)
{
double dMixID = 0.0 ;
int i ;
// generate the numerical ID for the composition
for (i=0 ; i<NUMBEROFCOMPONENTS ; i++) dMixID += ((i+2) * ptAGA10->adMixture[i]) ;
// update the history variable, if different from previous
if (dMixID != dOldMixID)
{
dOldMixID = dMixID ;
return true ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
64
}
else
{
return false;
}
} // Detail::compositionchange()
/**************************************************************************
* Function : Detail::Run()
* Arguments : AGA10STRUCT *
* Returns : void
* Purpose : public method to coordinate and run the full calc sequence
* Revisions :
**************************************************************************/
void Detail::Run(AGA10STRUCT *ptAGA10)
{
int i ;
// Check for gas composition change
ptAGA10->bForceUpdate = (ptAGA10->bForceUpdate || compositionchange(ptAGA10)) ;
// assign component IDs and values
if (ptAGA10->bForceUpdate)
{
iNCC = -1 ;
for (i=0 ;i<NUMBEROFCOMPONENTS ;i++)
{
if (ptAGA10->adMixture[i] > 0.0)
{
iNCC = iNCC + 1 ;
aiCID[iNCC] = i ;
dXi[iNCC] = ptAGA10->adMixture[i] ;
}
}
iNCC = iNCC +1 ;
// calculate composition dependent quantities; ported from original
// FORTRAN functions paramdl() and chardl()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
65
paramdl() ;
chardl(ptAGA10) ;
}
// evaluate T & P dependent parms at base pressure and temperature,
// but only if necessary
if ((fabs(ptAGA10->dPb - dOldPb) > P_CHG_TOL)||
(fabs(ptAGA10->dTb - dOldTb) > T_CHG_TOL)||
(ptAGA10->bForceUpdate))
{
dP = ptAGA10->dPb * 1.0e-6 ; // AGA 8 uses MPa internally
dT = ptAGA10->dTb ;
// calculate temperature dependent parms
temp() ;
// determine molar density
ddetail(ptAGA10) ;
ptAGA10->dDb = dRho ;
// determine compressibility
ptAGA10->dZb = zdetail(dRho) ;
// calculate mass density
dRhoTP = (dP * ptAGA10->dMrx) / (ptAGA10->dZb * RGASKJ * dT) ;
// calculate relative density
relativedensity(ptAGA10) ;
// copy density to data structure member
ptAGA10->dRhob = dRhoTP ;
// update history and clear the ForceUpdate flag
dOldTb = ptAGA10->dTb ;
dOldPb = ptAGA10->dPb ;
ptAGA10->bForceUpdate = true ;
}
// repeat the process using flowing conditions
// begin by loading P & T from data structure
// AGA 8 uses MPa internally; converted from Pa here
dP = ptAGA10->dPf * 1.0e-6 ;
dT = ptAGA10->dTf ;
// check whether to calculate temperature dependent parms
if ((fabs(ptAGA10->dTf - dOldTf) > T_CHG_TOL)||(ptAGA10->bForceUpdate))
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
66
{
// if temperature has changed, we must follow through
temp() ;
// force ForceUpdate flag to true
ptAGA10->bForceUpdate = true ;
}
// check whether to calculate other parms
if ((fabs(ptAGA10->dPf - dOldPf) > P_CHG_TOL)||(ptAGA10->bForceUpdate))
{
// determine molar density
ddetail(ptAGA10) ;
ptAGA10->dDf = dRho ;
// determine compressibility
ptAGA10->dZf = zdetail(dRho) ;
// calculate mass density
dRhoTP = (dP * ptAGA10->dMrx) / (ptAGA10->dZf * RGASKJ * dT) ;
// copy density to data structure member
ptAGA10->dRhof = dRhoTP ;
// update history
dOldTf = ptAGA10->dTf ;
dOldPf = ptAGA10->dPf ;
}
// calculate legacy factor Fpv
// NOTE: as implemented here, Fpv is not constrained to 14.73 psi and 60F
if ((ptAGA10->dZb > 0.0) && (ptAGA10->dZf > 0.0))
{
ptAGA10->dFpv = sqrt(ptAGA10->dZb / ptAGA10->dZf) ;
}
else
// if either Zb or Zf is zero at this point, we have a serious unexpected problem
{
ptAGA10->dFpv = ptAGA10->dZb = ptAGA10->dZf = 0.0 ;
ptAGA10->lStatus = GENERAL_CALCULATION_FAILURE ;
}
// we are now up to date; toggle off the update flag
ptAGA10->bForceUpdate = false ;
} // Detail::Run()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
67
/**************************************************************************
* Function : Detail::table()
* Arguments : void
* Returns : void
* Purpose : builds tables of constants
* Revisions :
**************************************************************************/
// Tables 4 and 6 are filled only during object initialization.
//
// component ID's, mapped to each species supported by AGA Report#8
// 1 - methane 8 - hydrogen 15 - n-hexane
// 2 - nitrogen 9 - carbon monoxide 16 - n-heptane
// 3 - carbon dioxide 10 - oxygen 17 - n-octane
// 4 - ethane 11 - i-butane 18 - n-nonane
// 5 - propane 12 - n-butane 19 - n-decane
// 6 - water 13 - i-pentane 20 - helium
// 7 - hydrogen sulfide 14 - n-pentane 21 - argon
void Detail::table(void)
{
int j, k ;
// 58 constants from table 4 - column A(n)
adAn[0] = 0.153832600 ;
adAn[1] = 1.341953000 ;
adAn[2] = -2.998583000 ;
adAn[3] = -0.048312280 ;
adAn[4] = 0.375796500 ;
adAn[5] = -1.589575000 ;
adAn[6] = -0.053588470 ;
adAn[7] = 0.886594630 ;
adAn[8] = -0.710237040 ;
adAn[9] = -1.471722000 ;
adAn[10] = 1.321850350 ;
adAn[11] = -0.786659250 ;
adAn[12] = 2.29129E-09 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
68
adAn[13] = 0.157672400 ;
adAn[14] = -0.436386400 ;
adAn[15] = -0.044081590 ;
adAn[16] = -0.003433888 ;
adAn[17] = 0.032059050 ;
adAn[18] = 0.024873550 ;
adAn[19] = 0.073322790 ;
adAn[20] = -0.001600573 ;
adAn[21] = 0.642470600 ;
adAn[22] = -0.416260100 ;
adAn[23] = -0.066899570 ;
adAn[24] = 0.279179500 ;
adAn[25] = -0.696605100 ;
adAn[26] = -0.002860589 ;
adAn[27] = -0.008098836 ;
adAn[28] = 3.150547000 ;
adAn[29] = 0.007224479 ;
adAn[30] = -0.705752900 ;
adAn[31] = 0.534979200 ;
adAn[32] = -0.079314910 ;
adAn[33] = -1.418465000 ;
adAn[34] = -5.99905E-17 ;
adAn[35] = 0.105840200 ;
adAn[36] = 0.034317290 ;
adAn[37] = -0.007022847 ;
adAn[38] = 0.024955870 ;
adAn[39] = 0.042968180 ;
adAn[40] = 0.746545300 ;
adAn[41] = -0.291961300 ;
adAn[42] = 7.294616000 ;
adAn[43] = -9.936757000 ;
adAn[44] = -0.005399808 ;
adAn[45] = -0.243256700 ;
adAn[46] = 0.049870160 ;
adAn[47] = 0.003733797 ;
adAn[48] = 1.874951000 ;
adAn[49] = 0.002168144 ;
adAn[50] = -0.658716400 ;
adAn[51] = 0.000205518 ;
adAn[52] = 0.009776195 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
69
adAn[53] = -0.020487080 ;
adAn[54] = 0.015573220 ;
adAn[55] = 0.006862415 ;
adAn[56] = -0.001226752 ;
adAn[57] = 0.002850908 ;
// 58 constants from table 4 - column Un
adUn[0] = 0.0 ;
adUn[1] = 0.5 ;
adUn[2] = 1.0 ;
adUn[3] = 3.5 ;
adUn[4] = -0.5 ;
adUn[5] = 4.5 ;
adUn[6] = 0.5 ;
adUn[7] = 7.5 ;
adUn[8] = 9.5 ;
adUn[9] = 6.0 ;
adUn[10] = 12.0;
adUn[11] = 12.5;
adUn[12] = -6.0;
adUn[13] = 2.0 ;
adUn[14] = 3.0 ;
adUn[15] = 2.0 ;
adUn[16] = 2.0 ;
adUn[17] = 11.0;
adUn[18] = -0.5 ;
adUn[19] = 0.5 ;
adUn[20] = 0.0 ;
adUn[21] = 4.0 ;
adUn[22] = 6.0 ;
adUn[23] = 21.0;
adUn[24] = 23.0;
adUn[25] = 22.0;
adUn[26] = -1.0 ;
adUn[27] = -0.5 ;
adUn[28] = 7.0 ;
adUn[29] = -1.0 ;
adUn[30] = 6.0 ;
adUn[31] = 4.0 ;
adUn[32] = 1.0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
70
adUn[33] = 9.0 ;
adUn[34] = -13.0;
adUn[35] = 21.0;
adUn[36] = 8.0 ;
adUn[37] = -0.5 ;
adUn[38] = 0.0 ;
adUn[39] = 2.0 ;
adUn[40] = 7.0 ;
adUn[41] = 9.0 ;
adUn[42] = 22.0;
adUn[43] = 23.0;
adUn[44] = 1.0 ;
adUn[45] = 9.0 ;
adUn[46] = 3.0 ;
adUn[47] = 8.0 ;
adUn[48] = 23.0;
adUn[49] = 1.5 ;
adUn[50] = 5.0 ;
adUn[51] = -0.5 ;
adUn[52] = 4.0 ;
adUn[53] = 7.0 ;
adUn[54] = 3.0 ;
adUn[55] = 0.0 ;
adUn[56] = 1.0 ;
adUn[57] = 0.0 ;
// Most of the tables are filled with 1.0 or 0.0
// It is up to us to set non-zero values
for (j=0 ; j < NUMBEROFCOMPONENTS ; j++)
{
for (k=j ; k < NUMBEROFCOMPONENTS ; k++)
{
adTable6Eij[j][k] = 1.0 ;
adTable6Uij[j][k] = 1.0 ;
adTable6Kij[j][k] = 1.0 ;
adTable6Gij[j][k] = 1.0 ;
}
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
71
// Lnsert the 132 items of non-zero and non-1.0 data
// This looks more cumbersome than it is, considering table 6 has 1764 members
adTable6Eij[0][1] = 0.971640 ;
adTable6Eij[0][2] = 0.960644 ;
adTable6Eij[0][4] = 0.994635 ;
adTable6Eij[0][5] = 0.708218 ;
adTable6Eij[0][6] = 0.931484 ;
adTable6Eij[0][7] = 1.170520 ;
adTable6Eij[0][8] = 0.990126 ;
adTable6Eij[0][10] = 1.019530 ;
adTable6Eij[0][11] = 0.989844 ;
adTable6Eij[0][12] = 1.002350 ;
adTable6Eij[0][13] = 0.999268 ;
adTable6Eij[0][14] = 1.107274 ;
adTable6Eij[0][15] = 0.880880 ;
adTable6Eij[0][16] = 0.880973 ;
adTable6Eij[0][17] = 0.881067 ;
adTable6Eij[0][18] = 0.881161 ;
adTable6Eij[1][2] = 1.022740 ;
adTable6Eij[1][3] = 0.970120 ;
adTable6Eij[1][4] = 0.945939 ;
adTable6Eij[1][5] = 0.746954 ;
adTable6Eij[1][6] = 0.902271 ;
adTable6Eij[1][7] = 1.086320 ;
adTable6Eij[1][8] = 1.005710 ;
adTable6Eij[1][9] = 1.021000 ;
adTable6Eij[1][10] = 0.946914 ;
adTable6Eij[1][11] = 0.973384 ;
adTable6Eij[1][12] = 0.959340 ;
adTable6Eij[1][13] = 0.945520 ;
adTable6Eij[2][3] = 0.925053 ;
adTable6Eij[2][4] = 0.960237 ;
adTable6Eij[2][5] = 0.849408 ;
adTable6Eij[2][6] = 0.955052 ;
adTable6Eij[2][7] = 1.281790 ;
adTable6Eij[2][8] = 1.500000 ;
adTable6Eij[2][10] = 0.906849 ;
adTable6Eij[2][11] = 0.897362 ;
adTable6Eij[2][12] = 0.726255 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
72
adTable6Eij[2][13] = 0.859764 ;
adTable6Eij[2][14] = 0.855134 ;
adTable6Eij[2][15] = 0.831229 ;
adTable6Eij[2][16] = 0.808310 ;
adTable6Eij[2][17] = 0.786323 ;
adTable6Eij[2][18] = 0.765171 ;
adTable6Eij[3][4] = 1.022560 ;
adTable6Eij[3][5] = 0.693168 ;
adTable6Eij[3][6] = 0.946871 ;
adTable6Eij[3][7] = 1.164460 ;
adTable6Eij[3][11] = 1.013060 ;
adTable6Eij[3][13] = 1.005320 ;
adTable6Eij[4][7] = 1.034787 ;
adTable6Eij[4][11] = 1.004900 ;
adTable6Eij[6][14] = 1.008692 ;
adTable6Eij[6][15] = 1.010126 ;
adTable6Eij[6][16] = 1.011501 ;
adTable6Eij[6][17] = 1.012821 ;
adTable6Eij[6][18] = 1.014089 ;
adTable6Eij[7][8] = 1.100000 ;
adTable6Eij[7][10] = 1.300000 ;
adTable6Eij[7][11] = 1.300000 ;
adTable6Uij[0][1] = 0.886106 ;
adTable6Uij[0][2] = 0.963827 ;
adTable6Uij[0][4] = 0.990877 ;
adTable6Uij[0][6] = 0.736833 ;
adTable6Uij[0][7] = 1.156390 ;
adTable6Uij[0][11] = 0.992291 ;
adTable6Uij[0][13] = 1.003670 ;
adTable6Uij[0][14] = 1.302576 ;
adTable6Uij[0][15] = 1.191904 ;
adTable6Uij[0][16] = 1.205769 ;
adTable6Uij[0][17] = 1.219634 ;
adTable6Uij[0][18] = 1.233498 ;
adTable6Uij[1][2] = 0.835058 ;
adTable6Uij[1][3] = 0.816431 ;
adTable6Uij[1][4] = 0.915502 ;
adTable6Uij[1][6] = 0.993476 ;
adTable6Uij[1][7] = 0.408838 ;
adTable6Uij[1][11] = 0.993556 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
73
adTable6Uij[2][3] = 0.969870 ;
adTable6Uij[2][6] = 1.045290 ;
adTable6Uij[2][8] = 0.900000 ;
adTable6Uij[2][14] = 1.066638 ;
adTable6Uij[2][15] = 1.077634 ;
adTable6Uij[2][16] = 1.088178 ;
adTable6Uij[2][17] = 1.098291 ;
adTable6Uij[2][18] = 1.108021 ;
adTable6Uij[3][4] = 1.065173 ;
adTable6Uij[3][6] = 0.971926 ;
adTable6Uij[3][7] = 1.616660 ;
adTable6Uij[3][10] = 1.250000 ;
adTable6Uij[3][11] = 1.250000 ;
adTable6Uij[3][12] = 1.250000 ;
adTable6Uij[3][13] = 1.250000 ;
adTable6Uij[6][14] = 1.028973 ;
adTable6Uij[6][15] = 1.033754 ;
adTable6Uij[6][16] = 1.038338 ;
adTable6Uij[6][17] = 1.042735 ;
adTable6Uij[6][18] = 1.046966 ;
adTable6Kij[0][1] = 1.003630 ;
adTable6Kij[0][2] = 0.995933 ;
adTable6Kij[0][4] = 1.007619 ;
adTable6Kij[0][6] = 1.000080 ;
adTable6Kij[0][7] = 1.023260 ;
adTable6Kij[0][11] = 0.997596 ;
adTable6Kij[0][13] = 1.002529 ;
adTable6Kij[0][14] = 0.982962 ;
adTable6Kij[0][15] = 0.983565 ;
adTable6Kij[0][16] = 0.982707 ;
adTable6Kij[0][17] = 0.981849 ;
adTable6Kij[0][18] = 0.980991 ;
adTable6Kij[1][2] = 0.982361 ;
adTable6Kij[1][3] = 1.007960 ;
adTable6Kij[1][6] = 0.942596 ;
adTable6Kij[1][7] = 1.032270 ;
adTable6Kij[2][3] = 1.008510 ;
adTable6Kij[2][6] = 1.007790 ;
adTable6Kij[2][14] = 0.910183 ;
adTable6Kij[2][15] = 0.895362 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
74
adTable6Kij[2][16] = 0.881152 ;
adTable6Kij[2][17] = 0.867520 ;
adTable6Kij[2][18] = 0.854406 ;
adTable6Kij[3][4] = 0.986893 ;
adTable6Kij[3][6] = 0.999969 ;
adTable6Kij[3][7] = 1.020340 ;
adTable6Kij[6][14] = 0.968130 ;
adTable6Kij[6][15] = 0.962870 ;
adTable6Kij[6][16] = 0.957828 ;
adTable6Kij[6][17] = 0.952441 ;
adTable6Kij[6][18] = 0.948338 ;
adTable6Gij[0][2] = 0.807653 ;
adTable6Gij[0][7] = 1.957310 ;
adTable6Gij[1][2] = 0.982746 ;
adTable6Gij[2][3] = 0.370296 ;
adTable6Gij[2][5] = 1.673090 ;
} // Detail::table()
/**************************************************************************
* Function : Detail::paramdl()
* Arguments : void
* Returns : void
* Purpose : sets up characterization & binary interaction parameters
* Revisions :
**************************************************************************/
void Detail::paramdl(void)
{
int j, k ;
// table 5 parameters; declared locally to this function
const double adTable5Mri[NUMBEROFCOMPONENTS] =
{16.0430, 28.0135, 44.0100, 30.0700, 44.0970,
18.0153, 34.0820, 2.0159, 28.0100, 31.9988,
58.1230, 58.1230, 72.1500, 72.1500, 86.1770,
100.2040,114.2310,128.2580,142.2850,4.0026,
39.9480} ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
75
const double adTable5Ei[NUMBEROFCOMPONENTS] =
{151.318300, 99.737780, 241.960600, 244.166700,
298.118300, 514.015600, 296.355000, 26.957940,
105.534800, 122.766700, 324.068900, 337.638900,
365.599900, 370.682300, 402.636293, 427.722630,
450.325022, 470.840891, 489.558373, 2.610111,
119.629900} ;
const double adTable5Ki[NUMBEROFCOMPONENTS] =
{0.4619255, 0.4479153, 0.4557489, 0.5279209,
0.5837490, 0.3825868, 0.4618263, 0.3514916,
0.4533894, 0.4186954, 0.6406937, 0.6341423,
0.6738577, 0.6798307, 0.7175118, 0.7525189,
0.7849550, 0.8152731, 0.8437826, 0.3589888,
0.4216551} ;
const double adTable5Gi[NUMBEROFCOMPONENTS] =
{0.000000,0.027815,0.189065,0.079300,0.141239,
0.332500,0.088500,0.034369,0.038953,0.021000,
0.256692,0.281835,0.332267,0.366911,0.289731,
0.337542,0.383381,0.427354,0.469659,0.000000,
0.000000} ;
// most of the table 5 parameters are zero
for (j=0 ; j < NUMBEROFCOMPONENTS ; j++)
{
adTable5Qi[j] = 0.0 ;
adTable5Fi[j] = 0.0 ;
adTable5Si[j] = 0.0 ;
adTable5Wi[j] = 0.0 ;
}
// a small number of exceptions
adTable5Qi[2] = 0.690000 ;
adTable5Qi[5] = 1.067750 ;
adTable5Qi[6] = 0.633276 ;
adTable5Fi[7] = 1.0000 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
76
adTable5Si[5] = 1.5822 ;
adTable5Si[6] = 0.3900 ;
adTable5Wi[5] = 1.0000 ;
// setup characterization parameters for non-zero components
for (j=iNCC-1 ; j >= 0 ; j--)
{
dMri[j] = adTable5Mri[aiCID[j]] ;
dKi[j] = adTable5Ki[aiCID[j]] ;
}
for (j=0 ; j < iNCC ; j++)
{
dGi[j] = adTable5Gi[aiCID[j]] ;
dEi[j] = adTable5Ei[aiCID[j]] ;
}
for (j=0 ; j < iNCC ; j++)
{
dQi[j] = adTable5Qi[aiCID[j]] ;
dFi[j] = 0.0 ;
if (aiCID[j] == 7) dFi[j] = adTable5Fi[7] ;
dSi[j] = adTable5Si[aiCID[j]] ;
dWi[j] = adTable5Wi[aiCID[j]] ;
}
// Binary interaction parameters for arrays: eij, kij, wij, uij
for (j=0 ; j < iNCC ; j++)
{
for (k=j ; k < iNCC ; k++)
{
dUij[j][k] = adTable6Uij[aiCID[j]][aiCID[k]] ;
dKij[j][k] = adTable6Kij[aiCID[j]][aiCID[k]] ;
dEij[j][k] = adTable6Eij[aiCID[j]][aiCID[k]] ;
dGij[j][k] = adTable6Gij[aiCID[j]][aiCID[k]] ;
}
}
} // Detail::paramdl()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
77
/**************************************************************************
* Function : Detail::chardl()
* Arguments : AGA10STRUCT *
* Returns : void
* Purpose : computes composition-dependent quantities
* Revisions :
**************************************************************************/
void Detail::chardl(AGA10STRUCT *ptAGA10)
{
// variables local to function
int i,j ;
double tmfrac, k5p0, k2p5, u5p0, u2p5, q1p0 ;
double Xij, Eij, Gij, e0p5, e2p0, e3p0, e3p5, e4p5, e6p0 ;
double e7p5,e9p5,e12p0,e12p5 ;
double e11p0, s3 ;
// normalize mole fractions and calculate molar mass
tmfrac = 0.0 ;

for (j=0 ; j < iNCC ; j++)
{
tmfrac = tmfrac + dXi[j] ;
}

for (j=0 ; j < iNCC ; j++)
{
dXi[j] = dXi[j]/tmfrac ;
}
// reset virial coefficients
for (j=0 ; j < 18 ; j++)
{
adBcoef[j] = 0.0 ;
}
// initialize a key subset of the local variables
k5p0 = 0.0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
78
k2p5 = 0.0 ;
u5p0 = 0.0 ;
u2p5 = 0.0 ;
dW = 0.0 ;
q1p0 = 0.0 ;
dF = 0.0 ;
// calculate gas molecular weight
ptAGA10->dMrx = 0.0 ;
for (j=0 ; j < iNCC ; j++)
{
ptAGA10->dMrx = ptAGA10->dMrx + dXi[j] * dMri[j] ;
}
// calculate the composition-dependent quantities, applying a nested loop
for (i=0 ; i < iNCC ; i++)
{
k2p5 = k2p5 + dXi[i] * dKi[i] * dKi[i] * sqrt(dKi[i]) ;
u2p5 = u2p5 + dXi[i] * dEi[i] * dEi[i] * sqrt(dEi[i]) ;
dW = dW + dXi[i] * dGi[i] ;
q1p0 = q1p0 + dXi[i] * dQi[i] ;
dF = dF + dXi[i] * dXi[i] * dFi[i] ;
for (j=i ; j < iNCC ; j++)
{
if (i != j) Xij = 2.0 * dXi[i] * dXi[j] ;
else Xij = dXi[i] * dXi[j] ;

// proceed while skipping interaction terms which equal 1.0
if (dKij[i][j] != 1.0)
k5p0 += Xij * (pow(dKij[i][j],5.0) - 1.0) * pow((pow(dKi[i],5.0)
* pow(dKi[j],5.0)),0.5) ;
if (dUij[i][j] != 1.0)
u5p0 += Xij * (pow(dUij[i][j],5.0) - 1.0) * pow((pow(dEi[i],5.0)
* pow(dEi[j],5.0)),0.5) ;

if (dGij[i][j] != 1.0)
dW += Xij * (dGij[i][j] - 1.0) * ((dGi[i] + dGi[j]) / 2.0) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
79
// calculate terms required for second virial coefficient, B
Eij = dEij[i][j] * sqrt(dEi[i] * dEi[j]) ;
Gij = dGij[i][j] * (dGi[i] + dGi[j]) / 2.0 ;
e0p5 = sqrt(Eij) ;
e2p0 = Eij * Eij ;
e3p0 = Eij * e2p0 ;
e3p5 = e3p0 * e0p5 ;
e4p5 = Eij * e3p5 ;
e6p0 = e3p0 * e3p0 ;
e11p0= e4p5 * e4p5 * e2p0 ;
e7p5 = e4p5 * Eij * e2p0 ;
e9p5 = e7p5 * e2p0 ;
e12p0= e11p0 * Eij ;
e12p5= e12p0 * e0p5 ;

s3 = Xij * pow((pow(dKi[i], 3.0) * pow(dKi[j],3)), 0.5) ;
adBcoef[0] = adBcoef[0] + s3 ;
adBcoef[1] = adBcoef[1] + s3 * e0p5 ;
adBcoef[2] = adBcoef[2] + s3 * Eij ;
adBcoef[3] = adBcoef[3] + s3 * e3p5 ;
adBcoef[4] = adBcoef[4] + s3 * Gij / e0p5 ;
adBcoef[5] = adBcoef[5] + s3 * Gij * e4p5 ;
adBcoef[6] = adBcoef[6] + s3 * dQi[i] * dQi[j] * e0p5 ;
adBcoef[7] = adBcoef[7] + s3 * dSi[i] * dSi[j] * e7p5 ;
adBcoef[8] = adBcoef[8] + s3 * dSi[i] * dSi[j] * e9p5 ;
adBcoef[9] = adBcoef[9] + s3 * dWi[i] * dWi[j] * e6p0 ;
adBcoef[10] = adBcoef[10]+ s3 * dWi[i] * dWi[j] * e12p0 ;
adBcoef[11] = adBcoef[11]+ s3 * dWi[i] * dWi[j] * e12p5 ;
adBcoef[12] = adBcoef[12] + s3 * dFi[i] * dFi[j] / e6p0 ;
adBcoef[13] = adBcoef[13] + s3 * e2p0 ;
adBcoef[14] = adBcoef[14] + s3 * e3p0 ;
adBcoef[15] = adBcoef[15] + s3 * dQi[i] * dQi[j] * e2p0 ;
adBcoef[16] = adBcoef[16] + s3 * e2p0 ;
adBcoef[17] = adBcoef[17] + s3 * e11p0 ;
}
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
80
// grab the first 18 constants from table 4, completing Bnij
for (i=0 ; i < 18 ; i++) adBcoef[i] *= adAn[i] ;
// final products of chardl are mixture size parameter K, energy parameter U,
// and quadrupole parameter Q
dKp3 = pow((k5p0 + k2p5 * k2p5), 0.6) ;
dU = pow((u5p0 + u2p5 * u2p5), 0.2) ;
dQp2 = q1p0 * q1p0 ;
} // Detail::chardl()
/**************************************************************************
* Function : Detail::bvir()
* Arguments : void
* Returns : void
* Purpose : computes 2nd virial coefficient & partial derivs thereof
* Revisions :
**************************************************************************/
void Detail::bvir(void)
{
// variables local to function
double t0p5, t2p0, t3p0, t3p5, t4p5, t6p0, t11p0 ;
double t7p5, t9p5, t12p0, t12p5 ;
double t1p5, t4p0 ;
double Bx[18] ;
int i ;
// reset B and partial devivatives to 0.0
dB = ddBdT = dd2BdT2 = 0.0 ;
// pre-calculate powers of T
t0p5 = sqrt(dT) ;
t2p0 = dT * dT ;
t3p0 = dT * t2p0 ;
t3p5 = t3p0 * t0p5 ;
t4p5 = dT * t3p5 ;
t6p0 = t3p0 * t3p0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
81
t11p0 = t4p5 * t4p5 * t2p0 ;
t7p5 = t6p0 * dT * t0p5 ;
t9p5 = t7p5 * t2p0 ;
t12p0 = t9p5 * t0p5 * t2p0 ;
t12p5 = t12p0 * t0p5 ;
t1p5 = dT * t0p5 ;
t4p0 = t2p0 * t2p0 ;
// coefficients for B
Bx[0] = adBcoef[0] ;
Bx[1] = adBcoef[1] / t0p5 ;
Bx[2] = adBcoef[2] / dT ;
Bx[3] = adBcoef[3] / t3p5 ;
Bx[4] = adBcoef[4] * t0p5 ;
Bx[5] = adBcoef[5] / t4p5 ;
Bx[6] = adBcoef[6] / t0p5 ;
Bx[7] = adBcoef[7] / t7p5 ;
Bx[8] = adBcoef[8] / t9p5 ;
Bx[9] = adBcoef[9] / t6p0 ;
Bx[10] = adBcoef[10] / t12p0 ;
Bx[11] = adBcoef[11] / t12p5 ;
Bx[12] = adBcoef[12] * t6p0 ;
Bx[13] = adBcoef[13] / t2p0 ;
Bx[14] = adBcoef[14] / t3p0 ;
Bx[15] = adBcoef[15] / t2p0 ;
Bx[16] = adBcoef[16] / t2p0 ;
Bx[17] = adBcoef[17] / t11p0 ;
// sum up the pieces for second virial coefficient, B
for (i= 0; i < 18; i++)
{
dB += Bx[i] ;
}
// calculate terms for first derivative of B, wrt T
for (i= 0; i < 18; i++)
{
if (adUn[i])
Bx[i] *= adUn[i] ;
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
82
// sum up the pieces of first derivative of B
// note div by dT; changes exponent of T
for (i= 0; i < 18; i++)
{
if (adUn[i])
ddBdT += Bx[i] / dT ;
}
// sign change here
ddBdT = -ddBdT ;
// calculate terms for second derivative of B, wrt T
for (i= 0; i < 18; i++)
{
if (adUn[i] && adUn[i] != -1.0)
Bx[i] *= (adUn[i] + 1.0) ;
}
// sum up the pieces of second derivative of B
// note division by dT, thereby changing the exponent of T
// loop will ignore Bx[0] which is = 0.0
for (i= 0; i < 18; i++)
{
if (adUn[i] && adUn[i] != -1.0)
dd2BdT2 += Bx[i] / t2p0 ;
}
} // Detail::bvir()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
83
/**************************************************************************
* Function : Detail::temp()
* Arguments : void
* Returns : void
* Purpose : computes temperature-dependent quantities
* Revisions :
**************************************************************************/
void Detail::temp(void)
{
// Note: this function was ported from the AGA Report No.8 FORTRAN listing,
// retaining as much of the original content as possible
// variables local to function
double tr0p5, tr1p5, tr2p0, tr3p0, tr4p0, tr5p0, tr6p0 ;
double tr7p0, tr8p0, tr9p0, tr11p0, tr13p0, tr21p0 ;
double tr22p0, tr23p0, tr ;
/* calculate second virial coefficient B */
bvir() ;
// calculate adFn(12) through adFn(57)
// adFn(0)-adFn(11) do not contribute to csm terms
tr = dT / (dU) ;
tr0p5 = sqrt(tr) ;
tr1p5 = tr * tr0p5 ;
tr2p0 = tr * tr ;
tr3p0 = tr * tr2p0 ;
tr4p0 = tr * tr3p0 ;
tr5p0 = tr * tr4p0 ;
tr6p0 = tr * tr5p0 ;
tr7p0 = tr * tr6p0 ;
tr8p0 = tr * tr7p0 ;
tr9p0 = tr * tr8p0 ;
tr11p0 = tr6p0 * tr5p0 ;
tr13p0 = tr6p0 * tr7p0 ;
tr21p0 = tr9p0 * tr9p0 * tr3p0 ;
tr22p0 = tr * tr21p0 ;
tr23p0 = tr * tr22p0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
84
adFn[12] = adAn[12] * dF * tr6p0 ;
adFn[13] = adAn[13] / tr2p0 ;
adFn[14] = adAn[14] / tr3p0 ;
adFn[15] = adAn[15] * dQp2 / tr2p0 ;
adFn[16] = adAn[16] / tr2p0 ;
adFn[17] = adAn[17] / tr11p0 ;
adFn[18] = adAn[18] * tr0p5 ;
adFn[19] = adAn[19] / tr0p5 ;
adFn[20] = adAn[20] ;
adFn[21] = adAn[21] / tr4p0 ;
adFn[22] = adAn[22] / tr6p0 ;
adFn[23] = adAn[23] / tr21p0 ;
adFn[24] = adAn[24] * dW / tr23p0 ;
adFn[25] = adAn[25] * dQp2 / tr22p0 ;
adFn[26] = adAn[26] * dF * tr ;
adFn[27] = adAn[27] * dQp2 * tr0p5 ;
adFn[28] = adAn[28] * dW / tr7p0 ;
adFn[29] = adAn[29] * dF * tr ;
adFn[30] = adAn[30] / tr6p0 ;
adFn[31] = adAn[31] * dW / tr4p0 ;
adFn[32] = adAn[32] * dW / tr ;
adFn[33] = adAn[33] * dW / tr9p0 ;
adFn[34] = adAn[34] * dF * tr13p0 ;
adFn[35] = adAn[35] / tr21p0 ;
adFn[36] = adAn[36] * dQp2 / tr8p0 ;
adFn[37] = adAn[37] * tr0p5 ;
adFn[38] = adAn[38] ;
adFn[39] = adAn[39] / tr2p0 ;
adFn[40] = adAn[40] / tr7p0 ;
adFn[41] = adAn[41] * dQp2 / tr9p0 ;
adFn[42] = adAn[42] / tr22p0 ;
adFn[43] = adAn[43] / tr23p0 ;
adFn[44] = adAn[44] / tr ;
adFn[45] = adAn[45] / tr9p0 ;
adFn[46] = adAn[46] * dQp2 / tr3p0 ;
adFn[47] = adAn[47] / tr8p0 ;
adFn[48] = adAn[48] * dQp2 / tr23p0 ;
adFn[49] = adAn[49] / tr1p5 ;
adFn[50] = adAn[50] * dW / tr5p0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
85
adFn[51] = adAn[51] * dQp2 * tr0p5 ;
adFn[52] = adAn[52] / tr4p0 ;
adFn[53] = adAn[53] * dW / tr7p0 ;
adFn[54] = adAn[54] / tr3p0 ;
adFn[55] = adAn[55] * dW ;
adFn[56] = adAn[56] / tr ;
adFn[57] = adAn[57] * dQp2 ;
} // Detail::temp()
/**************************************************************************
* Function : Detail::ddetail()
* Arguments : AGA10STRUCT *
* Returns : void
* Purpose : calculates density
* Revisions :
**************************************************************************/
// Note: this function was ported from the AGA Report No.8 FORTRAN listing,
// retaining as much of the original content as possible
void Detail::ddetail(AGA10STRUCT *ptAGA10)
{
int imax, i ;
double epsp, epsr, epsmin ;
double x1, x2, x3, y1, y2, y3 ;
double delx, delprv, delmin, delbis, xnumer, xdenom, sgndel ;
double y2my3, y3my1, y1my2, boundn ;
// initialize convergence tolerances
imax = 150 ;
epsp = 1.e-6 ;
epsr = 1.e-6 ;
epsmin = 1.e-7 ;
dRho =0.0 ;
// call subroutine braket to bracket density solution
braket(ptAGA10) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
86
// check value of "lStatus" returned from subroutine braket
if (ptAGA10->lStatus == MAX_NUM_OF_ITERATIONS_EXCEEDED ||
ptAGA10->lStatus == NEGATIVE_DENSITY_DERIVATIVE)
{
return ;
}
// set up to start Brent's method
// x is the independent variable, y the dependent variable
// delx is the current iteration change in x
// delprv is the previous iteration change in x
x1 = dRhoL ;
x2 = dRhoH ;
y1 = dPRhoL - dP ;
y2 = dPRhoH - dP ;
delx = x1 - x2 ;
delprv = delx ;
// solution is bracketed between x1 and x2
// a third point x3 is introduced for quadratic interpolation
x3 = x1 ;
y3 = y1 ;
for (i=0 ; i < imax ; i++)
{
// y3 must be opposite in sign from y2 so solution between x2,x3
if (y2 * y3 > 0.0)
{
x3 = x1 ;
y3 = y1 ;
delx = x1 - x2 ;
delprv = delx ;
}
// y2 must be value of y closest to y=0.0, then x2new=x2old+delx
if (fabs(y3) < fabs(y2))
{
x1 = x2 ;
x2 = x3 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
87
x3 = x1 ;
y1 = y2 ;
y2 = y3 ;
y3 = y1 ;
}
// delmin is minimum allowed step size for unconverged iteration
delmin = epsmin * fabs(x2) ;
// if procedure is not converging or if delprv is less than delmin
// use bisection instead
// delbis = 0.5d0*(x3 - x2) is the bisection delx
delbis = 0.5 * (x3 - x2) ;
// tests to select numerical method for current iteration
if (fabs(delprv) < delmin || fabs(y1) < fabs(y2))
{
// use bisection
delx = delbis ;
delprv = delbis ;
}
else
{
if (x3 != x1)
{
// use inverse quadratic interpolation
y2my3 = y2 - y3 ;
y3my1 = y3 - y1 ;
y1my2 = y1 - y2 ;
xdenom = -(y1my2) * (y2my3) * (y3my1) ;
xnumer = x1 * y2 * y3 * (y2my3)
+ x2 * y3 * y1 * (y3my1)
+ x3 * y1 * y2 * (y1my2)
- x2 * xdenom ;
}
else
{
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
88
// use inverse linear interpolation
xnumer = (x2-x1)*y2 ;
xdenom = y1-y2 ;
}
// before calculating delx check delx=xnumer/xdenom is not out of bounds
if (2.0 * fabs(xnumer) < fabs(delprv * xdenom))
{
// procedure converging, use interpolation
delprv = delx ;
delx = xnumer / xdenom ;
}
else
{
// procedure diverging, use bisection
delx = delbis ;
delprv = delbis ;
}
}
// check for convergence
if ((fabs(y2) < epsp * dP) && (fabs(delx) < epsr * fabs(x2)))
{
dRho = x2 + delx ;
return ;
}
// when unconverged, abs(delx) must be greater than delmin
// minimum allowed magnitude of change in x2 is 1.0000009*delmin
// sgndel, the sign of change in x2 is sign of delbis
if (fabs(delx) < delmin)
{
sgndel = delbis / fabs(delbis) ;
delx = 1.0000009 * sgndel * delmin ;
delprv = delx ;
}
// final check to insure that new x2 is in range of old x2 and x3
// boundn is negative if new x2 is in range of old x2 and x3
boundn = delx * (x2 + delx - x3) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
89
if (boundn > 0.0)
{
// procedure stepping out of bounds, use bisection
delx = delbis ;
delprv = delbis ;
}
// relable variables for next iteration
// x1new = x2old, y1new=y2old
x1 = x2 ;
y1 = y2 ;
// next iteration values for x2, y2
x2 = x2 + delx ;
pdetail(x2) ;
y2 = dPCalc - dP ;
}
// ddetail: maximum number of iterations exceeded
ptAGA10->lStatus=MAX_NUM_OF_ITERATIONS_EXCEEDED ;
dRho = x2 ;
} // Detail::ddetail()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
90
/**************************************************************************
* Function : Detail::braket()
* Arguments : AGA10STRUCT *
* Returns : void
* Purpose : brackets density solution
* Revisions :
**************************************************************************/
// Note: this function was ported from the AGA Report No.8 FORTRAN listing,
// retaining as much of the original content as possible
void Detail::braket(AGA10STRUCT *ptAGA10)
{
// variables local to function
int imax, it ;
double del, rhomax, videal ;
double rho1, rho2, p1, p2 ;
// initialize
imax = 200 ;
rho1 = 0.0 ;
p1 = 0.0 ;
rhomax = 1.0 / dKp3 ;
if (dT > 1.2593 * dU) rhomax = 20.0 * rhomax ;
videal = RGASKJ * dT / dP ;
if (fabs(dB) < (0.167 * videal))
{
rho2 = 0.95 / (videal + dB) ;
}
else
{
rho2 = 1.15 / videal ;
}
del = rho2 / 20.0 ;
// start iterative density search loop
for (it = 0; it < imax ; it++)
{
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
91
if (rho2 > rhomax && ptAGA10->lStatus != MAX_DENSITY_IN_BRAKET_EXCEEDED)
{
// density in braket exceeds maximum allowable density
ptAGA10->lStatus = MAX_DENSITY_IN_BRAKET_EXCEEDED ;
del = 0.01 * (rhomax - rho1) + (dP / (RGASKJ * dT)) / 20.0 ;
rho2 = rho1 + del ;
continue ;
}
// calculate pressure p2 at density rho2
pdetail(rho2) ;
p2 = dPCalc ;
// test value of p2 relative to p and relative to p1
if (p2 > dP)
{
// the density root is bracketed (p1<p and p2>p)
dRhoL = rho1 ;
dPRhoL = p1 ;
dRhoH = rho2 ;
dPRhoH = p2 ;
ptAGA10->lStatus = NORMAL ;
return;
}
else if (p2 > p1)
{
if (ptAGA10->lStatus == MAX_DENSITY_IN_BRAKET_EXCEEDED) del *= 2.0 ;
rho1 = rho2 ;
p1 = p2 ;
rho2 = rho1 + del ;
continue ;
}
else
{
// lStatus= NEGATIVE_DENSITY_DERIVATIVEindicates that
// pressure has a negative density derivative, since p2 is less than
// some previous pressure
ptAGA10->lStatus = NEGATIVE_DENSITY_DERIVATIVE;
dRho = rho1;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
92
return;
}
}
// maximum number of iterations exceeded if we fall through the bottom
ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED ;
dRho = rho2 ;
return ;
} // Detail::braket()
/**************************************************************************
* Function : Detail::pdetail()
* Arguments : double
* Returns : void
* Purpose : calculates pressure, given D and T. Calls zdetail()
* Revisions :
**************************************************************************/
void Detail::pdetail(double dD)
{
dPCalc = zdetail(dD) * dD * RGASKJ * dT ;
} // Detail::pdetail()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
93
/**************************************************************************
* Function : Detail::zdetail()
* Arguments : double
* Returns : void
* Purpose : calculates compressibility
* Revisions :
**************************************************************************/
double Detail::zdetail(double d)
{
// variables local to function
double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ;
// powers of reduced density
D1 = dKp3 * d ;
D2 = D1 * D1 ;
D3 = D2 * D1 ;
D4 = D3 * D1 ;
D5 = D4 * D1 ;
D6 = D5 * D1 ;
D7 = D6 * D1 ;
D8 = D7 * D1 ;
D9 = D8 * D1 ;
exp1 = exp(-D1) ;
exp2 = exp(-D2) ;
exp3 = exp(-D3) ;
exp4 = exp(-D4) ;
// the following expression for Z was adopted from FORTRAN example in AGA8
dZ = 1.0 + dB * d
+ adFn[12] * D1 * (exp3 - 1.0 - 3.0 * D3 * exp3)
+ (adFn[13] + adFn[14] + adFn[15]) * D1 * (exp2 - 1.0 - 2.0 * D2 * exp2)
+ (adFn[16] + adFn[17]) * D1 * (exp4 - 1.0 - 4.0 * D4 * exp4)
+ (adFn[18] + adFn[19]) * D2 * 2.0
+ (adFn[20] + adFn[21] + adFn[22]) * D2 * (2.0 - 2.0 * D2) * exp2
+ (adFn[23] + adFn[24] + adFn[25]) * D2 * (2.0 - 4.0 * D4) * exp4
+ adFn[26] * D2 * (2.0 - 4.0 * D4) * exp4
+ adFn[27] * D3 * 3.0
+ (adFn[28] + adFn[29]) * D3 * (3.0 - D1) * exp1
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
94
+ (adFn[30] + adFn[31]) * D3 * (3.0 - 2.0 * D2) * exp2
+ (adFn[32] + adFn[33]) * D3 * (3.0 - 3.0 * D3) * exp3
+ (adFn[34] + adFn[35] + adFn[36]) * D3 * (3.0 - 4.0 * D4) * exp4
+ (adFn[37] + adFn[38]) * D4 * 4.0
+ (adFn[39] + adFn[40] + adFn[41]) * D4 * (4.0 - 2.0 * D2) * exp2
+ (adFn[42] + adFn[43]) * D4 * (4.0 - 4.0 * D4) * exp4
+ adFn[44] * D5 * 5.0
+ (adFn[45] + adFn[46]) * D5 * (5.0 - 2.0 * D2) * exp2
+ (adFn[47] + adFn[48]) * D5 * (5.0 - 4.0 * D4) * exp4
+ adFn[49] * D6 * 6.0
+ adFn[50] * D6 * (6.0 - 2.0 * D2) * exp2
+ adFn[51] * D7 * 7.0
+ adFn[52] * D7 * (7.0 - 2.0 * D2) * exp2
+ adFn[53] * D8 * (8.0 - D1) * exp1
+ (adFn[54] + adFn[55]) * D8 * (8.0 - 2.0 * D2) * exp2
+ (adFn[56] + adFn[57]) * D9 * (9.0 - 2.0 * D2) * exp2 ;
return dZ ;
} // Detail::zdetail()
/**************************************************************************
* Function : Detail::dZdT()
* Arguments : double
* Returns : double
* Purpose : calculates the first partial derivative of Z wrt T
* Revisions :
**************************************************************************/
double Detail::dZdT(double d)
{
// variables local to function
double tmp ;
int i ;
double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ;
// set up powers of reduced density
D1 = dKp3 * d ;
D2 = D1 * D1 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
95
D3 = D2 * D1 ;
D4 = D3 * D1 ;
D5 = D4 * D1 ;
D6 = D5 * D1 ;
D7 = D6 * D1 ;
D8 = D7 * D1 ;
D9 = D8 * D1 ;
exp1 = exp(-D1) ;
exp2 = exp(-D2) ;
exp3 = exp(-D3) ;
exp4 = exp(-D4) ;
// create terms uC*T^-(un+1) from coefficients we've already computed (An[n])
for (i=12; i < 58; i++)
{
if (adUn[i] && adFn[i])
{
fx[i] = (adFn[i] * adUn[i] * D1) / dT;
}
else
{
fx[i] = 0.0 ;
}
}
// initial part of equation
ddZdT = d * ddBdT ;
// n=13 evaluates to zero except for hydrogen, for whom fn = 1
if (dF) ddZdT += fx[12] - (fx[12] * (1.0 - 3.0 * D3) * exp3) ;
tmp = (1.0 - 2.0 * D2) * exp2 ;
ddZdT += (fx[13] - (fx[13] * tmp)) ;
ddZdT += fx[14] - (fx[14] * tmp) ;
ddZdT += fx[15] - (fx[15] * tmp) ;
tmp = (1.0 - 4.0 * D4) * exp4 ;
ddZdT += fx[16] - (fx[16] * tmp) ;
ddZdT += fx[17] - (fx[17] * tmp) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
96
ddZdT = ddZdT - (fx[18] + fx[19]) * D1 * 2.0
- (fx[21] + fx[22]) * D1 * (2.0 - 2.0 * D2) * exp2
- (fx[23] + fx[24] + fx[25]) * D1 * (2.0 - 4.0 * D4) * exp4
- fx[26] * D1 * (2.0 - 4.0 * D4) * exp4
- fx[27] * D2 * 3.0
- (fx[28] + fx[29]) * D2 * (3.0 - D1) * exp1
- (fx[30] + fx[31]) * D2 * (3.0 - 2.0 * D2) * exp2
- (fx[32] + fx[33]) * D2 * (3.0 - 3.0 * D3) * exp3
- (fx[34] + fx[35] + fx[36]) * D2 * (3.0 - 4.0 * D4) * exp4
- fx[37] * D3 * 4.0
- (fx[39] + fx[40] + fx[41]) * D3 * (4.0 - 2.0 * D2) * exp2
- (fx[42] + fx[43]) * D3 * (4.0 - 4.0 * D4) * exp4
- fx[44] * D4 * 5.0
- (fx[45] + fx[46]) * D4 * (5.0 - 2.0 * D2) * exp2
- (fx[47] + fx[48]) * D4 * (5.0 - 4.0 * D4) * exp4
- fx[49] * D5 * 6.0
- fx[50] * D5 * (6.0 - 2.0 * D2) * exp2
- fx[51] * D6 * 7.0
- fx[52] * D6 * (7.0 - 2.0 * D2) * exp2
- fx[53] * D7 * (8.0 - D1) * exp1
- fx[54] * D7 * (8.0 - 2.0 * D2) * exp2
- fx[56] * D8 * (9.0 - 2.0 * D2) * exp2 ;
return ddZdT ;
} // Detail::dDdT()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
97
/**************************************************************************
* Function : Detail::d2ZdT2()
* Arguments : double
* Returns : double
* Purpose : calculates the second partial derivative of Z wrt T
* Revisions :
**************************************************************************/
double Detail::d2ZdT2(double d)
{
// variables local to function
double tmp ;
int i ;
double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ;
// set up powers of reduced density
D1 = dKp3 * d ;
D2 = D1 * D1 ;
D3 = D2 * D1 ;
D4 = D3 * D1 ;
D5 = D4 * D1 ;
D6 = D5 * D1 ;
D7 = D6 * D1 ;
D8 = D7 * D1 ;
D9 = D8 * D1 ;
exp1 = exp(-D1) ;
exp2 = exp(-D2) ;
exp3 = exp(-D3) ;
exp4 = exp(-D4) ;
// create terms uC*T^-(un+1) from coefficients we've already computed (An[n])
for (i=12; i < 58; i++)
{
if (adUn[i] && adFn[i])
{
fx[i] = (adFn[i] * D1 * adUn[i] * (adUn[i] + 1.0)) / (dT * dT) ;
}
else
{
fx[i] = 0.0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
98
}
}
// initial part of equation
dd2ZdT2 = d * dd2BdT2 ;
// n=13 evaluates to zero except for hydrogen, for whom fn = 1
if (dF) dd2ZdT2 += fx[12] - (fx[12] * (1.0 - 3.0 * D3) * exp3) ;
tmp = (1.0 - 2.0 * D2) * exp2 ;
dd2ZdT2 += -fx[13] + (fx[13] * tmp) ;
dd2ZdT2 += -fx[14] + (fx[14] * tmp) ;
dd2ZdT2 += -fx[15] + (fx[15] * tmp) ;
tmp = (1.0 - 4.0 * D4) * exp4 ;
dd2ZdT2 += -fx[16] + (fx[16] * tmp) ;
dd2ZdT2 += -fx[17] + (fx[17] * tmp) ;
dd2ZdT2 = dd2ZdT2 + (fx[18] + fx[19]) * D1 * 2.0
+ (fx[21] + fx[22]) * D1 * (2.0 - 2.0 * D2) * exp2
+ (fx[23] + fx[24] + fx[25]) * D1 * (2.0 - 4.0 * D4) * exp4
+ fx[26] * D1 * (2.0 - 4.0 * D4) * exp4
+ fx[27] * D2 * 3.0
+ (fx[28] + fx[29]) * D2 * (3.0 - D1) * exp1
+ (fx[30] + fx[31]) * D2 * (3.0 - 2.0 * D2) * exp2
+ (fx[32] + fx[33]) * D2 * (3.0 - 3.0 * D3) * exp3
+ (fx[34] + fx[35] + fx[36]) * D2 * (3.0 - 4.0 * D4) * exp4
+ fx[37] * D3 * 4.0
+ (fx[39] + fx[40] + fx[41]) * D3 * (4.0 - 2.0 * D2) * exp2
+ (fx[42] + fx[43]) * D3 * (4.0 - 4.0 * D4) * exp4
+ fx[44] * D4 * 5.0
+ (fx[45] + fx[46]) * D4 * (5.0 - 2.0 * D2) * exp2
+ (fx[47] + fx[48]) * D4 * (5.0 - 4.0 * D4) * exp4
+ fx[49] * D5 * 6.0
+ fx[50] * D5 * (6.0 - 2.0 * D2) * exp2
+ fx[51] * D6 * 7.0
+ fx[52] * D6 * (7.0 - 2.0 * D2) * exp2
+ fx[53] * D7 * (8.0 - D1) * exp1
+ fx[54] * D7 * (8.0 - 2.0 * D2) * exp2
+ fx[56] * D8 * (9.0 - 2.0 * D2) * exp2 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
99
return dd2ZdT2 ;
} // Detail::d2ZdT2()
/**************************************************************************
* Function : Detail::dZdD()
* Arguments : double
* Returns : double
* Purpose : calculates the first partial derivative of Z wrt D
* Revisions :
**************************************************************************/
// For efficiency and continuity with AGA 8 code example, each term
// is evaluated individually rather than through looping through tables.
// Temporary storage is used to hold portions of complex equations and
// to facilitate debugging. Additional speed optimization is possible.
double Detail::dZdD(double d)
{
double temp, temp1, temp2, temp3;
int i ;
double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ;
// set up powers of reduced density
D1 = dKp3 * d ;
D2 = D1 * D1 ;
D3 = D2 * D1 ;
D4 = D3 * D1 ;
D5 = D4 * D1 ;
D6 = D5 * D1 ;
D7 = D6 * D1 ;
D8 = D7 * D1 ;
D9 = D8 * D1 ;
exp1 = exp(-D1) ;
exp2 = exp(-D2) ;
exp3 = exp(-D3) ;
exp4 = exp(-D4) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
100
// create terms uC*T^-(un+1) from coefficients we've already computed (An[n])
for (i=12; i < 58; i++)
{
fx[i] = adFn[i] ;
}
// initial part of equation
ddZdD = dB / dKp3 ;
// evaluate all remaining terms, simplifying where possible
// n=13 evaluates to zero except for hydrogen, for whom fn = 1
if (dF)
{
temp1 = -9.0 * D3 * exp3 ;
temp2 = (1.0 - 3.0 * D3) * exp3 ;
temp3 = -temp2 * 3.0 * D6;
temp = temp1 + temp2 + temp3 ;
ddZdD += -fx[12] + fx[12] * temp ;
}
// n = 14..16
temp1 = -4.0 * D2 * exp2 ;
temp2 = (1.0 - 2.0 * D2) * exp2 ;
temp3 = -temp2 * 2.0 * D2;
temp = temp1 + temp2 + temp3 ;
ddZdD += -fx[13] + fx[13] * temp ;
ddZdD += -fx[14] + fx[14] * temp ;
ddZdD += -fx[15] + fx[15] * temp ;
// n = 17..18
temp1 = -16.0 * D4 * exp4 ;
temp2 = (1.0 - 4.0 * D4) * exp4 ;
temp3 = -temp2 * 4.0 * D4 ;
temp = temp1 + temp2 + temp3 ;
ddZdD += -fx[16] + fx[16] * temp ;
ddZdD += -fx[17] + fx[17] * temp ;
// n = 19..20
temp = 4.0 * D1 ;
ddZdD += fx[18] * temp ;
ddZdD += fx[19] * temp ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
101
// n = 21..23
temp1 = -4.0 * D3 * exp2 ;
temp2 = (2.0 - 2.0 * D2) * 2.0 * D1 * exp2 ;
temp3 = -temp2 * D2;
temp = temp1 + temp2 + temp3 ;
ddZdD += fx[20] * temp ;
ddZdD += fx[21] * temp ;
ddZdD += fx[22] * temp ;
// n = 24..27
temp1 = -16.0 * D5 * exp4 ;
temp2 = (2.0 - 4.0 * D4) * 2.0 * D1 * exp4 ;
temp3 = -temp2 * 2.0 * D4 ;
temp = temp1 + temp2 + temp3 ;
ddZdD += fx[23] * temp ;
ddZdD += fx[24] * temp ;
ddZdD += fx[25] * temp ;
ddZdD += fx[26] * temp ;
// n = 28
temp = 9.0 * D2 ;
ddZdD += fx[27] * temp ;
// n = 29..30
temp = -D3 * exp1 + (3.0 - D1) * 3.0 * D2 * exp1 ;
temp -= (3.0 - D1) * D3 * exp1 ;
ddZdD += fx[28] * temp ;
ddZdD += fx[29] * temp ;
// n = 31..32
temp1 = -4.0 * D4 * exp2 ;
temp2 = (3.0 - 2.0 * D2) * 3.0 * D2 * exp2 ;
temp3 = -(3.0 - 2.0 * D2) * 2.0 * D4 * exp2 ;
temp = temp1 + temp2 + temp3 ;
ddZdD += fx[30] * temp ;
ddZdD += fx[31] * temp ;
// n = 33..34
temp1 = -9.0 * D5 * exp3 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
102
temp2 = (3.0 - 3.0 * D3) * 3.0 * D2 * exp3 ;
temp3 = -(3.0 - 3.0 * D3) * 3.0 * D5 * exp3 ;
temp = temp1 + temp2 + temp3 ;
ddZdD += fx[32] * temp ;
ddZdD += fx[33] * temp ;
// n = 35..37
temp1 = -16.0 * D6 * exp4 ;
temp2 = (3.0 - 4.0 * D4) * 3.0 * D2 * exp4 ;
temp3 = -(3.0 - 4.0 * D4) * D6 * 4.0 * exp4 ;
temp = temp1 + temp2 + temp3 ;
ddZdD += fx[34] * temp ;
ddZdD += fx[35] * temp ;
ddZdD += fx[36] * temp ;
// n = 38..39
temp = 16.0 * D3 ;
ddZdD += fx[37] * temp ;
ddZdD += fx[38] * temp ;
// n = 40..42
temp1 = -4.0 * D5 * exp2 ;
temp2 = (4.0 - 2.0 * D2) * 4.0 * D3 * exp2 ;
temp3 = -(4.0 - 2.0 * D2) * 2.0 * D5 * exp2 ;
temp = temp1 + temp2 + temp3 ;
ddZdD += fx[39] * temp ;
ddZdD += fx[40] * temp ;
ddZdD += fx[41] * temp ;
// n = 43..44
temp = -16.0 * D7 * exp4 + (4.0 - 4.0 * D4) * 4.0 * D3 * exp4 ;
temp -= (4.0 - 4.0 * D4) * D7 * 4.0 * exp4 ;
ddZdD += fx[42] * temp ;
ddZdD += fx[43] * temp ;
// n = 45
temp = 25.0 * D4 ;
ddZdD += fx[44] * temp ;
// n = 46..47
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
103
temp = -4.0 * D6 * exp2 + (5.0 - 2.0 * D2) * 5.0 * D4 * exp2 ;
temp -= (5.0 - 2.0 * D2) * D6 * 2.0 * exp2 ;
ddZdD += fx[45] * temp ;
ddZdD += fx[46] * temp ;
// n = 48..49
temp = -16.0 * D8 * exp4 + (5.0 - 4.0 * D4) * 5.0 * D4 * exp4 ;
temp -= (5.0 - 4.0 * D4) * D8 * 4.0 * exp4 ;
ddZdD += fx[47] * temp ;
ddZdD += fx[48] * temp ;
// n = 50
temp = 36.0 * D5 ;
ddZdD += fx[49] * temp ;
// n = 51
temp = -4.0 * D7 * exp2 + (6.0 - 2.0 * D2) * 6.0 * D5 * exp2 ;
temp -= (6.0 - 2.0 * D2) * D7 * 2.0 * exp2 ;
ddZdD += fx[50] * temp ;
// n = 52
temp = 49.0 * D6 ;
ddZdD += fx[51] * temp ;
// n = 53
temp = -4.0 * D8 * exp2 + (7.0 - 2.0 * D2) * 7.0 * D6 * exp2 ;
temp -= (7.0 - 2.0 * D2) * D8 * 2.0 * exp2 ;
ddZdD += fx[52] * temp ;
// n = 54
temp = -1.0 * D8 * exp1 + (8.0 - D1) * 8.0 * D7 * exp1 ;
temp -= (8.0 - D1) * D8 * exp1 ;
ddZdD += fx[53] * temp ;
// n = 55..56
temp = -4.0 * D1 * D8 * exp2 + (8.0 - 2.0 * D2) * 8.0 * D7 * exp2 ;
temp -= (8.0 - 2.0 * D2) * D8 * 2.0 * D1 * exp2 ;
ddZdD += fx[54] * temp ;
ddZdD += fx[55] * temp ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
104
// n = 57..58
temp = -4.0 * D2 * D8 * exp2 + (9.0 - 2.0 * D2) * 9.0 * D8 * exp2 ;
temp -= (9.0 - 2.0 * D2) * D2 * D8 * 2.0 * exp2 ;
ddZdD += fx[56] * temp ;
ddZdD += fx[57] * temp ;
ddZdD *= dKp3 ;
return ddZdD ;
} // Detail::dZdD()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
105
/**************************************************************************
* Function : Detail::relativedensity()
* Arguments : AGA10STRUCT *
* Returns : void
* Purpose : calculates relative density via methods listed in AGA 8
* Revisions :
**************************************************************************/
void Detail::relativedensity(AGA10STRUCT *ptAGA10)
{
double dBX, dZa ;
const double dMWair = 28.96256 ;
// calculate second virial coefficient for air
dBX = -0.12527 + 5.91e-4 * ptAGA10->dTb - 6.62e-7 * ptAGA10->dTb * ptAGA10->dTb ;
// calculate compressibility of air
dZa = 1.0 + (dBX * dP) / (RGASKJ * ptAGA10->dTb) ;
// calculate ideal gas and real gas relative densities
ptAGA10->dRD_Ideal = ptAGA10->dMrx / dMWair ;
ptAGA10->dRD_Real = ptAGA10->dRD_Ideal * (dZa / ptAGA10->dZb) ;
} // Detail::relativedensity()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
106
/*************************************************************************
* File : therm.h
* Description : Header file for class 'Therm'
* See therm.cpp for implementation of this class
* Version : ver 1.7 2002.11.17
* Author : W.B. Peterson
* Revisions:
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#ifndef _THERM_H
#define _THERM_H
#include "aga10.h"
#include "detail.h"
class Therm
{
private:
// member data
double dT ; // current temperature, in Kelvins
double dP ; // current pressure, in Pascals
double dD ; // molar density, in moles/dm3
double dRho ; // mass density, in kg/m3
double dPdD ; // partial deriv of P wrt D
double dPdT ; // partial deriv of P wrt T
double dSi ; // ideal gas specific entropy, kJ/kg.K
double dTold ; // temperature previously used
double dMrxold ; // mixture molar mass previously used
// private methods
double CpiMolar(AGA10STRUCT *) ;
protected:
public:
Therm(void) ; // default constructor
~Therm() ; // default destructor
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
107
void Run(AGA10STRUCT *, Detail *) ; // runs an object based on this class
double Ho(AGA10STRUCT *) ; // ideal gas enthalpy
double So(AGA10STRUCT *) ; // ideal gas entropy
void CprCvrHS(AGA10STRUCT *, Detail *) ; // specific heat capacities + k_ideal + H + S
double H(AGA10STRUCT *, Detail *) ; // real gas specific enthalpy
double S(AGA10STRUCT *, Detail *) ; // real gas specific entropy
void HS_Mode(AGA10STRUCT *, Detail *, double, double, bool) ; // estimates P & T, given H & S
} ;
// Other data used by Therm class
// Roots and Weights for gaussian quadrature
const long double GK_root[5] =
{ 0.14887433898163121088,
0.43339539412924719080,
0.67940956829902440263,
0.86506336668898451073,
0.97390652851717172008 };

const long double GK_weight[5] =
{ 0.29552422471475286217,
0.26926671930999634918,
0.21908636251598204295,
0.14945134915058059038,
0.066671344308688137179 };
// set the number of points for quadrature
const int GK_points = 5 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
108
//equation constants for ideal gas heat capacity, enthalpy and entropy
const double ThermConstants[NUMBEROFCOMPONENTS[11] =
{{-29776.4, 7.95454, 43.9417, 1037.09, 1.56373, 813.205, -24.9027, 1019.98,-10.1601, 1070.14,-20.0615},
{-3495.34, 6.95587, 0.272892, 662.738,-0.291318,-680.562, 1.78980, 1740.06, 0.0, 100.0, 4.49823},
{ 20.7307, 6.96237, 2.68645, 500.371,-2.56429,-530.443, 3.91921, 500.198, 2.13290, 2197.22, 5.81381},
{-37524.4, 7.98139, 24.3668, 752.320, 3.53990, 272.846, 8.44724, 1020.13,-13.2732, 869.510,-22.4010},
{-56072.1, 8.14319, 37.0629, 735.402, 9.38159, 247.190, 13.4556, 1454.78,-11.7342, 984.518,-24.0426},
{-13773.1, 7.97183, 6.27078, 2572.63, 2.05010, 1156.72, 0.0, 100.0, 0.0, 100.0, -3.24989},
{-10085.4, 7.94680,-0.08380, 433.801, 2.85539, 843.792, 6.31595, 1481.43,-2.88457, 1102.23,-0.51551},
{-5565.60, 6.66789, 2.33458, 2584.98, .749019, 559.656, 0.0, 100.0, 0.0, 100.0, -7.94821},
{-2753.49, 6.95854, 2.02441, 1541.22, .096774, 3674.81, 0.0, 100.0, 0.0, 100.0, 6.23387},
{-3497.45, 6.96302, 2.40013, 2522.05, 2.21752, 1154.15, 0.0, 100.0, 0.0, 100.0, 9.19749},
{-72387.0, 17.8143, 58.2062, 1787.39, 40.7621, 808.645, 0.0, 100.0, 0.0, 100.0, -44.1341},
{-72674.8, 18.6383, 57.4178, 1792.73, 38.6599, 814.151, 0.0, 100.0, 0.0, 100.0, -46.1938},
{-91505.5, 21.3861, 74.3410, 1701.58, 47.0587, 775.899, 0.0, 100.0, 0.0, 100.0, -60.2474},
{-83845.2, 22.5012, 69.5789, 1719.58, 46.2164, 802.174, 0.0, 100.0, 0.0, 100.0, -62.2197},
{-94982.5, 26.6225, 80.3819, 1718.49, 55.6598, 802.069, 0.0, 100.0, 0.0, 100.0, -77.5366},
{-103353., 30.4029, 90.6941, 1669.32, 63.2028, 786.001, 0.0, 100.0, 0.0, 100.0, -92.0164},
{-109674., 34.0847, 100.253, 1611.55, 69.7675, 768.847, 0.0, 100.0, 0.0, 100.0, -106.149},
{-122599., 38.5014, 111.446, 1646.48, 80.5015, 781.588, 0.0, 100.0, 0.0, 100.0, -122.444},
{-133564., 42.7143, 122.173, 1654.85, 90.2255, 785.564, 0.0, 100.0, 0.0, 100.0, -138.006},
{ 0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0 },
{ 0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0 }};
// enumerations for indexing of coefficients
enum CoefficientList{ coefA = 0, coefB, coefC, coefD, coefE, coefF, coefG,
coefH, coefI, coefJ, coefK } ;
// conversion constant for thermochemical calories to Joules: 1 cal(IT) = 4.1840 J
const double CalTH = 4.1840 ;
#endif
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
109
/*************************************************************************
* File: therm.cpp
* Description: Contains thermodynamic functions for the meter object.
* heat capacity, enthalpy, entropy, sound speed
* Contains the functions:
* Therm(), ~Therm(), Run(), coth(), CpiMolar(), Ho(), So(),
* CprCvrHS(), HS_Mode(), H(), S()
* Version: ver 1.7 2002.11.17
* Author: W.B. Peterson
* Revisions:
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#include "aga10.h"
#include "detail.h"
#include "therm.h"
#include <math.h>
/**************************************************************************
* Function : Therm::Therm()
* Arguments : void
* Returns :
* Purpose : default constructor
* Revisions :
**************************************************************************/
Therm::Therm(void)
{
// initialize 3 history-sensitive variables
dSi = 0.0 ;
dTold = 0.0 ;
dMrxold = 0.0 ;
} // Therm::Therm()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
110
/**************************************************************************
* Function : Therm::~Therm()
* Arguments :
* Returns : default destructor
* Purpose : void
* Revisions :
**************************************************************************/
Therm::~Therm()
{
} // Therm::~Therm()
/**************************************************************************
* Function : coth()
* Arguments : double
* Returns : double
* Purpose : calculate hyperbolic cotangent; used in Ho calculations
* Revisions :
* Notes : Not a Therm object class member, just a utility for this
* file. The C++ language has no intrinsic support for
* hyperbolic cotangent
**************************************************************************/
double coth (double x)
{
return cosh(x)/sinh(x);
} // coth()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
111
/**************************************************************************
* Function : Therm::Run()
* Arguments : AGA10STRUCT *, Detail *
* Returns : void
* Purpose : overall execution control; top level math for SOS and k
* Revisions :
**************************************************************************/
void Therm::Run(AGA10STRUCT *ptAGA10, Detail *ptD)
{
// local variables
double c, x, y, z ;
// first run basic set of functions within AGA 8 (1994) Detail Method
ptD->Run(ptAGA10) ;
// find first partial derivative of Z wrt D
ptD->dZdD(ptAGA10->dDf) ;
// find real gas cv, cp, specific enthalpy and entropy
CprCvrHS(ptAGA10, ptD) ;
// ratio of real gas specific heats
ptAGA10->dk = ptAGA10->dCp / ptAGA10->dCv ;
// solve c in three steps, for clarity and ease of debugging
x = ptAGA10->dk * RGAS * 1000.0 * ptAGA10->dTf ;
y = ptAGA10->dMrx ;
z = ptAGA10->dZf + ptAGA10->dDf * ptD->ddZdD ;
// calculate c, which is SOS^2
c = (x / y) * z ;
// speed of sound
ptAGA10->dSOS = sqrt(c) ;
// calculate the real gas isentropic exponent
// using expression functionally equivalent to Equation 3.2
ptAGA10->dKappa = (c * ptAGA10->dRhof) / ptAGA10->dPf ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
112
return ;
} // Therm::Run()
/**************************************************************************
* Function : Therm::CpiMolar()
* Arguments : AGA10STRUCT *
* Returns : double
* Purpose : Calculate constant pressure ideal gas molar heat capacity
* in (J/mol-K), applying eqns from Aly, Lee, McFall
* Notes : For continuity, the original constants and eqn's have been
* retained. Conversion from thermochemical calories(th) to
* Joules is applied after the primary calculations are complete.
* Revisions :
**************************************************************************/
double Therm::CpiMolar(AGA10STRUCT *ptAGA10)
{
double Cp = 0.0 ;
double Cpx ;
double DT, FT, HT, JT ;
double Dx, Fx, Hx, Jx ;
double T ;
int i ;
// to maximize readability of this section, use intermediate variable T
T = ptAGA10->dTf ;
// calculate heat capacity for each component
for (i= 0; i< NUMBEROFCOMPONENTS; i++)
{
// skip species whose concentration is zero
if (ptAGA10->adMixture[i] <= 0.0) continue ;
// initialize Cp of species to zero
Cpx = 0.0 ;
// calculate species intermediate terms
DT = ThermConstants[i][coefD] / T ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
113
FT = ThermConstants[i][coefF] / T ;
HT = ThermConstants[i][coefH] / T ;
JT = ThermConstants[i][coefJ] / T ;
// use intermediate terms to avoid redundant calcs
Dx = DT/sinh(DT) ;
Fx = FT/cosh(FT) ;
Hx = HT/sinh(HT) ;
Jx = JT/cosh(JT) ;
Cpx += ThermConstants[i][coefB] ;
Cpx += ThermConstants[i][coefC] * Dx * Dx ;
Cpx += ThermConstants[i][coefE] * Fx * Fx ;
Cpx += ThermConstants[i][coefG] * Hx * Hx ;
Cpx += ThermConstants[i][coefI] * Jx * Jx ;
// use current mole fraction to weight the contribution
Cpx *= ptAGA10->adMixture[i];
// add this contribution to the sum
Cp += Cpx ;
}
// convert from cal(th)/mol-K to J/mol-K
Cp *= CalTH ;
return Cp ;
} // Therm::CpiMolar()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
114
/**************************************************************************
* Function : Therm::Ho()
* Arguments : AGA10STRUCT *
* Returns : double
* Purpose : Calculate ideal gas specific enthalpy (J/kg)
* Notes : For continuity, the original constants and eqn's have been
* retained. Conversion from thermochemical calories(th) to
* Joules is applied after the primary calculations are complete.
* Revisions :
**************************************************************************/
double Therm::Ho(AGA10STRUCT *ptAGA10)
{
double H = 0.0 ;
double Hx ;
double DT, FT, HT, JT ;
double cothDT, tanhFT, cothHT, tanhJT ;
double T ;
int i ;
// to maximize readability of this section, use intermediate variable T
T = ptAGA10->dTf ;
for (i= 0; i< NUMBEROFCOMPONENTS; i++)
{
// skip species whose concentration is zero
if (ptAGA10->adMixture[i] <= 0.0) continue ;
Hx = 0.0 ;
// calculate species intermediate terms
DT = ThermConstants[i][coefD] / T ;
FT = ThermConstants[i][coefF] / T ;
HT = ThermConstants[i][coefH] / T ;
JT = ThermConstants[i][coefJ] / T ;
cothDT = coth(DT) ;
tanhFT = tanh(FT) ;
cothHT = coth(HT) ;
tanhJT = tanh(JT) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
115
Hx += ThermConstants[i][coefA] ;
Hx += ThermConstants[i][coefB] * T ;
Hx += ThermConstants[i][coefC] * ThermConstants[i][coefD] * cothDT;
Hx -= ThermConstants[i][coefE] * ThermConstants[i][coefF] * tanhFT;
Hx += ThermConstants[i][coefG] * ThermConstants[i][coefH] * cothHT;
Hx -= ThermConstants[i][coefI] * ThermConstants[i][coefJ] * tanhJT;
// use current mole fraction to weight the contribution
Hx *= ptAGA10->adMixture[i];
// add this contribution to the sum
H += Hx ;
}
// convert from cal(th)/g-mol to kJ/kg-mol
H *= CalTH ;
// convert from kJ/kg-mol to J/kg
H /= ptAGA10->dMrx ;
// return in J/kg
return H * 1.e3;
} // Therm::Ho()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
116
/**************************************************************************
* Function : Therm::So()
* Arguments : AGA10STRUCT *
* Returns : double
* Purpose : ideal gas specific entropy (J/kg-K)
* Notes : For continuity, the original constants and eqn's have been
* retained. Conversion from thermochemical calories(th) to
* Joules is applied after the primary calculations are complete.
* Revisions :
**************************************************************************/
double Therm::So(AGA10STRUCT *ptAGA10)
{
double S = 0.0 ;
double Sx ;
double DT, FT, HT, JT ;
double cothDT, tanhFT, cothHT, tanhJT ;
double sinhDT, coshFT, sinhHT, coshJT ;
double T ;
int i ;
// to improve readability of this section, use intermediate variable T
T = ptAGA10->dTf ;
for (i= 0; i< NUMBEROFCOMPONENTS; i++)
{
// skip species whose concentration is zero
if (ptAGA10->adMixture[i] <= 0.0) continue ;
Sx = 0.0 ;
// calculate species intermediate terms
DT = ThermConstants[i][coefD] / T ;
FT = ThermConstants[i][coefF] / T ;
HT = ThermConstants[i][coefH] / T ;
JT = ThermConstants[i][coefJ] / T ;
cothDT = coth(DT) ;
tanhFT = tanh(FT) ;
cothHT = coth(HT) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
117
tanhJT = tanh(JT) ;
sinhDT = sinh(DT) ;
coshFT = cosh(FT) ;
sinhHT = sinh(HT) ;
coshJT = cosh(JT) ;
Sx += ThermConstants[i][coefK] ;
Sx += ThermConstants[i][coefB] * log(T) ;
Sx += ThermConstants[i][coefC] * (DT * cothDT - log(sinhDT)) ;
Sx -= ThermConstants[i][coefE] * (FT * tanhFT - log(coshFT)) ;
Sx += ThermConstants[i][coefG] * (HT * cothHT - log(sinhHT)) ;
Sx -= ThermConstants[i][coefI] * (JT * tanhJT - log(coshJT)) ;
// use current mole fraction to weight the contribution
Sx *= ptAGA10->adMixture[i];
// add this contribution to the sum
S += Sx ;
}
// convert cal(th)/mol-K basis to to kJ/kg mol-K
S *= CalTH ;
// convert from kJ/kg mol-K to kJ/kg-K
S /= ptAGA10->dMrx ;
// return in J/kg-K
return S * 1.e3;
} // Therm::So()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
118
/**************************************************************************
* Function : Therm::CprCvrHS()
* Arguments : AGA10STRUCT *, Detail *
* Returns : void
* Purpose : reasonably efficient group calculation of Cp, Cv, H and S
* Revisions :
**************************************************************************/
void Therm::CprCvrHS(AGA10STRUCT *ptAGA10, Detail *ptD)
{
double Cvinc, Cvr, Cpr ;
double Hinc ;
double Sinc ;
double Smixing ;
double Cp, Si ;
double a, b, x ;
int i ;
// initialize integrals to zero
Cvinc = 0.0 ;
Hinc = 0.0 ;
Sinc = 0.0 ;
// initialize entropy of mixing
Smixing = 0.0 ;
// find ideal gas Cp
Cp = CpiMolar(ptAGA10) ;
// find ideal gas enthalpy
ptAGA10->dHo = Ho(ptAGA10) ;
// find ideal gas entropy
Si = So(ptAGA10) ;
// calculate ideal gas specific heat capacity at constant pressure in J/kgK
ptAGA10->dCpi = (Cp * 1000.0) / ptAGA10->dMrx ;
// integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature
for ( i= 0; i < GK_points; i++)
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
119
{
// set calculation point at + abscissa
x = ptAGA10->dDf * (1.0 + GK_root[i]) / 2.0 ;
// get Z at D
ptD->zdetail(x) ;
ptD->dZdT(x) ;
ptD->d2ZdT2(x) ;
// gather contributions at + abscissa; applying weighting factor
Hinc += GK_weight[i] * ptD->ddZdT / x ;
Cvinc += GK_weight[i] * (2.0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x ;
Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ;
// set calculation point at - abscissa
x = ptAGA10->dDf * (1.0 - GK_root[i]) / 2.0 ;
// get Z at D
ptD->zdetail(x) ;
// calculate 1st and 2nd partial derivatives of Z wrt T
ptD->dZdT(x) ;
ptD->d2ZdT2(x) ;
// gather contributions at - abscissa; applying weighting factor
Hinc += GK_weight[i] * ptD->ddZdT / x ;
Cvinc += GK_weight[i] * (2.0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x ;
Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ;
}
// return Z and partial derivatives to full molar density
ptD->zdetail(ptAGA10->dDf) ;
ptD->dZdT(ptAGA10->dDf) ;
ptD->d2ZdT2(ptAGA10->dDf) ;
// complete Cv molar
Cvr = Cp - RGAS * (1.0 + ptAGA10->dTf * Cvinc * 0.5 * ptAGA10->dDf) ;
// intermediate values for Cp, containing 2 partial derivatives
a =(ptAGA10->dZf + ptAGA10->dTf * ptD->ddZdT) ;
b =(ptAGA10->dZf + ptAGA10->dDf * ptD->ddZdD) ;
// calculate dPdT, the partial derivative of P wrt T, at D
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
120
dPdT = RGAS * ptAGA10->dDf * a ;
// calculate dPdD, the partial derivative of P wrt D, at T
dPdD = RGAS * ptAGA10->dTf * b ;
// equation completing molar Cp, cancelling appropriate terms
Cpr = Cvr + RGAS * ((a * a)/b) ;
// change from molar to mass basis
Cpr /= ptAGA10->dMrx ;
Cvr /= ptAGA10->dMrx ;
// write to the data stucture
ptAGA10->dCv = Cvr * 1000.0 ; // convert from joules/kgK to kilojoules/kgK
ptAGA10->dCp = Cpr * 1000.0 ;
// calculate specific enthalpy
ptAGA10->dH = ptAGA10->dHo + 1000.0 * RGAS * ptAGA10->dTf *
(ptAGA10->dZf - 1.0 - ptAGA10->dTf * Hinc * 0.5 * ptAGA10->dDf) /
ptAGA10->dMrx ;
// calculate entropy of mixing
for (i= 0; i< NUMBEROFCOMPONENTS; i++)
{
if (ptAGA10->adMixture[i]) Smixing += ptAGA10->adMixture[i] * log(ptAGA10->adMixture[i]) ;
}
Smixing *= RGAS ;
// calculate specific entropy
ptAGA10->dS = Si Smixing - 1000.0 * RGAS * (log(ptAGA10->dPf/101325.0) - log(ptAGA10->dZf) +
Sinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ;
return ;
} // Therm::CprCvrHS()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
121
/**************************************************************************
* Function : Therm::HS_Mode()
* Arguments : AGA10STRUCT *, Detail *, double, double, bool
* Returns : void
* Purpose : Calculates a pressure & temperature from known enthalpy & entropy,
* with or without prior estimates.This function has a role in the
* calculation of C*.
* Solution based on a doubly-nested trial & error algorithm and Newton's
* method.
*
* For illustrative purpose, two approaches are supported by this example.
* If you are starting without advance knowledge of P & T, set the input parm
* bGuess to false, thus specifying a conservative search approach.
* If, however, you have a basis for guessing P & T (plenum conditions of a
* critical flow nozzle, for example) set P & T via AGA10STRUCT and set
* bGuess = true. The initial guess allows the search function to be more
* aggressive and, typically, faster.
*
* Revisions :
**************************************************************************/
void Therm::HS_Mode(AGA10STRUCT *ptAGA10, Detail *ptD, double H, double S, bool bGuess)
{
double s0, s1, s2, t0, t1, t2, tmin, tmax ;
double h0, h1, h2, p0, p1, p2, px, pmin, pmax ;
double delta1, delta2 ;
double tolerance = 0.001 ;// convergence tolerance (used for both H and S searches)
int i, j ;
// s0and h0 are our real gas reference points
s0 = S ;
h0 = H ;
// calling function specifies whether search parameters are supplied thru ptAGA10 or unknown
if (bGuess)
{
t1 = ptAGA10->dTf ;
px = ptAGA10->dPf ;
pmax = px * 2.0 ;
pmin = px * 0.1 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
122
tmax = t1 * 1.5 ;
tmin = t1 * 0.67 ;
}
else // use arbitrary, generic limits
{
t1 = 273.15 ;
px = 1013250.0 ; // 10 atmospheres
pmax = P_MAX ;
pmin = 10000.0 ; // 10 kPa
tmax = T_MAX ;
tmin = T_MIN ;
}
// set the temperature differential
t2 = t1 + 10.0 ;
///////////////////////////////////////////
// begin double trial-and-error, searching for T & P
// run the calculation with initial guesses
ptD->Run(ptAGA10) ;
// h1 is difference between h given and h@Tf, Pf
h1 = this->H(ptAGA10, ptD) - h0;
// outer loop: search for a t2 which will satisfy constant enthalpy
for ( i= 0; i < MAX_NUM_OF_ITERATIONS; i++)
{
ptAGA10->dTf = t2 ;
p1 = px ; // reset one bracket
p2 = px * 0.1 ;// set other bracket to 0.1x the upper bracket
ptAGA10->dPf = p1 ;
ptD->Run(ptAGA10) ;
s1 = this->S(ptAGA10, ptD) - s0;
// inside loop: search for a p2 which will satisfy constant entropy
for (j= 0; j < MAX_NUM_OF_ITERATIONS; j++)
{
ptAGA10->dPf = p2 ;
ptD->Run(ptAGA10) ;
s2 = this->S(ptAGA10, ptD) - s0 ;
// calculate our proportional change
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
123
delta2 = fabs(s1 - s2) / s0 ;
// close enough?
if (delta2 < tolerance) break ;
// revise our estimate to p2
p0 = p2 ;
p2 = (p1 * s2 - p2 * s1) / (s2 - s1) ;
// check for negative pressure and clamp to pmin for safety
if (p2 <= pmin)
{
p2 = pmin ;
}
// check if we've created an unrealistic pressure
if (p2 >= pmax ) p2 = pmax ;
// swap values
p1 = p0 ;
s1 = s2 ;
}
// check for failure to converge
if (j >= MAX_NUM_OF_ITERATIONS) ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED ;
// calc enthalpy at guessed P & current iter T
h2 = this->H(ptAGA10, ptD) - h0 ;
// calculate our proportional change
delta1 = fabs(h1 - h2) / h0 ;
// close enough?
if (delta1 < tolerance && i > 0) break ;
// revise our estimate to t2
t0 = t2 ;
t2 = (t1 * h2 - t2 * h1) / (h2 - h1) ;
// check if we've created an unrealistic temperature
if (t2 >= tmax ) t2 = tmax ;
// revise t2, if necessary
if (t2 <= tmin )
{
t2 = t0 + 10.0 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
124
ptAGA10->dTf = t2 ;
ptD->Run(ptAGA10) ;
h2 = this->H(ptAGA10, ptD) - h0 ;
}
t1 = t0 ;
h1 = h2 ;
}
// check for failure to converge
if (i >= MAX_NUM_OF_ITERATIONS) ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED ;
} // Therm::HS_Mode()
/**************************************************************************
* Function : Therm::H()
* Arguments : AGA10STRUCT *, Detail *
* Returns : double
* Purpose : real gas specific enthalpy
* Revisions :
**************************************************************************/
double Therm::H(AGA10STRUCT *ptAGA10, Detail *ptD)
{
double Hinc ;
double x ;
int i ;
// initialize integral
Hinc = 0.0 ;
// find ideal gas enthalpy
ptAGA10->dHo = Ho(ptAGA10) ;
// integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature
for ( i= 0; i < GK_points; i++)
{
// calculate 1st and 2nd partial derivatives of Z wrt T
x = ptAGA10->dDf * (1.0 + GK_root[i]) / 2.0 ;
ptD->zdetail(x) ;
ptD->dZdT(x) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
125
ptD->d2ZdT2(x) ;
Hinc += GK_weight[i] * ptD->ddZdT / x ;
if (i == 10) break;
x = ptAGA10->dDf * (1.0 - GK_root[i]) / 2.0 ;
ptD->zdetail(x) ;
ptD->dZdT(x) ;
ptD->d2ZdT2(x) ;
Hinc += GK_weight[i] * ptD->ddZdT / x ;
}
ptD->zdetail(ptAGA10->dDf) ;
ptD->dZdT(ptAGA10->dDf) ;
ptD->d2ZdT2(ptAGA10->dDf) ;
// calculate specific enthalpy
ptAGA10->dH = ptAGA10->dHo + 1000.0 * RGAS * ptAGA10->dTf *
(ptAGA10->dZf - 1.0 - ptAGA10->dTf * Hinc * 0.5 * ptAGA10->dDf)
/ ptAGA10->dMrx ;
return(ptAGA10->dH) ;
} // Therm::H()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
126
/**************************************************************************
* Function : Therm::S()
* Arguments : AGA10STRUCT *, Detail *
* Returns : double
* Purpose : real gas specific entropy
* Revisions :
**************************************************************************/
double Therm::S(AGA10STRUCT *ptAGA10, Detail *ptD)
{
double Sinc ;
double Smixing ;
double x ;
int i ;
// initialize integral
Sinc = 0.0 ;
// initialize entropy of mixing
Smixing = 0.0 ;
// integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature
for ( i= 0; i < GK_points; i++)
{
// calculate 1st and 2nd partial derivatives of Z wrt T
x = ptAGA10->dDf * (1.0 + GK_root[i]) / 2.0 ;
ptD->zdetail(x) ;
ptD->dZdT(x) ;
ptD->d2ZdT2(x) ;
Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ;
if (i == 10) break;
x = ptAGA10->dDf * (1.0 - GK_root[i]) / 2.0 ;
ptD->zdetail(x) ;
ptD->dZdT(x) ;
ptD->d2ZdT2(x) ;
Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ;
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
127
// reset Z and partial deivatives dZdT and d2ZdT2
ptD->zdetail(ptAGA10->dDf) ;
ptD->dZdT(ptAGA10->dDf) ;
ptD->d2ZdT2(ptAGA10->dDf) ;
// find ideal gas entropy, but only if temperature or composition have changed
if (ptAGA10->dTf != dTold || ptAGA10->dMrx != dMrxold)
{
dSi = So(ptAGA10) ;
dTold = ptAGA10->dTf ;
dMrxold = ptAGA10->dMrx ;
}
// calculate entropy of mixing
for (i= 0; i< NUMBEROFCOMPONENTS; i++)
{
if (ptAGA10->adMixture[i]) Smixing += ptAGA10->adMixture[i] * log(ptAGA10->adMixture[i]) ;
}
Smixing *= RGAS ;
// calculate specific entropy
ptAGA10->dS = dSi Smixing - 1000.0 * RGAS * (log(ptAGA10->dPf/101325.0) - log(ptAGA10->dZf)
+ Sinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ;
return(ptAGA10->dS) ;
} // Therm::S()
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
128
/*************************************************************************
*
* File : entry.cpp
* Purpose : This file contains the startup code for aga10.dll
* and is only required for Windows DLL creation.
* Project : AGA10 DLL
* Version : ver 1.7 2002.11.17
* Author : W.B. Peterson
* Revisions:
* Copyright (c) 2002 American Gas Association
*
**************************************************************************/
#include <windows.h>
/* win32 DLL startup code */
int WINAPI DLLMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved)
{
return TRUE ;
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
129
// File : script1.rc
// Description : resource script for aga10 dll
// Version : 1.7 2002.11.17
// Author : W.B. Peterson
// Revisions :
// Copyright (c) 2002 American Gas Association
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,0,0
PRODUCTVERSION 1,7,0,0
FILEFLAGSMASK 0x3fL
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
130
#ifdef _DEBUG
FILEFLAGS 0x21L
#else
FILEFLAGS 0x20L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Post-Ballot Version\0"
VALUE "CompanyName", "American Gas Association\0"
VALUE "FileDescription", "aga10\0"
VALUE "FileVersion", "1, 7, 0, 0\0"
VALUE "InternalName", "aga10\0"
VALUE "LegalCopyright", "Copyright 2002 American Gas Association\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "aga10.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "AGA10.DLL\0"
VALUE "ProductVersion", "1, 6, 0, 0\0"
VALUE "SpecialBuild", "2002.11.17 Build\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
131
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
132
File Group #2 - Example Windows Application
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
133
/*************************************************************************
* File : aga10win.h
* Description : function prototypes and defines for aga10win.cpp
* Version : 1.7 2002.11.17
* Author : W.B. Peterson
* Revisions :
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#ifndef _AGA10WIN_H
#define _AGA10WIN_H
#include <windows.h>
#include <commdlg.h>
/* control IDs for windows interface */
#define IDC_LSTATUS 20
#define IDC_XIC1 21
#define IDC_XIN2 22
#define IDC_XICO2 23
#define IDC_XIC2 24
#define IDC_XIC3 25
#define IDC_XIH2O 26
#define IDC_XIH2S 27
#define IDC_XIH2 28
#define IDC_XICO 29
#define IDC_XIO2 30
#define IDC_XIIC4 31
#define IDC_XINC4 32
#define IDC_XIIC5 33
#define IDC_XINC5 34
#define IDC_XINC6 35
#define IDC_XINC7 36
#define IDC_XINC8 37
#define IDC_XINC9 38
#define IDC_XINC10 39
#define IDC_XIHE 40
#define IDC_XIAR 41
#define IDC_PB 42
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
134
#define IDC_TB 43
#define IDC_PF 44
#define IDC_TF 45
#define IDC_MRX 46
#define IDC_ZB 47
#define IDC_ZF 48
#define IDC_FPV 49
#define IDC_DB 50
#define IDC_DF 51
#define IDC_RHOB 52
#define IDC_RHOF 53
#define IDC_RD_IDEAL 54
#define IDC_RD_REAL 55
#define IDC_HO 56
#define IDC_H 57
#define IDC_S 58
#define IDC_CPI 59
#define IDC_CP 60
#define IDC_CV 61
#define IDC_K 62
#define IDC_KAPPA 63
#define IDC_SOS 64
#define IDC_CSTAR 65
#define IDC_PB_U 66
#define IDC_TB_U 67
#define IDC_PF_U 68
#define IDC_TF_U 69
#define IDC_SOS_U 70
#define IDC_RHOB_U 71
#define IDC_RHOF_U 72
#define IDC_ENTHALPY_U 73
#define IDC_ENTROPY_U 74
#define IDC_TOTAL 75
#define IDC_CLEAR 76
#define IDC_NORMALIZE 77
#define KILOPASCAL 78
#define MEGAPASCAL 79
#define PSI 80
#define KELVIN 81
#define CELSIUS 82
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
135
#define RANKINE 83
#define FAHRENHEIT 84
#define KGPERCUBICMETRE 85
#define LBMPERCUBICFOOT 86
#define METREPERSECOND 87
#define FOOTPERSECOND 88
#define KJPERKG 89
#define BTUPERLBM 90
#define KJPERKGK 91
#define BTUPERLBMF 92
#define CM_FILEOPEN 93
#define CM_FILESAVE 94
#define CM_FILESAVEAS 95
#define CM_HELPABOUT 96
#define IDR_MENU1 97
#define IDC_STATIC (-1)
/* buffer sizes */
#define FIELD40 40
#define FIELD30 30
/* function prototypes */
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
void PressureDlgHelp(HWND) ;
void TemperatureDlgHelp(HWND) ;
void DensityDlgHelp(HWND) ;
void SOSDlgHelp(HWND) ;
void EnthalpyDlgHelp(HWND) ;
void EntropyDlgHelp(HWND) ;
void FileInitialize (HWND) ;
BOOL FileOpenDlg (HWND, PSTR, PSTR) ;
BOOL FileSaveDlg (HWND, PSTR, PSTR) ;
#endif
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
136
/*************************************************************************
* File : aga10win.cpp
* Description : Simple Win32 program demonstrating use of aga10.dll
* Supports Windows dialog box and file operations
* Version : 1.7 2002.11.17
* Author : W.B. Peterson
* Revisions :
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#include "aga10win.h"
#include "aga10.h"
/* create pointer to a data structure for exchanging data with aga10.dll */
static AGA10STRUCT *A10 ;
/* global variables for strings, filenames, etc */
static char szAppName[] = "aga10win" ;
static char szBuffer[FIELD40] ;
char szFileName[_MAX_PATH] ;
char szTitleName[_MAX_FNAME + _MAX_EXT] ;
/* declare one application instance */
HINSTANCE hInst ;
/* global variables for units of measure and critical flow coefficient C* */
double total = 0.0 ;
long int lPb_unit ; /* unit of measure for base pressure */
long int lPf_unit ; /* unit of measure for flowing pressure */
long int lTb_unit ; /* unit of measure for base temperature */
long int lTf_unit ; /* unit of measure for flowing temperature */
long int lRhob_unit ; /* unit of measure for density at base conditions */
long int lRhof_unit ; /* unit of measure for density at flowing conditions */
long int lSOS_unit ; /* unit of measure for speed of sound */
long int lEnthalpy_unit ; /* unit of measure for specific enthalpy */
long int lEntropy_unit ; /* unit of measure for specific entropy */
// prototypes for support functions not prototyped in aga10win.h
bool FileRead(HWND, PSTR, AGA10STRUCT *);
bool FileWrite(HWND, PSTR, AGA10STRUCT *) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
137
void ReadInputs(HWND, AGA10STRUCT *) ;
void WriteInputs(HWND, AGA10STRUCT *) ;
void WriteOutputs(HWND, AGA10STRUCT *) ;
void SetDefaults(AGA10STRUCT *) ;
/**************************************************************************
* Function : WinMain()
* Arguments : HINSTANCE, HINSTANCE, PSTR, int
* Returns : int
* Purpose : Every Windows application has a WinMain()
* Revisions :
**************************************************************************/
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hWnd ;
MSG msg ;
WNDCLASSEX wndclass ;
/* set window class properties */
wndclass.cbSize = sizeof (wndclass) ;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = DLGWINDOWEXTRA ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, szAppName) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE+1) ;
wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1) ;
wndclass.lpszClassName = szAppName ;
wndclass.hIconSm = LoadIcon (hInstance, szAppName) ;
/* register the class */
RegisterClassEx (&wndclass) ;
/* create a dialog box */
hWnd = CreateDialog (hInstance, "aga10win", 0, NULL) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
138
/* start the application's message pump */
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
return msg.wParam ;
}
/**************************************************************************
* Function : WndProc()
* Arguments : HWND, UINT, WPARAM, LPARAM
* Returns : LRESULT
* Purpose : One and only window process for this app
* Revisions :
**************************************************************************/
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
int i = 0 ;
double temp ;
switch (iMsg)
{
case WM_CREATE :
/* get application instance */
hInst = ((LPCREATESTRUCT) lParam)->hInstance ;
/* initialize file data */
FileInitialize (hwnd) ;
/* initialize calculation library */
AGA10_Init() ;
/* create an object at the pointer we have already defined */
if (NULL == (A10 = new AGA10STRUCT)) return TRUE ;
/* set the defaults for this application */
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
139
SetDefaults(A10) ;
return FALSE ;
case WM_COMMAND :
/* refresh the input data, triggered by focus change */
if (lParam && HIWORD (wParam) == EN_KILLFOCUS)
{
ReadInputs(hwnd, A10) ;
WriteInputs(hwnd, A10) ;
lstrcpy(szBuffer, "Press Calculate") ;
SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ;
return FALSE ;
}
/* decode WM_COMMAND messages */
switch (LOWORD (wParam))
{
case IDOK :
/* refresh input fields */
ReadInputs(hwnd, A10) ;
WriteInputs(hwnd, A10) ;
// ensure the compositions adds up before proceeding
// find the current sum of fractions
temp = 0.0 ;
for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++) temp += A10->adMixture[i] ;
if (temp < 0.9999 || temp > 1.0001)
{
MessageBox (hwnd,"Error. Composition must total 100%, +/- 0.01%",
szAppName, MB_OK | MB_ICONERROR) ;
lstrcpy(szBuffer, "Error. Composition <> 100%.") ;
SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ;
return FALSE ;
}
// ensure the pressure is acceptable before proceeding
if (A10->dPf < P_MIN || A10->dPf > P_MAX)
{
MessageBox (hwnd,"Error. Pf out of range.",
szAppName, MB_OK | MB_ICONERROR) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
140
lstrcpy(szBuffer, "Error. Pf out of range.") ;
SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ;
return FALSE ;
}
// ensure the temperature is acceptable before proceeding
if (A10->dTf < T_MIN || A10->dTf > T_MAX)
{
MessageBox (hwnd,"Error. Tf out of range.",
szAppName, MB_OK | MB_ICONERROR) ;
lstrcpy(szBuffer, "Error. Tf out of range.") ;
SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ;
return FALSE ;
}
/* indicate that a calculation has begun */
lstrcpy(szBuffer, "Calculation In Progress") ;
SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ;
/* run the sound speed AND C* calculation */
Crit(A10, 0.0) ;
/* write the outputs to the dialog box */
WriteOutputs(hwnd, A10) ;
return FALSE ;
case IDC_CLEAR :
/* zero out the composition and then display it */
for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++) A10->adMixture[i] = 0.0 ;
WriteInputs(hwnd, A10) ;
return FALSE ;
case IDC_NORMALIZE :
// normalize the composition to equal 1.0000
ReadInputs(hwnd, A10) ;
temp = 0.0 ;
// find the current sum of fractions
for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++) temp += A10->adMixture[i] ;
// adjust each non-zero entry by the required proportion
for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++)
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
141
if (A10->adMixture[i] > 0.0) A10->adMixture[i] /= temp ;
// write the adjusted values to the screen
WriteInputs(hwnd, A10) ;
return FALSE ;
case IDCANCEL :
/* start tear-down process */
SendMessage(hwnd, WM_CLOSE, 0,0L) ;
return FALSE ;
case IDRETRY :
// reset the defaults
SetDefaults(A10) ;
// display the input data to the screen
WriteInputs(hwnd, A10) ;
// send a message back to this proc, requesting a calculation
SendMessage(hwnd, WM_COMMAND, IDOK,0L) ;
return FALSE ;
case CM_FILEOPEN :
// standard Windows file operations
GetFileTitle (szFileName, szTitleName, sizeof (szTitleName)) ;
if (FileOpenDlg (hwnd, szFileName, szTitleName))
{
if (!FileRead (hwnd, szFileName, A10))
{
MessageBox(hwnd,"Could not read file.", szTitleName,
MB_OK | MB_ICONSTOP) ;
}
}
else return FALSE ;
// Write the new values to the window
WriteInputs(hwnd, A10) ;
// send a message back to this proc, requesting a calculation
SendMessage(hwnd, WM_COMMAND, IDOK,0L) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
142
return FALSE ;
case CM_FILESAVE :
// standard Windows file operations
GetFileTitle (szFileName, szTitleName, sizeof (szTitleName)) ;
if (szFileName[0])
{
if (FileWrite(hwnd, szFileName, A10))
{
return TRUE ;
}
else
{
MessageBox(hwnd,"Could not write file.", szTitleName,
MB_OK | MB_ICONSTOP) ;
}
return FALSE ;
}
// fall through
case CM_FILESAVEAS :
// standard Windows file operations
GetFileTitle (szFileName, szTitleName, sizeof (szTitleName)) ;
if (FileSaveDlg (hwnd, szFileName, szTitleName))
{
if (FileWrite (hwnd, szFileName, A10))
{
return 1 ;
}
else
{
MessageBox(hwnd,"Could not write file.", szTitleName,
MB_OK | MB_ICONSTOP) ;
}
}
return FALSE ;
case CM_HELPABOUT :
MessageBox (hwnd,
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
143
"AGA10win.exe and AGA10.dll (c) American Gas Association, 2002",
szAppName, MB_OK | MB_ICONINFORMATION) ;
return FALSE ;
}
return FALSE ;
case WM_CLOSE :
/* un-initialize the calculation library */
AGA10_UnInit() ;
// remove the AGA10STRUCT object from memory
delete A10 ;
/* request Windows to terminate the app */
DestroyWindow (hwnd) ;
return FALSE ;
case WM_DESTROY :
/* final message exhange with Windows during shut-down */
PostQuitMessage (0) ;
return FALSE ;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
144
/*************************************************************************
* File : file.cpp
* Description : Supports file access to AGA10 functions
* Author : W.B. Peterson
* Version : 1.7 2002.11.17
* Revisions :
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#include "aga10.h"
// declare a Windows-defined structure for file names
static OPENFILENAME ofn ;
/**************************************************************************
* Function : FileInitialize()
* Arguments : HWND
* Returns : void
* Purpose : Prepares for Windows file access
* Revisions :
**************************************************************************/
void FileInitialize (HWND hWnd)
{
/* set file filters; assign the filename extension 'sos' for
files of this type */
static char szFilter[] = "AGA10 Files (*.sos)\0*.sos\0" ;
static char szExt[] = "sos" ;
// populate a OPENFILENAME structure
ofn.lStructSize = sizeof (OPENFILENAME) ;
ofn.hwndOwner = hWnd ;
ofn.hInstance = NULL ;
ofn.lpstrFilter = szFilter ;
ofn.lpstrCustomFilter = NULL ;
ofn.nMaxCustFilter = 0 ;
ofn.nFilterIndex = 0 ;
ofn.lpstrFile = NULL ;
ofn.nMaxFile = _MAX_PATH ;
ofn.lpstrFileTitle = NULL ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
145
ofn.nMaxFileTitle = _MAX_FNAME + _MAX_EXT ;
ofn.lpstrInitialDir = NULL ;
ofn.lpstrTitle = NULL ;
ofn.Flags = 0 ;
ofn.nFileOffset = 0 ;
ofn.nFileExtension = 0 ;
ofn.lpstrDefExt = szExt ;
ofn.lCustData = 0L ;
ofn.lpfnHook = NULL ;
ofn.lpTemplateName = NULL ;
}
/**************************************************************************
* Function : FileOpenDlg()
* Arguments : HWND, PSTR, PSTR
* Returns : BOOL
* Purpose : Access common controls for file-open operation
* Revisions :
**************************************************************************/
BOOL FileOpenDlg (HWND hWnd, PSTR pstrFileName, PSTR pstrTitleName)
{
ofn.hwndOwner = hWnd ;
ofn.lpstrFile = pstrFileName ;
ofn.lpstrFileTitle = pstrTitleName ;
ofn.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT ;
return GetOpenFileName (&ofn) ;
}
/**************************************************************************
* Function : FileSaveDlg()
* Arguments : HWND, PSTR, PSTR
* Returns : BOOL
* Purpose : Access common controls for file-save operation
* Revisions :
**************************************************************************/
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
146
BOOL FileSaveDlg (HWND hWnd, PSTR pstrFileName, PSTR pstrTitleName)
{
ofn.hwndOwner = hWnd ;
ofn.lpstrFile = pstrFileName ;
ofn.lpstrFileTitle = pstrTitleName ;
ofn.Flags = OFN_OVERWRITEPROMPT ;
return GetSaveFileName (&ofn) ;
}
/**************************************************************************
* Function : FileRead()
* Arguments : HWND, PSTR, AGA10STRUCT
* Returns : bool
* Purpose : Reads contents of a .sos file into a AGA10STRUCT
* Revisions :
**************************************************************************/
bool FileRead(HWND hWnd, PSTR pstrFileName, AGA10STRUCT *A10)
{
FILE *file ;
// open the file in binary mode, if it exists
if (NULL == (file = fopen (pstrFileName, "rb"))) return false ;
// set file position to beginning
rewind(file) ;
// read one (only) data structure
if (fread(A10, sizeof (AGA10STRUCT), 1, file))
{
fclose (file) ;
return true;
}
else
{
// some problem encountered
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
147
fclose (file) ;
return false ;
}
}
/**************************************************************************
* Function : FileWrite()
* Arguments : HWND, PSTR, AGA10STRUCT
* Returns : bool
* Purpose : Writes contents of a AGA10STRUCT into a .vos file
* Revisions :
**************************************************************************/
bool FileWrite(HWND hWnd, PSTR pstrFileName, AGA10STRUCT *A10)
{
FILE *file ;
// open the file in binary mode; create if necessary
if (NULL == (file = fopen (pstrFileName, "wb"))) return false ;
// set file position to beginning
rewind(file) ;
// write one (only) data structure
if (fwrite(A10, sizeof (AGA10STRUCT), 1, file))
{
fclose (file) ;
return true;
}
else
{
// problem encountered; close and return 'false'
fclose (file) ;
return false ;
}
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
148
/*************************************************************************
* File : dlghlp.cpp
* Description : Helper functions for aga10win main dialog box
* Version : 1.7 2002.11.17
* Author : W.B. Peterson
* Revisions :
* Copyright (c) 2002 American Gas Association
**************************************************************************/
#include "aga10win.h"
#include "aga10.h"
/* variables declared externally */
extern HINSTANCE hInst ;
extern double total ;
extern long int lPb_unit ;
extern long int lPf_unit ;
extern long int lTb_unit ;
extern long int lTf_unit ;
extern long int lRhob_unit ;
extern long int lRhof_unit ;
extern long int lSOS_unit ;
extern long int lEnthalpy_unit ;
extern long int lEntropy_unit ;
/* a local buffer for text strings */
static char szBuffer[FIELD40] ;
/**************************************************************************
* Function : WriteInputs()
* Arguments : HWND
* Returns : void
* Purpose : Function for writing the input fields of the main window
* Notes : Uses non-portable, run-time library function _gcvt()
* for converting strings to double precision floats.
* Revisions :
**************************************************************************/
void WriteInputs(HWND hDlg, AGA10STRUCT *A10)
{
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
149
HWND hListBox;
int i ;
double Pbx, Tbx, Pfx, Tfx ;
/* calculate Pb in specified unit of measure */
switch (lPb_unit)
{
case KILOPASCAL :
Pbx = A10->dPb * 1.0e-3 ;
break ;
case MEGAPASCAL :
Pbx = A10->dPb * 1.0e-6 ;
break ;
case PSI :
Pbx = A10->dPb / 6894.75729 ;
}
/* calculate Pf in specified unit of measure */
switch (lPf_unit)
{
case KILOPASCAL :
Pfx = A10->dPf * 1.0e-3 ;
break ;
case MEGAPASCAL :
Pfx = A10->dPf * 1.0e-6 ;
break ;
case PSI :
Pfx = A10->dPf / 6894.75729 ;
}
/* calculate Tb in specified unit of measure */
switch (lTb_unit)
{
case CELSIUS :
Tbx = A10->dTb - 273.15 ;
break ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
150
case FAHRENHEIT :
Tbx = (A10->dTb * 1.8) - 459.67 ;
break ;
case KELVIN :
Tbx = A10->dTb ;
break ;
case RANKINE :
Tbx = A10->dTb * 1.8 ;
}
/* calculate Tf in specified unit of measure */
switch (lTf_unit)
{
case CELSIUS :
Tfx = A10->dTf - 273.15 ;
break ;
case FAHRENHEIT :
Tfx = (A10->dTf * 1.8) - 459.67 ;
break ;
case KELVIN :
Tfx = A10->dTf ;
break ;
case RANKINE :
Tfx = A10->dTf * 1.8 ;
}
// Pb
_gcvt (Pbx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_PB, szBuffer) ;
// Tb
_gcvt (Tbx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_TB, szBuffer) ;
// Pf
_gcvt (Pfx, 9, szBuffer);
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
151
SetDlgItemText (hDlg, IDC_PF, szBuffer) ;
// Tf
_gcvt (Tfx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_TF, szBuffer) ;
// composition
_gcvt (A10->adMixture[XiC1] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIC1, szBuffer) ;
_gcvt (A10->adMixture[XiN2] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIN2, szBuffer) ;
_gcvt (A10->adMixture[XiCO2] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XICO2, szBuffer) ;
_gcvt (A10->adMixture[XiC2] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIC2, szBuffer) ;
_gcvt (A10->adMixture[XiC3] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIC3, szBuffer) ;
_gcvt (A10->adMixture[XiH2O] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIH2O, szBuffer) ;
_gcvt (A10->adMixture[XiH2S] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIH2S, szBuffer) ;
_gcvt (A10->adMixture[XiH2] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIH2, szBuffer) ;
_gcvt (A10->adMixture[XiCO] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XICO, szBuffer) ;
_gcvt (A10->adMixture[XiO2] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIO2, szBuffer) ;
_gcvt (A10->adMixture[XiIC4] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIIC4, szBuffer) ;
_gcvt (A10->adMixture[XiNC4] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XINC4, szBuffer) ;
_gcvt (A10->adMixture[XiIC5] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIIC5, szBuffer) ;
_gcvt (A10->adMixture[XiNC5] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XINC5, szBuffer) ;
_gcvt (A10->adMixture[XiNC6] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XINC6, szBuffer) ;
_gcvt (A10->adMixture[XiNC7] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XINC7, szBuffer) ;
_gcvt (A10->adMixture[XiNC8] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XINC8, szBuffer) ;
_gcvt (A10->adMixture[XiNC9] * 100.0, 9, szBuffer);
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
152
SetDlgItemText (hDlg, IDC_XINC9, szBuffer) ;
_gcvt (A10->adMixture[XiNC10] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XINC10, szBuffer) ;
_gcvt (A10->adMixture[XiHe] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIHE, szBuffer) ;
_gcvt (A10->adMixture[XiAr] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIAR, szBuffer) ;
for (i=0, total = 0.0 ; i<NUMBEROFCOMPONENTS; i++) total += A10->adMixture[i];
sprintf(szBuffer, "%6.6f", total * 100.0) ;
SetDlgItemText(hDlg, IDC_TOTAL, szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_PB_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) PressureDlgHelp(hListBox) ;
LoadString(hInst, lPb_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_PF_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) PressureDlgHelp(hListBox) ;
LoadString(hInst, lPf_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_TB_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) TemperatureDlgHelp(hListBox) ;
LoadString(hInst, lTb_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_TF_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) TemperatureDlgHelp(hListBox) ;
LoadString(hInst, lTf_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_RHOB_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) DensityDlgHelp(hListBox) ;
LoadString(hInst, lRhob_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_RHOF_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) DensityDlgHelp(hListBox) ;
LoadString(hInst, lRhof_unit, szBuffer, FIELD40) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
153
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_SOS_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) SOSDlgHelp(hListBox) ;
LoadString(hInst, lSOS_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_ENTHALPY_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) EnthalpyDlgHelp(hListBox) ;
LoadString(hInst, lEnthalpy_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
hListBox = GetDlgItem(hDlg, IDC_ENTROPY_U) ;
if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) EntropyDlgHelp(hListBox) ;
LoadString(hInst, lEntropy_unit, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;
}
/**************************************************************************
* Function : WriteInputs()
* Arguments : HWND
* Returns : void
* Purpose : Function for writing the input fields of the main window
* Notes : Uses non-portable, run-time library function _gcvt()
* for converting strings to double precision floats.
* Revisions :
**************************************************************************/
void WriteOutputs(HWND hDlg, AGA10STRUCT *A10)
{
double Rhofx, SOSx, Enthalpyx, Entropyx ;
/* calculate Rhof in specified unit of measure */
switch (lRhof_unit)
{
case KGPERCUBICMETRE :
Rhofx = A10->dRhof ;
break ;
case LBMPERCUBICFOOT :
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
154
Rhofx = (A10->dRhof / 0.45359237) * pow(0.3048, 3.0) ;
}
/* calculate SOS in specified unit of measure */
switch (lSOS_unit)
{
case METREPERSECOND :
SOSx = A10->dSOS ;
break ;
case FOOTPERSECOND :
SOSx = A10->dSOS / 0.3048 ;
}
/* calculate specific enthalpy in specified unit of measure */
switch (lEnthalpy_unit)
{
case KJPERKG :
Enthalpyx = A10->dH * 0.001 ;
break ;
case BTUPERLBM :
Enthalpyx = A10->dH / ((5000./9.) * 4.1868) ;
}
/* calculate specific entropy in specified unit of measure */
switch (lEntropy_unit)
{
case KJPERKGK :
Entropyx = A10->dS * 0.001 ;
break ;
case BTUPERLBMF :
Entropyx = A10->dS / (1.0e3 * 4.1868) ;
}
/* write the outputs to the window */
_gcvt (Rhofx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_RHOF, szBuffer) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
155
_gcvt (SOSx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_SOS, szBuffer) ;
_gcvt (A10->dZb, 9, szBuffer);
SetDlgItemText (hDlg, IDC_ZB, szBuffer) ;
_gcvt (A10->dZf, 9, szBuffer);
SetDlgItemText (hDlg, IDC_ZF, szBuffer) ;
_gcvt (A10->dFpv, 9, szBuffer);
SetDlgItemText (hDlg, IDC_FPV, szBuffer) ;
_gcvt (A10->dDf, 9, szBuffer);
SetDlgItemText (hDlg, IDC_DF, szBuffer) ;
_gcvt (A10->dRD_Ideal, 9, szBuffer);
SetDlgItemText (hDlg, IDC_RD_IDEAL, szBuffer) ;
_gcvt (A10->dRD_Real, 9, szBuffer);
SetDlgItemText (hDlg, IDC_RD_REAL, szBuffer) ;
_gcvt (A10->dMrx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_MRX, szBuffer) ;
_gcvt (A10->dCpi * 0.001, 9, szBuffer);
SetDlgItemText (hDlg, IDC_CPI, szBuffer) ;
_gcvt (A10->dCp * 0.001, 9, szBuffer);
SetDlgItemText (hDlg, IDC_CP, szBuffer) ;
_gcvt (A10->dCv * 0.001, 9, szBuffer);
SetDlgItemText (hDlg, IDC_CV, szBuffer) ;
_gcvt (A10->dk, 9, szBuffer);
SetDlgItemText (hDlg, IDC_K, szBuffer) ;
_gcvt (A10->dKappa, 9, szBuffer);
SetDlgItemText (hDlg, IDC_KAPPA, szBuffer) ;
_gcvt (A10->dHo * 0.001, 9, szBuffer);
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
156
SetDlgItemText (hDlg, IDC_HO, szBuffer) ;
_gcvt (Enthalpyx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_H, szBuffer) ;
_gcvt (Entropyx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_S, szBuffer) ;
// reality check included for C*
if (A10->dCstar > 0.3 && A10->dCstar < 1.3)
{
_gcvt (A10->dCstar, 9, szBuffer);
SetDlgItemText (hDlg, IDC_CSTAR, szBuffer) ;
}
else
{
lstrcpy(szBuffer, "Cannot Solve!") ;
SetDlgItemText (hDlg, IDC_CSTAR, szBuffer) ;
}
/* update status indicator, based on return codes */
if (A10->lStatus == 9000)
{
lstrcpy(szBuffer, "Calculation Completed") ;
SetDlgItemText (hDlg, IDC_LSTATUS, szBuffer) ;
}
else
{
_ltoa (A10->lStatus, szBuffer, 10);
SetDlgItemText (hDlg, IDC_LSTATUS, szBuffer) ;
}
}
/**************************************************************************
* Function : ReadInputs()
* Arguments : HWND
* Returns : void
* Purpose : Function for reading the input fields of the main window
* Revisions :
**************************************************************************/
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
157
void ReadInputs(HWND hDlg, AGA10STRUCT *A10)
{
HWND hListBox;
int iSelection;
int i ;
char * stopstr;
//Pb
GetDlgItemText(hDlg, IDC_PB, szBuffer, FIELD30) ;
hListBox = GetDlgItem(hDlg, IDC_PB_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
switch (iSelection)
{
case 0 :
lPb_unit = KILOPASCAL ;
A10->dPb = strtod(szBuffer, &stopstr) * 1.0e3 ;
break ;
case 1 :
lPb_unit = MEGAPASCAL ;
A10->dPb = strtod(szBuffer, &stopstr) * 1.0e6 ;
break ;
case 2 :
lPb_unit = PSI ;
A10->dPb = strtod(szBuffer, &stopstr) * 6894.75729 ;
}
//Pf
GetDlgItemText(hDlg, IDC_PF, szBuffer, FIELD30) ;
hListBox = GetDlgItem(hDlg, IDC_PF_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
switch (iSelection)
{
case 0 :
lPf_unit = KILOPASCAL ;
A10->dPf = strtod(szBuffer, &stopstr) * 1.0e3 ;
break ;
case 1 :
lPf_unit = MEGAPASCAL ;
A10->dPf = strtod(szBuffer, &stopstr) * 1.0e6 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
158
break ;
case 2 :
lPf_unit = PSI ;
A10->dPf = strtod(szBuffer, &stopstr) * 6894.75729 ;
}
//Tb
GetDlgItemText(hDlg, IDC_TB, szBuffer, FIELD30) ;
hListBox = GetDlgItem(hDlg, IDC_TB_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
switch (iSelection)
{
case 0 :
lTb_unit = CELSIUS ;
A10->dTb = strtod(szBuffer, &stopstr) + 273.15;
break ;
case 1 :
lTb_unit = FAHRENHEIT ;
A10->dTb = (strtod(szBuffer, &stopstr) + 459.67) / 1.8 ;
break ;
case 2 :
lTb_unit = KELVIN ;
A10->dTb = strtod(szBuffer, &stopstr) ;
break ;
case 3 :
lTb_unit = RANKINE ;
A10->dTb = strtod(szBuffer, &stopstr) / 1.8;
}
//Tf
GetDlgItemText(hDlg, IDC_TF, szBuffer, FIELD30) ;
hListBox = GetDlgItem(hDlg, IDC_TF_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
switch (iSelection)
{
case 0 :
lTf_unit = CELSIUS ;
A10->dTf = strtod(szBuffer, &stopstr) + 273.15;
break ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
159
case 1 :
lTf_unit = FAHRENHEIT ;
A10->dTf = (strtod(szBuffer, &stopstr) + 459.67) / 1.8 ;
break ;
case 2 :
lTf_unit = KELVIN ;
A10->dTf = strtod(szBuffer, &stopstr) ;
break ;
case 3 :
lTf_unit = RANKINE ;
A10->dTf = strtod(szBuffer, &stopstr) / 1.8;
}
//Rhof
hListBox = GetDlgItem(hDlg, IDC_RHOF_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
switch (iSelection)
{
case 0 :
lRhof_unit = KGPERCUBICMETRE ;
break ;
case 1 :
lRhof_unit = LBMPERCUBICFOOT ;
}
//SOS
hListBox = GetDlgItem(hDlg, IDC_SOS_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
switch (iSelection)
{
case 0 :
lSOS_unit = METREPERSECOND ;
break ;
case 1 :
lSOS_unit = FOOTPERSECOND ;
}
//Enthalpy
hListBox = GetDlgItem(hDlg, IDC_ENTHALPY_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
160
switch (iSelection)
{
case 0 :
lEnthalpy_unit = KJPERKG ;
break ;
case 1 :
lEnthalpy_unit = BTUPERLBM ;
}
//Entropy
hListBox = GetDlgItem(hDlg, IDC_ENTROPY_U) ;
iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ;
switch (iSelection)
{
case 0 :
lEntropy_unit = KJPERKGK ;
break ;
case 1 :
lEntropy_unit = BTUPERLBMF ;
}
// composition
GetDlgItemText(hDlg,IDC_XIC1, szBuffer, FIELD30) ;
A10->adMixture[XiC1] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIN2, szBuffer, FIELD30) ;
A10->adMixture[XiN2] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XICO2, szBuffer, FIELD30) ;
A10->adMixture[XiCO2] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIC2, szBuffer, FIELD30) ;
A10->adMixture[XiC2] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIC3, szBuffer, FIELD30) ;
A10->adMixture[XiC3] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIH2O, szBuffer, FIELD30) ;
A10->adMixture[XiH2O] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIH2S, szBuffer, FIELD30) ;
A10->adMixture[XiH2S] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIH2, szBuffer, FIELD30) ;
A10->adMixture[XiH2] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XICO, szBuffer, FIELD30) ;
A10->adMixture[XiCO] = strtod(szBuffer, &stopstr) * 0.01 ;
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
161
GetDlgItemText(hDlg,IDC_XIO2, szBuffer, FIELD30) ;
A10->adMixture[XiO2] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIIC4, szBuffer, FIELD30) ;
A10->adMixture[XiIC4] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XINC4, szBuffer, FIELD30) ;
A10->adMixture[XiNC4] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIIC5, szBuffer, FIELD30) ;
A10->adMixture[XiIC5] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XINC5, szBuffer, FIELD30) ;
A10->adMixture[XiNC5] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XINC6, szBuffer, FIELD30) ;
A10->adMixture[XiNC6] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XINC7, szBuffer, FIELD30) ;
A10->adMixture[XiNC7] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XINC8, szBuffer, FIELD30) ;
A10->adMixture[XiNC8] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XINC9, szBuffer, FIELD30) ;
A10->adMixture[XiNC9] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XINC10, szBuffer, FIELD30) ;
A10->adMixture[XiNC10] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIHE, szBuffer, FIELD30) ;
A10->adMixture[XiHe] = strtod(szBuffer, &stopstr) * 0.01 ;
GetDlgItemText(hDlg,IDC_XIAR, szBuffer, FIELD30) ;
A10->adMixture[XiAr] = strtod(szBuffer, &stopstr) * 0.01 ;
// sum up the mole fractions
for (i=0,total = 0.0; i<NUMBEROFCOMPONENTS; i++) total += A10->adMixture[i];
sprintf(szBuffer, "%6.6f", total * 100.0) ;
SetDlgItemText(hDlg, IDC_TOTAL, szBuffer) ;
}
/**************************************************************************
* Function : PressureDlgHelp()
* Arguments : HWND
* Returns : void
* Purpose : Helper function for loading strings into pressure
* drop-list controls
* Revisions :
**************************************************************************/
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
162
void PressureDlgHelp(HWND hListBox)
{
LoadString(hInst, KILOPASCAL, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, MEGAPASCAL, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, PSI, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 2, (LONG)(LPSTR) szBuffer) ;
}
/**************************************************************************
* Function : TemperatureDlgHelp()
* Arguments : HWND
* Returns : void
* Purpose : Helper function for loading strings into temperature
* drop-list controls
* Revisions :
**************************************************************************/
void TemperatureDlgHelp(HWND hListBox)
{
LoadString(hInst, CELSIUS, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, FAHRENHEIT, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, KELVIN, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 2, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, RANKINE, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 3, (LONG)(LPSTR) szBuffer) ;
}
/**************************************************************************
* Function : DensityDlgHelp()
* Arguments : HWND
* Returns : void
* Purpose : Helper function for loading strings into density
* drop-list controls
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
163
* Revisions :
**************************************************************************/
void DensityDlgHelp(HWND hListBox)
{
LoadString(hInst, KGPERCUBICMETRE, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, LBMPERCUBICFOOT, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ;
}
/**************************************************************************
* Function : SOSDlgHelp()
* Arguments : HWND
* Returns : void
* Purpose : Helper function for loading strings into SOS
* drop-list controls
* Revisions :
**************************************************************************/
void SOSDlgHelp(HWND hListBox)
{
LoadString(hInst, METREPERSECOND, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, FOOTPERSECOND, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ;
}
/**************************************************************************
* Function : EnthalpyDlgHelp()
* Arguments : HWND
* Returns : void
* Purpose : Helper function for loading strings into enthalpy
* drop-list controls
* Revisions :
**************************************************************************/
void EnthalpyDlgHelp(HWND hListBox)
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
164
{
LoadString(hInst, KJPERKG, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, BTUPERLBM, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ;
}
/**************************************************************************
* Function : EntropyDlgHelp()
* Arguments : HWND
* Returns : void
* Purpose : Helper function for loading strings into entropy
* drop-list controls
* Revisions :
**************************************************************************/
void EntropyDlgHelp(HWND hListBox)
{
LoadString(hInst, KJPERKGK, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ;
LoadString(hInst, BTUPERLBMF, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ;
}
/**************************************************************************
* Function : SetDefaults()
* Arguments : void
* Returns : void
* Purpose : initializes AGA10STRUCT and units of measure
* Revisions :
**************************************************************************/
void SetDefaults(AGA10STRUCT *A10)
{
A10->lStatus = 9000 ; /* 9000 is status code for 'ok' */
A10->bForceUpdate = true; /* ensures that full calculation is performed */
A10->dPb = 101325.0 ; /* 1 atm */
A10->dTb = 288.15; /* 15 C */
A10->dPf = 4000000.0 ; /* 4 MPa */
A10->dTf = 283.15; /* 10 C */
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
165
A10->adMixture[XiC1] = 0.906724; /* AMARILLO example composition...*/
A10->adMixture[XiN2] = 0.031284;
A10->adMixture[XiCO2] = 0.004676;
A10->adMixture[XiC2] = 0.045279;
A10->adMixture[XiC3] = 0.00828;
A10->adMixture[XiH2O] = 0.0;
A10->adMixture[XiH2S] = 0.0;
A10->adMixture[XiH2] = 0.0;
A10->adMixture[XiCO] = 0.0;
A10->adMixture[XiO2] = 0.0;
A10->adMixture[XiIC4] = 0.001037;
A10->adMixture[XiNC4] = 0.001563;
A10->adMixture[XiIC5] = 0.000321;
A10->adMixture[XiNC5] = 0.000443;
A10->adMixture[XiNC6] = 0.000393;
A10->adMixture[XiNC7] = 0.0;
A10->adMixture[XiNC8] = 0.0;
A10->adMixture[XiNC9] = 0.0;
A10->adMixture[XiNC10] = 0.0;
A10->adMixture[XiHe] = 0.0;
A10->adMixture[XiAr] = 0.0;
/* reset units of measure */
lPb_unit = KILOPASCAL ;
lPf_unit = KILOPASCAL ;
lTb_unit = CELSIUS ;
lTf_unit = CELSIUS ;
lRhob_unit = KGPERCUBICMETRE ;
lRhof_unit = KGPERCUBICMETRE ;
lSOS_unit = METREPERSECOND ;
lEnthalpy_unit = KJPERKG ;
lEntropy_unit = KJPERKGK ;
}
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
166
// File : resource.h
// Description : header file used for Windows resource file
// Version : 1.7 2002.11.17
// Author : W.B. Peterson
// Revisions :
// Copyright (c) 2002 American Gas Association
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by aga10win.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40003
#define _APS_NEXT_CONTROL_VALUE 1018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
167
// File : aga10win.rc
// Description : resource script for aga10wins interface
// Version : 1.7 2002.11.17
// Author : W.B. Peterson
// Revisions :
// Copyright (c) 2002 American Gas Association
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "aga10win.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
168
AGA10WIN ICON DISCARDABLE "aga10win.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
AGA10WIN DIALOGEX 0, 0, 575, 315
STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT
CAPTION "AGA 10 Example Program"
MENU IDR_MENU1
CLASS "aga10win"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_XIHE,55,15,44,14,ES_AUTOHSCROLL | WS_GROUP
EDITTEXT IDC_XIH2,55,33,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIN2,55,51,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XICO2,55,69,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIH2S,55,87,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIC1,55,105,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIC2,55,123,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIC3,153,16,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIIC4,153,34,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XINC4,153,52,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIIC5,153,70,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XINC5,154,89,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XINC6,154,107,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XINC7,154,125,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XINC8,259,16,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XINC9,259,34,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XINC10,259,52,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIAR,259,70,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIH2O,259,88,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XICO,259,106,44,14,ES_AUTOHSCROLL
EDITTEXT IDC_XIO2,259,124,44,14
PUSHBUTTON "Clear Mixture",IDC_CLEAR,47,149,60,20
EDITTEXT IDC_PB,34,196,60,14,ES_AUTOHSCROLL
COMBOBOX IDC_PB_U,98,197,60,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
169
EDITTEXT IDC_TB,34,215,60,14,ES_AUTOHSCROLL
COMBOBOX IDC_TB_U,98,216,60,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_PF,191,196,60,14,ES_AUTOHSCROLL
COMBOBOX IDC_PF_U,254,196,60,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_TF,191,215,60,14,ES_AUTOHSCROLL
COMBOBOX IDC_TF_U,255,215,60,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Calculate",IDOK,137,282,50,20
PUSHBUTTON "Initialize",IDRETRY,61,282,50,20
PUSHBUTTON "Quit",IDCANCEL,213,282,50,20,WS_GROUP
GROUPBOX "Composition (Mole Percent)",IDC_STATIC,5,3,322,175
LTEXT "Helium",IDC_STATIC,21,18,28,8,NOT WS_GROUP
LTEXT "Hydrogen",IDC_STATIC,21,36,32,8,NOT WS_GROUP
LTEXT "Nitrogen",IDC_STATIC,21,55,28,8,NOT WS_GROUP
LTEXT "CO2",IDC_STATIC,22,71,15,8,NOT WS_GROUP
LTEXT "H2S",IDC_STATIC,22,89,15,8,NOT WS_GROUP
LTEXT "Methane",IDC_STATIC,22,108,29,8,NOT WS_GROUP
LTEXT "Ethane",IDC_STATIC,22,126,24,8,NOT WS_GROUP
LTEXT "Propane",IDC_STATIC,116,18,28,8,NOT WS_GROUP
LTEXT "i-Butane",IDC_STATIC,116,37,27,8,NOT WS_GROUP
LTEXT "n-Butane",IDC_STATIC,116,55,30,8,NOT WS_GROUP
LTEXT "i-Pentane",IDC_STATIC,116,72,31,8,NOT WS_GROUP
LTEXT "n-Pentane",IDC_STATIC,115,92,34,8,NOT WS_GROUP
LTEXT "n-Hexane",IDC_STATIC,115,110,32,8,NOT WS_GROUP
LTEXT "n-Heptane",IDC_STATIC,115,128,34,8,NOT WS_GROUP
LTEXT "n-Octane",IDC_STATIC,218,19,30,8,NOT WS_GROUP
LTEXT "n-Nonane",IDC_STATIC,218,37,32,8,NOT WS_GROUP
LTEXT "n-Decane",IDC_STATIC,218,55,32,8,NOT WS_GROUP
LTEXT "Argon",IDC_STATIC,219,73,27,8,NOT WS_GROUP
LTEXT "Water",IDC_STATIC,219,91,23,8,NOT WS_GROUP
LTEXT "CO",IDC_STATIC,219,109,11,8,NOT WS_GROUP
LTEXT "O2",IDC_STATIC,219,128,24,8,NOT WS_GROUP
LTEXT "TOTAL",IDC_STATIC,218,147,24,8,NOT WS_GROUP
LTEXT "Static",IDC_TOTAL,259,146,44,12,SS_SUNKEN | NOT
WS_GROUP
GROUPBOX "Gas Temperature and Absolute Pressure",IDC_STATIC,6,182,
322,56
LTEXT "Pb",IDC_STATIC,12,199,10,8
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
170
LTEXT "Tb",IDC_STATIC,11,217,10,8
LTEXT "Pf",IDC_STATIC,177,199,8,8
LTEXT "Tf",IDC_STATIC,176,217,8,8
GROUPBOX "Calculation Results",IDC_STATIC,334,3,234,306
LTEXT "Speed of Sound",IDC_STATIC,348,24,52,8
LTEXT "Zf",IDC_STATIC,348,173,8,8
LTEXT "Zb",IDC_STATIC,348,158,10,8
LTEXT "Fpv",IDC_STATIC,348,187,13,8
LTEXT "Cp (real gas)",IDC_STATIC,348,232,40,8
LTEXT "Cv (real gas)",IDC_STATIC,348,248,40,8
LTEXT "Cp/Cv",IDC_STATIC,348,264,22,8
LTEXT "Isentropic Exponent",IDC_STATIC,348,53,67,8
LTEXT "Mass Density",IDC_STATIC,348,113,43,8
LTEXT "Molar Density",IDC_STATIC,348,98,44,8
LTEXT "Specific Enthalpy",IDC_STATIC,348,68,56,8
LTEXT "Specific Entropy",IDC_STATIC,348,83,52,8
LTEXT "Enthalpy (ideal gas)",IDC_STATIC,348,280,62,8
LTEXT "Cp (ideal gas)",IDC_STATIC,348,216,44,8
LTEXT "Molar Mass",IDC_STATIC,348,201,37,8
LTEXT "0",IDC_SOS,422,24,50,8,NOT WS_GROUP
LTEXT "0",IDC_H,422,69,50,8,NOT WS_GROUP
LTEXT "0",IDC_S,422,83,50,8,NOT WS_GROUP
LTEXT "0",IDC_DF,422,99,60,8,NOT WS_GROUP
LTEXT "0",IDC_RHOF,422,113,55,8,NOT WS_GROUP
LTEXT "0",IDC_ZB,422,157,50,8,NOT WS_GROUP
LTEXT "0",IDC_ZF,422,171,50,8,NOT WS_GROUP
LTEXT "0",IDC_FPV,422,186,50,8,NOT WS_GROUP
LTEXT "0",IDC_MRX,422,201,50,8,NOT WS_GROUP
LTEXT "0",IDC_CPI,422,216,50,8,NOT WS_GROUP
LTEXT "0",IDC_HO,422,280,50,8,NOT WS_GROUP
LTEXT "0",IDC_CP,422,232,50,8,NOT WS_GROUP
LTEXT "0",IDC_CV,422,248,50,8,NOT WS_GROUP
LTEXT "0",IDC_K,422,264,50,8,NOT WS_GROUP
LTEXT "0",IDC_KAPPA,422,53,50,8,NOT WS_GROUP
LTEXT "moles/dm3",IDC_STATIC,483,98,32,8
LTEXT "kJ/kg-K",IDC_STATIC,483,216,26,8
LTEXT "kJ/kg",IDC_STATIC,483,280,20,8
LTEXT "RD (ideal gas)",IDC_STATIC,348,128,46,8
LTEXT "RD (real gas)",IDC_STATIC,348,143,42,8
LTEXT "0",IDC_RD_IDEAL,422,128,50,8,NOT WS_GROUP
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
171
LTEXT "0",IDC_RD_REAL,422,143,50,8,NOT WS_GROUP
LTEXT "Press Initialize Button to Begin",IDC_LSTATUS,106,259,
107,8
LTEXT "kJ/kg-K",IDC_STATIC,483,232,26,8
LTEXT "kJ/kg-K",IDC_STATIC,483,248,26,8
LTEXT "C*",IDC_STATIC,348,39,10,8
LTEXT "0",IDC_CSTAR,422,39,58,8
COMBOBOX IDC_SOS_U,482,21,80,43,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_RHOF_U,482,111,80,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_ENTHALPY_U,482,66,80,40,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_ENTROPY_U,482,82,80,37,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
GROUPBOX "Current Status",IDC_STATIC,5,247,322,27
PUSHBUTTON "Normalize",IDC_NORMALIZE,118,149,60,20
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""aga10win.h""\r\n"
"\0"
END
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
172
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
"AGA10WIN", DIALOG
BEGIN
LEFTMARGIN, 5
RIGHTMARGIN, 568
BOTTOMMARGIN, 309
END
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,0,0
PRODUCTVERSION 1,7,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x21L
#else
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
173
FILEFLAGS 0x20L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Post Ballot Version\0"
VALUE "CompanyName", "American Gas Association\0"
VALUE "FileDescription", "aga10win\0"
VALUE "FileVersion", "1, 7, 0, 0\0"
VALUE "InternalName", "aga10win\0"
VALUE "LegalCopyright", "Copyright 2002 American Gas Association\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "aga10win.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "aga10win\0"
VALUE "ProductVersion", "1, 7, 0, 0\0"
VALUE "SpecialBuild", "2002.11.17 Build\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU1 MENU DISCARDABLE
BEGIN
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
174
POPUP "&File"
BEGIN
MENUITEM "&Open...", CM_FILEOPEN
MENUITEM "&Save...", CM_FILESAVE
MENUITEM "Save &As...", CM_FILESAVEAS
MENUITEM "E&xit", IDCANCEL
END
POPUP "&Help"
BEGIN
MENUITEM "&About", CM_HELPABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
KILOPASCAL "kilopascals"
MEGAPASCAL "megapascals"
END
STRINGTABLE DISCARDABLE
BEGIN
PSI "PSI"
KELVIN "Kelvin"
CELSIUS "Celsius"
RANKINE "Rankine"
FAHRENHEIT "Fahrenheit"
KGPERCUBICMETRE "kg per cubic metre"
LBMPERCUBICFOOT "lbm per cubic foot"
METREPERSECOND "metres per second"
FOOTPERSECOND "feet per second"
KJPERKG "kJ per kg"
BTUPERLBM "Btu per lbm"
KJPERKGK "kJ per kg-K"
BTUPERLBMF "Btu per lbm-F"
This report is the property of AGA and is part of its process for developing new documents. This report or any of
its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval
from AGA.
175
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Você também pode gostar