You are on page 1of 177

Speed of Sound in Natural Gas and

Other Related Hydrocarbon Gases


Catalog # XQ0310

Prepared by

Transmission Measurement Committee

Copyright 2003 American Gas Association

All Rights Reserved

400 North Capitol Street, NW, 4th Floor Washington, DC 20001, USA

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

AGA Report No. 10

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

ii

Nothing contained in this publication is to be construed as granting any right, by implication or


otherwise, for the manufacture, sale, or use in connection with any method, apparatus, or product
covered by letters patent, or as insuring anyone against liability for infringement of letters patent.
The American Gas Associations Transmission Measurement Committee developed this publication
as a service to the natural gas industry and to the public. Use of this publication is voluntary and
should be taken after an independent review of the applicable facts and circumstances.
Efforts have been made to ensure the accuracy and reliability of the data contained in this
publication; however, the American Gas Association (AGA) makes no representation, warranty, or
guarantee in connection with this publication and hereby expressly disclaims any liability or
responsibility for loss or damage resulting from its use or from the use of any product or
methodology described herein; for any violation of any federal, state, or municipal regulation with
which this publication may conflict; or for the infringement of any patent from the use of this
publication. Nothing contained in this publication should be viewed as an endorsement by AGA of
any particular manufacturers products.
Permission is granted to republish material herein in laws or ordinances, and in regulations,
administrative orders, or similar documents issued by public authorities. Those desiring permission
for other publications should consult the Operating and Engineering Section, American Gas
th
Association, 400 North Capitol Street, NW, 4 Floor, Washington, DC 20001, USA.

Copyright 2003 American Gas Association, All Rights Reserved.

iii

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Disclaimers and Copyright

This report outlines a method for the calculation of the speed of sound in natural gas and the
individual components that make up natural gas. It also calculates the entropy, enthalpy and C*
coefficient for sonic nozzles. This information is based on research that was developed and managed
by the Gas Technology Institute (formerly the Gas Research Institute). The research indicates that the
calculation is highly accurate and is consistent with the equation-of-state used in AGA Report No. 8,
Compressibility Factors of Natural Gas and Other Related Hydrocarbon Gases. The original work
for AGA Report No. 8 was developed under the auspices of the Gas Research Institutes Basic Fluid
Properties Research Program, the AGA Transmission Measurement Committee, the Gas European de
Researchers Group (GERG), members of the American Petroleum Institute (API) and the
International Standards Organization (ISO).
The purpose of this report is to provide the natural gas industry with a method for solving problems
involving thermodynamics. Industrys incentive for establishing these methods was spurred by the
advent of ultrasonic gas meters. However, the value of these methods is apparent for other
applications of natural gas thermodynamics, such as compression.
The audience of the report is gas measurement engineers, especially those supporting ultrasonic
meters, as well as those who intend to apply the principles of thermodynamics to gas production,
transmission or distribution.
The intended benefits to users of this report are:

clear traceability to recognized scientific sources


extensive testing and validation
an implementation example upon which to build

The report is based on scientific data collected for pure gases and natural gas mixtures. As such, the
range of application is focused on the single-phase natural gas mixtures common to industry. The
performance of the methods is intended to meet the needs of the gas industry. Caution is advised to
users applying this technology to other purposes and other fluids.
It may become necessary to make revisions to this document in the future. Whenever any revisions
are advisable, recommendations should be forwarded to the American Gas Association, 400 N.
Capitol Street, NW, 4th Floor, Washington, DC 20001, USA. A form has been included at the end of
this report for that purpose.

iv

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

FOREWORD

AGA Report No. 10, Speed of Sound in Natural Gas and Other Related Hydrocarbon Gases, was
developed by an AGA Transmission Measurement Committee task group chaired by Jerry Paul
Smith (retired), Williams Gas Pipeline-Transco. AGA is especially thankful for the significant
contributions of Warren Peterson, TransCanada PipeLines, who prepared the first draft of this report
and wrote the computer program to calculate the speed of sound and other related properties. He also
completed the final version of this report.
Those who deserve special recognition and appreciation for their help, suggestions and guidance in
finalizing this report are Dr. Eric Lemmon, National Institute of Standards and Technology; Paul
J. LaNasa, CPL & Associates; Dr. Kenneth Starling, Starling Associates, Inc.; and Dr. Jeff Savidge,
Consultant.
This report was originally initiated under the chairmanship of late Ron Rich, Natural Gas Pipeline,
who could not complete it because of his untimely death. He is respectfully remembered and
recognized for his contributions in initiating this document.
Others who participated during the development of this report, reviewed the final draft or provided
comments and should also be acknowledged are:
Last Name
Baldwin
Bowen
Bowles, Jr.
Brown
Caldwell
Ceglia
Farestvedt
French
Gallagher
Mercer
Moir
Naber
Overgaard
Peters
Podgers
Poellnitz
Poon
Raper
Rebman
Sandlin
Schieber, II
Stappert
Stuart
Weatherly
Witte

First Name
Stephen
James W.
Edgar B.
Frank
Steve
Paul
Lars
Charles E.
James E.
Dannie
Kevin
John
Chris
Robert J.
Alex R.
Henry W.
King
Jimmy
Daniel H.
Mike
William M.
Karl
John W.
Dennis
James

Organization
Unocal, Inc.
Instromet, Inc.
Southwest Research Inst.
CMS Energy
CEESI
GE Panametrics
FMC Measurement Solutions
Gas Technology Institute
Savant Measurement Corp.
Oncor Pipeline Services
MichCon
Daniel Measurement
Nicor
McCrometer
American Meter Co.
Southern Natural Gas
Thermo Flow Systems
BP Americas
WGP Transco
CITGO
Solar Turbines, Inc.
Daniel Measurement
Stuart Consulting
El Paso
El Paso

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

ACKNOWLEDGEMENTS

Lori Traweek
Sr. Vice President
Operations & Engineering
American Gas Association

Ali Quraishi
Director
Engineering Services
American Gas Association

vi

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

The experimental data and modeling efforts used to develop and analyze both the speed of sound data
and the associated models were obtained from various independent laboratories and research sources.
Significant amounts of data were obtained through Gas Technology Institutes (formerly the Gas
Research Institute) speed of sound and physical properties basic research program. Laboratories in
both the United States and Europe carried out the research work. Contributions of all the research
organizations and laboratories are acknowledged.

DISCLAIMERS AND COPYRIGHT ........................................................................................................................ iii


FOREWORD................................................................................................................................................................iv
ACKNOWLEDGMENTS............................................................................................................................................ v
1. INTRODUCTION................................................................................................................................................ 1
1.1.
Scope ............................................................................................................................................................ 1
1.2.
Background................................................................................................................................................... 1
1.3.
Field of Application...................................................................................................................................... 1
1.4.
Types of Properties....................................................................................................................................... 1
1.5.
Types of Gases ............................................................................................................................................. 2
1.6.
Types of Conditions.......................................................................................................................................3
2.

UNCERTAINTY.................................................................................................................................................. 4

3. CALCULATIONS ...............................................................................................................................................
3.1.
Symbols ........................................................................................................................................................
3.2.
Overview of Calculation Method and Sequence ..........................................................................................
3.3.
Compliance...................................................................................................................................................
3.4.
Equations for Speed of Sound ......................................................................................................................

6
6
6
7
7

4.

CRITICAL FLOW FACTOR DETERMINATION........................................................................................... 12

5.

CHARACTERISTICS OF TYPICAL GASES .................................................................................................. 13

6.

REFERENCES ................................................................................................................................................... 18

7.

COMPUTATION FLOW CHARTS .................................................................................................................. 19

8. CALCULATION OUTPUT FOR PROGRAM VERIFICATION .....................................................................


8.1.
Detailed Output Results for Program Development ...................................................................................
8.1.1.
Detailed Output Result #1 .............................................................................................................
8.1.2.
Detailed Output Result #2 .............................................................................................................
8.1.3.
Detailed Output Result #3 .............................................................................................................
8.2.
Tabled Results for Compliance Checking and Program Development.......................................................

21
21
21
22
23
24

APPENDIX C++ LANGUAGE EXAMPLE IMPLEMENTATION.................................................................... 38


A1. OVERVIEW OF COMPUTER CODE .............................................................................................................. 38
A1.1.
File Group 1 Calculation Library........................................................................................................... 38
A1.1.1.
Overview of Classes and Key Functions ............................................................................................ 38
A1.1.2.
Detail Class......................................................................................................................................... 39
A1.1.3.
Therm Class........................................................................................................................................ 39
A1.1.4.
Function SOS() ................................................................................................................................... 39
A1.1.5.
Function Crit() .................................................................................................................................... 39
A1.2.
File Group 2 Example Windows Application........................................................................................ 40
A2. PRINTOUTS OF COMPUTER CODE...............................................................................................................40
A2.1.
File Group 1 Calculation Code .............................................................................................................. 40
A2.2.
File Group 2 Example Windows Application Code .............................................................................124

vii

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

TABLE OF CONTENTS

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

viii

1.1. Scope
This document contains information for 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, Second Edition,
Second 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 AGA, API and 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 other
related hydrocarbon gases. The equations utilized are consistent 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.

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

1. Introduction

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 currently
is not 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.
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

Gross Heating Value ***

18.7 to 45.1 MJ/m

0 to 1800 Btu/scf
0 to 66 MJ/m

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.

Table 1: Range of Gas Mixture Characteristics Consistent with this Report

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

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.

-60

-8

62

120

200

20000

140
Region 4

1.0%

70
0.5%
Pressure, MPa

Pressure, psia

Region 3

2500

0.3%

Pressure, MPa

10000

17

Region 2
1750

0.1%

12

Region 1

-200

-80

17

143
Temperature, F

250

400

Figure 1: Targeted Uncertainty for Natural Gas Speed of Sound


Using the AGA Report No. 10 Method

1.6. Types of Conditions


This report is for the gas phase only. 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.

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature, C
-130

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 of 250 K to 350 K (-10 F to 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).
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:

Wdiff =

BIAS =

AAD =

Wcalc Wexp
Wexp

(2.1)

x100

1
N

1
N

[(W ) ]

i =1

(2.2)

diff ,i

i =1

diff ,i

1
2 2

(2.3)
1

2
1 N
2
(
)

Std .Dev. =
W
BIAS
diff ,i

N 1 i =1

(2.4)

where:
Wdiff = relative percentage difference between calculated and experimental speed of sound
Wdiff,i = Wdiff for ith data point
Wcalc = calculated speed of sound
Wexp = experimental speed of sound
AAD = average absolute deviation
BIAS = bias
Std.Dev. = standard deviation

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

2. Uncertainty

Methane Nitrogen
0.94985
0.84992
0.68526
0.50217
0.34524
0.90016
0.95114
0.8513
0.71373
0.94979
0.85026
0.69944
0
0.96561
0.90708
0.8398
0.74348

0
0
0
0
0
0
0.04886
0.1487
0.28627
0
0
0
0.49593
0.00262
0.03113
0.00718
0.00537

Carbon
Dioxide
0
0
0
0
0
0
0
0
0
0.05021
0.14974
0.30056
0.50407
0.00597
0.005
0.00756
0.01028

Ethane Propane Isobutane


0.05015
0.15008
0.31474
0.49783
0.65476
0
0
0
0
0
0
0
0
0.01829
0.04491
0.13475
0.12005

0
0
0
0
0
0.09984
0
0
0
0
0
0
0
0.0041
0.00815
0.00943
0.08251

0
0
0
0
0
0
0
0
0
0
0
0
0
0.00098
0.00106
0.0004
0

Normal Isopentane Normal Normal


Butane
Pentane Hexane
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.00098
0.00046 0.00032 0.00067
0.00141
0.00065 0.00027 0.00034
0.00067
0.00013 0.00008
0
0.03026
0 0.00575
0.0023

Table 2: Gas Mixture Characteristics Included in Statistical Analysis

Gas No. No. Points AAD %


2
80
0.021
3
67
0.079
4
95
0.600
5
78
0.418
6
72
0.086
7
76
0.327
8
81
0.021
9
87
0.024
10
97
0.025
11
80
0.026
12
71
0.024
13
90
0.096
14
65
0.148
15
83
0.030
16
82
0.031
17
91
0.094
18
44
0.148

Bias % Std. Dev. %


-0.026
0.026
0.016
0.133
0.317
1.094
0.103
0.803
-0.011
0.127
0.144
0.721
-0.037
0.026
-0.036
0.029
-0.023
0.033
-0.053
0.038
-0.041
0.039
-0.009
0.184
0.230
0.205
-0.045
0.040
-0.026
0.051
0.001
0.153
0.068
0.224

Table 3: Statistical Analysis of the Differences between Calculated


and Experimental Speed of Sound Values for 17 Natural Gas Mixtures

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Gas
No.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

3.1. Symbols

B T
2 B T 2
Z T
2 Z T 2

First partial derivative of B wrt T


Second partial derivative of B wrt T
First partial derivative of Z wrt T

Second partial derivative of Z wrt T


First partial derivative of Z wrt

Molar density

Isentropic exponent

Second virial coefficient

cp

Constant pressure heat capacity (real gas)

cp

Constant pressure heat capacity (ideal gas)

cv

Constant volume heat capacity (real gas)

cv

Constant volume heat capacity (ideal gas)

Enthalpy (real gas)

Enthalpy (ideal gas)

Mr

Molar mass

Absolute pressure

Universal gas constant

Entropy (real gas)

So

Entropy (ideal gas)

Temperature

Speed of sound

Xi

Mole fraction of ith component

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 and 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 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.

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

3. Calculations

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 Z T 2 ,
Z ) are solved using the approach given in AGA Report No. 8 for subroutine ZDETAIL. Two
other derivatives, B T and 2 B T 2 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, cp/cv, at the operating conditions.
8. Calculate the speed of sound, based on the results of the preceding steps.
9. Calculate the isentropic exponent, .

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 8.2, Table 6a
(English units) or Table 6b (Metric units).
Other tables of computed values are given in Section 8 for computational checks but a compliance
level is not specified.

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.

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

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].

c p RT
W =
cv M r

Z
Z +

0.5

(3.1)

The isentropic exponent may be expressed in terms of its relationship to the speed of sound:

=W 2

Mr
ZRT

(3.2)

The quantities cv and cp are the constant volume and constant pressure heat capacities of the gas.

o
2 Z
T 2Z

c v = c p R 1 + T
+
d

T T
c p = cv + 2
P

T

(3.3)

(3.4a)

or, expressed in terms of compressibility:

Z

Z + T
T

c p = cv + R

Z

Z +
T

(3.4b)

Note that the ideal gas specific heat ratio,

cp

cv

, real gas specific heat ratio,

cp
cv

, 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

cp

J /T
H /T
F /T
D /T
+ I
+ G
= B + C
+ E

sinh(D / T )
cosh(J / T )
sinh(H / T )
cosh(F / T )

(3.5)

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

The basic speed of sound relation can be expressed as:

H o = A + BT + CD coth (D / T ) EF tanh( F / T ) + GH coth( H / T ) IJ tanh( J / T )

(3.6)

The real gas enthalpy is computed as:

T Z
H = H + RT (Z 1)

T
0

(3.7)

The pure fluid ideal gas entropy is computed as:

S o = K + B ln(T ) + C [( D / T ) coth( D / T ) ln(sinh( D / T ))]


E [( F / T ) tanh( F / T ) ln(cosh( F / T ))]
+ G[( H / T ) coth( H / T ) ln(sinh( H / T ))]
I [( J / T ) tanh( J / T ) ln(cosh( J / T ))]

(3.8)

The entropy of mixing is computed as:


N

S mixing = R X i ln ( X i )

(3.9)

i =1

The real gas entropy is computed as:

(Z 1) T Z
P
R ln( o ) R
+

ZP

T
0

S = S + S mixing
o

(3.10)

where Po = 0.101325 MPa


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).
The basic equation for the compressibility factor, from AGA Report No. 8, is:

Z = 1+

18
58
DB
* u n

D
C
T
+
Cn*T u n bn cn k n D k n D bn exp cn D k n

n
3
K
n =13
n =13

(3.11)

where
*
B = anT u n xi x j Eiju n (K i K j )2 Bnij
18

n =1

i =1 j =1

(3.12)

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

The pure fluid ideal gas enthalpy is computed as:

A
(cal/mol)

(cal/mol-K) (cal/mol-K)

(K)

(cal/mol-K)

(K)

(cal/mol-K)

(K)

(cal/mol-K)

(K)

(cal/mol-K)

Methane

-29776.4

7.95454

43.9417 1037.09

Nitrogen

-3495.34

6.95587 0.272892 662.738 -0.291318 -680.562 1.78980 1740.06

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

-3.24989

Hydrogen
Sulfide

-10085.4

7.94680

-0.0838

2.85539

843.792 6.31595 1481.43 -2.88457 1102.23

Hydrogen

-5565.6

6.66789

2.33458 2584.98 0.749019 559.656

100

100

-7.94821

Carbon
Monoxide

-2753.49

6.95854

2.02441 1541.22 0.096774 3674.81

100

100

6.23387

Oxygen

-3497.45

6.96302

2.40013 2522.05

2.21752

1154.15

100

100

9.19749

Isobutane

-72387

17.8143

58.2062 1787.39

40.7621

808.645

100

100

-44.1341

Normal
Butane

-72674.8

18.6383

57.4178 1792.73

38.6599

814.151

100

100

-46.1938

Isopentane

-91505.5

21.3861

74.3410 1701.58

47.0587

775.899

100

100

-60.2474

Normal
Pentane

-83845.2

22.5012

69.5789 1719.58

46.2164

802.174

100

100

-62.2197

Normal
Hexane

-94982.5

26.6225

80.3819 1718.49

55.6598

802.069

100

100

-77.5366

Normal
Heptane

-103353

30.4029

90.6941 1669.32

63.2028

786.001

100

100

-92.0164

Normal
Octane

-109674

34.0847

100.253 1611.55

69.7675

768.847

100

100

-106.149

Normal
Nonane

-122599

38.5014

111.446 1646.48

80.5015

781.588

100

100

-122.444

Normal
Decane

-133564

42.7143

122.173 1654.85

90.2255

785.564

100

100

-138.006

Helium

0.0

4.968

100

100

100

100

1.8198

Argon

0.0

4.968

100

100

100

100

8.6776

433.801

1.56373

813.205 -24.9027 1019.98 -10.1601 1070.14

100

Table 4: Calculation Coefficients for Heat Capacity, Enthalpy and Entropy

10

100

100

-20.0615
4.49823

-0.51551

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Component

18
D B
Z
* (u +1)
+ D u n C nT n

= 3

T
K
T

d
n =13

58

(3.13)

u n C n*T (u n +1) bn cn k n D k n D bn exp cn D k n


where

n =13

18
N N
3
B
(u n +1)
*
=

u
a
T
xi x j Eijun (K i K j )2 Bnij

n n
T d
n =1
i =1 j =1

(3.14)

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


18
2Z
D 2B
2 = 3 2 D u n (u n + 1)C n*T (un + 2 )
n =13
T d K T d

58

(3.15)

+ u n (u n + 1)C n*T (u n + 2 ) bn cn k n D k n D bn exp cn D k n

n =13

where
18
N N
3
2B
*
2 = un (un + 1)anT (un + 2 ) xi x j Eijun (K i K j )2 Bnij
i =1 j =1
T d n =1

(3.16)

The first partial derivative of Z with respect to is:

18
B
Z
58
= K 3 3 Cn*T un + Cn*T un cn k n2 D (k n 1) D bn exp cn D k n
n =13
T
K n =13

58

) (

+ Cn*T un bn cn k n D k n bn D (bn 1) exp cn D k n

(3.17)

n =13

) (

58

Cn*T un bn cn k n D k n D bn cn k n D (k n 1) exp cn D k n
n =13

11

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

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

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.

12

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

4. Critical Flow Factor Determination

This section contains graphical representations (Figures 2 through 5) 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.
The gas mixtures in Table 5 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

13

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

5. Characteristics of Typical Gases

1450

sound speed (ft/s)

1400

Gulf Coast

1350

Amarillo
Ekofisk
High N2
1300

High CO2

1250

1200

1150
30

50

70

90

110

130

temperature (degrees F)

Figure 2a: Sound Speed at 1200 psia as a Function of Temperature

460

450

440

sound speed (m/s)

430

420
Gulf Coast
Amarillo
410

Ekofisk
High N2
High CO2

400

390

380

370

360
0.0

10.0

20.0

30.0

40.0

50.0

temperature (degrees C)

Figure 2b: Sound Speed at 8.27 MPa as a Function of Temperature

14

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

1500

sound speed (ft/s)

1350

1300
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2

1250

1200

1150
0

200

400

600

800

1000

1200

absolute pressure (psia)

Figure 3a: Sound Speed at 32 F as a Function of Pressure

430

420

410

sound speed (m/s)

400
Gulf Coast
Amarillo
390

Ekofisk
High N2
High CO2

380

370

360

350
0

absolute pressure (MPa)

Figure 3b: Sound Speed at 0 C as a Function of Pressure

15

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

1400

0.77

0.76

0.75

Gulf Coast

0.74
C*

Amarillo
Ekofisk
High N2

0.73

High CO2

0.72

0.71

0.7

0.69
30

50

70

90

110

130

temperature (degrees F)

Figure 4a: Critical Flow Coefficient, C*, at 1000 psia as a Function of Stagnation Temperature

0.780

0.770

0.760

0.750

Gulf Coast

0.740
C*

Amarillo
Ekofisk
High N2

0.730

High CO2

0.720

0.710

0.700

0.690
0.0

10.0

20.0

30.0

40.0

50.0

60.0

temperature (degrees C)

Figure 4b: Critical Flow Coefficient, C*, at 6.9 MPa as a Function of Stagnation Temperature

16

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

0.78

isentropic exponent

1.45

1.4
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2

1.35

1.3

1.25
0.00

200.00

400.00

600.00

800.00

1000.00

1200.00

absolute pressure (psia)

Figure 5a: Isentropic Exponent at 32 F as a Function of Pressure

1.50

isentropic exponent

1.45

1.40
Gulf Coast
Amarillo
Ekofisk
High N2
High CO2

1.35

1.30

1.25
0.00

1.00

2.00

3.00

4.00

5.00

6.00

7.00

8.00

absolute pressure (MPa)

Figure 5b: Isentropic Exponent at 0 C as a Function of Pressure

17

9.00

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

1.5

[1]
K.E. Starling and J.L. Savidge, Compressibility Factors of Natural Gas and Other Related Hydrocarbon
Gases, AGA 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 2nd 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]
00.

Canadian Standards Association, Canadian Standards Association Metric Practice Guide, 2000: Z234.1-

18

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

6. References

Extending the calculation process of AGA Report No. 8, the method for calculating speed of sound,
enthalpy and entropy can be summarized as shown in Figure 6.

begin

color codes
original AGA 8
algorithm

initialize tables of
constants

new function for


cpo (ideal gas)

AGA8 function
paramdl

new function for


H (ideal gas)

AGA8 function
chardl

new function for


S (ideal gas)

modified AGA8
function bvir

AGA8 function
temp

new function
Cp, H, S
(real gas)

AGA8 function
zdetail

AGA8 function
braket

AGA8 function
ddetail

new functions
for Cv, k, c, SOS

new AGA8
function
dZdT

new or modified
AGA8 algorithm
new algorithm

process endpoint

AGA8 function
pdetail

AGA8 function
zdetail

AGA8 function
pdetail

AGA8 function
zdetail
end

AGA8 function
relative density

new AGA8
function
dZdD

Figure 6: Flowchart of Sound Speed Calculation Procedure

19

new AGA8
function
d2ZdT2

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

7. Computation Flow Charts

begin

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

find a pressure
that satisfies a
given entropy and
temperature

find a temperature
that satisfies a
given enthalpy and
pressure

no

convergence
tolerance met?

yes

no

convergence
tolerance met?

yes

no

convergence
tolerance met?

yes
end

Figure 7: Diagram of Critical Flow Function Calculation

20

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

The calculation sequence for the critical flow function, C*, is an extension of the algorithms for sound speed,
enthalpy and entropy, as shown in Figure 7.

8.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.
8.1.1.

Detailed Output Result #1

Input
Composition
Pressure
Temperature

:
:
:

Pure Methane
8.000 MPa (1160.3019 psia)
20.0 C (68.0 F)

:
:
:
:

3.79174963 moles/dm3
16.0430000 kg/kg-mol
0.865613011
0.001370797803

2 Z T 2

-1.08884683127e-005

-0.02602812374

B T

0.000396764069

2 B T 2

-3.34719916156e-006

cpo (ideal gas)


cp (real gas)
cv (real gas)
Isentropic exponent
Sound Speed
Specific Enthalpy
Specific Entropy
C*

:
:
:
:
:
:
:
:

2.21437395 kJ/kg-K
2.86910318 kJ/kg-K
1.78350108 kJ/kg-K
1.42527799
432.944437 m/s
528.977205 kJ/kg
9.09475139 kJ/kg-K
0.732987437

Output
Molar Density
Molar Mass
Compressibility Factor

Z T

21

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

8. Calculation Output for Program Verification

Detailed Output Result #2

Input
Composition
Pressure
Temperature

:
:
:

Amarillo
4.000 MPa (580.15095 psia)
10.0 C (50 F)

:
:
:
:

1.87396178 moles/dm3
17.5955109 kg/kg-mol
0.90666330
0.00084934112

2 Z T 2

-7.3766250161e-6

-0.0442939010

B T

0.00047962844

2 B T 2

-4.2808097391e-006

cpo (ideal gas)


cp (real gas)
cv (real gas)
Isentropic exponent
Sound Speed
Specific Enthalpy
Specific Entropy
C*

:
:
:
:
:
:
:
:

2.06018714 kJ/kg-K
2.40008811 kJ/kg-K
1.64511520 kJ/kg-K
1.32535394
400.972536 m/s
499.296977 kJ/kg
9.02299618 kJ/kg-K
0.704302274

Output
Molar Density
Molar Mass
Compressibility Factor

Z T

22

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

8.1.2.

Detailed Output Result #3

Input
Composition: Hypothetical 21 Component Mixture
Methane
Nitrogen
Carbon Dioxide
Ethane
Propane
Water
Hydrogen Sulfide
Hydrogen
Carbon Monoxide
Oxygen
i-Butane
n-Butane
i-Pentane
n-Pentane
n-Hexane
n-Heptane
n-Octane
n-Nonane
n-Decane
Helium
Argon
Pressure
Temperature

:
:

86.29
2.0
0.50
5.0
3.0
0.01
0.1
0.01
0.01
0.02
1.10
0.90
0.35
0.25
0.20
0.10
0.05
0.02
0.01
0.04
0.04
6.000 MPa (870.2264 psia)
40.0 C (104.0 F)

Output
:
:
:
:

2.62533592 moles/dm3
19.4780144 kg/kg-mol
0.877763047
0.00110251388

2 Z T 2

-8.7236464045e-006

-0.0375423163

B T

0.0004594320

2 B T 2

-3.776948019e-006

cpo (ideal gas)


cp (real gas)
cv (real gas)
Isentropic exponent
Sound Speed
Specific Enthalpy
Specific Entropy
C*

:
:
:
:
:
:
:
:

2.08298699 kJ/kg-K
2.55641833 kJ/kg-K
1.73699984 kJ/kg-K
1.30648621
391.528389 m/s
508.00420 kJ/kg
8.51434681 kJ/kg-K
0.710708883

Molar Density
Molar Mass
Compressibility Factor

Z T

23

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

8.1.3.

The following tables (Tables 6a and 6b through Tables 12a and 12b) 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 in Tables 6a and
6b.
Temperature
o

Pressure

Speed of Sound (ft/s)

psia

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

32
32
32
32
32
32
32
32

14.73
100
200
400
600
800
1000
1200

1376.597
1366.745
1355.642
1335.321
1318.413
1306.276
1300.594
1303.310

1342.938
1332.778
1321.304
1300.228
1282.605
1269.889
1263.899
1266.743

1292.325
1279.700
1265.215
1237.817
1213.748
1195.063
1184.617
1186.056

1310.350
1302.556
1293.922
1278.667
1266.847
1259.523
1257.912
1263.309

1265.813
1255.856
1244.570
1223.691
1205.990
1192.885
1186.169
1187.957

50
50
50
50
50
50
50
50

14.73
100
200
400
600
800
1000
1200

1399.778
1391.213
1381.650
1364.443
1350.531
1340.972
1337.006
1339.995

1365.493
1356.638
1346.728
1328.825
1314.261
1304.165
1299.870
1302.842

1313.880
1302.733
1290.049
1266.410
1246.097
1230.700
1222.250
1223.155

1332.486
1325.815
1318.509
1305.883
1296.509
1291.207
1290.879
1296.448

1287.058
1278.371
1268.612
1250.851
1236.186
1225.721
1220.765
1222.771

100
100
100
100
100
100
100
100

14.73
100
200
400
600
800
1000
1200

1460.830
1455.126
1448.935
1438.390
1430.716
1426.462
1426.212
1430.551

1424.940
1418.987
1412.505
1401.389
1393.186
1388.482
1387.900
1392.061

1370.746
1362.902
1354.172
1338.541
1325.949
1317.221
1313.273
1315.055

1390.875
1386.697
1382.301
1375.317
1371.076
1369.996
1372.500
1378.986

1343.132
1337.269
1330.855
1319.748
1311.372
1306.299
1305.135
1308.491

130
130
130
130
130
130
130
130

14.73
100
200
400
600
800
1000
1200

1495.370
1490.996
1486.351
1478.794
1473.848
1471.893
1473.315
1478.487

1458.605
1454.003
1449.093
1441.021
1435.600
1433.233
1434.333
1439.294

1403.004
1396.704
1389.791
1377.738
1368.490
1362.617
1360.724
1363.406

1423.961
1420.941
1417.877
1413.428
1411.448
1412.219
1416.016
1423.092

1374.940
1370.392
1365.511
1357.384
1351.750
1349.001
1349.538
1353.747

Table 6a: Speed of Sound (W); English Units

24

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

8.2. Tabled Results for Compliance Checking and Program Development

Speed of Sound (m/s)

Pressure
MPa

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

0
0
0
0
0
0
0
0

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

419.5867
416.5839
413.1998
407.0058
401.8523
398.1531
396.4209
397.2489

409.3274
406.2307
402.7334
396.3094
390.9379
387.0622
385.2363
386.1033

393.9008
390.0524
385.6374
377.2867
369.9503
364.2551
361.0712
361.5100

399.3948
397.0190
394.3874
389.7378
386.1351
383.9027
383.4116
385.0567

385.8198
382.7850
379.3451
372.9809
367.5856
363.5914
361.5444
362.0892

10
10
10
10
10
10
10
10

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

426.6523
424.0418
421.1270
415.8822
411.6419
408.7283
407.5195
408.4305

416.2024
413.5034
410.4828
405.0260
400.5867
397.5095
396.2005
397.1062

400.4707
397.0729
393.2070
386.0018
379.8104
375.1172
372.5418
372.8175

406.1417
404.1083
401.8816
398.0332
395.1759
393.5599
393.4601
395.1572

392.2953
389.6475
386.6731
381.2593
376.7896
373.5999
372.0890
372.7007

37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

445.2610
443.5224
441.6354
438.4214
436.0821
434.7855
434.7095
436.0321

434.3217
432.5074
430.5315
427.1435
424.6432
423.2094
423.0320
424.3002

417.8034
415.4124
412.7517
407.9873
404.1493
401.4891
400.2857
400.8288

423.9387
422.6653
421.3253
419.1965
417.9039
417.5749
418.3379
420.3148

409.3866
407.5996
405.6445
402.2592
399.7063
398.1599
397.8052
398.8279

54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

455.7889
454.4556
453.0398
450.7364
449.2290
448.6331
449.0665
450.6429

444.5827
443.1802
441.6836
439.2233
437.5708
436.8495
437.1847
438.6969

427.6358
425.7152
423.6082
419.9346
417.1157
415.3258
414.7486
415.5661

434.0233
433.1027
432.1689
430.8128
430.2093
430.4443
431.6017
433.7584

419.0817
417.6954
416.2077
413.7308
412.0134
411.1754
411.3391
412.6220

Table 6b: Speed of Sound (W); Metric Units

25

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Pressure

C*

psia

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

32
32
32
32
32
32
32
32

14.73
100
200
400
600
800
1000
1200

0.670417
0.675541
0.681844
0.695500
0.710734
0.727755
0.746747
0.767596

0.669863
0.675065
0.681589
0.695774
0.711681
0.729555
0.749611
0.771751

0.667375
0.673485
0.681097
0.697897
0.717468
0.740770
0.767156
0.798146

0.671600
0.676352
0.682164
0.694621
0.708285
0.723243
0.739544
0.756775

0.670255
0.675744
0.682419
0.697193
0.713849
0.732690
0.753948
0.777601

50
50
50
50
50
50
50
50

14.73
100
200
400
600
800
1000
1200

0.669873
0.674358
0.679953
0.691938
0.705083
0.719491
0.735236
0.751996

0.669189
0.673917
0.679608
0.692034
0.705721
0.720788
0.737325
0.755020

0.666598
0.672034
0.678754
0.693445
0.709959
0.729277
0.750218
0.774151

0.670993
0.675235
0.680394
0.691341
0.703174
0.715923
0.729588
0.743905

0.669556
0.674450
0.680355
0.693279
0.707576
0.723392
0.740840
0.759633

100
100
100
100
100
100
100
100

14.73
100
200
400
600
800
1000
1200

0.667905
0.671300
0.675397
0.683874
0.692961
0.702570
0.712829
0.723242

0.667144
0.670641
0.674866
0.683630
0.693044
0.703021
0.713688
0.724557

0.663869
0.668316
0.673183
0.683511
0.694685
0.706747
0.719707
0.733378

0.669223
0.672365
0.676043
0.683878
0.692103
0.700698
0.709787
0.718835

0.667476
0.671094
0.675470
0.684666
0.694475
0.704905
0.715930
0.727355

130
130
130
130
130
130
130
130

14.73
100
200
400
600
800
1000
1200

0.666606
0.669465
0.672895
0.680003
0.687336
0.695076
0.703241
0.711526

0.665350
0.668756
0.672289
0.679624
0.687314
0.695346
0.703692
0.712298

0.662451
0.665798
0.670296
0.678807
0.687851
0.697432
0.707531
0.718088

0.667998
0.670639
0.673795
0.680297
0.686925
0.693870
0.701146
0.708427

0.665680
0.669192
0.672851
0.680458
0.688452
0.696821
0.705538
0.714547

Table 7a: Critical Flow Coefficient (C*); English Units

26

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Pressure

C*

MPa

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

0
0
0
0
0
0
0
0

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

0.670417
0.675541
0.681844
0.695500
0.710734
0.727755
0.746747
0.767596

0.669863
0.675065
0.681589
0.695774
0.711681
0.729555
0.749611
0.771751

0.667375
0.673485
0.681097
0.697897
0.717468
0.740770
0.767156
0.798146

0.671600
0.676352
0.682164
0.694621
0.708285
0.723243
0.739544
0.756775

0.670255
0.675744
0.682419
0.697193
0.713849
0.732690
0.753948
0.777601

10
10
10
10
10
10
10
10

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

0.669873
0.674358
0.679953
0.691938
0.705083
0.719491
0.735236
0.751996

0.669189
0.673917
0.679608
0.692034
0.705721
0.720788
0.737325
0.755020

0.666598
0.672034
0.678754
0.693445
0.709959
0.729277
0.750218
0.774151

0.670993
0.675235
0.680394
0.691341
0.703174
0.715923
0.729588
0.743905

0.669556
0.674450
0.680355
0.693279
0.707576
0.723392
0.740840
0.759633

37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

0.667905
0.671300
0.675397
0.683874
0.692961
0.702570
0.712829
0.723242

0.667144
0.670641
0.674866
0.683630
0.693044
0.703021
0.713688
0.724557

0.663869
0.668316
0.673183
0.683511
0.694685
0.706747
0.719707
0.733378

0.669223
0.672365
0.676043
0.683878
0.692103
0.700698
0.709787
0.718835

0.667476
0.671094
0.675470
0.684666
0.694475
0.704905
0.715930
0.727355

54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

0.666606
0.669465
0.672895
0.680003
0.687336
0.695076
0.703241
0.711526

0.665350
0.668756
0.672289
0.679624
0.687314
0.695346
0.703692
0.712298

0.662451
0.665798
0.670296
0.678807
0.687851
0.697432
0.707531
0.718088

0.667998
0.670639
0.673795
0.680297
0.686925
0.693870
0.701146
0.708427

0.665680
0.669192
0.672851
0.680458
0.688452
0.696821
0.705538
0.714547

Table 7b: Critical Flow Coefficient (C*); Metric Units

27

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Isentropic Exponent

Pressure

psia

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

32
32
32
32
32
32
32
32

14.73
100
200
400
600
800
1000
1200

1.305655
1.306753
1.309207
1.318742
1.336248
1.364448
1.406731
1.467046

1.301604
1.302437
1.304616
1.313783
1.331335
1.360274
1.404366
1.468004

1.286355
1.285530
1.285824
1.291748
1.307683
1.338425
1.390576
1.472470

1.312895
1.315093
1.318859
1.330968
1.350659
1.380034
1.421522
1.477732

1.303308
1.304100
1.306240
1.315401
1.333142
1.362646
1.407936
1.473756

50
50
50
50
50
50
50
50

14.73
100
200
400
600
800
1000
1200

1.301927
1.303386
1.306168
1.315861
1.332420
1.357804
1.394331
1.444570

1.297762
1.298975
1.301500
1.310837
1.327375
1.353264
1.391058
1.443593

1.282196
1.281857
1.282621
1.288893
1.303641
1.330207
1.372867
1.436681

1.309313
1.311802
1.315805
1.327887
1.346517
1.373215
1.409667
1.457613

1.299415
1.300595
1.303089
1.312423
1.329108
1.355410
1.394037
1.448015

100
100
100
100
100
100
100
100

14.73
100
200
400
600
800
1000
1200

1.290446
1.292600
1.295972
1.305799
1.320395
1.340624
1.367416
1.401707

1.286086
1.288045
1.291213
1.300745
1.315252
1.335680
1.363040
1.398353

1.269898
1.270578
1.272307
1.279297
1.292024
1.311904
1.340524
1.379548

1.298338
1.301364
1.305760
1.317578
1.333960
1.355575
1.383107
1.417209

1.287777
1.289724
1.292886
1.302444
1.317060
1.337718
1.365478
1.401410

130
130
130
130
130
130
130
130

14.73
100
200
400
600
800
1000
1200

1.283014
1.285431
1.289002
1.298767
1.312465
1.330650
1.353891
1.382745

1.278619
1.280867
1.284263
1.293772
1.307379
1.325687
1.349315
1.378866

1.262233
1.263345
1.265466
1.272716
1.284661
1.302202
1.326299
1.357915

1.291253
1.294468
1.298971
1.310547
1.325890
1.345425
1.369567
1.398701

1.280429
1.282679
1.286084
1.295641
1.309355
1.327855
1.351784
1.381773

Table 8a: Isentropic Exponent (); English Units

28

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Isentropic Exponent

Pressure
MPa

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

0
0
0
0
0
0
0
0

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

1.305655
1.306753
1.309207
1.318742
1.336248
1.364448
1.406731
1.467046

1.301604
1.302437
1.304616
1.313783
1.331335
1.360274
1.404366
1.468004

1.286355
1.285530
1.285824
1.291748
1.307683
1.338425
1.390576
1.472470

1.312895
1.315093
1.318859
1.330968
1.350659
1.380034
1.421522
1.477732

1.303308
1.304100
1.306240
1.315401
1.333142
1.362646
1.407936
1.473756

10
10
10
10
10
10
10
10

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

1.301927
1.303386
1.306168
1.315861
1.332420
1.357804
1.394331
1.444570

1.297762
1.298975
1.301500
1.310837
1.327375
1.353264
1.391058
1.443593

1.282196
1.281857
1.282621
1.288893
1.303641
1.330207
1.372867
1.436681

1.309313
1.311802
1.315805
1.327887
1.346517
1.373215
1.409667
1.457613

1.299415
1.300595
1.303089
1.312423
1.329108
1.355410
1.394037
1.448015

37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

1.290446
1.292600
1.295972
1.305799
1.320395
1.340624
1.367416
1.401707

1.286086
1.288045
1.291213
1.300745
1.315252
1.335680
1.363040
1.398353

1.269898
1.270578
1.272307
1.279297
1.292024
1.311904
1.340524
1.379548

1.298338
1.301364
1.305760
1.317578
1.333960
1.355575
1.383107
1.417209

1.287777
1.289724
1.292886
1.302444
1.317060
1.337718
1.365478
1.401410

54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

1.283014
1.285431
1.289002
1.298767
1.312465
1.330650
1.353891
1.382745

1.278619
1.280867
1.284263
1.293772
1.307379
1.325687
1.349315
1.378866

1.262233
1.263345
1.265466
1.272716
1.284661
1.302202
1.326299
1.357915

1.291253
1.294468
1.298971
1.310547
1.325890
1.345425
1.369567
1.398701

1.280429
1.282679
1.286084
1.295641
1.309355
1.327855
1.351784
1.381773

Table 8b: Isentropic Exponent (); Metric Units

29

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Pressure

Heat Capacity (Btu/Lbm-F)

psia

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

32
32
32
32
32
32
32
32

14.73
100
200
400
600
800
1000
1200

0.506950
0.518114
0.532186
0.563920
0.601144
0.644486
0.693897
0.747987

0.488994
0.500128
0.514205
0.546124
0.583864
0.628144
0.678904
0.734493

0.477059
0.489423
0.505335
0.542691
0.589308
0.647377
0.717702
0.796947

0.448710
0.458100
0.469826
0.495794
0.525400
0.558743
0.595435
0.634328

0.432120
0.442493
0.455646
0.485648
0.521447
0.563887
0.613040
0.667301

50
50
50
50
50
50
50
50

14.73
100
200
400
600
800
1000
1200

0.511648
0.521749
0.534357
0.562282
0.594169
0.630235
0.670243
0.713203

0.493747
0.503814
0.516412
0.544440
0.576644
0.613283
0.654098
0.697959

0.482430
0.493600
0.507791
0.540281
0.579264
0.625738
0.679782
0.739439

0.452580
0.461077
0.471596
0.494533
0.520103
0.548245
0.578580
0.610298

0.436334
0.445689
0.457424
0.483658
0.514021
0.548845
0.587951
0.630260

100
100
100
100
100
100
100
100

14.73
100
200
400
600
800
1000
1200

0.526964
0.534780
0.544344
0.564789
0.586982
0.610810
0.635996
0.662074

0.509059
0.516831
0.526357
0.546775
0.569016
0.592965
0.618330
0.644607

0.499361
0.507931
0.518543
0.541706
0.567593
0.596203
0.627234
0.659951

0.465094
0.471676
0.479681
0.496606
0.514686
0.533765
0.553580
0.573759

0.449703
0.456882
0.465695
0.484641
0.505364
0.527779
0.551626
0.576432

130
130
130
130
130
130
130
130

14.73
100
200
400
600
800
1000
1200

0.537585
0.544378
0.552620
0.569986
0.588468
0.607928
0.628141
0.648786

0.519568
0.526314
0.534509
0.551812
0.570272
0.589748
0.610004
0.630697

0.510761
0.518166
0.527238
0.546667
0.567808
0.590549
0.614615
0.639530

0.473714
0.479439
0.486349
0.500775
0.515928
0.531665
0.547787
0.564040

0.458758
0.464972
0.472531
0.488524
0.505642
0.523762
0.542670
0.562046

Table 9a: Constant Pressure Heat Capacity (cp); English Units

30

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Heat Capacity (kJ/kg-K)

Pressure
MPa

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

0
0
0
0
0
0
0
0

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

2.12250
2.16924
2.22816
2.36102
2.51687
2.69833
2.90521
3.13167

2.04732
2.09394
2.15287
2.28651
2.44452
2.62991
2.84243
3.07517

1.99735
2.04912
2.11574
2.27214
2.46732
2.71044
3.00487
3.33666

1.87866
1.91797
1.96707
2.07579
2.19974
2.33935
2.49297
2.65581

1.80920
1.85263
1.90770
2.03331
2.18319
2.36088
2.56667
2.79386

10
10
10
10
10
10
10
10

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

2.14217
2.18446
2.23725
2.35416
2.48767
2.63867
2.80617
2.98604

2.06722
2.10937
2.16212
2.27946
2.41429
2.56769
2.73858
2.92222

2.01984
2.06660
2.12602
2.26205
2.42526
2.61984
2.84611
3.09588

1.89486
1.93044
1.97448
2.07051
2.17757
2.29539
2.42240
2.55520

1.82684
1.86601
1.91514
2.02498
2.15210
2.29790
2.46163
2.63877

37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

2.20629
2.23902
2.27906
2.36466
2.45758
2.55734
2.66279
2.77197

2.13133
2.16387
2.20375
2.28924
2.38236
2.48262
2.58883
2.69884

2.09073
2.12661
2.17104
2.26802
2.37640
2.49618
2.62610
2.76308

1.94726
1.97481
2.00833
2.07919
2.15489
2.23477
2.31773
2.40221

1.88282
1.91287
1.94977
2.02909
2.11586
2.20971
2.30955
2.41340

54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

2.25076
2.27920
2.31371
2.38642
2.46380
2.54527
2.62990
2.71634

2.17533
2.20357
2.23788
2.31033
2.38761
2.46916
2.55396
2.64060

2.13845
2.16946
2.20744
2.28879
2.37730
2.47251
2.57327
2.67758

1.98334
2.00732
2.03625
2.09665
2.16009
2.22598
2.29347
2.36152

1.92073
1.94674
1.97839
2.04535
2.11702
2.19289
2.27205
2.35317

Table 9b: Constant Pressure Heat Capacity (cp); Metric Units

31

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Heat Capacity (Btu/Lbm-F)

Pressure

psia

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

32
32
32
32
32
32
32
32

14.73
100
200
400
600
800
1000
1200

0.387265
0.389480
0.392083
0.397320
0.402606
0.407916
0.413161
0.418161

0.374671
0.376927
0.379584
0.384949
0.390400
0.395913
0.401382
0.406590

0.369665
0.372301
0.375442
0.381940
0.388807
0.396052
0.403474
0.410529

0.340975
0.342837
0.345015
0.349356
0.353668
0.357921
0.362048
0.365939

0.330630
0.332836
0.335446
0.340756
0.346213
0.351802
0.357415
0.362807

50
50
50
50
50
50
50
50

14.73
100
200
400
600
800
1000
1200

0.392092
0.394071
0.396389
0.401011
0.405612
0.410166
0.414611
0.418844

0.379553
0.381570
0.383934
0.388666
0.393398
0.398106
0.402719
0.407113

0.375178
0.377553
0.380363
0.386095
0.392009
0.398091
0.404216
0.410094

0.344953
0.346614
0.348551
0.352385
0.356154
0.359831
0.363370
0.366705

0.334963
0.336924
0.339230
0.343873
0.348560
0.353270
0.357930
0.362403

100
100
100
100
100
100
100
100

14.73
100
200
400
600
800
1000
1200

0.407690
0.409168
0.410885
0.414267
0.417562
0.420752
0.423811
0.426708

0.395145
0.396646
0.398393
0.401835
0.405197
0.408458
0.411588
0.414554

0.392419
0.394186
0.396254
0.400370
0.404454
0.408481
0.412407
0.416161

0.357706
0.358944
0.360380
0.363195
0.365920
0.368537
0.371029
0.373373

0.348592
0.350029
0.351705
0.355018
0.358268
0.361437
0.364494
0.367403

130
130
130
130
130
130
130
130

14.73
100
200
400
600
800
1000
1200

0.418440
0.419699
0.421160
0.424025
0.426802
0.429476
0.432029
0.434446

0.405783
0.407059
0.408539
0.411444
0.414263
0.416979
0.419574
0.422028

0.403959
0.405451
0.407189
0.410622
0.413987
0.417263
0.420423
0.423430

0.366435
0.367490
0.368713
0.371104
0.373410
0.375619
0.377718
0.379695

0.357766
0.358978
0.360386
0.363155
0.365849
0.368454
0.370949
0.373315

Table 10a: Constant Volume Heat Capacity (cv); English Units

32

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Heat Capacity (kJ/kg-K)

Pressure
MPa

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

0
0
0
0
0
0
0
0

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

1.62140
1.63067
1.64157
1.66350
1.68563
1.70786
1.72982
1.75076

1.56867
1.57812
1.58924
1.61171
1.63453
1.65761
1.68050
1.70231

1.54772
1.55875
1.57190
1.59911
1.62786
1.65819
1.68926
1.71880

1.42760
1.43539
1.44451
1.46268
1.48074
1.49854
1.51582
1.53212

1.38428
1.39352
1.40444
1.42668
1.44953
1.47293
1.49642
1.51900

10
10
10
10
10
10
10
10

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

1.64161
1.64990
1.65960
1.67895
1.69822
1.71728
1.73589
1.75362

1.58911
1.59756
1.60746
1.62727
1.64708
1.66679
1.68611
1.70450

1.57079
1.58074
1.59250
1.61650
1.64126
1.66673
1.69237
1.71698

1.44425
1.45120
1.45931
1.47537
1.49115
1.50654
1.52136
1.53532

1.40243
1.41063
1.42029
1.43973
1.45935
1.47907
1.49858
1.51731

37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

1.70692
1.71310
1.72029
1.73445
1.74825
1.76161
1.77441
1.78654

1.65440
1.66068
1.66799
1.68240
1.69648
1.71013
1.72324
1.73566

1.64298
1.65038
1.65904
1.67627
1.69337
1.71023
1.72667
1.74238

1.49764
1.50283
1.50884
1.52062
1.53203
1.54299
1.55342
1.56324

1.45948
1.46550
1.47252
1.48639
1.50000
1.51326
1.52606
1.53824

54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

1.75193
1.75720
1.76331
1.77531
1.78693
1.79813
1.80882
1.81894

1.69893
1.70427
1.71047
1.72264
1.73444
1.74581
1.75667
1.76695

1.69130
1.69754
1.70482
1.71919
1.73328
1.74700
1.76023
1.77282

1.53419
1.53861
1.54373
1.55374
1.56339
1.57264
1.58143
1.58971

1.49790
1.50297
1.50886
1.52046
1.53174
1.54264
1.55309
1.56300

Table 10b: Constant Volume Heat Capacity (cv); Metric Units

33

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Pressure

Specific Enthalpy (Btu/Lbm)

psia

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

32
32
32
32
32
32
32
32

14.73
100
200
400
600
800
1000
1200

235.100
232.112
228.542
221.187
213.549
205.649
197.538
189.316

224.943
221.980
218.437
211.127
203.517
195.628
187.514
179.284

214.460
211.209
207.298
199.136
190.486
181.334
171.728
161.838

208.312
205.820
202.855
196.788
190.553
184.182
177.726
171.266

197.589
194.867
191.610
184.873
177.837
170.514
162.952
155.254

50
50
50
50
50
50
50
50

14.73
100
200
400
600
800
1000
1200

244.267
241.470
238.139
231.321
224.303
217.113
209.802
202.448

233.787
231.014
227.711
220.940
213.957
206.792
199.497
192.156

223.095
220.055
216.415
208.879
200.996
192.779
184.282
175.629

216.423
214.092
211.327
205.699
199.960
194.139
188.284
182.455

205.405
202.860
199.826
193.594
187.151
180.520
173.747
166.911

100
100
100
100
100
100
100
100

14.73
100
200
400
600
800
1000
1200

270.219
267.866
265.085
259.460
253.770
248.043
242.313
236.626

258.845
256.515
253.759
248.183
242.537
236.849
231.156
225.506

247.628
245.078
242.051
235.887
229.589
223.188
216.730
210.277

239.354
237.398
235.091
230.448
225.782
221.118
216.485
211.917

227.546
225.411
222.886
217.768
212.577
207.338
202.086
196.864

130
130
130
130
130
130
130
130

14.73
100
200
400
600
800
1000
1200

286.185
284.050
281.535
276.476
271.393
266.311
261.259
256.267

274.272
272.159
269.669
264.656
259.617
254.577
249.564
244.613

262.777
260.467
257.735
252.206
246.610
240.974
235.335
229.737

253.435
251.662
249.579
245.404
241.235
237.090
232.993
228.968

241.171
239.237
236.956
232.360
227.734
223.100
218.484
213.919

Table 11a: Specific Enthalpy (H); English Units

34

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Pressure

Specific Enthalpy (kJ/kg)

MPa

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

0
0
0
0
0
0
0
0

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

546.844
539.892
531.588
514.481
496.716
478.339
459.473
440.350

523.217
516.325
508.084
491.081
473.381
455.030
436.157
417.015

498.833
491.272
482.175
463.189
443.069
421.782
399.440
376.436

484.533
478.738
471.841
457.729
443.227
428.407
413.391
398.364

459.592
453.262
445.684
430.014
413.648
396.615
379.027
361.122

10
10
10
10
10
10
10
10

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

568.165
561.658
553.912
538.051
521.728
505.006
488.000
470.894

543.788
537.339
529.657
513.906
497.665
480.999
464.030
446.955

518.918
511.849
503.381
485.854
467.518
448.404
428.640
408.514

503.399
497.978
491.546
478.456
465.106
451.568
437.948
424.391

477.771
471.853
464.795
450.300
435.314
419.889
404.135
388.235

37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

628.530
623.056
616.587
603.503
590.269
576.947
563.621
550.392

602.072
596.653
590.244
577.273
564.140
550.910
537.670
524.527

575.982
570.051
563.012
548.672
534.024
519.136
504.114
489.105

556.738
552.187
546.822
536.022
525.169
514.319
503.543
492.919

529.272
524.307
518.432
506.527
494.453
482.269
470.053
457.906

54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444

0.101560
0.689476
1.378951
2.757903
4.136854
5.515806
6.894757
8.273709

665.666
660.701
654.851
643.082
631.261
619.440
607.687
596.077

637.956
633.042
627.249
615.590
603.870
592.146
580.487
568.970

611.220
605.845
599.490
586.631
573.614
560.505
547.388
534.369

589.489
585.366
580.520
570.810
561.111
551.471
541.941
532.579

560.964
556.465
551.160
540.470
529.709
518.930
508.195
497.576

Table 11b: Specific Enthalpy (H); Metric Units

35

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Specific Entropy (Btu/Lbm-F)

Pressure

psia

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

32
32
32
32
32
32
32
32

14.73
100
200
400
600
800
1000
1200

2.65254
2.42183
2.33472
2.24200
2.18272
2.13682
2.09807
2.06387

2.57924
2.35881
2.27545
2.18651
2.12944
2.08507
2.04751
2.01424

2.47804
2.27075
2.19178
2.10654
2.05079
2.00651
1.96814
1.93348

2.45345
2.24586
2.16770
2.08491
2.03239
1.99209
1.95845
1.92906

2.34134
2.14561
2.07147
1.99218
1.94110
1.90123
1.86732
1.83717

50
50
50
50
50
50
50
50

14.73
100
200
400
600
800
1000
1200

2.67085
2.44052
2.35389
2.26225
2.20420
2.15972
2.12258
2.09010

2.59691
2.37686
2.29398
2.20611
2.15029
2.10738
2.07144
2.03996

2.49529
2.28842
2.20999
2.12601
2.07179
2.02938
1.99323
1.96103

2.46965
2.26239
2.18463
2.10271
2.05118
2.01198
1.97954
1.95142

2.35695
2.16157
2.08788
2.00960
1.95971
1.92122
1.88888
1.86045

100
100
100
100
100
100
100
100

14.73
100
200
400
600
800
1000
1200

2.71941
2.48992
2.40431
2.31491
2.25936
2.21762
2.18345
2.15411

2.64379
2.42458
2.34272
2.25710
2.20379
2.16365
2.13073
2.10242

2.54119
2.33524
2.25797
2.17655
2.12531
2.08632
2.05400
2.02594

2.51257
2.30600
2.22910
2.14903
2.09951
2.06249
2.03234
2.00659

2.39838
2.20377
2.13104
2.05484
2.00730
1.97143
1.94195
1.91656

130
130
130
130
130
130
130
130

14.73
100
200
400
600
800
1000
1200

2.74720
2.51808
2.43295
2.34453
2.29004
2.24942
2.21643
2.18830

2.67064
2.45181
2.37041
2.28577
2.23352
2.19451
2.16277
2.13568

2.56756
2.36202
2.28526
2.20496
2.15494
2.11727
2.08638
2.05981

2.53707
2.33083
2.25431
2.17506
2.12641
2.09029
2.06107
2.03627

2.42209
2.22783
2.15552
2.08024
2.03368
1.99887
1.97050
1.94624

Table 12a: Specific Entropy (S); English Units

36

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

Specific Entropy (kJ/kg-K)

Pressure
MPa

Gulf Coast

Amarillo

Ekofisk

High N2

High CO2

0
0
0
0
0
0
0
0

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

11.10565
10.13971
9.77499
9.38682
9.13863
8.94642
8.78422
8.64101

10.79876
9.87588
9.52686
9.15449
8.91553
8.72979
8.57249
8.43324

10.37505
9.50716
9.17655
8.81967
8.58626
8.40087
8.24023
8.09508

10.27211
9.40298
9.07574
8.72910
8.50920
8.34049
8.19962
8.07660

9.80271
8.98322
8.67282
8.34085
8.12699
7.96008
7.81809
7.69184

10
10
10
10
10
10
10
10

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

11.18231
10.21797
9.85526
9.47157
9.22856
9.04231
8.88680
8.75084

10.87272
9.95144
9.60442
9.23656
9.00284
8.82317
8.67272
8.54090

10.44727
9.58115
9.25280
8.90116
8.67417
8.49660
8.34524
8.21044

10.33995
9.47216
9.14659
8.80362
8.58786
8.42377
8.28793
8.17019

9.86807
9.05007
8.74154
8.41379
8.20490
8.04377
7.90838
7.78935

37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778
37.77778

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

11.38563
10.42478
10.06638
9.69207
9.45950
9.28474
9.14167
9.01883

11.06904
10.15122
9.80851
9.45004
9.22682
9.05876
8.92092
8.80241

10.63946
9.77719
9.45366
9.11279
8.89826
8.73499
8.59967
8.48219

10.51961
9.65476
9.33279
8.99756
8.79023
8.63523
8.50899
8.40117

10.04154
9.22675
8.92222
8.60322
8.40417
8.25399
8.13057
8.02423

54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444
54.44444

0.10156
0.68948
1.37895
2.75790
4.13685
5.51581
6.89476
8.27371

11.50197
10.54271
10.18625
9.81607
9.58792
9.41787
9.27973
9.16197

11.18145
10.26522
9.92444
9.57008
9.35129
9.18795
9.05508
8.94166

10.74985
9.88932
9.56794
9.23171
9.02230
8.86460
8.73526
8.62402

10.62220
9.75870
9.43836
9.10654
8.90284
8.75162
8.62930
8.52544

10.14082
9.32750
9.02475
8.70955
8.51462
8.36885
8.25007
8.14853

Table 12b: Specific Entropy (S); Metric Units

37

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Temperature

A1.

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.

A1.1.

File Group 1 Calculation Library

File Group 1 is limited to mathematical calculations. User interface is not 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
aga10.cpp
detail.h
detail.cpp
therm.h
therm.cpp
entry.cpp
script1.rc

header file for AGA 10 data structures, macros and prototypes


c++ source code for overall execution control
header file for detail class
detail class implementation
header file for therm class
therm class implementation
Windows DLL entry code
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.
A1.1.1.

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

38

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

APPENDIX C++ Language Example Implementation

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.
A1.1.2.

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.
A1.1.3.

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 on the Detail class to perform density-related
work.
A1.1.4.

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.
A1.1.5.

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.
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 that 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.

39

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

density-related computations. The Therm class is designed for additional thermodynamic


calculations, including speed of sound.

A1.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)


request 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.
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:

A2

aga10win.h
aga10win.cpp
dlghlp.cpp
file.cpp
ga10win.rc

header file for application


main source code for Windows application
utility functions supporting dialog box operations
functions supporting file input/output
Windows resource template

Printouts of Computer Code


A2.1 File Group 1 Calculation Code
The code begins on the following page.

40

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

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.

#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
#include
#include
#include
#include
#include

includes */
<strstream>
<iostream>
<fstream>
<iomanip>
<math.h>

/*
status codes */
#define NORMAL
#define AGA10_INITIALIZED
#define MEMORY_ALLOCATION_ERROR
#define GENERAL_CALCULATION_FAILURE
#define MAX_NUM_OF_ITERATIONS_EXCEEDED
#define NEGATIVE_DENSITY_DERIVATIVE
#define MAX_DENSITY_IN_BRAKET_EXCEEDED
/*
number of components */
#define NUMBEROFCOMPONENTS

9000
9001
9002
9003
9004
9005
9006

21

/*
maximum number of tries within search routines */
#define MAX_NUM_OF_ITERATIONS 100

41

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

*************************************************************************
* 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
**************************************************************************/

/*
const
const
const
const

maximum allowable
double P_MAX
double P_MIN
double T_MAX
double T_MIN

P & T */
=
1.379e8 ;
=
0.0 ;
=
473.15 ;
=
143.0 ;

//
//
//
//

maximum
maximum
maximum
maximum

pressure (Pa) ~= 20,000 psi


pressure = 0
temperature (K) ~= 392 F
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 */
double dH ;
/* real gas specific enthalpy (J/kg) */
double dS ;
/* real gas specific entropy (J/kg-mol.K)*/

42

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*
default tolerance limits */
#define P_CHG_TOL 0.001 /* 0.001 Pa */
#define T_CHG_TOL 0.001 /* 0.001 of a Kelvin */

/*
/*
/*
/*
/*
/*
/*

ideal gas constant pressure heat capacity (J/kg-mol.K)*/


real gas constant pressure heat capacity (J/kg-mol.K)*/
real gas constant volume heat capacity (J/kg-mol.K)*/
ratio of specific heats */
isentropic exponent, denoted with Greek letter kappa */
speed of sound (m/s) */
critical flow factor C* */

/* 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) ;
DllExport int AGA10_UnInit(void) ;

/* initialize library */
/* un-initialize library */

/* function prototype for basic SOS calculation */


DllExport double SOS(AGA10STRUCT *) ;
/* function prototype for a C* calculation */
DllExport double Crit(AGA10STRUCT *, double) ;
#endif

43

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

double dCpi ;
double dCp ;
double dCv ;
double dk ;
double dKappa ;
double dSOS ;
double dCstar ;
} AGA10STRUCT ;

#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
if (NULL == (ptTherm = new Therm))

44

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

}
}

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() ;
AGA10_Init() ;
}

45

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 ;
}
}
// begin by calculating densities and thermodynamic properties

46

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// Call function to calculate 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 ;

// 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) ;

47

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

ptTherm->Run(ptAGA10, ptDetail) ;

// 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

48

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// put the original plenum pressure and temperature back


ptAGA10->dPf = P ;
ptAGA10->dTf = T ;

double CRi(AGA10STRUCT *ptAGA10)


{
return (Cperf(ptAGA10) / sqrt(ptAGA10->dZf)) ;
}
// CRi()

49

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
CRi()
*
Arguments
:
pointer to external AGA10 data struct
*
Returns
:
double
*
Purpose
:
calculates isentropic real gas critical flow function CRi
*
Revisions
:
**************************************************************************/

#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
double dSi[21] ;
// dipole parameter

50

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

// association parameter

double
double
double
double

dEij[21][21]
dUij[21][21]
dKij[21][21]
dGij[21][21]

;
;
;
;

//
//
//
//

double
double
double
double

adTable6Eij[21][21]
adTable6Uij[21][21]
adTable6Kij[21][21]
adTable6Gij[21][21]

;
;
;
;

double
double
double
double

adTable5Qi[21]
adTable5Fi[21]
adTable5Si[21]
adTable5Wi[21]

table
table
table
table

;
;
;
;

//
//
//
//

virial
binary
binary
binary
//
//
//
//

coefficient
interaction
interaction
interaction

Table
Table
Table
Table
5
5
5
5

6
6
6
6

energy binary
parameter for
parameter for
parameter for

interaction parm
conformal energy
size
orientation

constants
constants
constants
constants

constants
constants
constants
constants

double dXi[21] ;

// mole fraction of component i

double dPCalc ;

// pressure calculated by pdetail()

double dT ;
double dP ;

// current temperature
// current pressure

double
double
double
double
double

dRhoTP ;
dB ;
adBcoef[18] ;
adFn[58] ;
fx[58] ;

//
//
//
//
//

molar density at T & P


2nd virial coefficient, B
18 coefficients to calculate B
function for coefficients of density
modified coefficients used for 3 derivs

double
double
double
double
double

dU ;
dKp3 ;
dW ;
dQp2 ;
dF ;

//
//
//
//
//

mixture energy parameter


mixture size parameter ^3
mixture orientation parameter
mixture quadrupole parameter ^2
high temperature parameter

double
double
double
double
double

dRho ;
dRhoL ;
dRhoH ;
dPRhoL ;
dPRhoH ;

//
//
//
//
//

molar density
low density used in braket function
high density used in braket function
low pressure used in braket function
high pressure used in braket function

51

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

double dWi[21] ;

protected:
public:
Detail(void) ;
~Detail() ;

// default constructor
// 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

52

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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

#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 ;
// function table() populates tables of static constants

53

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

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 ;
}
else

54

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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()
paramdl() ;
chardl(ptAGA10) ;

55

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
//
//
dP
dT

repeat the process using flowing conditions


begin by loading P & T from data structure
AGA 8 uses MPa internally; converted from Pa here
= ptAGA10->dPf * 1.0e-6 ;
= ptAGA10->dTf ;

// check whether to calculate temperature dependent parms


if ((fabs(ptAGA10->dTf - dOldTf) > T_CHG_TOL)||(ptAGA10->bForceUpdate))
{
// if temperature has changed, we must follow through
temp() ;
// force ForceUpdate flag to true

56

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 ;
}

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()

/**************************************************************************
*
Function
:
Detail::table()

57

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
//
//
//
//
//
//
//
//
//

Tables 4 and 6 are filled only during object initialization.


component ID's, mapped to each species supported
1 - methane
8 - hydrogen
2 - nitrogen
9 - carbon monoxide
3 - carbon dioxide
10 - oxygen
4 - ethane
11 - i-butane
5 - propane
12 - n-butane
6 - water
13 - i-pentane
7 - hydrogen sulfide
14 - n-pentane

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 ;
adAn[13] = 0.157672400 ;
adAn[14] = -0.436386400 ;
adAn[15] = -0.044081590 ;
adAn[16] = -0.003433888 ;
adAn[17] = 0.032059050 ;
adAn[18] = 0.024873550 ;

58

by
15
16
17
18
19
20
21

AGA Report#8
- n-hexane
- n-heptane
- n-octane
- n-nonane
- n-decane
- helium
- argon

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

*
Arguments
:
void
*
Returns
:
void
*
Purpose
:
builds tables of constants
*
Revisions
:
**************************************************************************/

=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

0.073322790
-0.001600573
0.642470600
-0.416260100
-0.066899570
0.279179500
-0.696605100
-0.002860589
-0.008098836
3.150547000
0.007224479
-0.705752900
0.534979200
-0.079314910
-1.418465000
-5.99905E-17
0.105840200
0.034317290
-0.007022847
0.024955870
0.042968180
0.746545300
-0.291961300
7.294616000
-9.936757000
-0.005399808
-0.243256700
0.049870160
0.003733797
1.874951000
0.002168144
-0.658716400
0.000205518
0.009776195
-0.020487080
0.015573220
0.006862415
-0.001226752
0.002850908

;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;

// 58 constants from table 4 - column Un

59

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

adAn[19]
adAn[20]
adAn[21]
adAn[22]
adAn[23]
adAn[24]
adAn[25]
adAn[26]
adAn[27]
adAn[28]
adAn[29]
adAn[30]
adAn[31]
adAn[32]
adAn[33]
adAn[34]
adAn[35]
adAn[36]
adAn[37]
adAn[38]
adAn[39]
adAn[40]
adAn[41]
adAn[42]
adAn[43]
adAn[44]
adAn[45]
adAn[46]
adAn[47]
adAn[48]
adAn[49]
adAn[50]
adAn[51]
adAn[52]
adAn[53]
adAn[54]
adAn[55]
adAn[56]
adAn[57]

=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

0.0 ;
0.5 ;
1.0 ;
3.5 ;
-0.5 ;
4.5 ;
0.5 ;
7.5 ;
9.5 ;
6.0 ;
12.0;
12.5;
-6.0;
2.0 ;
3.0 ;
2.0 ;
2.0 ;
11.0;
-0.5 ;
0.5 ;
0.0 ;
4.0 ;
6.0 ;
21.0;
23.0;
22.0;
-1.0 ;
-0.5 ;
7.0 ;
-1.0 ;
6.0 ;
4.0 ;
1.0 ;
9.0 ;
-13.0;
21.0;
8.0 ;
-0.5 ;
0.0 ;
2.0 ;
7.0 ;

60

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

adUn[0]
adUn[1]
adUn[2]
adUn[3]
adUn[4]
adUn[5]
adUn[6]
adUn[7]
adUn[8]
adUn[9]
adUn[10]
adUn[11]
adUn[12]
adUn[13]
adUn[14]
adUn[15]
adUn[16]
adUn[17]
adUn[18]
adUn[19]
adUn[20]
adUn[21]
adUn[22]
adUn[23]
adUn[24]
adUn[25]
adUn[26]
adUn[27]
adUn[28]
adUn[29]
adUn[30]
adUn[31]
adUn[32]
adUn[33]
adUn[34]
adUn[35]
adUn[36]
adUn[37]
adUn[38]
adUn[39]
adUn[40]

= 9.0 ;
= 22.0;
= 23.0;
= 1.0 ;
= 9.0 ;
= 3.0 ;
= 8.0 ;
= 23.0;
= 1.5 ;
= 5.0 ;
= -0.5 ;
= 4.0 ;
= 7.0 ;
= 3.0 ;
= 0.0 ;
= 1.0 ;
= 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 ;
}
}
// 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 ;

61

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

adUn[41]
adUn[42]
adUn[43]
adUn[44]
adUn[45]
adUn[46]
adUn[47]
adUn[48]
adUn[49]
adUn[50]
adUn[51]
adUn[52]
adUn[53]
adUn[54]
adUn[55]
adUn[56]
adUn[57]

62

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;
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 ;

63

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;
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 ;

64

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;
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 ;

1.957310
0.982746
0.370296
1.673090

;
;
;
;

/**************************************************************************
*
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} ;
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,

65

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

adTable6Gij[0][7] =
adTable6Gij[1][2] =
adTable6Gij[2][3] =
adTable6Gij[2][5] =
// Detail::table()

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 ;
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++)

66

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

0.6738577, 0.6798307, 0.7175118, 0.7525189,


0.7849550, 0.8152731, 0.8437826, 0.3589888,
0.4216551} ;

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()

/**************************************************************************
*
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 ;

67

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 ;
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

68

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

double e7p5,e9p5,e12p0,e12p5 ;
double e11p0, s3 ;

i < iNCC ; i++)


=
=
=
=
=

k2p5
u2p5
dW
q1p0
dF

+
+
+
+
+

dXi[i]
dXi[i]
dXi[i]
dXi[i]
dXi[i]

*
*
*
*
*

dKi[i]
dEi[i]
dGi[i]
dQi[i]
dXi[i]

* dKi[i] * sqrt(dKi[i]) ;
* dEi[i] * sqrt(dEi[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) ;
// 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 ;

69

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

for (i=0 ;
{
k2p5
u2p5
dW
q1p0
dF

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 ;
}

;
;
;
;

// 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

70

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

s3 = Xij * pow((pow(dKi[i], 3.0) * pow(dKi[j],3)), 0.5) ;

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 ;
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
Bx[0] = adBcoef[0]
Bx[1] = adBcoef[1]
Bx[2] = adBcoef[2]
Bx[3] = adBcoef[3]
Bx[4] = adBcoef[4]
Bx[5] = adBcoef[5]
Bx[6] = adBcoef[6]
Bx[7] = adBcoef[7]
Bx[8] = adBcoef[8]
Bx[9] = adBcoef[9]

B
;
/
/
/
*
/
/
/
/
/

t0p5
dT ;
t3p5
t0p5
t4p5
t0p5
t7p5
t9p5
t6p0

;
;
;
;
;
;
;
;

71

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

*
Revisions
:
**************************************************************************/

=
=
=
=
=
=
=
=

adBcoef[10]
adBcoef[11]
adBcoef[12]
adBcoef[13]
adBcoef[14]
adBcoef[15]
adBcoef[16]
adBcoef[17]

/
/
*
/
/
/
/
/

t12p0 ;
t12p5 ;
t6p0 ;
t2p0 ;
t3p0 ;
t2p0 ;
t2p0 ;
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] ;
}
//
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

72

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

Bx[10]
Bx[11]
Bx[12]
Bx[13]
Bx[14]
Bx[15]
Bx[16]
Bx[17]

// Detail::bvir()

73

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
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 ;
}

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 ;

74

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Detail::temp()
*
Arguments
:
void
*
Returns
:
void
*
Purpose
:
computes temperature-dependent quantities
*
Revisions
:
**************************************************************************/

=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

adAn[12]
adAn[13]
adAn[14]
adAn[15]
adAn[16]
adAn[17]
adAn[18]
adAn[19]
adAn[20]
adAn[21]
adAn[22]
adAn[23]
adAn[24]
adAn[25]
adAn[26]
adAn[27]
adAn[28]
adAn[29]
adAn[30]
adAn[31]
adAn[32]
adAn[33]
adAn[34]
adAn[35]
adAn[36]
adAn[37]
adAn[38]
adAn[39]
adAn[40]
adAn[41]
adAn[42]
adAn[43]
adAn[44]
adAn[45]
adAn[46]
adAn[47]
adAn[48]
adAn[49]
adAn[50]
adAn[51]
adAn[52]

*
/
/
*
/
/
*
/
;
/
/
/
*
*
*
*
*
*
/
*
*
*
*
/
*
*
;
/
/
*
/
/
/
/
*
/
*
/
*
*
/

dF * tr6p0 ;
tr2p0 ;
tr3p0 ;
dQp2 / tr2p0 ;
tr2p0 ;
tr11p0 ;
tr0p5 ;
tr0p5 ;
tr4p0 ;
tr6p0 ;
tr21p0 ;
dW / tr23p0 ;
dQp2 / tr22p0 ;
dF * tr ;
dQp2 * tr0p5 ;
dW / tr7p0 ;
dF * tr ;
tr6p0 ;
dW / tr4p0 ;
dW / tr ;
dW / tr9p0 ;
dF * tr13p0 ;
tr21p0 ;
dQp2 / tr8p0 ;
tr0p5 ;
tr2p0 ;
tr7p0 ;
dQp2 / tr9p0 ;
tr22p0 ;
tr23p0 ;
tr ;
tr9p0 ;
dQp2 / tr3p0 ;
tr8p0 ;
dQp2 / tr23p0 ;
tr1p5 ;
dW / tr5p0 ;
dQp2 * tr0p5 ;
tr4p0 ;

75

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

adFn[12]
adFn[13]
adFn[14]
adFn[15]
adFn[16]
adFn[17]
adFn[18]
adFn[19]
adFn[20]
adFn[21]
adFn[22]
adFn[23]
adFn[24]
adFn[25]
adFn[26]
adFn[27]
adFn[28]
adFn[29]
adFn[30]
adFn[31]
adFn[32]
adFn[33]
adFn[34]
adFn[35]
adFn[36]
adFn[37]
adFn[38]
adFn[39]
adFn[40]
adFn[41]
adFn[42]
adFn[43]
adFn[44]
adFn[45]
adFn[46]
adFn[47]
adFn[48]
adFn[49]
adFn[50]
adFn[51]
adFn[52]

*
/
*
/
*

dW / tr7p0 ;
tr3p0 ;
dW ;
tr ;
dQp2 ;

/**************************************************************************
*
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) ;
// check value of "lStatus" returned from subroutine braket
if (ptAGA10->lStatus == MAX_NUM_OF_ITERATIONS_EXCEEDED ||
ptAGA10->lStatus == NEGATIVE_DENSITY_DERIVATIVE)

76

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

adFn[53] = adAn[53]
adFn[54] = adAn[54]
adFn[55] = adAn[55]
adFn[56] = adAn[56]
adFn[57] = adAn[57]
// Detail::temp()

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 ;
//
//
x3
y3

solution is bracketed between x1 and x2


a third point x3 is introduced for quadratic interpolation
= x1 ;
= 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 ;
x3 = x1 ;
y1 = y2 ;
y2 = y3 ;
y3 = y1 ;

77

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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
{
// use inverse linear interpolation
xnumer = (x2-x1)*y2 ;
xdenom = y1-y2 ;
}

78

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// check for convergence


if ((fabs(y2) < epsp * dP) && (fabs(delx) < epsr * fabs(x2)))
{
dRho = x2 + delx ;
return ;
}
//
//
//
if
{

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
(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) ;
if (boundn > 0.0)
{
// procedure stepping out of bounds, use bisection
delx = delbis ;
delprv = delbis ;
}

79

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 ;
}

relable variables for next iteration


x1new = x2old, y1new=y2old
= x2 ;
= 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()

80

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
//
x1
y1

// 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++)
{
if (rho2 > rhomax && ptAGA10->lStatus != MAX_DENSITY_IN_BRAKET_EXCEEDED)

81

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Detail::braket()
*
Arguments
:
AGA10STRUCT *
*
Returns
:
void
*
Purpose
:
brackets density solution
*
Revisions
:
**************************************************************************/

// 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;
return;
}

82

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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()

83

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

}
// maximum number of iterations exceeded if we fall through the bottom
ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED ;
dRho = rho2 ;
return ;

double Detail::zdetail(double d)
{
// variables local to function
double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ;
//
D1
D2
D3
D4
D5
D6
D7
D8
D9

powers
= dKp3
= D1 *
= D2 *
= D3 *
= D4 *
= D5 *
= D6 *
= D7 *
= D8 *

exp1
exp2
exp3
exp4

=
=
=
=

of reduced density
* d ;
D1 ;
D1 ;
D1 ;
D1 ;
D1 ;
D1 ;
D1 ;
D1 ;

exp(-D1)
exp(-D2)
exp(-D3)
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
+ (adFn[30] + adFn[31]) * D3 * (3.0 - 2.0 * D2) * exp2

84

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Detail::zdetail()
*
Arguments
:
double
*
Returns
:
void
*
Purpose
:
calculates compressibility
*
Revisions
:
**************************************************************************/

(adFn[32]
(adFn[34]
(adFn[37]
(adFn[39]
(adFn[42]
adFn[44]
(adFn[45]
(adFn[47]
adFn[49]
adFn[50]
adFn[51]
adFn[52]
adFn[53]
(adFn[54]
(adFn[56]

+
+
+
+
+
*
+
+
*
*
*
*
*
+
+

adFn[33]) * D3 * (3.0 - 3.0 * D3) * exp3


adFn[35] + adFn[36]) * D3 * (3.0 - 4.0 * D4) * exp4
adFn[38]) * D4 * 4.0
adFn[40] + adFn[41]) * D4 * (4.0 - 2.0 * D2) * exp2
adFn[43]) * D4 * (4.0 - 4.0 * D4) * exp4
D5 * 5.0
adFn[46]) * D5 * (5.0 - 2.0 * D2) * exp2
adFn[48]) * D5 * (5.0 - 4.0 * D4) * exp4
D6 * 6.0
D6 * (6.0 - 2.0 * D2) * exp2
D7 * 7.0
D7 * (7.0 - 2.0 * D2) * exp2
D8 * (8.0 - D1) * exp1
adFn[55]) * D8 * (8.0 - 2.0 * D2) * exp2
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 ;
//
D1
D2
D3
D4

set up
= dKp3
= D1 *
= D2 *
= D3 *

powers of reduced density


* d ;
D1 ;
D1 ;
D1 ;

85

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

=
=
=
=
=

exp1
exp2
exp3
exp4

D4
D5
D6
D7
D8
=
=
=
=

*
*
*
*
*

D1
D1
D1
D1
D1

;
;
;
;
;

exp(-D1)
exp(-D2)
exp(-D3)
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 =
ddZdT
ddZdT
ddZdT

(1.0 - 2.0 * D2) * exp2 ;


+= (fx[13] - (fx[13] * tmp)) ;
+= fx[14] - (fx[14] * tmp) ;
+= fx[15] - (fx[15] * tmp) ;

tmp = (1.0 - 4.0 * D4) * exp4 ;


ddZdT += fx[16] - (fx[16] * tmp) ;
ddZdT += fx[17] - (fx[17] * tmp) ;
ddZdT = ddZdT - (fx[18] + fx[19]) * D1 * 2.0
- (fx[21] + fx[22]) * D1 * (2.0 - 2.0 * D2) * exp2

86

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

D5
D6
D7
D8
D9

(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()

87

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;
}

88

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Detail::d2ZdT2()
*
Arguments
:
double
*
Returns
:
double
*
Purpose
:
calculates the second partial derivative of Z wrt T
*
Revisions
:
**************************************************************************/

// 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
dd2ZdT2 +=
dd2ZdT2 +=
dd2ZdT2 +=

- 2.0 *
-fx[13]
-fx[14]
-fx[15]

D2) * exp2 ;
+ (fx[13] * tmp) ;
+ (fx[14] * tmp) ;
+ (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 ;

return dd2ZdT2 ;

89

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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) ;
// create terms uC*T^-(un+1) from coefficients we've already computed (An[n])
for (i=12; i < 58; i++)
{

90

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;
// n = 21..23
temp1 = -4.0 * D3 * exp2 ;
temp2 = (2.0 - 2.0 * D2) * 2.0 * D1 * exp2 ;

91

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

temp3 ;
;
;
;

// 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 ;
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 ;

92

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

temp3 = -temp2 * D2;


temp = temp1 + temp2 +
ddZdD += fx[20] * temp
ddZdD += fx[21] * temp
ddZdD += fx[22] * 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
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

93

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 = 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 ;
// 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 ;

94

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;

95

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

return ddZdD ;
// Detail::dZdD()
}

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()

96

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Detail::relativedensity()
*
Arguments
:
AGA10STRUCT *
*
Returns
:
void
*
Purpose
:
calculates relative density via methods listed in AGA 8
*
Revisions
:
**************************************************************************/

#ifndef _THERM_H
#define _THERM_H
#include "aga10.h"
#include "detail.h"
class Therm
{
private:
// member data
double dT ;
double dP ;
double dD ;
double dRho ;
double dPdD ;
double dPdT ;
double dSi ;
double dTold ;
double dMrxold ;

// current temperature, in Kelvins


// current pressure, in Pascals
// molar density, in moles/dm3
// mass density, in kg/m3
// partial deriv of P wrt D
// partial deriv of P wrt T
// ideal gas specific entropy, kJ/kg.K
// temperature previously used
// mixture molar mass previously used

// private methods
double CpiMolar(AGA10STRUCT *) ;
protected:
public:
Therm(void) ;
~Therm() ;

// default constructor
// default destructor

void Run(AGA10STRUCT *, Detail *) ;

// runs an object based on this class

97

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

//

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 ;

98

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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
} ;

{{-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,
1.8198},
{ 0.0,
4.9680,
0.0,
100.0,
0.0,
100.0,
0.0,
100.0,
0.0,
100.0,
8.6776}};

// 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:
const double CalTH = 4.1840 ;
#endif

99

1 cal(IT) = 4.1840 J

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//equation constants for ideal gas heat capacity, enthalpy and entropy
const double ThermConstants[NUMBEROFCOMPONENTS[11] =

#include
#include
#include
#include

"aga10.h"
"detail.h"
"therm.h"
<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()

100

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

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()

101

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Therm::~Therm()
*
Arguments
:
*
Returns
:
default destructor
*
Purpose
:
void
*
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 ;
return ;

102

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Therm::Run()
*
Arguments
:
AGA10STRUCT *, Detail *
*
Returns
:
void
*
Purpose
:
overall execution control; top level math for SOS and k
*
Revisions
:
**************************************************************************/

//

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 ;
//
DT
FT
HT

calculate species intermediate


= ThermConstants[i][coefD] / T
= ThermConstants[i][coefF] / T
= ThermConstants[i][coefH] / T

terms
;
;
;

103

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
Dx
Fx
Hx
Jx

use intermediate terms to avoid redundant calcs


= DT/sinh(DT) ;
= FT/cosh(FT) ;
= HT/sinh(HT) ;
= JT/cosh(JT) ;

Cpx
Cpx
Cpx
Cpx
Cpx

+=
+=
+=
+=
+=

ThermConstants[i][coefB]
ThermConstants[i][coefC]
ThermConstants[i][coefE]
ThermConstants[i][coefG]
ThermConstants[i][coefI]

;
*
*
*
*

Dx
Fx
Hx
Jx

*
*
*
*

Dx
Fx
Hx
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()

104

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

JT = ThermConstants[i][coefJ] / T ;

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 ;
//
DT
FT
HT
JT

calculate species intermediate


= ThermConstants[i][coefD] / T
= ThermConstants[i][coefF] / T
= ThermConstants[i][coefH] / T
= ThermConstants[i][coefJ] / T

terms
;
;
;
;

cothDT = coth(DT) ;
tanhFT = tanh(FT) ;
cothHT = coth(HT) ;
tanhJT = tanh(JT) ;
Hx += ThermConstants[i][coefA] ;

105

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
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
:
**************************************************************************/

+=
+=
-=
+=
-=

ThermConstants[i][coefB]
ThermConstants[i][coefC]
ThermConstants[i][coefE]
ThermConstants[i][coefG]
ThermConstants[i][coefI]

*
*
*
*
*

T ;
ThermConstants[i][coefD]
ThermConstants[i][coefF]
ThermConstants[i][coefH]
ThermConstants[i][coefJ]

// 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()

106

*
*
*
*

cothDT;
tanhFT;
cothHT;
tanhJT;

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

Hx
Hx
Hx
Hx
Hx

double Therm::So(AGA10STRUCT *ptAGA10)


{
double S = 0.0 ;
double Smixing = 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 ;
//
DT
FT
HT
JT

calculate species intermediate


= ThermConstants[i][coefD] / T
= ThermConstants[i][coefF] / T
= ThermConstants[i][coefH] / T
= ThermConstants[i][coefJ] / T

terms
;
;
;
;

cothDT = coth(DT) ;
tanhFT = tanh(FT) ;

107

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
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.
*
The entropy of mixing is also calculated in this function.
*
Revisions
:
**************************************************************************/

sinhDT
coshFT
sinhHT
coshJT
Sx
Sx
Sx
Sx
Sx
Sx

+=
+=
+=
-=
+=
-=

=
=
=
=

sinh(DT)
cosh(FT)
sinh(HT)
cosh(JT)

;
;
;
;

ThermConstants[i][coefK]
ThermConstants[i][coefB]
ThermConstants[i][coefC]
ThermConstants[i][coefE]
ThermConstants[i][coefG]
ThermConstants[i][coefI]

;
*
*
*
*
*

log(T) ;
(DT * cothDT
(FT * tanhFT
(HT * cothHT
(JT * tanhJT

log(sinhDT))
log(coshFT))
log(sinhHT))
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 ;
// calculate entropy of mixing
for (i= 0; i< NUMBEROFCOMPONENTS; i++)
{
if (ptAGA10->adMixture[i]) Smixing += ptAGA10->adMixture[i] * log(ptAGA10->adMixture[i]) ;
}
Smixing *= -RGAS ;
// add the entropy of mixing
S += Smixing ;
// convert from kJ/kg mol-K to kJ/kg-K
S /= ptAGA10->dMrx ;

// return in J/kg-K
return S * 1.e3;
//
Therm::So()

108

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

cothHT = coth(HT) ;
tanhJT = tanh(JT) ;

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

109

void Therm::CprCvrHS(AGA10STRUCT *ptAGA10, Detail *ptD)


{
double Cvinc, Cvr, Cpr ;
double Hinc ;
double Sinc ;
double Cp, Si ;
double a, b, x ;
int i ;
// initialize integrals to zero
Cvinc = 0.0 ;
Hinc = 0.0 ;
Sinc = 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++)
{
// set calculation point at + abscissa
x = ptAGA10->dDf * (1.0 + GK_root[i]) / 2.0 ;
// get Z at D
ptD->zdetail(x) ;

110

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Therm::CprCvrHS()
*
Arguments
:
AGA10STRUCT *, Detail *
*
Returns
:
void
*
Purpose
:
reasonably efficient group calculation of Cp, Cv, H and S
*
Revisions
:
**************************************************************************/

// gather contributions
Hinc += GK_weight[i] *
Cvinc += GK_weight[i] *
Sinc += GK_weight[i] *

at + abscissa; applying weighting factor


ptD->ddZdT / x ;
(2.0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x ;
(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
Hinc += GK_weight[i] *
Cvinc += GK_weight[i] *
Sinc += GK_weight[i] *

at - abscissa; applying weighting factor


ptD->ddZdT / x ;
(2.0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x ;
(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
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

111

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

ptD->dZdT(x) ;
ptD->d2ZdT2(x) ;

// change from molar to mass basis


Cpr /= ptAGA10->dMrx ;
Cvr /= ptAGA10->dMrx ;
// write to the data stucture
ptAGA10->dCv = Cvr * 1000.0 ;
ptAGA10->dCp = Cpr * 1000.0 ;

// convert from joules/kgK to kilojoules/kgK

// 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 specific entropy
ptAGA10->dS = Si 1000.0 * RGAS * (log(ptAGA10->dPf/101325.0) - log(ptAGA10->dZf) +
Sinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ;
}

return ;
//
Therm::CprCvrHS()

112

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

Cpr = Cvr + RGAS * ((a * a)/b) ;

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 ;
tmax = t1 * 1.5 ;

113

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
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
:
**************************************************************************/

tmin = t1 * 0.67 ;
// use arbitrary, generic limits
t1 =
px =
pmax
pmin
tmax
tmin

273.15 ;
1013250.0 ;
= P_MAX ;
= 10000.0 ;
= T_MAX ;
= T_MIN ;

// 10 atmospheres
// 10 kPa

// 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
delta2 = fabs(s1 - s2) / s0 ;
// close enough?

114

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

}
else
{

}
//
if
//
p1
s1

(delta2 < tolerance) break ;


revise our estimate to p2
= p2 ;
= (p1 * s2 - p2 * s1) / (s2 - s1) ;
check for negative pressure and clamp to pmin for safety
(p2 <= pmin)
p2 = pmin ;
check if we've created an unrealistic pressure
(p2 >= pmax ) p2 = pmax ;
swap values
= p0 ;
= 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 ;
ptAGA10->dTf = t2 ;
ptD->Run(ptAGA10) ;
h2 = this->H(ptAGA10, ptD) - h0 ;

115

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

if
//
p0
p2
//
if
{

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) ;
ptD->d2ZdT2(x) ;
Hinc += GK_weight[i] * ptD->ddZdT / x ;
if (i == 10) break;

116

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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()

117

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

x = ptAGA10->dDf * (1.0 - GK_root[i]) / 2.0 ;


ptD->zdetail(x) ;
ptD->dZdT(x) ;
ptD->d2ZdT2(x) ;

double Therm::S(AGA10STRUCT *ptAGA10, Detail *ptD)


{
double Sinc ;
double x ;
int i ;
// initialize integral
Sinc = 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 ;

// reset Z and partial deivatives dZdT and d2ZdT2


ptD->zdetail(ptAGA10->dDf) ;
ptD->dZdT(ptAGA10->dDf) ;
ptD->d2ZdT2(ptAGA10->dDf) ;

118

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
Function
:
Therm::S()
*
Arguments
:
AGA10STRUCT *, Detail *
*
Returns
:
double
*
Purpose
:
real gas specific entropy
*
Revisions
:
**************************************************************************/

// calculate specific entropy


ptAGA10->dS = dSi - 1000.0 * RGAS * (log(ptAGA10->dPf/101325.0) - log(ptAGA10->dZf)
+ Sinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ;
}

return(ptAGA10->dS) ;
//
Therm::S()

119

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 ;
}

#include <windows.h>
/* win32 DLL startup code */
int WINAPI DLLMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved)
{
return TRUE ;
}

120

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
*
* 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
*
**************************************************************************/

File
Description
Version
Author
Revisions
Copyright (c)

:
script1.rc
:
resource script for aga10 dll
:
1.7.2 2002.12.05
:
W.B. Peterson
:
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,2,0
PRODUCTVERSION 1,7,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG

121

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
//
//
//
//
//

#endif

// !_MAC

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

122

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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, 2, 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, 7, 2, 0\0"
VALUE "SpecialBuild", "2002.12.05 Build\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
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

123

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END

The code begins on the following page.

124

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

A2.2 File Group 2 Example Windows Application Code

#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
#define IDC_TB
43

*/

125

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

IDC_PF
IDC_TF
IDC_MRX
IDC_ZB
IDC_ZF
IDC_FPV
IDC_DB
IDC_DF
IDC_RHOB
IDC_RHOF
IDC_RD_IDEAL
IDC_RD_REAL
IDC_HO
IDC_H
IDC_S
IDC_CPI
IDC_CP
IDC_CV
IDC_K
IDC_KAPPA
IDC_SOS
IDC_CSTAR
IDC_PB_U
IDC_TB_U
IDC_PF_U
IDC_TF_U
IDC_SOS_U
IDC_RHOB_U
IDC_RHOF_U
IDC_ENTHALPY_U
IDC_ENTROPY_U
IDC_TOTAL
IDC_CLEAR
IDC_NORMALIZE
KILOPASCAL
MEGAPASCAL
PSI
KELVIN
CELSIUS
RANKINE
FAHRENHEIT

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

126

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define

KGPERCUBICMETRE
LBMPERCUBICFOOT
METREPERSECOND
FOOTPERSECOND
KJPERKG
BTUPERLBM
KJPERKGK
BTUPERLBMF
CM_FILEOPEN
CM_FILESAVE
CM_FILESAVEAS
CM_HELPABOUT
IDR_MENU1
IDC_STATIC

/* buffer sizes */
#define FIELD40
#define FIELD30

85
86
87
88
89
90
91
92
93
94
95
96
97
(-1)
40
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

127

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define

#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 *) ;
void ReadInputs(HWND, AGA10STRUCT *) ;

128

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

/**************************************************************************
*
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) ;
/* start the application's message pump */

129

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

void WriteInputs(HWND, AGA10STRUCT *) ;


void WriteOutputs(HWND, AGA10STRUCT *) ;
void SetDefaults(AGA10STRUCT *) ;

/**************************************************************************
*
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 */
SetDefaults(A10) ;
return FALSE ;

130

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

while (GetMessage (&msg, NULL, 0, 0))


{
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
return msg.wParam ;

/*
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) ;
lstrcpy(szBuffer, "Error. Pf out of range.") ;
SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ;
return FALSE ;
}

131

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;
}

/* 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++)
if (A10->adMixture[i] > 0.0) A10->adMixture[i] /= temp ;
// write the adjusted values to the screen
WriteInputs(hwnd, A10) ;
return FALSE ;

132

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 ;
}

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) ;
return FALSE ;
case CM_FILESAVE :
// standard Windows file operations
GetFileTitle (szFileName, szTitleName, sizeof (szTitleName)) ;
if (szFileName[0])

133

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

case IDCANCEL :
/* start tear-down process
*/
SendMessage(hwnd, WM_CLOSE, 0,0L) ;
return FALSE ;

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,
"AGA10win.exe and AGA10.dll (c) American Gas Association, 2002",
szAppName, MB_OK | MB_ICONINFORMATION) ;
return FALSE ;
}
return FALSE ;
case WM_CLOSE :

134

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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) ;

135

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/* un-initialize the calculation library */


AGA10_UnInit() ;

#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 ;
ofn.nMaxFileTitle
= _MAX_FNAME + _MAX_EXT

136

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

=
=
=
=
=
=
=
=
=

NULL
NULL
0 ;
0 ;
0 ;
szExt
0L ;
NULL
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
:
**************************************************************************/
BOOL FileSaveDlg (HWND hWnd, PSTR pstrFileName, PSTR pstrTitleName)

137

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

ofn.lpstrInitialDir
ofn.lpstrTitle
ofn.Flags
ofn.nFileOffset
ofn.nFileExtension
ofn.lpstrDefExt
ofn.lCustData
ofn.lpfnHook
ofn.lpTemplateName

ofn.hwndOwner
ofn.lpstrFile
ofn.lpstrFileTitle
ofn.Flags

=
=
=
=

hWnd ;
pstrFileName ;
pstrTitleName ;
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
fclose (file) ;
return false ;
}

138

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/**************************************************************************
*
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 ;
}

139

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

#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)
{
HWND hListBox;

140

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/*************************************************************************
* 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
**************************************************************************/

/*
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 ;
case FAHRENHEIT :

141

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

int i ;
double Pbx, Tbx, Pfx, Tfx ;

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,
SetDlgItemText
// Tb
_gcvt (Tbx, 9,
SetDlgItemText
// Pf
_gcvt (Pfx, 9,
SetDlgItemText
// Tf
_gcvt (Tfx, 9,

szBuffer);
(hDlg, IDC_PB, szBuffer) ;
szBuffer);
(hDlg, IDC_TB, szBuffer) ;
szBuffer);
(hDlg, IDC_PF, szBuffer) ;
szBuffer);

142

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

Tbx = (A10->dTb * 1.8) - 459.67 ;


break ;

143

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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);
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);

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) ;
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) ;

144

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

SetDlgItemText (hDlg, IDC_XIHE, szBuffer) ;


_gcvt (A10->adMixture[XiAr] * 100.0, 9, szBuffer);
SetDlgItemText (hDlg, IDC_XIAR, 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 :
Rhofx = (A10->dRhof / 0.45359237) * pow(0.3048, 3.0)

/*
calculate SOS in specified unit of measure
switch (lSOS_unit)
{

145

*/

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ;

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) ;
_gcvt (SOSx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_SOS, szBuffer) ;
_gcvt (A10->dZb, 9, szBuffer);
SetDlgItemText (hDlg, IDC_ZB, szBuffer) ;
_gcvt (A10->dZf, 9, szBuffer);

146

*/

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

case METREPERSECOND :
SOSx = A10->dSOS ;
break ;

_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);
SetDlgItemText (hDlg, IDC_HO, szBuffer) ;
_gcvt (Enthalpyx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_H, szBuffer) ;
_gcvt (Entropyx, 9, szBuffer);
SetDlgItemText (hDlg, IDC_S, szBuffer) ;

147

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

SetDlgItemText (hDlg, IDC_ZF, 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
:
**************************************************************************/
void ReadInputs(HWND hDlg, AGA10STRUCT *A10)
{
HWND hListBox;
int iSelection;
int i ;
char * stopstr;
//Pb

148

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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) ;
}

//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 ;
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) ;

149

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;
}

= CELSIUS ;
= strtod(szBuffer, &stopstr) + 273.15;
= FAHRENHEIT ;
= (strtod(szBuffer, &stopstr) + 459.67) / 1.8 ;
= KELVIN ;
= strtod(szBuffer, &stopstr) ;
= RANKINE ;
= 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 ;
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;

150

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

switch (iSelection)
{
case 0 :
lTb_unit
A10->dTb
break ;
case 1 :
lTb_unit
A10->dTb
break ;
case 2 :
lTb_unit
A10->dTb
break ;
case 3 :
lTb_unit
A10->dTb
}

//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) ;
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) ;

151

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

// 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 ;
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) ;

152

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

switch (iSelection)
{
case 0 :
lEntropy_unit = KJPERKGK ;
break ;
case 1 :
lEntropy_unit = BTUPERLBMF ;
}

// 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
:
**************************************************************************/
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()

153

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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 ;

void TemperatureDlgHelp(HWND hListBox)


{
LoadString(hInst, CELSIUS, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR)
LoadString(hInst, FAHRENHEIT, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR)
LoadString(hInst, KELVIN, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 2, (LONG)(LPSTR)
LoadString(hInst, RANKINE, szBuffer, FIELD40) ;
SendMessage(hListBox, CB_INSERTSTRING, 3, (LONG)(LPSTR)
}

szBuffer) ;
szBuffer) ;
szBuffer) ;
szBuffer) ;

/**************************************************************************
*
Function
:
DensityDlgHelp()
*
Arguments
:
HWND
*
Returns
:
void
*
Purpose
:
Helper function for loading strings into density
*
drop-list controls
*
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

154

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

*
Arguments
:
HWND
*
Returns
:
void
*
Purpose
:
Helper function for loading strings into temperature
*
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)
{
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
:
**************************************************************************/

155

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

*
Returns
:
void
*
Purpose
:
Helper function for loading strings into SOS
*
drop-list controls
*
Revisions
:
**************************************************************************/

/**************************************************************************
*
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 */
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;

156

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

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) ;
}

/* 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 ;

157

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

A10->adMixture[XiNC9] = 0.0;
A10->adMixture[XiNC10] = 0.0;
A10->adMixture[XiHe] = 0.0;
A10->adMixture[XiAr] = 0.0;

File
Description
Version
Author
Revisions
Copyright (c)

:
resource.h
:
header file used for Windows resource file
:
1.7
2002.11.17
:
W.B. Peterson
:
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
#define _APS_NEXT_RESOURCE_VALUE
#define _APS_NEXT_COMMAND_VALUE
#define _APS_NEXT_CONTROL_VALUE
#define _APS_NEXT_SYMED_VALUE
#endif
#endif

1
105
40003
1018
101

158

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
//
//
//
//
//

File
Description
Version
Author
Revisions
Copyright (c)

:
aga10win.rc
:
resource script for aga10wins interface
:
1.7
2002.11.17
:
W.B. Peterson
:
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.
AGA10WIN
ICON
DISCARDABLE
"aga10win.ico"

159

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

//
//
//
//
//
//

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
EDITTEXT
IDC_TB,34,215,60,14,ES_AUTOHSCROLL
COMBOBOX
IDC_TB_U,98,216,60,44,CBS_DROPDOWNLIST | CBS_SORT |

160

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

EDITTEXT
COMBOBOX
DEFPUSHBUTTON
PUSHBUTTON
PUSHBUTTON
GROUPBOX
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
GROUPBOX
LTEXT
LTEXT
LTEXT
LTEXT

WS_VSCROLL | WS_TABSTOP
IDC_PF,191,196,60,14,ES_AUTOHSCROLL
IDC_PF_U,254,196,60,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
IDC_TF,191,215,60,14,ES_AUTOHSCROLL
IDC_TF_U,255,215,60,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
"Calculate",IDOK,137,282,50,20
"Initialize",IDRETRY,61,282,50,20
"Quit",IDCANCEL,213,282,50,20,WS_GROUP
"Composition (Mole Percent)",IDC_STATIC,5,3,322,175
"Helium",IDC_STATIC,21,18,28,8,NOT WS_GROUP
"Hydrogen",IDC_STATIC,21,36,32,8,NOT WS_GROUP
"Nitrogen",IDC_STATIC,21,55,28,8,NOT WS_GROUP
"CO2",IDC_STATIC,22,71,15,8,NOT WS_GROUP
"H2S",IDC_STATIC,22,89,15,8,NOT WS_GROUP
"Methane",IDC_STATIC,22,108,29,8,NOT WS_GROUP
"Ethane",IDC_STATIC,22,126,24,8,NOT WS_GROUP
"Propane",IDC_STATIC,116,18,28,8,NOT WS_GROUP
"i-Butane",IDC_STATIC,116,37,27,8,NOT WS_GROUP
"n-Butane",IDC_STATIC,116,55,30,8,NOT WS_GROUP
"i-Pentane",IDC_STATIC,116,72,31,8,NOT WS_GROUP
"n-Pentane",IDC_STATIC,115,92,34,8,NOT WS_GROUP
"n-Hexane",IDC_STATIC,115,110,32,8,NOT WS_GROUP
"n-Heptane",IDC_STATIC,115,128,34,8,NOT WS_GROUP
"n-Octane",IDC_STATIC,218,19,30,8,NOT WS_GROUP
"n-Nonane",IDC_STATIC,218,37,32,8,NOT WS_GROUP
"n-Decane",IDC_STATIC,218,55,32,8,NOT WS_GROUP
"Argon",IDC_STATIC,219,73,27,8,NOT WS_GROUP
"Water",IDC_STATIC,219,91,23,8,NOT WS_GROUP
"CO",IDC_STATIC,219,109,11,8,NOT WS_GROUP
"O2",IDC_STATIC,219,128,24,8,NOT WS_GROUP
"TOTAL",IDC_STATIC,218,147,24,8,NOT WS_GROUP
"Static",IDC_TOTAL,259,146,44,12,SS_SUNKEN | NOT
WS_GROUP
"Gas Temperature and Absolute Pressure",IDC_STATIC,6,182,
322,56
"Pb",IDC_STATIC,12,199,10,8
"Tb",IDC_STATIC,11,217,10,8
"Pf",IDC_STATIC,177,199,8,8
"Tf",IDC_STATIC,176,217,8,8

161

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

EDITTEXT
COMBOBOX

LTEXT

"Calculation Results",IDC_STATIC,334,3,234,306
"Speed of Sound",IDC_STATIC,348,24,52,8
"Zf",IDC_STATIC,348,173,8,8
"Zb",IDC_STATIC,348,158,10,8
"Fpv",IDC_STATIC,348,187,13,8
"Cp (real gas)",IDC_STATIC,348,232,40,8
"Cv (real gas)",IDC_STATIC,348,248,40,8
"Cp/Cv",IDC_STATIC,348,264,22,8
"Isentropic Exponent",IDC_STATIC,348,53,67,8
"Mass Density",IDC_STATIC,348,113,43,8
"Molar Density",IDC_STATIC,348,98,44,8
"Specific Enthalpy",IDC_STATIC,348,68,56,8
"Specific Entropy",IDC_STATIC,348,83,52,8
"Enthalpy (ideal gas)",IDC_STATIC,348,280,62,8
"Cp (ideal gas)",IDC_STATIC,348,216,44,8
"Molar Mass",IDC_STATIC,348,201,37,8
"0",IDC_SOS,422,24,50,8,NOT WS_GROUP
"0",IDC_H,422,69,50,8,NOT WS_GROUP
"0",IDC_S,422,83,50,8,NOT WS_GROUP
"0",IDC_DF,422,99,60,8,NOT WS_GROUP
"0",IDC_RHOF,422,113,55,8,NOT WS_GROUP
"0",IDC_ZB,422,157,50,8,NOT WS_GROUP
"0",IDC_ZF,422,171,50,8,NOT WS_GROUP
"0",IDC_FPV,422,186,50,8,NOT WS_GROUP
"0",IDC_MRX,422,201,50,8,NOT WS_GROUP
"0",IDC_CPI,422,216,50,8,NOT WS_GROUP
"0",IDC_HO,422,280,50,8,NOT WS_GROUP
"0",IDC_CP,422,232,50,8,NOT WS_GROUP
"0",IDC_CV,422,248,50,8,NOT WS_GROUP
"0",IDC_K,422,264,50,8,NOT WS_GROUP
"0",IDC_KAPPA,422,53,50,8,NOT WS_GROUP
"moles/dm3",IDC_STATIC,483,98,32,8
"kJ/kg-K",IDC_STATIC,483,216,26,8
"kJ/kg",IDC_STATIC,483,280,20,8
"RD (ideal gas)",IDC_STATIC,348,128,46,8
"RD (real gas)",IDC_STATIC,348,143,42,8
"0",IDC_RD_IDEAL,422,128,50,8,NOT WS_GROUP
"0",IDC_RD_REAL,422,143,50,8,NOT WS_GROUP
"Press Initialize Button to Begin",IDC_LSTATUS,106,259,
107,8
"kJ/kg-K",IDC_STATIC,483,232,26,8

162

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

GROUPBOX
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT
LTEXT

COMBOBOX
COMBOBOX
COMBOBOX

END

GROUPBOX
PUSHBUTTON

"kJ/kg-K",IDC_STATIC,483,248,26,8
"C*",IDC_STATIC,348,39,10,8
"0",IDC_CSTAR,422,39,58,8
IDC_SOS_U,482,21,80,43,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
IDC_RHOF_U,482,111,80,44,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
IDC_ENTHALPY_U,482,66,80,40,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
IDC_ENTROPY_U,482,82,80,37,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
"Current Status",IDC_STATIC,5,247,322,27
"Normalize",IDC_NORMALIZE,118,149,60,20

#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
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END

163

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

LTEXT
LTEXT
LTEXT
COMBOBOX

// 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
FILEFLAGS 0x20L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN

164

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

#endif

#endif

// !_MAC

/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU1 MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Open...",
MENUITEM "&Save...",
MENUITEM "Save &As...",
MENUITEM "E&xit",
END

CM_FILEOPEN
CM_FILESAVE
CM_FILESAVEAS
IDCANCEL

165

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

END

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

CM_HELPABOUT

/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
KILOPASCAL
MEGAPASCAL
END
STRINGTABLE DISCARDABLE
BEGIN
PSI
KELVIN
CELSIUS
RANKINE
FAHRENHEIT
KGPERCUBICMETRE
LBMPERCUBICFOOT
METREPERSECOND
FOOTPERSECOND
KJPERKG
BTUPERLBM
KJPERKGK
BTUPERLBMF
END

"kilopascals"
"megapascals"

"PSI"
"Kelvin"
"Celsius"
"Rankine"
"Fahrenheit"
"kg per cubic metre"
"lbm per cubic foot"
"metres per second"
"feet per second"
"kJ per kg"
"Btu per lbm"
"kJ per kg-K"
"Btu per lbm-F"

#endif
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

#ifndef APSTUDIO_INVOKED

166

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

END

POPUP "&Help"
BEGIN
MENUITEM "&About",
END

/////////////////////////////////////////////////////////////////////////////
#endif
// not APSTUDIO_INVOKED

167

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Associatio

/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

Send to:

Operations and Engineering Section


American Gas Association
400 North Capitol St., N.W., 4th Floor
Washington, DC 20001
U.S.A.
Fax: (202) 824-7082

Name:__________________________________________________________________________
Company:_______________________________________________________________________
Address:________________________________________________________________________
Phone: ___________________ Fax:____________________E-mail________________________
Please Indicate Organization Represented (if any):_____________________________________
1. Section/Paragraph :____________________________________________________________
2. Proposal Recommends: (check one):

new text

revised text

deleted text

3. Proposal (include proposed new or revised wording, or identification of wording to be deleted, use separate
sheet if needed): [Proposed text should be in legislative format; i.e., use underscore to denote wording to be inserted
(inserted wording) and strike-through to denote wording to be deleted (deleted wording).]

4. Statement of Problem and Substantiation for Proposal (use separate sheet if needed): (State the problem that
will be resolved by your recommendation; give the specific reason for your proposal including copies of tests, research
papers, etc.)

5.
This proposal is original material. (Note: Original material is considered to be the submitters own idea based
on or as a result of his/her own experience, thought or research and, to the best of his/her knowledge, is not copied from
another source.)
This proposal is not original material; its source (if known) is as follows: ____________
________________________________________________________________________________
Type or print legibly. If supplementary material (photographs, diagrams, reports, etc.) is included, you may be
required to submit sufficient copies for all members of reviewing committees or task forces.
I hereby grant the American Gas Association the non-exclusive, royalty-free rights, including non-exclusive,
royalty-free rights in copyright, in this proposal and I understand that I acquire no rights in any publication of the
American Gas Association in which this proposal in this or another similar or analogous form is used.
Date: ___________________ Signature (Required) _________________________________
FOR
OFFI
C
EUSE
LY ON
Log
#__
_________
____
_____
Date
ecd
_
____
___
________
R_

Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.
No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC, www.techstreet.com, under license from the American Gas Association (AGA), www.aga.org.

PROPOSAL TO REVISE AGA REPORT NO.10

You might also like