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 Association’s 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 manufacturer’s 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

techstreet. A form has been included at the end of this report for that purpose. especially those supporting ultrasonic meters. The research indicates that the calculation is highly accurate and is consistent with the equation-of-state used in AGA Report No. 4th Floor. Compressibility Factors of Natural Gas and Other Related Hydrocarbon Gases. such as compression. DC 20001. 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. It may become necessary to make revisions to this document in the future. the AGA Transmission Measurement Committee. It also calculates the entropy. Distributed by Thomson Reuters (Scientific) LLC. NW. the value of these methods is apparent for other applications of natural gas thermodynamics. enthalpy and C* coefficient for sonic nozzles. 400 N. transmission or distribution. www. Whenever any revisions are advisable. However. Washington. 8. The original work for AGA Report No. recommendations should be forwarded to the American Gas Association. No further reproduction or networking is permitted. The purpose of this report is to provide the natural gas industry with a method for solving problems involving thermodynamics. the range of application is focused on the single-phase natural gas mixtures common to industry. Caution is advised to users applying this technology to other purposes and other fluids. the Gas European de Researchers Group (GERG). USA. as well as those who intend to apply the principles of thermodynamics to gas production.com. Capitol Street. FOREWORD . under license from the American Gas Association (AGA).aga. members of the American Petroleum Institute (API) and the International Standards Organization (ISO). iv Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 8 was developed under the auspices of the Gas Research Institute’s Basic Fluid Properties Research Program. Industry’s incentive for establishing these methods was spurred by the advent of ultrasonic gas meters. This information is based on research that was developed and managed by the Gas Technology Institute (formerly the Gas Research Institute).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. The audience of the report is gas measurement engineers. www.org. The performance of the methods is intended to meet the needs of the gas industry. As such.

and Dr. James E. Southern Natural Gas Thermo Flow Systems BP Americas WGP – Transco CITGO Solar Turbines. Frank Steve Paul Lars Charles E. ACKNOWLEDGEMENTS . Those who deserve special recognition and appreciation for their help. Eric Lemmon.org..AGA Report No. 10. Consultant. Karl John W. reviewed the final draft or provided comments and should also be acknowledged are: Last Name Baldwin Bowen Bowles. Instromet. Edgar B. under license from the American Gas Association (AGA). King Jimmy Daniel H. Mike William M. who prepared the first draft of this report and wrote the computer program to calculate the speed of sound and other related properties. Dr.aga. AGA is especially thankful for the significant contributions of Warren Peterson. LaNasa. Natural Gas Pipeline. Alex R. This report was originally initiated under the chairmanship of late Ron Rich. Oncor Pipeline Services MichCon Daniel Measurement Nicor McCrometer American Meter Co. Distributed by Thomson Reuters (Scientific) LLC. TransCanada PipeLines. National Institute of Standards and Technology. Speed of Sound in Natural Gas and Other Related Hydrocarbon Gases. Brown Caldwell Ceglia Farestvedt French Gallagher Mercer Moir Naber Overgaard Peters Podgers Poellnitz Poon Raper Rebman Sandlin Schieber.techstreet. Inc. Jr. Dennis James v Organization Unocal. CPL & Associates. Inc. Williams Gas Pipeline-Transco. Inc. He also completed the final version of this report. Jeff Savidge. Henry W. suggestions and guidance in finalizing this report are — Dr. Inc. www. II Stappert Stuart Weatherly Witte First Name Stephen James W. Kenneth Starling. was developed by an AGA Transmission Measurement Committee task group chaired by Jerry Paul Smith (retired). Southwest Research Inst. Daniel Measurement Stuart Consulting El Paso El Paso Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. Dannie Kevin John Chris Robert J. CMS Energy CEESI GE Panametrics FMC Measurement Solutions Gas Technology Institute Savant Measurement Corp. Others who participated during the development of this report. No further reproduction or networking is permitted.com. www. He is respectfully remembered and recognized for his contributions in initiating this document. who could not complete it because of his untimely death. Paul J. Starling Associates.

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 Institute’s (formerly the Gas Research Institute) speed of sound and physical properties basic research program. No further reproduction or networking is permitted.techstreet. Laboratories in both the United States and Europe carried out the research work.com. Distributed by Thomson Reuters (Scientific) LLC. Contributions of all the research organizations and laboratories are acknowledged. .aga. www. www.org.Lori Traweek Sr. under license from the American Gas Association (AGA). 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.

................ 1 1...........1.....................DISCLAIMERS AND COPYRIGHT ..............................................................................................................................................124 vii Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only..........................................3...................... 39 A1...................................1................................................. 12 5....................................... 18 7...........................................................................................................................................5......................... 8....................................................................................org....... Function Crit() .................... 1 1.................................... 8...................................................... COMPUTATION FLOW CHARTS ............. 1 1....... under license from the American Gas Association (AGA)..... Detailed Output — Result #3 ............................................. Types of Conditions..................................... Tabled Results for Compliance Checking and Program Development................... Types of Gases ...................................... 38 A1.............................. www........................................................................................................................2.......... Distributed by Thomson Reuters (Scientific) LLC........................................................................... Overview of Classes and Key Functions .................................................... File Group 1 — Calculation Code ................... Detailed Output — Result #2 .............2.......... TABLE OF CONTENTS .....................................................1............................................40 A2..3 2...1.......... 3................1............1.......................... Therm Class............................................................................................................................ Background..........1.............................. UNCERTAINTY..................................................... File Group 2 — Example Windows Application Code ................................................................................................................................................................... 19 8......................................................................... Equations for Speed of Sound ..........................4................................................................... 6 6 6 7 7 4...........com................. 39 A1.................................................................................................................................................................................... CALCULATIONS ........1................................................ 38 A1...................................................... 4 3..................................2........................................................3...................................................... PRINTOUTS OF COMPUTER CODE........................................................................................ Detail Class...........................techstreet......................................... Detailed Output — Result #1 .....................................5............................................................................. CHARACTERISTICS OF TYPICAL GASES ..................................................................... CRITICAL FLOW FACTOR DETERMINATION....... 1 1..........1.................................aga........... 3.............................. Detailed Output Results for Program Development ......................... Overview of Calculation Method and Sequence .......3..............6......................................................... Function SOS() .......... 38 A1.............. CALCULATION OUTPUT FOR PROGRAM VERIFICATION .................1.................... INTRODUCTION................1.....1...................................... 39 A1..................2......................... File Group 1 — Calculation Library............................ 40 A2............................... Compliance............................. www...........................2.........................................................2................... 1 1..........4................................................................................................................................................................................................................... Symbols ......2............................................ 2 1............................................................................................................. OVERVIEW OF COMPUTER CODE ...................... 21 21 21 22 23 24 APPENDIX — C++ LANGUAGE EXAMPLE IMPLEMENTATION........1....................................................................................................... 3..............iv ACKNOWLEDGMENTS...................................... 8. Scope ............................................... File Group 2 — Example Windows Application................................................... 40 A2......................1........................... v 1... 39 A1............ No further reproduction or networking is permitted................................................................. REFERENCES ........ iii FOREWORD....................................................................................................................... 8................................................ 8..... 38 A1.................................................................................. Field of Application................................................................3.......... 3.......................................1....................4............................................ 13 6.......................... Types of Properties..............

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

Field of Application High-accuracy sound speed information is needed in a variety of gas flow measurement applications. 8 solution methods have been carried forward with little change.com. This document contains excerpts from Report No. C*. heat capacity and critical flow coefficient. are based on the information in appendix E of ASME/ANSI MFC-7M-1987. such as volumetric heating value and relative density. Procedures are included for computation of several related gas properties. Distributed by Thomson Reuters (Scientific) LLC. 8. The equations utilized are consistent with AGA Report No. AGA Transmission Measurement Committee Report No. but intentionally does not reproduce the full report. Computer code development for Report No.4. Types of Properties The methods in this document may be used to compute a number of gas properties including speed of sound.2 and ISO Standard 12213 Part 2. API MPMS Chapter 14. 1 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 10 will be modest and incremental to most existing AGA Report No. Background This is the first AGA document on speed of sound. C*.aga. 8. This report provides the information needed to compute the speed of sound in natural gas and other related hydrocarbon gases. Scope This document contains information for computation of sound speed in natural gas and other related hydrocarbon gases. including heat capacity. www. Introduction . under license from the American Gas Association (AGA). 1. 1. API and GERG. 1.1. www.3. enthalpy. The methods presented in this AGA document utilize high-accuracy calculation procedures and related equations-of-state already implemented by AGA.1. 8. such as ultrasonic meters and critical flow nozzles. For continuity and ease of application. Second Printing (1994). as well as analytical applications such as transducers and densitometers. entropy and the critical flow coefficient. Second Edition.org. 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. entropy.2.techstreet. 1. The methods in this document are extensions to Compressibility Factors for Natural Gas and Other Hydrocarbon Gases. 8 implementations. the original AGA Report No. Similarly. enthalpy. the methods for computing the critical flow coefficient. API and ISO. Procedures for computing other natural gas properties. Users are referred to this source for background and pertinent references. fall outside of the scope of this report and are not included. No further reproduction or networking is permitted.

0 0 to 3. 14.0 Mole Percent Hexanes Plus 0 to 0. Types of Gases This report is intended for natural gases and other related hydrocarbon gases. Distributed by Thomson Reuters (Scientific) LLC.554 to 0. . Table 1: Range of Gas Mixture Characteristics Consistent with this Report 2 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. Thus.0 * Reference Conditions: Relative Density at 60° F. and pure hydrogen sulfide.0 Mole Percent Argon # 0 to 1. heavy hydrocarbons and hydrogen sulfide in natural gases currently is not available for determinations of uncertainties of calculated gas properties.0 0 to 100.com. ** Reference Conditions: Combustion at 60° F.0 0 to 12. The normal range column gives the range of gas characteristics for which the average expected uncertainty corresponds to the uncertainties identified in Figure 1. 14. compressor efficiency and heat exchanger calculations.0 0 to 6.07 to 1.73 psia.0 Mole Percent Total Butanes 0 to 1.org.101325 MPa.0 Mole Percent Hydrogen 0 to 10.0 to 100. which is expected to be higher.2 0 to Dew Point Mole Percent Helium 0 to 0. Quantity Normal Range Expanded Range Relative Density * 0.1 MJ/m 3 0 to 1800 Btu/scf 0 to 66 MJ/m Mole Percent Methane 45.0 Mole Percent Carbon Monoxide 0 to 3.0 Mole Percent Nitrogen 0 to 50.0 Mole Percent Carbon Dioxide 0 to 30.02 0 to 100.101325 MPa. Therefore.0 0 to 100.0 0 to 100. procedures can be developed to support a variety of applications including sonic nozzles. density at 60° F. # The normal range is considered to be zero for these compounds. under license from the American Gas Association (AGA). www.73 psia. 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.0 0 to 100.aga.0 Mole Percent Propane 0 to 4. Table 1 identifies the ranges of gas characteristics for which this report can be used.3 0 to 4. 8.05 0 to Dew Point Mole Percent Hydrogen Sulfide 0 to 0. An accepted database for water. the limits are the water dew point for mole percent water.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. 0.techstreet.0 Mole Percent Water 0 to 0.0 0 to 100. No further reproduction or networking is permitted. In conjunction with the methods in AGA Report No. as a practical matter.5. the hydrocarbon dew point for mole percent heavy hydrocarbons. The expanded range of gas characteristics has an uncertainty. 0.87 0.7 to 45.0 Mole Percent Ethane 0 to 10.73 psia. the only limitation is that the calculation is for the gas phase.0 3 Mole Percent Total Pentanes 0 to 0. 14. *** Reference Conditions: Combustion at 25° C. www. especially outside of region 1 of Figure 1.2 0 to 3.0 Mole Percent Oxygen # 0 to 21.52 Gross Heating Value ** 477 to 1150 Btu/scf Gross Heating Value *** 18. density at 0° C.

°F 250 400 Figure 1: Targeted Uncertainty for Natural Gas Speed of Sound Using the AGA Report No.g.com. 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.-60 -8 62 120 200 20000 140 Region 4 1. MPa Pressure. No further reproduction or networking is permitted.techstreet. Application at extreme conditions should be verified by other means (e. MPa 10000 17 Region 2 1750 0. 10 Method 1.. under license from the American Gas Association (AGA). www.0% 70 0. experimental verification). this is usually not a constraint because operating conditions near the critical point generally are not encountered. °C -130 .aga.5% Pressure.1% 12 Region 1 -200 -80 17 143 Temperature. For pipeline-quality gas.6. Temperature.000 psia). Distributed by Thomson Reuters (Scientific) LLC. 3 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. Use of the calculation method is not recommended within the vicinity of the critical point. www.org. Types of Conditions This report is for the gas phase only. psia Region 3 2500 0.3% Pressure.

com.aga.i   N − 1 i =1  (2. under license from the American Gas Association (AGA). =  W BIAS ∑ diff . Some of the gas mixtures included in the uncertainty analysis are outside of the range of Table 1. 2. listed in Table 2.techstreet. pressure and composition.i 1 2 2 (2.4) where: Wdiff = relative percentage difference between calculated and experimental speed of sound Wdiff.2) diff .1% for other gas mixtures whose characteristics fall within the normal range of Table 1.The uncertainty of calculated speed of sound depends on natural gas temperature. The uncertainty in the speed of sound is also within 0. Statistical analyses of the differences between calculated and experimental values were performed to evaluate the uncertainties in the calculated speed of sound values. No further reproduction or networking is permitted.i N i =1 diff . www. The measurements conducted demonstrate that the uncertainty in the speed of sound is within 0. over the range of 250° K to 350° K (-10° F to 165° F) and pressures up to 17 MPa (2500 psia).1) x100 N 1 N ∑W 1 N ∑ [(W ) ] i =1 (2. The uncertainties of speed of sound methods were evaluated by comparing calculated values to experimentally measured speed of sound from NIST Monograph 178 [7].Dev.1% for Gulf Coast.org.3) 1 2  1 N 2 ( ) − Std . Higher levels of uncertainty are indicated for gases outside of the normal range of Table 1.Dev.i = Wdiff for ith data point Wcalc = calculated speed of sound Wexp = experimental speed of sound AAD = average absolute deviation BIAS = bias Std. Distributed by Thomson Reuters (Scientific) LLC. Calculations were compared with experimental measured values for 17 gravimetrically prepared natural gas mixtures. = standard deviation 4 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 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). Uncertainty . Statistics were calculated using the following equations where N is the number of data points: Wdiff = BIAS = AAD = Wcalc − Wexp Wexp (2. www.

040 -0.133 0.65476 0 0 0 0 0 0 0 0 0.026 12 71 0.96561 0.023 0.94985 0.051 0.026 0.036 0.026 0.00537 Carbon Dioxide 0 0 0 0 0 0 0 0 0 0. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 .90708 0.71373 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.28627 0 0 0 0.00262 0.90016 0.016 0.025 11 80 0.041 0.15008 0.09984 0 0 0 0 0 0 0 0.00943 0.053 0.04886 0.031 17 91 0.00098 0.34524 0. www.024 10 97 0.Methane Nitrogen 0.00008 0 0.00067 0.103 0.00718 0.00067 0. No further reproduction or networking is permitted.05021 0.04491 0.148 15 83 0.13475 0.00575 0.024 13 90 0.033 -0.49783 0.021 3 67 0.31474 0.0023 Table 2: Gas Mixture Characteristics Included in Statistical Analysis Gas No.05015 0.086 7 76 0.com.005 0.01829 0.094 0.418 6 72 0.00027 0.00098 0.039 -0.026 -0. % -0.224 Table 3: Statistical Analysis of the Differences between Calculated and Experimental Speed of Sound Values for 17 Natural Gas Mixtures 5 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. No.00597 0.30056 0.aga.50407 0.01028 Ethane Propane Isobutane 0.03026 0 0.0041 0.00046 0.69944 0 0.50217 0.8398 0.068 0.037 0.803 -0.85026 0.00065 0.49593 0.094 18 44 0.021 9 87 0.184 0.600 5 78 0. Points AAD % 2 80 0.079 4 95 0.74348 0 0 0 0 0 0 0.00815 0.03113 0.721 -0.8513 0.84992 0.230 0.317 1.144 0.00756 0.12005 0 0 0 0 0 0.00013 0.038 -0.94979 0. Gas No.08251 0 0 0 0 0 0 0 0 0 0 0 0 0 0. under license from the American Gas Association (AGA). Distributed by Thomson Reuters (Scientific) LLC.011 0. Dev.045 0.techstreet.00106 0.029 -0.00034 0.68526 0.1487 0.00141 0.127 0.327 8 81 0.14974 0.00032 0. www.030 16 82 0.009 0.153 0.096 14 65 0.org.205 -0.026 0.95114 0.001 0.148 Bias % Std.

a representative gas analysis). pressure data. Distributed by Thomson Reuters (Scientific) LLC. 3. No further reproduction or networking is permitted. The method used in this report utilizes a detail characterization of the gas composition (i.org.1.2. implementation is limited to methods provided in the AGA Report No.com.techstreet.” The reliability of calculation results is dependent on the reliability of the gas composition data. temperature data and. www. under license from the American Gas Association (AGA). 8. 8 is needed to implement the AGA speed of sound calculation. 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. As such. 6 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. The information contained in this report and in AGA Report No.aga.3. to a lesser extent. “Detail Characterization Method. www..e. 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 ρ ∂ Z ∂ρ ρ Molar density κ Isentropic exponent B 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) H Enthalpy (real gas) H o Enthalpy (ideal gas) Mr Molar mass P Absolute pressure R Universal gas constant S Entropy (real gas) So Entropy (ideal gas) T Temperature W Speed of sound Xi Mole fraction of ith component Z Compressibility Factor 3. Calculations .

org. Calculate the molar mass of the mixture. necessitating conversion from thermochemical calories to joules. Calculate the real gas constant pressure heat capacity at the operating conditions. ratio of specific heats. density. Calculate the isentropic exponent. molar mass and the partial derivative of the compressibility factor with respect to the density at a constant temperature. In the appendix to this report. Calculate the compressibility and density of the fluid at the conditions of interest. 8.” Two other derivatives. Calculate the real gas constant volume heat capacity at the operating conditions. real gas heat capacity. For conversions to other unit systems.techstreet. The originally published constants and units of measure have been preserved for this set of equations. In this document. 5. No further reproduction or networking is permitted. enthalpies and entropies are computed from equations given by Aly and Lee[3]. Except where noted. Equations for Speed of Sound The speed of sound is derived from thermodynamic relationships[1-9]. enthalpy and entropy are solved through numerical integration.4. with the additions given by McFall[2].3.com. ∂ 2 Z ∂T 2 . at the operating conditions.2. applying gaussian quadrature. www. 9. all computations are performed in metric units. all references to the Btu refer to the International Table Btu (Btu(IT)). Alternative solution methods are feasible but users are advised to carefully evaluate the potential impact on accuracy and robustness. Distributed by Thomson Reuters (Scientific) LLC. 6. κ. 3. 2. . The relationships include the compressibility factor. Input the operating temperature (T). Other tables of computed values are given in Section 8 for computational checks but a compliance level is not specified. www. Several partial derivatives are solved during computation. users are referred to applicable documents by NIST[10] and the Canadian Standards Association[11].aga. Calculate the ratio of heat capacities. 8 for subroutine “ZDETAIL. ∂B ∂T and ∂ 2 B ∂T 2 are solved as minor additions to subroutine “B. 7.Pure fluid ideal gas heat capacities. Three of these ( ∂Z ∂T . under license from the American Gas Association (AGA). Calculate the ideal gas constant pressure heat capacity at the operating temperature. operating pressure (P) and gas analysis.” also given in AGA Report No. 7 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. based on the results of the preceding steps. ∂Z ∂ρ ) are solved using the approach given in AGA Report No. Calculate the speed of sound. The general procedure for computing speed of sound at the flowing or operating condition of interest is: 1. 3. cp/cv. Compliance To be compliant with this AGA Report. Table 6a (English units) or Table 6b (Metric units). 4. 3. 8. 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.

expressed in terms of compressibility:   ∂Z     Z + T   ∂T  ρ   c p = cv + R   ∂Z      Z + ρ   ∂ρ T   2 (3. Distributed by Thomson Reuters (Scientific) LLC. κ.1) The isentropic exponent may be expressed in terms of its relationship to the speed of sound: κ =W 2 Mr ZRT (3. The basic speed of sound relation can be expressed as: . c p  RT W =    cv  M r   ∂Z     Z + ρ       ∂ρ T   0. The pure fluid constant pressure ideal gas heat capacity is computed as: 2 2 cp o 2  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 )  8 2 (3.4b) Note that the ideal gas specific heat ratio. cp cv . In certain gas industry applications.com. ρ  o 2  ∂Z    T  ∂ 2Z   c v = c p − R 1 + T ∫   +  dρ   2  ρ ρ ∂ T ∂ T  ρ       0  ρ   ∂P       T   ∂T  ρ  c p = cv +  2   ρ   ∂P       ∂ρ T  (3. No further reproduction or networking is permitted.2) The quantities cv and cp are the constant volume and constant pressure heat capacities of the gas. and the isentropic exponent.5) Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.4a) or.org.techstreet. www. are related but separate quantities. cp o cv o . www. the ratio of ideal gas specific heats is assumed to be synonymous with the isentropic exponent. real gas specific heat ratio. under license from the American Gas Association (AGA).5 (3.3) 2 (3.aga.

Distributed by Thomson Reuters (Scientific) LLC. under license from the American Gas Association (AGA).techstreet.10) where Po = 0. www. In this table. www. the unit of measure for energy is the thermochemical calorie (1 cal(th) = 4.org.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.6) The real gas enthalpy is computed as: ρ  T  ∂Z   H = H + RT (Z − 1) − ∫  ∂ρ  ρ  ∂T   0  o (3.aga.11) where * B = ∑ anT −u n ∑∑ xi x j Eiju n (K i K j )2 Bnij 18 N n =1 i =1 j =1 N 3 (3. No further reproduction or networking is permitted.184 J). 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.101325 MPa The coefficients for computing the ideal gas constant pressure heat capacity.H o = A + BT + CD coth (D / T ) − EF tanh( F / T ) + GH coth( H / T ) − IJ tanh( J / T ) (3. 8.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. The basic equation for the compressibility factor. enthalpy and entropy are given in Table 4.12) 9 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. from AGA Report No. The pure fluid ideal gas enthalpy is computed as: .8) The entropy of mixing is computed as: N S mixing = − R ∑ X i ln ( X i ) (3.com.

96237 2.6225 80.291318 -680.56373 813.21752 1154.0587 775.518 -24.24989 Hydrogen Sulfide -10085.198 2.63 2.792 6.02441 1541.49823 -0.56429 -530.9027 1019.78980 1740.32 63.8 18.91921 500.98139 24.2474 Normal Pentane -83845.13 -13.006 Helium 0.95854 2.com.13290 2197.23 Hydrogen -5565. under license from the American Gas Association (AGA).0629 735.72 -3.58 46.aga.85539 843.1341 Normal Butane -72674.7307 6. www.564 0 100 0 100 -138.22 0.3668 752.94821 Carbon Monoxide -2753. Distributed by Thomson Reuters (Scientific) LLC.0 4.2197 Normal Hexane -94982.48 80.645 0 100 0 100 -44.371 -2.27078 2572.81381 Ethane -37524.68645 500. Component .9417 1037.94680 -0.33458 2584.6383 57.6 6.38159 247.95587 0.4010 Propane -56072.3819 1718.96302 2.402 9.7621 808.738 -0.19749 Isobutane -72387 17.23387 Oxygen -3497.443 3.173 1654.968 0 100 0 100 0 100 0 100 8.0615 4.4556 1454.58 47. No further reproduction or networking is permitted.3410 1701.2028 786.3861 74.2062 1787.4 7.5012 69.001 0 100 0 100 -92.22 5.05 2.510 -22.446 1646.2164 802.801 1.6941 1669. www.1601 1070.1 7.0426 Water -13773.49 6.98 0.149 Normal Nonane -122599 38.272892 662.09 Nitrogen -3495.98 -10.096774 3674.7143 122.847 0 100 0 100 -106.73 38.org.15 0 100 0 100 9.31595 1481.34 6.562 1.6599 814.85 90.0164 Normal Octane -109674 34.968 0 100 0 100 0 100 0 100 1.78 -11.95454 43.4178 1792.0 4.2732 869.588 0 100 0 100 -122.320 3.53990 272.44724 1020.069 0 100 0 100 -77. Enthalpy and Entropy 10 100 100 -20.A (cal/mol) B C (cal/mol-K) (cal/mol-K) D E F G H I J K (K) (cal/mol-K) (K) (cal/mol-K) (K) (cal/mol-K) (K) (cal/mol-K) Methane -29776.8143 58.14319 37.0847 100.444 Normal Decane -133564 42.5015 781.5789 1719.55 69.66789 2.656 0 100 0 100 -7.2255 785.88457 1102.5 26.05010 1156.5 21.7342 984.5014 111.45 6.190 13.4029 90.7675 768.6776 433.43 -2.846 8.39 40.0838 2.8198 Argon 0.899 0 100 0 100 -60.51551 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.40013 2522.5366 Normal Heptane -103353 30.4 7.4 7.151 0 100 0 100 -46.49 55.81 0 100 0 100 6.97183 6.205 -24.6598 802.174 0 100 0 100 -62.1 8.2 22.techstreet.14 0 100 0 0 Table 4: Calculation Coefficients for Heat Capacity.253 1611.749019 559.06 Carbon Dioxide 20.1938 Isopentane -91505.

www. Distributed by Thomson Reuters (Scientific) LLC.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.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.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. No further reproduction or networking is permitted.aga.techstreet.org. www.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.com. The first partial derivative of Z with respect to T is: . under license from the American Gas Association (AGA).18 D  ∂B   ∂Z  * − (u +1)  + D ∑ u n C nT n   = 3 ∂ ∂ T K T  d  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.

Critical Flow Factor Determination . Applying procedures listed in the appendix of ASME standard MFC-7M [5]. 12 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 4. isentropic and adiabatic. No further reproduction or networking is permitted.aga.com. The method may be implemented to account for non-zero gas velocity in the plenum. www. www.org.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. An assumption is made of one-dimensional flow. thermodynamic changes are predicted for the acceleration of gas from the plenum to the throat of a critical flow nozzle. under license from the American Gas Association (AGA). Distributed by Thomson Reuters (Scientific) LLC.techstreet.

Ekofisk.6724 85.9063 81. www. 5.1040 0.aga.4954 0. No further reproduction or networking is permitted. Each characteristic is mapped.4919 3. critical flow coefficient and isentropic exponent.2595 3.0480 0.0000 0.1563 0.1284 1.7020 Carbon Dioxide 0.1007 0. The gas mixtures in Table 5 match the examples given in AGA Report No.9850 7.0324 0.8950 Isobutane 0.org.0000 Normal Hexane 0.This section contains graphical representations (Figures 2 through 5) of thermodynamic properties relevant to this document.8186 4.0393 0. www.5850 Ethane 1. as a function of pressure and/or temperature. The Amarillo. Gulf Coast.1510 Normal Butane 0.2110 Nitrogen 0.4596 0.0068 13.0000 Table 5: Composition of Typical Gases 13 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.4650 5.techstreet. Second Edition.0000 0. not as a substitute for the equations given elsewhere in this report.5222 90.1520 Isopentane 0.0664 0.5279 8.3486 0.000 0. under license from the American Gas Association (AGA). Component Gulf Coast Amarillo Ekofisk High N2 High CO2 Methane 96. Characteristics of Typical Gases .1037 0.4410 81.1000 0.8280 2.0443 0.3506 0.0473 0.3030 Propane 0.com. Five different gas mixtures are explored in terms of speed of sound.5956 0.3015 0.0977 0.6050 0. Distributed by Thomson Reuters (Scientific) LLC.0000 Normal Pentane 0.4676 1. The graphs are intended as an aid to familiarity with concepts.3000 4.0000 0. 8.0321 0.0509 0. High N2 and High CO2 mixtures represent a range of commercial quality natural gases found throughout the industry.

1500 .0 30.27 MPa as a Function of Temperature 14 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. under license from the American Gas Association (AGA).techstreet. www. www.com.0 10. No further reproduction or networking is permitted.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.org.0 20.0 temperature (degrees C) Figure 2b: Sound Speed at 8.aga.0 50.0 40. Distributed by Thomson Reuters (Scientific) LLC.

under license from the American Gas Association (AGA). No further reproduction or networking is permitted.org.com.aga. www. www. 1400 .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 1 2 3 4 5 6 7 8 absolute pressure (MPa) Figure 3b: Sound Speed at 0° C as a Function of Pressure 15 9 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.techstreet. Distributed by Thomson Reuters (Scientific) LLC.

72 0.710 0.71 0.aga.0 10.0.com.74 C* Amarillo Ekofisk High N2 0.org. under license from the American Gas Association (AGA).0 20.0 50.720 0. C*.7 0.78 .73 High CO2 0.740 C* Amarillo Ekofisk High N2 0.techstreet.0 30. www. Distributed by Thomson Reuters (Scientific) LLC.730 High CO2 0. at 1000 psia as a Function of Stagnation Temperature 0.69 30 50 70 90 110 130 temperature (degrees F) Figure 4a: Critical Flow Coefficient.75 Gulf Coast 0.760 0. at 6.0 60. C*.0 40.770 0. www. 0.77 0.9 MPa as a Function of Stagnation Temperature 16 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.750 Gulf Coast 0.780 0.0 temperature (degrees C) Figure 4b: Critical Flow Coefficient.700 0.690 0.76 0. No further reproduction or networking is permitted.

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. C*. . Distributed by Thomson Reuters (Scientific) LLC. 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. is an extension of the algorithms for sound speed.aga. www. www. entropy and sound speed at plenum compute enthalpy and sound speed at throat compute temperature and pressure. The calculation sequence for the critical flow function. as shown in Figure 7. No further reproduction or networking is permitted.techstreet.com.org. enthalpy and entropy. under license from the American Gas Association (AGA).

865613011 0.1.org.000396764069 ∂ 2 B ∂T 2 : -3. No further reproduction or networking is permitted. www.000 MPa (1160.1.3019 psia) 20.02602812374 ∂B ∂T : 0.42527799 432.8.21437395 kJ/kg-K 2.0430000 kg/kg-mol 0. www.0° C (68.techstreet.86910318 kJ/kg-K 1.79174963 moles/dm3 16.944437 m/s 528. The purpose of this data set is to facilitate computer program development. Distributed by Thomson Reuters (Scientific) LLC.1.09475139 kJ/kg-K 0. Detailed Output Results for Program Development The following three calculation scenarios provide detailed intermediate and output data for specific sets of input conditions.977205 kJ/kg 9.001370797803 ∂ 2 Z ∂T 2 : -1. 8.com. under license from the American Gas Association (AGA).aga.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.0° F) : : : : 3. Detailed Output — Result #1 Input Composition Pressure Temperature : : : Pure Methane 8.08884683127e-005 ∂Z ∂ρ : -0.78350108 kJ/kg-K 1.34719916156e-006 cpo (ideal gas) cp (real gas) cv (real gas) Isentropic exponent Sound Speed Specific Enthalpy Specific Entropy C* : : : : : : : : 2. Calculation Output for Program Verification . 8.

00047962844 ∂ 2 B ∂T 2 : -4.02299618 kJ/kg-K 0.org.com.techstreet. 8.0442939010 ∂B ∂T : 0.5955109 kg/kg-mol 0.15095 psia) 10.2808097391e-006 cpo (ideal gas) cp (real gas) cv (real gas) Isentropic exponent Sound Speed Specific Enthalpy Specific Entropy C* : : : : : : : : 2.40008811 kJ/kg-K 1.3766250161e-6 ∂Z ∂ρ : -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.2. .0° C (50° F) : : : : 1. under license from the American Gas Association (AGA).64511520 kJ/kg-K 1.aga.00084934112 ∂ 2 Z ∂T 2 : -7.Detailed Output — Result #2 Input Composition Pressure Temperature : : : Amarillo 4.1. No further reproduction or networking is permitted.296977 kJ/kg 9. www. www.06018714 kJ/kg-K 2. Distributed by Thomson Reuters (Scientific) LLC.90666330 0.87396178 moles/dm3 17.32535394 400.972536 m/s 499.000 MPa (580.

www.29 2.877763047 0.00110251388 ∂ 2 Z ∂T 2 : -8.10 0. .org.0° F) Output : : : : 2.0 0.3.01 0.02 0.04 0.2264 psia) 40.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.20 0.05 0. No further reproduction or networking is permitted.10 0. under license from the American Gas Association (AGA).com.51434681 kJ/kg-K 0.08298699 kJ/kg-K 2.01 0.techstreet.0 0.01 0.50 5.00420 kJ/kg 8.0° C (104.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.1 0.776948019e-006 cpo (ideal gas) cp (real gas) cv (real gas) Isentropic exponent Sound Speed Specific Enthalpy Specific Entropy C* : : : : : : : : 2.1. 8. Distributed by Thomson Reuters (Scientific) LLC.35 0.0 3.02 1.0004594320 ∂ 2 B ∂T 2 : -3.01 0.55641833 kJ/kg-K 1.7236464045e-006 ∂Z ∂ρ : -0.528389 m/s 508.4780144 kg/kg-mol 0.000 MPa (870.90 0.0375423163 ∂B ∂T : 0.62533592 moles/dm3 19.73699984 kJ/kg-K 1.30648621 391. www.04 6.aga.25 0.

505 1401.551 1424.743 1292.299 1305.880 1302.304 1300.021 1435.004 1396.612 1250.2 of this document refer only to the results given in Tables 6a and 6b. Distributed by Thomson Reuters (Scientific) LLC.700 1222.778 1391.215 1237.750 1349.063 1184.691 1205.538 1353.825 1314.325 1279.617 1186.097 1230.957 50 50 50 50 50 50 50 50 14.413 1306. English Units 24 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.370 1490.856 1244.491 130 130 130 130 130 130 130 130 14.321 1318.893 1473.509 1291.135 1308.912 1263.667 1266.155 1332.724 1363.250 1223.132 1337.269 1330.384 1351.728 1328.372 1306.949 1317. under license from the American Gas Association (AGA).73 100 200 400 600 800 1000 1200 1399.207 1290.172 1338.704 1389.638 1346. No further reproduction or networking is permitted.556 1293.899 1266.855 1319.406 1423.511 1357.006 1339.650 1364.276 1300.847 1259. Temperature o Pressure Speed of Sound (ft/s) F psia Gulf Coast Amarillo Ekofisk High N2 High CO2 32 32 32 32 32 32 32 32 14.771 100 100 100 100 100 100 100 100 14.500 1378.126 1448.061 1370.001 1349.900 1392.219 1416.875 1386.996 1372. Tabled Results for Compliance Checking and Program Development .605 1269.986 1343.390 1430.016 1423.The following tables (Tables 6a and 6b through Tables 12a and 12b) were generated with the alogrithms described in this report.315 1478.092 1374.462 1426.605 1454.990 1192.389 1393.350 1302.techstreet.883 1296.73 100 200 400 600 800 1000 1200 1376.482 1387.2.509 1305.541 1325.523 1257.186 1388.972 1337.487 1458.294 1403.428 1411.443 1350.392 1365.938 1332.765 1222. The numerical resolution provided is suitable for compliance checking but does not reflect the uncertainties inherent in the solution method itself.996 1486.748 1311.186 1225.058 1278.738 1368.747 Table 6a: Speed of Sound (W).301 1375.531 1340.922 1278.830 1455.212 1430.889 1263. The compliance criteria given in Section 3.815 1318.448 1412.987 1412.597 1366.165 1299.940 1370.73 100 200 400 600 800 1000 1200 1495.848 1471.778 1321.310 1342.594 1303.791 1377.org.371 1268.813 1255.817 1213.490 1362.794 1473. www.493 1356.570 1223.642 1335.746 1362.600 1433.049 1266.961 1420.076 1369. 8.233 1434.745 1355.486 1325.317 1371.309 1265.879 1296.697 1382.com.733 1290.842 1313.935 1438.877 1413.721 1220.617 1360.700 1265.333 1439.169 1187.273 1315.941 1417.410 1246.351 1478.885 1186. www.055 1390.261 1304.228 1282.093 1441.213 1381.221 1313.73 100 200 400 600 800 1000 1200 1460.940 1418.716 1426.902 1354.056 1310.870 1302.448 1287.851 1236.748 1195.003 1449.995 1365.aga.

6017 433.2077 413.136854 5.9346 417.3253 419.44444 54.5914 361.0321 434.2093 430.com.1759 393.3391 412.0524 385.77778 37.2592 399.2593 376.5315 427.3094 390.7152 423.3274 406.515806 6.894757 8.5749 418.4214 436.894757 8.6731 381.0729 393.3148 409.1172 372.5100 399.2363 386.44444 54.0018 379.9809 367.8279 54.2005 397.5856 363.5661 434.4116 385.5074 430.7850 379.8104 375.0332 395.6836 439.8523 398.77778 0.7364 449.894757 8.8495 437.9039 417.3002 417.757903 4.7063 398.0821 434. Distributed by Thomson Reuters (Scientific) LLC.7896 373.8052 398.0665 450.7584 419.0892 10 10 10 10 10 10 10 10 0.1062 400.8816 398.8175 406.9873 404.273709 419.757903 4.org.273709 426.9387 422.1847 438.689476 1.9027 383.3866 407.2867 369.4828 405.1531 396.2610 443.1083 401.77778 37.77778 37.5224 441.0418 421.5444 362.44444 54.1998 407.8128 430.8288 423.techstreet.5996 405.6954 416.aga.9008 390.1027 432.378951 2.5599 393.3379 420.0190 394.0890 372.77778 37.5418 372.1033 393.689476 1.1351 383.2094 423.44444 54.5999 372.4556 453.0260 400.757903 4.4305 416.77778 37.44444 0.5195 408.5708 436.689476 1.2233 437.8198 382.0233 433.77778 37.2953 389.101560 0.6358 425.44444 54.515806 6.136854 5.0622 385.5867 416.1157 415.136854 5.6354 438.7283 407.o C Speed of Sound (m/s) Pressure MPa Gulf Coast Amarillo Ekofisk High N2 High CO2 0 0 0 0 0 0 0 0 0.3258 414.1493 401.6429 444.2024 413.2857 400. No further reproduction or networking is permitted.0320 424. Temperature .0398 450.4443 431.7517 407.4124 412.0817 417.7007 37.6653 421.7855 434.4891 400.8822 411.6475 386.1802 441.5867 397.101560 0.136854 5.6374 377.77778 37.3217 432.7308 412.6432 423.0134 411.8034 415. www.1435 424.9503 364.6331 449.7378 386.6220 Table 6b: Speed of Sound (W).3948 397.1689 430.1417 404.1572 392.515806 6.4707 397.1599 397.44444 54.101560 0. under license from the American Gas Association (AGA).515806 6.3451 372.1754 411.0567 385. www.3874 389.7334 396.2489 409.378951 2.5034 410.689476 1.2551 361.0058 401.273709 445.6523 424.7889 454.6082 419.4601 395.1270 415.5827 443.2290 448.6969 427.9379 387.2070 386.5095 396.894757 8.378951 2.4209 397.757903 4.6445 402.6419 408.2307 402.273709 455.5839 413.7095 436.0712 361.101560 0.1965 417. Metric Units 25 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.378951 2.44444 54.7486 415.

675235 0.663869 0.671300 0.707576 0.767156 0.670993 0.673795 0.759633 100 100 100 100 100 100 100 100 14.675541 0.679624 0.729555 0. English Units 26 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.750218 0.712298 0.681589 0.679608 0.691341 0.693279 0.756775 0.705083 0.683874 0.691938 0.692034 0.695500 0.671094 0.709787 0. www.723243 0.715930 0.749611 0.712829 0.692961 0.710734 0.669189 0.688452 0.o Pressure C* F psia Gulf Coast Amarillo Ekofisk High N2 High CO2 32 32 32 32 32 32 32 32 14.670255 0.678754 0.714547 Table 7a: Critical Flow Coefficient (C*).679953 0.681097 0.694475 0.696821 0.694621 0.73 100 200 400 600 800 1000 1200 0.694685 0.669465 0.672895 0.703692 0.680297 0.675744 0.686925 0.702570 0.669223 0.666606 0.708285 0.755020 0.746747 0.753948 0. www.718088 0.662451 0.665350 0.701146 0.680003 0.665680 0.724557 0.672365 0.667375 0.673917 0.708427 0.687851 0.672034 0.aga.735236 0.704905 0.707531 0.718835 0.697897 0.680355 0.670639 0. Distributed by Thomson Reuters (Scientific) LLC.692103 0.668316 0.672851 0.683630 0.670296 0.740770 0.693870 0.681844 0.727755 0.703021 0.739544 0.697193 0.711681 0.671600 0.674866 0.723242 0.727355 130 130 130 130 130 130 130 130 14. No further reproduction or networking is permitted.798146 0.73 100 200 400 600 800 1000 1200 0.774151 0.705721 0.669192 0.683878 0.682419 0.667905 0.687336 0.667998 0.719707 0.695076 0.717468 0.670641 0.674358 0.673183 0.737325 0.org.682164 0.675470 0.675397 0.techstreet.706747 0.740840 0.693445 0.693044 0.676043 0.723392 0.669873 0.703241 0.703174 0.680458 0.713688 0.705538 0.667144 0.684666 0.669556 0.729277 0.670417 0.com.709959 0.720788 0. Temperature .743905 0.666598 0.676352 0.675065 0.751996 0.678807 0.711526 0.665798 0.700698 0.674450 0. under license from the American Gas Association (AGA).73 100 200 400 600 800 1000 1200 0.713849 0.683511 0.729588 0.73 100 200 400 600 800 1000 1200 0.733378 0.715923 0.695346 0.669863 0.673485 0.687314 0.732690 0.697432 0.668756 0.680394 0.667476 0.767596 0.719491 0.672289 0.695774 0.771751 0.777601 50 50 50 50 50 50 50 50 14.

695346 0.672365 0.729555 0.680394 0.714547 Table 7b: Critical Flow Coefficient (C*).680297 0.733378 0.727755 0.44444 54.709787 0.678807 0.668756 0.719707 0.894757 8.674450 0.740840 0.663869 0.692034 0.750218 0.673917 0.683511 0.org.378951 2.691938 0.688452 0.715930 0.777601 10 10 10 10 10 10 10 10 0.515806 6.670993 0.729588 0.695500 0.683630 0.273709 0.689476 1.691341 0.694475 0.687336 0.692103 0.711526 0.693279 0.707531 0.702570 0. No further reproduction or networking is permitted.77778 37.675744 0.44444 54.675397 0.686925 0.692961 0.705721 0. www.894757 8.727355 54.751996 0.681589 0.378951 2.694685 0.675541 0.667476 0.670641 0.675065 0.704905 0.136854 5.672034 0.723392 0.101560 0.687851 0.670255 0.701146 0.672895 0.717468 0.729277 0.675470 0.757903 4.682164 0.666606 0. Temperature .com.77778 37.aga.techstreet.672289 0.680458 0.667998 0.666598 0.674358 0.732690 0.669556 0.665350 0.749611 0.667905 0.700698 0.668316 0. under license from the American Gas Association (AGA).894757 8.667375 0.378951 2.669223 0.669192 0.798146 0.705083 0.693870 0.672851 0.44444 54. Metric Units 27 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.665798 0.708285 0.676043 0.694621 0.669873 0.771751 0. www.273709 0.894757 8.676352 0.273709 0. Distributed by Thomson Reuters (Scientific) LLC.739544 0.696821 0.767596 0.515806 6.665680 0.515806 6.273709 0.101560 0.671300 0.77778 37.703692 0.44444 54.136854 5.682419 0.683874 0.77778 37.670296 0.712298 0.723242 0.684666 0.44444 54.707576 0.77778 37.673183 0.515806 6.735236 0.671600 0.680355 0.679953 0.697897 0.719491 0.724557 0.680003 0.712829 0.703241 0.711681 0.705538 0.673795 0.44444 0.669189 0.755020 0.695076 0.77778 0.756775 0.715923 0.101560 0.378951 2.670639 0.713849 0.101560 0.77778 37.77778 37.678754 0.44444 54.697432 0.703021 0.720788 0.757903 4.767156 0.718088 0.687314 0.689476 1.757903 4.695774 0.679624 0.718835 0.753948 0.679608 0.774151 0.740770 0.710734 0.759633 37.713688 0.669465 0.743905 0.746747 0.673485 0.708427 0.667144 0.723243 0.706747 0.675235 0.681844 0.737325 0.44444 54.669863 0.697193 0.662451 0.689476 1.689476 1.757903 4.136854 5.693445 0.136854 5.709959 0.693044 0.674866 0.703174 0.681097 0.o C Pressure C* MPa Gulf Coast Amarillo Ekofisk High N2 High CO2 0 0 0 0 0 0 0 0 0.671094 0.670417 0.683878 0.

457613 1.379548 1.307379 1.288045 1.265466 1.330207 1.378866 1.320395 1. Distributed by Thomson Reuters (Scientific) LLC.367416 1.302437 1.284661 1.477732 1.398353 1.355575 1.292024 1.292886 1.315401 1.263345 1.293772 1.309355 1.394331 1.305799 1.444570 1.357804 1.404366 1.381773 Table 8a: Isentropic Exponent (κ).299415 1.306240 1.318742 1.306168 1.333960 1.73 100 200 400 600 800 1000 1200 1.techstreet.329108 1.473756 50 50 50 50 50 50 50 50 14.394037 1.330650 1.448015 100 100 100 100 100 100 100 100 14.355410 1.289002 1.337718 1.353891 1.282196 1.372867 1.286084 1.318859 1.279297 1.310547 1.409667 1.436681 1.287777 1.303641 1.285530 1.301604 1.301364 1.349315 1.303089 1. under license from the American Gas Association (AGA).272716 1.417209 1.292600 1.401707 1.280867 1.327887 1. www.284263 1.383107 1.345425 1.330968 1.315252 1.468004 1.286355 1.303386 1.304616 1.331335 1.312423 1.467046 1.278619 1.327855 1.338425 1.73 100 200 400 600 800 1000 1200 1.o Isentropic Exponent Pressure F psia Gulf Coast Amarillo Ekofisk High N2 High CO2 32 32 32 32 32 32 32 32 14.270578 1.382745 1.73 100 200 400 600 800 1000 1200 1.357915 1.317578 1.291253 1.326299 1.org.286086 1.390576 1.351784 1.309207 1.306753 1.288893 1.309313 1.421522 1. Temperature .283014 1.327375 1.313783 1.311802 1.325687 1.336248 1.282621 1.269898 1.305760 1.307683 1.298975 1.280429 1.364448 1.291748 1.406731 1.285824 1.281857 1.443593 1.301500 1.365478 1.333142 1.300595 1.295641 1.391058 1.aga.305655 1.303308 1.380034 1.com.369567 1.291213 1. 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.363040 1.362646 1.302444 1.350659 1.282679 1.302202 1.472470 1.312895 1.346517 1.311904 1.310837 1.272307 1.300745 1.407936 1.262233 1.401410 130 130 130 130 130 130 130 130 14.373215 1.294468 1.315861 1.298338 1.73 100 200 400 600 800 1000 1200 1.298767 1.398701 1.335680 1.317060 1.297762 1.289724 1.315805 1.340524 1.340624 1.353264 1.295972 1.315093 1.325890 1.304100 1.285431 1.290446 1.360274 1. www.301927 1.312465 1.332420 1.298971 1.

www.306240 1.272716 1.303386 1.362646 1.357804 1.org.404366 1.315252 1.312465 1.101560 0.443593 1.298975 1.401707 1.o C Isentropic Exponent Pressure MPa Gulf Coast Amarillo Ekofisk High N2 High CO2 0 0 0 0 0 0 0 0 0.350659 1.309355 1.263345 1.269898 1.282621 1.101560 0.309207 1.311802 1.136854 5.307379 1.291748 1.315093 1.394331 1.136854 5.401410 54.391058 1.44444 0.303641 1.379548 1.136854 5.340524 1.298971 1.409667 1.281857 1.313783 1. www.335680 1.894757 8.282679 1.345425 1.318859 1.301604 1.436681 1.378866 1.298338 1.330207 1.297762 1.515806 6.270578 1.331335 1.285824 1.305760 1.468004 1.77778 37.300595 1.77778 37.346517 1.306753 1.894757 8.340624 1.333960 1.421522 1.757903 4.295641 1.77778 0.291253 1.477732 1.338425 1.techstreet.44444 54.278619 1.330968 1.444570 1.320395 1.383107 1.292886 1.515806 6.382745 1.305799 1.380034 1.287777 1.304100 1.325687 1.398353 1.302437 1.515806 6.689476 1. Distributed by Thomson Reuters (Scientific) LLC.aga.312423 1.353891 1.301364 1.329108 1.286355 1.310547 1.457613 1.378951 2.294468 1.289724 1.309313 1.364448 1.44444 54.689476 1.325890 1.894757 8.279297 1.286086 1.472470 1.301500 1. No further reproduction or networking is permitted.44444 54.307683 1.360274 1.292024 1.com.894757 8.372867 1.317578 1.757903 4.310837 1.285530 1.336248 1.330650 1.299415 1.355575 1.273709 1.305655 1.417209 1.312895 1.367416 1.351784 1.101560 0.280429 1.407936 1.390576 1.327855 1.273709 1.136854 5.44444 54.378951 2.473756 10 10 10 10 10 10 10 10 0.288893 1.318742 1.332420 1.398701 1.326299 1.284263 1.306168 1.265466 1.373215 1.304616 1.284661 1.285431 1.355410 1.302202 1.291213 1.44444 54.302444 1.77778 37.77778 37.327887 1.283014 1.298767 1.467046 1.262233 1.448015 37.315401 1.272307 1.282196 1.303089 1.333142 1.292600 1.77778 37.369567 1.280867 1.757903 4.757903 4.273709 1.689476 1.289002 1.317060 1. Temperature .77778 37.381773 Table 8b: Isentropic Exponent (κ).515806 6.303308 1.689476 1.44444 54.378951 2.315805 1.349315 1.378951 2.365478 1.315861 1.286084 1.327375 1.311904 1.293772 1.353264 1.357915 1. under license from the American Gas Association (AGA).337718 1.273709 1.300745 1.363040 1.406731 1. Metric Units 29 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.288045 1.101560 0.295972 1.44444 54.301927 1.290446 1.394037 1.77778 37.

547787 0.505642 0.488994 0.583864 0.483658 0.644486 0.540281 0.534509 0.610298 0.507791 0.570272 0.544344 0. English Units 30 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.534357 0.562046 Table 9a: Constant Pressure Heat Capacity (cp).610810 0.567593 0.630235 0.489423 0.564040 0.464972 0.678904 0.542670 0.486349 0.563887 0.526314 0.639530 0.541706 0.717702 0.659951 0.601144 0.518166 0.532186 0.567808 0.521749 0.488524 0.586982 0.613040 0.630260 100 100 100 100 100 100 100 100 14. www.505364 0.734493 0.662074 0.713203 0.445689 0.473714 0.469826 0.595435 0.644607 0.542691 0.73 100 200 400 600 800 1000 1200 0.461077 0.534780 0.551626 0.573759 0.518114 0.589748 0. www.562282 0.458100 0.techstreet.625738 0.500128 0.511648 0.546775 0.527238 0.679782 0.505335 0.553580 0.455646 0.589308 0.533765 0.494533 0.448710 0.627234 0.484641 0. Temperature .618330 0.520103 0.596203 0.479439 0.456882 0.514205 0.697959 0.465094 0.578580 0.493600 0.519568 0.516831 0.576644 0.493747 0.527779 0.590549 0.452580 0.500775 0.o Pressure Heat Capacity (Btu/Lbm-F) F psia Gulf Coast Amarillo Ekofisk High N2 High CO2 32 32 32 32 32 32 32 32 14.521447 0.544440 0.499361 0.516412 0.796947 0.503814 0.73 100 200 400 600 800 1000 1200 0.465695 0.634328 0.546124 0.693897 0.569016 0.670243 0.506950 0.458758 0.496606 0.73 100 200 400 600 800 1000 1200 0.515928 0.526357 0.628144 0.523762 0.509059 0.525400 0.747987 0.org.648786 0.436334 0.485648 0.628141 0.531665 0.537585 0.610004 0.564789 0.548845 0.482430 0.635996 0.495794 0.471676 0.588468 0. No further reproduction or networking is permitted.546667 0.558743 0.739439 0.com.510761 0.551812 0.544378 0.563920 0.479681 0.552620 0.449703 0.442493 0.471596 0.667301 50 50 50 50 50 50 50 50 14.576432 130 130 130 130 130 130 130 130 14.607928 0.592965 0.432120 0. under license from the American Gas Association (AGA).647377 0.526964 0.477059 0.630697 0.579264 0.73 100 200 400 600 800 1000 1200 0.614615 0.aga.472531 0.514021 0.518543 0.613283 0.548245 0.587951 0. Distributed by Thomson Reuters (Scientific) LLC.457424 0.594169 0.654098 0.507931 0.569986 0.514686 0.

27214 2.23477 2.11574 2.68948 1.55520 1.69884 2.88282 1.58883 2.28879 2.44444 54.16212 2.75790 4.89476 8.55734 2.97448 2.49618 2.65581 1.97481 2.20971 2.96707 2.67758 1.26802 2.31371 2.89476 8.42240 2.85263 1.92222 2.91797 1.00487 3.92073 1.44444 54.07579 2.29790 2.29347 2.10156 0.00833 2.31033 2.28651 2.75790 4.97839 2.18319 2.62990 2.82684 1.69833 2.11702 2.27371 2.36102 2.89476 8.44444 54.02498 2.84611 3.07051 2.17104 2.19289 2. Temperature .80617 2.77778 37.66279 2.51581 6.28924 2.46163 2.27920 2.44444 54.38642 2. No further reproduction or networking is permitted.27371 2.98604 2.30955 2.03331 2.16924 2.09073 2.36466 2.12250 2. under license from the American Gas Association (AGA).73858 2.76308 1.93044 1.80920 1.37895 2.51581 6.48767 2.38236 2.07517 1.77778 37.68948 1.51581 6.63877 37.09588 1.20629 2.12602 2.23902 2.20375 2.98334 2.33666 1.36088 2.13133 2.27371 2.56769 2.44452 2.com.71044 3.77197 2.46732 2. Distributed by Thomson Reuters (Scientific) LLC.62991 2.15489 2.57327 2.64060 2.27205 2.42526 2.02909 2.techstreet.20744 2.10156 0.31773 2. www.41340 54. www.11586 2.91514 2.55396 2.77778 0.99735 2.37895 2.94674 1.27946 2.13685 5.12661 2.71634 2.23788 2.46380 2.10156 0.62610 2.51581 6.77778 37.27906 2.40221 1.17757 2.94977 2.68948 1.aga.44444 0.94726 1.63867 2.44444 54.04912 2.20357 2.o C Heat Capacity (kJ/kg-K) Pressure MPa Gulf Coast Amarillo Ekofisk High N2 High CO2 0 0 0 0 0 0 0 0 0.48262 2.46916 2.09394 2.10156 0.22598 2.19974 2.35416 2.16946 2.89486 1.37730 2.68948 1.90521 3.22816 2.41429 2.77778 37.03625 2.75790 4.38761 2.91287 1.44444 54.04732 2.10937 2.47251 2.37895 2.23725 2.77778 37.13685 5.09665 2.18446 2.61984 2.45758 2.16387 2.36152 1.07919 2.44444 54.15287 2.84243 3.35317 Table 9b: Constant Pressure Heat Capacity (cp).87866 1.01984 2.00732 2.54527 2.27371 2.51687 2.06722 2.86601 1.13167 2.37895 2.13685 5.org.13845 2.17533 2.37640 2.90770 2.16009 2.77778 37.25076 2.15210 2. Metric Units 31 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.06660 2.75790 4.89476 8.33935 2.79386 10 10 10 10 10 10 10 10 0.49297 2.04535 2.77778 37.14217 2.29539 2.13685 5.26205 2.56667 2.

o

Heat Capacity (Btu/Lbm-F)

Pressure

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

o

C

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

o

Pressure

Specific Enthalpy (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

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

640 408.77778 37. Distributed by Thomson Reuters (Scientific) LLC.030 436.300 435.105 556.44444 54.894 543.670 524.955 518.072 596.941 532.101560 0.440 376.810 561.648 396.273709 665.082 631.44444 54.273709 546.576 Table 11b: Specific Enthalpy (H).910 537.919 529.481 496.217 516.235 37. www.350 523.272 524.378951 2.407 413.757903 4.339 529.org.136854 5.889 404.514 503.084 491.845 599.aga.892 531.851 643.146 580.999 464.157 417.709 518.77778 37.757903 4.319 503.487 568.701 654.160 540.665 480.77778 37.44444 0.77778 37.399 497.579 560.527 494. under license from the American Gas Association (AGA).964 556.391 398.870 592.948 424.515806 6.101560 0.894757 8.techstreet.471 541.378951 2.187 546.490 586.339 459.906 497.590 603.530 623.918 511.269 470.489 585.261 619.122 10 10 10 10 10 10 10 10 0.978 491.388 534.473 440.689476 1.44444 54. www.391 477.970 611.111 551.653 590.325 508.44444 54.440 607.404 428.533 478.366 580.587 603.077 637.244 577.227 428.689476 1.912 538.795 450.44444 54.515806 6.689476 1.030 446.436 484.520 570.378951 2.906 54.614 560.956 633. No further reproduction or networking is permitted.728 505.136854 5.114 489.014 413.666 660.307 518.015 498.189 443.012 548.364 459.136854 5.249 615.136 504.053 457.106 451.272 482.515806 6.853 464.44444 54.369 589.771 471.042 627.com.081 473.77778 37.657 513.947 563.757903 4.854 467.470 529.165 561.894757 8.738 552.687 596.269 576.453 482.101560 0.527 575.220 605.392 602.505 547.515806 6.77778 0.195 497.77778 37.051 563.314 419.738 471.273709 568.262 445.684 430.689476 1.930 508.672 534.456 465. Metric Units 35 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.658 553.833 491. Temperature .788 537.378951 2.381 455.465 551.894757 8.273 564.77778 37.841 457.716 478.101560 0.022 525.894757 8.631 573.982 570.844 539.169 514.432 506.175 463.503 590.135 388.136854 5.o C Pressure Specific Enthalpy (kJ/kg) MPa Gulf Coast Amarillo Ekofisk High N2 High CO2 0 0 0 0 0 0 0 0 0.000 470.822 536.588 514.273709 628.44444 54.051 521.024 519.069 421.615 379.757903 4.518 448.729 443.027 361.546 478.621 550.592 453.006 488.849 503.568 437.782 399.140 550.543 492.056 616.381 485.

34134 2.03627 2.10242 2.14903 2.94624 Table 12a: Specific Entropy (S).16365 2.59691 2.aga.73 100 200 400 600 800 1000 1200 2. www.15552 2.42183 2.00730 1.97954 1.35695 2.05118 2.08632 2.34272 2.73 100 200 400 600 800 1000 1200 2.26225 2.14561 2.67085 2.96814 1.18651 2.10654 2.95971 1.46965 2.08788 2.15029 2.13568 2.19451 2.12531 2.20999 2.04751 2.18272 2.28842 2.45181 2.51808 2.64379 2.07179 2.34453 2.45345 2.26239 2.06387 2.03996 2.25797 2.33472 2.o Specific Entropy (Btu/Lbm-F) Pressure F psia Gulf Coast Amarillo Ekofisk High N2 High CO2 32 32 32 32 32 32 32 32 14.15411 2.06249 2.00651 1.24200 2.97143 1.16770 2.10271 2. under license from the American Gas Association (AGA). English Units 36 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.93348 2.43295 2.05981 2.11727 2. Distributed by Thomson Reuters (Scientific) LLC.12601 2.47804 2.90123 1.67064 2.20496 2.09029 2.94195 1.65254 2.20611 2.20379 2.36202 2.08491 2.25431 2.08507 2.92906 2.57924 2.19178 2.08638 2.17655 2.91656 130 130 130 130 130 130 130 130 14.09807 2.28526 2.15972 2.56756 2.49529 2.73 100 200 400 600 800 1000 1200 2.01198 1.37041 2.13073 2.99323 1.09951 2.31491 2.16277 2.08024 2.42458 2.97050 1.02938 1.28577 2.29004 2. No further reproduction or networking is permitted.13104 2.48992 2.07144 2.54119 2.33524 2.00659 2.71941 2.09010 2.86045 100 100 100 100 100 100 100 100 14.01424 2.73 100 200 400 600 800 1000 1200 2.12641 2.23352 2.17506 2.99887 1.05400 2.96103 2.22783 2.07147 1.40431 2.27075 2.83717 50 50 50 50 50 50 50 50 14.03368 1.20420 2.20377 2.33083 2.42209 2.30600 2.18345 2.95845 1.22910 2.techstreet.00960 1.12944 2.94110 1.39838 2.com.03239 1.24942 2.12258 2.25710 2.95142 2.25936 2.06107 2.org.16157 2.99218 1.44052 2.51257 2.13682 2.18830 2.21762 2.35881 2.18463 2.21643 2.05079 2.24586 2. Temperature .10738 2.74720 2.99209 1.35389 2.03234 2.86732 1.27545 2.05484 2.29398 2.15494 2.02594 2.92122 1.37686 2.88888 1. www.53707 2.

77719 9. under license from the American Gas Association (AGA).07574 8.51581 6. Temperature .37505 9.05007 8.44444 54.62930 8.44444 54.89476 8.34085 8.34524 8.44727 9.73499 8.88680 8.02475 8.40087 8.22675 8.77778 0.82317 8.90838 7.15122 9.10156 0.27371 11.13685 5.13863 8.87272 9.18625 9.58792 9.77778 37.63946 9.35129 9.25280 8.18231 10.26522 9.91553 8.49660 8.23656 9.14853 Table 12b: Specific Entropy (S).96008 7.38682 9.99756 8.aga.13685 5.77499 9.88932 9.60442 9.77778 37.22682 9.14659 8. No further reproduction or networking is permitted. www.77778 37. Distributed by Thomson Reuters (Scientific) LLC.20490 8.40117 10.74985 9.80241 10.77778 37.90116 8.75790 4.58626 8.24023 8.68948 1.67282 8.19962 8.51581 6.27371 11.67272 8.45950 9.10156 0.52544 10.81607 9.28474 9.10156 0.32750 9.86460 8.89826 8.10654 8.45366 9.51462 8.79876 9.06904 10.90284 8.51581 6.50920 8.40298 9.04377 7. www.59967 8.27371 11.09508 10.78422 8.58115 9.27371 11.36885 8.27973 9.75790 4.17655 8.57008 9.43836 9.16197 11.68948 1.75084 10.60322 8.13057 8.86807 9.81967 8.22856 9.63523 8.38563 10.52686 9.44444 0.65476 9.79023 8.18145 10.50197 10.92444 9.72979 8.54090 10.69184 10 10 10 10 10 10 10 10 0.75790 4.o C Specific Entropy (kJ/kg-K) Pressure MPa Gulf Coast Amarillo Ekofisk High N2 High CO2 0 0 0 0 0 0 0 0 0.47216 9.47157 9.44444 54.13685 5.77778 37.57249 8.40417 8.81809 7.06638 9. Metric Units 37 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.74154 8.13971 9.75790 4.56794 9.05876 8.02423 54.77778 37.44444 54.41787 9.98322 8.10565 10.75870 9.80851 9.54271 10.33995 9.25007 8.51961 9.41379 8.94166 10.89476 8.72910 8.23171 9.15449 8.34049 8.48219 10.10156 0.27211 9.94642 8.80362 8.42478 10.17019 9.techstreet.37895 2.21797 9.89476 8.45004 9.77778 37.37895 2.04231 8.com.87588 9.05508 8.80271 8.78935 37.12699 7.13685 5.89476 8.43324 10.75162 8.14167 9.62220 9.50716 9.58786 8.92222 8.95144 9.44444 54.25399 8.73526 8.04154 9.62402 10.02230 8.68948 1.01883 11.64101 10.67417 8.37895 2.50899 8.92092 8.85526 9.42377 8.21044 10.70955 8.68948 1.37895 2.11279 8.28793 8.44444 54.69207 9.33279 8.18795 9.org.44444 54.00284 8.51581 6.14082 9.07660 9.

APPENDIX — C++ Language Example Implementation . www. Distributed by Thomson Reuters (Scientific) LLC. The calling function supplies a pointer argument to a custom structure (defined in aga10. version information As implemented.1.h) containing input as well as output data. No further reproduction or networking is permitted. recognizing the large community of Windows developers. support has been included for the creation of a Win32 DLL (dynamic link library). A1. The Detail class is responsible for 38 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. as it appeared in the 1994 printing of AGA Report No.h detail. The C++ implementation in this report is derived from an implementation in the FORTRAN programming language.1. The second group of files may be used to create a Windows-based example application for testing or demonstrating.cpp entry. Overview of Classes and Key Functions In the C++ programming language.org. A1. Much of the original program structure and nomenclature was preserved for traceability and ease of conversion. www.h aga10. Two classes were created for this implementation. File Group 1 — Calculation Library File Group 1 is limited to mathematical calculations. under license from the American Gas Association (AGA). Consideration has also been given to secondary objectives of speed and efficiency. 8.techstreet. 8. The first group of computer files demonstrates a C++ implementation of the AGA speed of sound calculation method. Overview of Computer Code Two groups of computer code are included in Appendix A. 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. Conversion to ANSI C or other computer languages is feasible. The primary goals of this implementation are clarity and compatibility with AGA Report No. data and functions are typically grouped in structures called classes.com.A1. external processes communicate with the library through a single function call. Differences exist due to the syntax and grammar associated with each programming language but the code is not strongly idiomatic to the C++ language.aga.cpp detail. Files included in Group 1 are: • • • • • • • • aga10.rc header file for AGA 10 data structures.cpp therm.h therm.1.cpp script1. User interface is not provided at this level but.

Function Crit() Function Crit() provides the same basic services of SOS(). including the density search procedure. such as those for critical flow nozzles.3.2. www. the Detail class contains the new functions for solving the partial derivatives of Z and the second virial coefficient.org. The Therm class is designed for additional thermodynamic calculations.5. an important parameter for critical flow calculations. Detail Class The Detail class contains all the data and methods required to compute gas compressibility and density-related parameters. www. enthalpy. Function SOS() Function. No further reproduction or networking is permitted. launches calculations supported by the classes and then removes the objects from memory. A1. Crit() imposes a significantly larger computing burden than SOS() and is recommended only for situations where C* is required. Distributed by Thomson Reuters (Scientific) LLC. Therm Class The Therm class contains data and functions for calculating heat capacity. 39 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. density-related computations.1. including speed of sound.aga. A1.1. In the course of its execution.1.1. the Therm class supports a method of estimating pressure and temperature from enthalpy and entropy. but also estimates the critical flow function.The Detail and Therm classes are designed for efficient repeated operation. In typical calculations involving the speed of sound. It creates an object of each required class. Those familiar with AGA Report No.com.4. entropy and the speed of sound. temperature and gas composition. the Therm class calls on the Detail class to perform density-related work. under license from the American Gas Association (AGA).” Several important design features were carried over to the C++ version. . A1. For other calculations.techstreet. the user provides the process pressure. B. Crit() relies on support function HS_Mode() to predict gas pressure and temperature from enthalpy and entropy. SOS() is responsible for basic execution and memory management. A1. Any number of calculations can be executed between the creation and deletion of these objects. 8 will note strong resemblance between this code and the original FORTRAN “Detail Characterization Method. HS_Mode() uses a nested algorithm and Newton’s Method to converge upon pressures and temperatures that satisfy given enthalpy and entropy states. C*. Extending the original functionality.

The gas velocity is used to refine the estimate of enthalpy at the plenum. 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. No further reproduction or networking is permitted.cpp file. Distributed by Thomson Reuters (Scientific) LLC. 40 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. version 6 (SP5). 98.1 File Group 1 — Calculation Code The code begins on the following page. The application interacts with aga10. tested under the following Windows operating systems: Windows 95. Through a conventional dialog-based interface. www. This implementation was created with Microsoft Visual C++.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.2.A1. The interface consists of one non-modal dialog box and basic file operations. www. function Crit() will accept gas velocity at the plenum as an optional input.techstreet.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.0 (SP6). Standard Windows and C++ run-time library process are used for file access.cpp dlghlp. As implented in this Appendix. .org. under license from the American Gas Association (AGA).com.aga. NT 4.h aga10win.cpp ga10win. A simple Win32 application can be created with this code. Windows XP. The application requires basic Win32 support. 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. supported widely by vendors of software development systems.

11.B.#ifndef _AGA10_H #define _AGA10_H /* Windows-specific export macro and header #include */ #if WIN32 #define DllExport __declspec (dllexport) #include <windows. www. No further reproduction or networking is permitted.com.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.17 * Author: W.h> #else #define DllExport #endif /* other #include #include #include #include #include includes */ <strstream> <iostream> <fstream> <iomanip> <math.techstreet. under license from the American Gas Associatio ************************************************************************* * File: aga10.cpp * Version: ver 1. Distributed by Thomson Reuters (Scientific) LLC.h * Description: function prototypes and defines for aga10.7 2002. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ .

001 Pa */ #define T_CHG_TOL 0. /* calculation status */ bool bForceUpdate. = 473.techstreet.001 /* 0. /* compressibility at flowing condition */ double dFpv .K)*/ 42 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. /* real gas specific entropy (J/kg-mol. /* real gas relative density */ // additional output double dHo . = 143. Distributed by Thomson Reuters (Scientific) LLC. /* mixture molar mass */ double dZb . /* Absolute Pressure (Pa) */ double dTf . = 0. /* mass density at contract base conditions (kg/m3) */ double dRhof .314510e-3 /* in kJ mol^-1 K^-1 */ #define RGAS 8. // // // // maximum maximum maximum maximum pressure (Pa) ~= 20. /* compressibility at contract base condition */ double dZf . /* molar density at contract base conditions (moles/dm3) */ double dDf . /* molar density at flowing conditions (moles/dm3) */ double dRhob .001 /* 0.15 .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 . under license from the American Gas Associatio /* default tolerance limits */ #define P_CHG_TOL 0. No further reproduction or networking is permitted. /* real gas specific enthalpy (J/kg) */ double dS .379e8 .0 .com./* const const const const maximum allowable double P_MAX double P_MIN double T_MAX double T_MIN P & T */ = 1. /* ideal gas specific enthalpy */ double dH . /* Flowing temperature (K) */ // basic output from AGA 8 Detail method double dMrx . in two configurations */ #define RGASKJ 8.001 of a Kelvin */ .0 . /* mass density at flowing conditions (kg/m3) */ double dRD_Ideal . /* signal to perform full calculation */ double adMixture[NUMBEROFCOMPONENTS] . /* Composition in mole fraction */ double dPb . /* supercompressibility */ double dDb .000 psi pressure = 0 temperature (K) ~= 392 F temperature (K) ~= -200 F /* universal gas constant. /* ideal gas relative density */ double dRD_Real . www. /* Contract base Pressure (Pa) */ double dTb . /* Contract base temperature (K) */ double dPf .

XiNC6.K)*/ ratio of specific heats */ isentropic exponent. www.K)*/ real gas constant volume heat capacity (J/kg-mol. double dCstar . Distributed by Thomson Reuters (Scientific) LLC.techstreet.com. XiC3. double dk . XiNC4. double dKappa . . /* FUNCTION PROTOTYPES */ /* prototypes for initialization */ DllExport int AGA10_Init(void) . double dCv . XiHe. XiNC5. XiCO. XiH2S. #endif 43 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. double dCp .K)*/ real gas constant pressure heat capacity (J/kg-mol. No further reproduction or networking is permitted. double) . DllExport int AGA10_UnInit(void) . XiNC10. /* function prototype for a C* calculation */ DllExport double Crit(AGA10STRUCT *. XiH2. XiAr } . XiCO2. XiIC4. XiN2. double dSOS . /* initialize library */ /* un-initialize library */ /* function prototype for basic SOS calculation */ DllExport double SOS(AGA10STRUCT *) . XiC2. under license from the American Gas Associatio double dCpi . XiNC8./* /* /* /* /* /* /* ideal gas constant pressure heat capacity (J/kg-mol. XiIC5. } AGA10STRUCT . denoted with Greek letter kappa */ speed of sound (m/s) */ critical flow factor C* */ /* enumerations for tracking gas components */ enum gascomp{ XiC1=0. XiH2O. XiO2. XiNC9. XiNC7.

Crit(). creates and uses objects based on Detail and Therm classes * Contains the following functions: * AGA10_Init().7 2002. } // 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. CRi() * Version: ver 1.com.11. www. AGA10_UnInit(). No further reproduction or networking is permitted. /************************************************************************** * Function : AGA10_Init() * Arguments : void * Returns : int * Purpose : Initializes library. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ .cpp * Description: Manages overall process of calculating speed of sound * or C*.h" #include "therm.#include "aga10.techstreet. creates required objects * Revisions : **************************************************************************/ DllExport int AGA10_Init(void) { // create object for calculating density if (NULL == (ptDetail = new Detail)) { return MEMORY_ALLOCATION_ERROR . static Therm *ptTherm . one of Therm class // and one of Detail class.h" // Create file-scope pointers to objects we will need. static Detail *ptDetail .17 * Author: W. Cperf(). under license from the American Gas Associatio /************************************************************************* * File: aga10. SOS(). Distributed by Thomson Reuters (Scientific) LLC.B.h" #include "detail.

}
}

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

} // return the critical flow function to caller return ptAGA10->dCstar . ptDetail) .0) . exponent))) .// restore fluid props to plenum conditions ptTherm->Run(ptAGA10.0 / (k + 1. . under license from the American Gas Associatio // put the original plenum pressure and temperature back ptAGA10->dPf = P . k = ptAGA10->dKappa . exponent = (k + 1. Distributed by Thomson Reuters (Scientific) LLC. } // isentropic perfect gas critical flow function C*i return(sqrt(k * pow(root.0) .techstreet. // 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.com. root = 2. exponent .1. ptAGA10->dTf = T . www. No further reproduction or networking is permitted. root.0) / (k . // Cperf 48 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.

techstreet.double CRi(AGA10STRUCT *ptAGA10) { return (Cperf(ptAGA10) / sqrt(ptAGA10->dZf)) . www. 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 : **************************************************************************/ . Distributed by Thomson Reuters (Scientific) LLC. No further reproduction or networking is permitted.com. } // CRi() 49 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.

m^3/kg-mol ^1/3 double dGi[21] . // characterization parameters from table 5 double dMri[21] . // dipole parameter 50 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // Pb from previous calc double dOldTb .h * Description: Header file for the 'Detail' class * See 'detail. // number of components int aiCID[21] . // Pf from previous calc double dOldTf . Distributed by Thomson Reuters (Scientific) LLC. // Tf from previous calc // EOS parameters from table 4.#ifndef _DETAIL_H #define _DETAIL_H #include "aga10.B. * Version : ver 1.cpp' for the implementation. double adUn[58] .com. // Tb from previous calc double dOldPf . www. column 1 double adAn[58] . // molecular weight of ith component double dEi[21] .17 * Author : W. No further reproduction or networking is permitted. // mixture ID from previous calc double dOldPb . Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ .7 2002. // component IDs // five history variables are used to improve efficiency during repeated calculations double dOldMixID . under license from the American Gas Associatio /************************************************************************* * File : detail. // characteristic energy parameter for ith component double dKi[21] . // orientation parameter double dQi[21] . // quadrupole parameter double dFi[21] . // high temperature parameter double dSi[21] . // size parameter for ith component .techstreet.11.h" class Detail { private: // member data int iNCC .

dPRhoL . . // current temperature // current pressure double double double double double dRhoTP . dRhoL . . No further reproduction or networking is permitted. . // // // // double double double double adTable6Eij[21][21] adTable6Uij[21][21] adTable6Kij[21][21] adTable6Gij[21][21] . adBcoef[18] . . . under license from the American Gas Associatio double dWi[21] . Distributed by Thomson Reuters (Scientific) LLC. dB . double double double double adTable5Qi[21] adTable5Fi[21] adTable5Si[21] adTable5Wi[21] table table table table . fx[58] . // pressure calculated by pdetail() double dT . dKp3 . // mole fraction of component i double dPCalc . . // // // // // molar density at T & P 2nd virial coefficient. // // // // // 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. dQp2 . dPRhoH .com. .// association parameter double double double double dEij[21][21] dUij[21][21] dKij[21][21] dGij[21][21] . dW . double dP .techstreet. dF . . . . B 18 coefficients to calculate B function for coefficients of density modified coefficients used for 3 derivs double double double double double dU . adFn[58] . // // // // // mixture energy parameter mixture size parameter ^3 mixture orientation parameter mixture quadrupole parameter ^2 high temperature parameter double double double double double dRho . www. // // // // 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] . dRhoH .

protected: public: Detail(void) . // calculates mass density . // calculates composition dependent quantities void bvir() . ~Detail() . // calculates 1st partial derivative of Z wrt T double d2ZdT2(double) . under license from the American Gas Associatio // private class methods bool compositionchange(AGA10STRUCT *) . // first partial derivative of Z wrt molar density double ddBdT . // second partial derivative of B wrt T // the Run() command launches a full calculation sequence void Run(AGA10STRUCT *) . // current compressibility double ddZdT . www. } .com. // calculates temperature dependent quantities void braket(AGA10STRUCT *) . No further reproduction or networking is permitted. // first partial derivative of B wrt T double dd2BdT2 . // Table 5 and binary interaction parms void chardl(AGA10STRUCT *) . // calculates the 2nd virial coefficient void temp() . // calculates compressibility factor double dZdT(double) . // calculates pressure as a function of P and T void ddetail(AGA10STRUCT *) . // default constructor // default destructor // public functions to support advanced fluid property calculations double zdetail(double) . // calculates 1st partial derivative of Z wrt D // public variables also used for advanced fluid property calculations double dZ . given pressure & temperature void relativedensity(AGA10STRUCT *) . // calculates 2st partial derivative of Z wrt T double dZdD(double) . // sets up Table 4 and 6 characterization parms void paramdl() .techstreet. // brackets density solutions void pdetail(double) . #endif 52 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // compares new composition to old void table() . Distributed by Thomson Reuters (Scientific) LLC. // calculates a density. // first partial derivative of Z wrt T double dd2ZdT2 . // second partial derivative of Z wrt T double ddZdD .

// function table() populates tables of static constants 53 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // flowing pressure from previous calc dOldTf = 0.B. No further reproduction or networking is permitted. www. braket().techstreet.0 .h" #include <math. zdetail(). * pdetail(). * paramdl(). includes initialization of * history-sensitive variables & data tables 4 and 6 * Revisions : **************************************************************************/ Detail::Detail(void) { // initialize history-sensitive variables dOldMixID = 0.h" #include "detail.com. // base pressure from previous calc dOldTb = 0. chardl().7 2002. bvir(). * dZdD() * Version : ver 1. dZdT(). 10 * Contains the functions: * Detail().0 . // flowing temperature from previous calc // initialize gas component array used within this class for (int i=0 . relativedensity(). d2ZdT2().cpp * Description: This file contains functions implementing * AGA Report No.i<NUMBEROFCOMPONENTS .0 . under license from the American Gas Associatio /************************************************************************* * File : detail. table().11.h> /************************************************************************** * Function : Detail::Detail() * Arguments : void * Returns : * Purpose : default constructor.i++) dXi[i] = 0 .17 * Author : W. ddetail(). Run(). // mixture ID from previous calc dOldPb = 0. ~Detail().Detail Method. compositionchange().#include "aga10. // base temperature from previous calc dOldPf = 0. temp().0 . Distributed by Thomson Reuters (Scientific) LLC. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ . plus new features * required for AGA Report No.8 1994 .0 .

// update the history variable. Distributed by Thomson Reuters (Scientific) LLC. No further reproduction or networking is permitted.table() . 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. // generate the numerical ID for the composition for (i=0 .0 . 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. i<NUMBEROFCOMPONENTS . int i . www.com.techstreet. // 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. under license from the American Gas Associatio } . i++) dMixID += ((i+2) * ptAGA10->adMixture[i]) .

55 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.} return false.com. aiCID[iNCC] = i .techstreet. No further reproduction or networking is permitted. dXi[iNCC] = ptAGA10->adMixture[i] . ported from original // FORTRAN functions paramdl() and chardl() paramdl() . // calculate composition dependent quantities. under license from the American Gas Associatio { .i++) { if (ptAGA10->adMixture[i] > 0. // Check for gas composition change ptAGA10->bForceUpdate = (ptAGA10->bForceUpdate || compositionchange(ptAGA10)) . } // 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 .i<NUMBEROFCOMPONENTS . chardl(ptAGA10) .0) { iNCC = iNCC + 1 . Distributed by Thomson Reuters (Scientific) LLC. www. // assign component IDs and values if (ptAGA10->bForceUpdate) { iNCC = -1 . } } } iNCC = iNCC +1 . for (i=0 .

0e-6 .com.dOldTb) > T_CHG_TOL)|| (ptAGA10->bForceUpdate)) { dP = ptAGA10->dPb * 1. dOldPb = ptAGA10->dPb . // force ForceUpdate flag to true 56 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // update history and clear the ForceUpdate flag dOldTb = ptAGA10->dTb . // copy density to data structure member ptAGA10->dRhob = dRhoTP . No further reproduction or networking is permitted. // determine molar density ddetail(ptAGA10) .techstreet. converted from Pa here = ptAGA10->dPf * 1. // calculate relative density relativedensity(ptAGA10) .dOldPb) > P_CHG_TOL)|| (fabs(ptAGA10->dTb . ptAGA10->dDb = dRho . // calculate temperature dependent parms temp() . // check whether to calculate temperature dependent parms if ((fabs(ptAGA10->dTf . // calculate mass density dRhoTP = (dP * ptAGA10->dMrx) / (ptAGA10->dZb * RGASKJ * dT) . we must follow through temp() . // AGA 8 uses MPa internally dT = ptAGA10->dTb . // but only if necessary if ((fabs(ptAGA10->dPb .dOldTf) > T_CHG_TOL)||(ptAGA10->bForceUpdate)) { // if temperature has changed.0e-6 . // determine compressibility ptAGA10->dZb = zdetail(dRho) . under license from the American Gas Associatio // evaluate T & P dependent parms at base pressure and temperature.// // // dP dT repeat the process using flowing conditions begin by loading P & T from data structure AGA 8 uses MPa internally. = ptAGA10->dTf . Distributed by Thomson Reuters (Scientific) LLC. ptAGA10->bForceUpdate = true . } . www.

Distributed by Thomson Reuters (Scientific) LLC. } else // if either Zb or Zf is zero at this point.dOldPf) > P_CHG_TOL)||(ptAGA10->bForceUpdate)) { // determine molar density ddetail(ptAGA10) . No further reproduction or networking is permitted. dOldPf = ptAGA10->dPf . ptAGA10->lStatus = GENERAL_CALCULATION_FAILURE . } } // we are now up to date.ptAGA10->bForceUpdate = true . Fpv is not constrained to 14.0) && (ptAGA10->dZf > 0. under license from the American Gas Associatio } . // check whether to calculate other parms if ((fabs(ptAGA10->dPf . } // calculate legacy factor Fpv // NOTE: as implemented here.0)) { ptAGA10->dFpv = sqrt(ptAGA10->dZb / ptAGA10->dZf) .techstreet. // Detail::Run() /************************************************************************** * Function : Detail::table() 57 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // determine compressibility ptAGA10->dZf = zdetail(dRho) .com.0 . // 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 . we have a serious unexpected problem { ptAGA10->dFpv = ptAGA10->dZb = ptAGA10->dZf = 0. www. ptAGA10->dDf = dRho .73 psi and 60F if ((ptAGA10->dZb > 0. toggle off the update flag ptAGA10->bForceUpdate = false .

adAn[18] = 0.hydrogen 2 . adAn[8] = -0. adAn[15] = -0.471722000 .carbon dioxide 10 .water 13 .n-pentane void Detail::table(void) { int j.i-butane 5 .044081590 .carbon monoxide 3 . under license from the American Gas Associatio * Arguments : void * Returns : void * Purpose : builds tables of constants * Revisions : **************************************************************************/ .886594630 .n-heptane .// // // // // // // // // // Tables 4 and 6 are filled only during object initialization. adAn[7] = 0. adAn[3] = -0.argon Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. adAn[4] = 0. adAn[5] = -1.375796500 .n-hexane .helium . adAn[16] = -0.048312280 .436386400 .column A(n) adAn[0] = 0. adAn[17] = 0.ethane 11 .157672400 . adAn[11] = -0. 58 by 15 16 17 18 19 20 21 AGA Report#8 .methane 8 .29129E-09 .hydrogen sulfide 14 .710237040 . component ID's.i-pentane 7 .786659250 .024873550 .341953000 . Distributed by Thomson Reuters (Scientific) LLC.321850350 . adAn[14] = -0.153832600 .techstreet. // 58 constants from table 4 . adAn[10] = 1.propane 12 . adAn[2] = -2.032059050 . adAn[1] = 1. adAn[9] = -1.oxygen 4 .n-butane 6 . k .nitrogen 9 .003433888 . adAn[6] = -0. No further reproduction or networking is permitted.053588470 .n-octane .n-nonane . adAn[13] = 0.998583000 .589575000 .n-decane . mapped to each species supported 1 . adAn[12] = 2.com. www.

418465000 -5. . . .015573220 0. . . www.009776195 -0.658716400 0.003733797 1.079314910 -1. No further reproduction or networking is permitted.642470600 -0.007022847 0.000205518 0.936757000 -0. .024955870 0.002168144 -0.066899570 0.746545300 -0. .001600573 0.696605100 -0.com.705752900 0.294616000 -9.243256700 0.001226752 0.534979200 -0.007224479 -0. .020487080 0.column Un 59 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. . . . . .291961300 7.= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 0. . Distributed by Thomson Reuters (Scientific) LLC.techstreet. .005399808 -0. . . . . . . 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] . . . . . // 58 constants from table 4 . . . .279179500 -0. .006862415 -0.150547000 0.049870160 0.105840200 0. .034317290 -0.416260100 -0. . .002850908 . .008098836 3. .002860589 -0.042968180 0. . .073322790 -0.99905E-17 0. .874951000 0. .

21. 60 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 0. 2. 6. 2. 2.0 . 9.0 .0 .0. 21.5 .0 . 7.0 . 4. 22. -6.5 .0 . 0. 6. -0. 3. 2.5 . 3.5 .0 .0. 8.0 .0 . 0. 12. 4.5 .com. -0.0 .0 . www. 23. 1.5 .= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 0.0 . 1.5 .0.0 . -1. No further reproduction or networking is permitted. 12.0 . 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] .0 . -0. 6. Distributed by Thomson Reuters (Scientific) LLC.5 . 0. 7.5 .0 .techstreet. 9.0.0 . 11.0 .0 .5.0 . -13. 0.0.5 .0.5 .0.0 . 4. -0. -1.0. 7.

0 .0 . = 23. adTable6Uij[j][k] = 1. = 3.0 // It is up to us to set non-zero values for (j=0 .0 .0 . = 3.170520 .5 . adTable6Gij[j][k] = 1.0 or 0.0 . 61 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.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] .0 . j++) { for (k=j . } } // Lnsert the 132 items of non-zero and non-1.0 . // Most of the tables are filled with 1.960644 .techstreet. = 0.0 . = 1. adTable6Eij[0][5] = 0. adTable6Eij[0][6] = 0. www. = -0. = 0.0 . adTable6Eij[0][2] = 0.0 .0 .0 data // This looks more cumbersome than it is.0 .0 . k < NUMBEROFCOMPONENTS .0. = 7. = 8.5 . = 1.971640 .994635 . No further reproduction or networking is permitted. = 4.931484 . = 23. = 1. j < NUMBEROFCOMPONENTS . considering table 6 has 1764 members adTable6Eij[0][1] = 0.0.0 . adTable6Eij[0][7] = 1.0.= 9. adTable6Eij[0][4] = 0.0 . = 9. k++) { adTable6Eij[j][k] = 1. = 5.708218 . = 22.0 . adTable6Kij[j][k] = 1. Distributed by Thomson Reuters (Scientific) LLC.

adTable6Eij[0][12] = 1. adTable6Eij[1][12] = 0.62 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. adTable6Eij[0][15] = 0. adTable6Eij[1][5] = 0. adTable6Eij[1][7] = 1.019530 . adTable6Eij[1][2] = 1. adTable6Eij[3][4] = 1. under license from the American Gas Associatio adTable6Eij[0][8] = 0.960237 . adTable6Eij[1][11] = 0.946871 . adTable6Eij[1][10] = 0.765171 .281790 .002350 . adTable6Eij[0][13] = 0. adTable6Eij[2][17] = 0.726255 .693168 . adTable6Eij[2][6] = 0.849408 . adTable6Eij[1][4] = 0.906849 .022560 . www.897362 .959340 . adTable6Eij[3][7] = 1. adTable6Eij[0][18] = 0. adTable6Eij[2][16] = 0.945520 .746954 .945939 . adTable6Eij[3][5] = 0.902271 .021000 .990126 . Distributed by Thomson Reuters (Scientific) LLC. adTable6Eij[1][8] = 1. adTable6Eij[2][15] = 0.881161 . adTable6Eij[1][9] = 1.970120 .808310 .com.999268 . adTable6Eij[2][18] = 0. No further reproduction or networking is permitted. .831229 . adTable6Eij[1][3] = 0. adTable6Eij[2][14] = 0. adTable6Eij[0][14] = 1. adTable6Eij[2][4] = 0.973384 .881067 . adTable6Eij[3][6] = 0.500000 . adTable6Eij[2][10] = 0. adTable6Eij[0][17] = 0.880880 . adTable6Eij[0][16] = 0. adTable6Eij[1][13] = 0.989844 .005710 .164460 . adTable6Eij[2][12] = 0. adTable6Eij[0][11] = 0.955052 .946914 . adTable6Eij[2][5] = 0.880973 . adTable6Eij[1][6] = 0. adTable6Eij[2][3] = 0.925053 . adTable6Eij[0][10] = 1. adTable6Eij[2][13] = 0. adTable6Eij[2][11] = 0. adTable6Eij[2][7] = 1.techstreet.022740 . adTable6Eij[2][8] = 1.107274 .855134 .786323 .859764 .086320 .

adTable6Eij[6][15] = 1. adTable6Uij[1][3] = 0. adTable6Uij[0][17] = 1. www. No further reproduction or networking is permitted.004900 .098291 .088178 .003670 . adTable6Eij[4][11] = 1. adTable6Uij[2][6] = 1.100000 .066638 . adTable6Uij[1][7] = 0. adTable6Uij[1][11] = 0.300000 .005320 .077634 . adTable6Uij[3][4] = 1. adTable6Uij[0][14] = 1. adTable6Eij[4][7] = 1.045290 .013060 . adTable6Uij[3][6] = 0.191904 .300000 .011501 . adTable6Uij[0][16] = 1.992291 .969870 . adTable6Eij[6][17] = 1. adTable6Uij[2][3] = 0.techstreet.736833 . adTable6Uij[2][8] = 0. adTable6Uij[1][6] = 0.108021 . adTable6Uij[0][7] = 1.008692 . adTable6Uij[2][18] = 1. Distributed by Thomson Reuters (Scientific) LLC.616660 .915502 .012821 .014089 .034787 . adTable6Eij[6][18] = 1.219634 .993556 .990877 .408838 .963827 .886106 . adTable6Uij[0][2] = 0. adTable6Uij[2][17] = 1. adTable6Eij[7][10] = 1. adTable6Eij[7][11] = 1. adTable6Uij[0][15] = 1. adTable6Uij[1][2] = 0.835058 .156390 .205769 .971926 . adTable6Uij[2][15] = 1. adTable6Uij[2][14] = 1.63 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. adTable6Uij[3][7] = 1.900000 .993476 . adTable6Uij[0][6] = 0. adTable6Uij[0][4] = 0. adTable6Eij[6][14] = 1. adTable6Eij[7][8] = 1.010126 . adTable6Uij[2][16] = 1.com. adTable6Uij[0][18] = 1. adTable6Eij[3][13] = 1.233498 . .816431 . adTable6Uij[1][4] = 0. adTable6Uij[0][1] = 0. adTable6Uij[0][11] = 0.302576 . under license from the American Gas Associatio adTable6Eij[3][11] = 1. adTable6Eij[6][16] = 1.065173 . adTable6Uij[0][13] = 1.

adTable6Kij[6][16] = 0. adTable6Kij[0][1] = 1.995933 . adTable6Uij[6][18] = 1.999969 .002529 . adTable6Uij[6][15] = 1.957828 .046966 .895362 . adTable6Kij[0][2] = 0. adTable6Kij[2][16] = 0. . Distributed by Thomson Reuters (Scientific) LLC. No further reproduction or networking is permitted. adTable6Kij[0][6] = 1.250000 .982962 . adTable6Kij[0][13] = 1.981849 .250000 . adTable6Kij[0][18] = 0.64 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. adTable6Kij[0][11] = 0. adTable6Uij[6][14] = 1.007619 .020340 . adTable6Kij[1][2] = 0. adTable6Uij[6][17] = 1.982361 . adTable6Kij[6][18] = 0. adTable6Uij[6][16] = 1.023260 . adTable6Kij[2][17] = 0. adTable6Uij[3][12] = 1. adTable6Kij[0][14] = 0.008510 .250000 .968130 . adTable6Uij[3][13] = 1. under license from the American Gas Associatio adTable6Uij[3][10] = 1. adTable6Kij[3][6] = 0.980991 . adTable6Kij[6][17] = 0. adTable6Kij[3][7] = 1.982707 . adTable6Gij[0][2] = 0. adTable6Kij[0][4] = 1.com. adTable6Kij[6][15] = 0.007790 .033754 . adTable6Kij[2][15] = 0.910183 . adTable6Kij[2][14] = 0. adTable6Kij[2][3] = 1.986893 . adTable6Kij[0][16] = 0.003630 .techstreet. adTable6Kij[0][17] = 0.250000 .807653 . www. adTable6Kij[6][14] = 0. adTable6Kij[0][15] = 0. adTable6Kij[3][4] = 0. adTable6Kij[1][3] = 1.000080 .867520 . adTable6Kij[0][7] = 1. adTable6Kij[2][18] = 0.028973 .038338 .983565 .881152 .042735 . adTable6Kij[2][6] = 1.952441 . adTable6Kij[1][7] = 1. adTable6Kij[1][6] = 0. adTable6Uij[3][11] = 1.942596 .997596 .948338 .962870 .854406 .032270 .007960 .

0.0100. . 86. 365. 0. 0. 244. // table 5 parameters.558373.6341423. 39.142. 0.2580.722630. 100.370296 1.4186954. 58.610111.9480} . 2. 34. 65 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 0. 241. . 470.0820. 514.0700. 402.4479153.4618263. declared locally to this function const double adTable5Mri[NUMBEROFCOMPONENTS] = {16.4533894.2310. 298. 0. const double adTable5Ei[NUMBEROFCOMPONENTS] = {151.9988. 0. 119.1230.4557489.840891.0430. 30.128.673090 .1230.682300. 296.118300. 72. 489. 44.068900.0135. 337.0026.534800.957940.4.960600. 427. www. 0.0153.com.166700. 99. 105. 2. 31.766700.3514916.6406937.318300.629900} .636293.0970. Distributed by Thomson Reuters (Scientific) LLC. 0. 0. 324. k .techstreet. 28. 26. 72.5837490. . const double adTable5Ki[NUMBEROFCOMPONENTS] = {0. 0.3825868.4619255.5279209.737780.0100. 28.2850.957310 0.1. 44. under license from the American Gas Associatio } adTable6Gij[0][7] = adTable6Gij[1][2] = adTable6Gij[2][3] = adTable6Gij[2][5] = // Detail::table() .015600. 450. 18.1500.325022. No further reproduction or networking is permitted.355000.599900.638900. 122. /************************************************************************** * Function : Detail::paramdl() * Arguments : void * Returns : void * Purpose : sets up characterization & binary interaction parameters * Revisions : **************************************************************************/ void Detail::paramdl(void) { int j.0159.982746 0. 370. 58.2040.1770.1500.114.

under license from the American Gas Associatio 0.8437826.3900 .0. dKi[j] = adTable5Ki[aiCID[j]] . // setup characterization parameters for non-zero components for (j=iNCC-1 .0. 0. 0.5822 .038953.383381.427354. j < iNCC .0. j >= 0 .0 . adTable5Si[j] = 0.281835. 0.0.0.0000 . } for (j=0 . adTable5Qi[5] = 1.techstreet.332500. 0. adTable5Fi[j] = 0. 0.079300.141239.6738577.0.0. adTable5Fi[7] = 1. adTable5Qi[6] = 0.4216551} .8152731. adTable5Si[5] = 1.027815. 0.0.0.189065. .7525189.3589888.0. 0. www. j++) 66 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0. 0.7849550. 0. 0. adTable5Wi[5] = 1.0 .0 . adTable5Wi[j] = 0.088500.034369.7175118.const double adTable5Gi[NUMBEROFCOMPONENTS] = {0.0.366911. Distributed by Thomson Reuters (Scientific) LLC.289731. j--) { dMri[j] = adTable5Mri[aiCID[j]] .000000} .256692. j++) { adTable5Qi[j] = 0.000000. j < NUMBEROFCOMPONENTS . } // a small number of exceptions adTable5Qi[2] = 0.000000. No further reproduction or networking is permitted. // most of the table 5 parameters are zero for (j=0 .0.com.0 .337542.332267.0.6798307.0.0. 0.021000.469659.067750 .0000 .633276 . adTable5Si[6] = 0.690000 . 0.

j < iNCC . uij for (j=0 . e3p0. j < iNCC . dWi[j] = adTable5Wi[aiCID[j]] . www. e4p5.j . double Xij. under license from the American Gas Associatio { . j++) { dQi[j] = adTable5Qi[aiCID[j]] . wij. Distributed by Thomson Reuters (Scientific) LLC. e3p5.com. if (aiCID[j] == 7) dFi[j] = adTable5Fi[7] . dFi[j] = 0. 67 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. e6p0 . e2p0. No further reproduction or networking is permitted. Gij. k5p0. k2p5.techstreet. double tmfrac. } } // 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. kij. q1p0 . j++) { for (k=j . dEij[j][k] = adTable6Eij[aiCID[j]][aiCID[k]] . k++) { dUij[j][k] = adTable6Uij[aiCID[j]][aiCID[k]] .} dGi[j] = adTable5Gi[aiCID[j]] . e0p5. for (j=0 . } } // Binary interaction parameters for arrays: eij.0 . dGij[j][k] = adTable6Gij[aiCID[j]][aiCID[k]] . u5p0. u2p5. Eij. dSi[j] = adTable5Si[aiCID[j]] . k < iNCC . dEi[j] = adTable5Ei[aiCID[j]] . dKij[j][k] = adTable6Kij[aiCID[j]][aiCID[k]] .

// calculate gas molecular weight ptAGA10->dMrx = 0. u2p5 = 0. } // reset virial coefficients for (j=0 .techstreet. double e11p0.// normalize mole fractions and calculate molar mass tmfrac = 0. dF = 0. j++) { dXi[j] = dXi[j]/tmfrac . . for (j=0 . No further reproduction or networking is permitted.0 . Distributed by Thomson Reuters (Scientific) LLC. for (j=0 . q1p0 = 0. j++) { adBcoef[j] = 0.e12p0.e12p5 .0 . k2p5 = 0. s3 .com.e9p5.0 . u5p0 = 0. j++) { ptAGA10->dMrx = ptAGA10->dMrx + dXi[j] * dMri[j] .0 . under license from the American Gas Associatio double e7p5.0 .0 .0 . j < iNCC . j < iNCC . } for (j=0 . www. j < 18 . j++) { tmfrac = tmfrac + dXi[j] . } // initialize a key subset of the local variables k5p0 = 0.0 . dW = 0.0 . } // calculate the composition-dependent quantities.0 . j < iNCC . applying a nested loop 68 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.

* dFi[i] . e2p0 = Eij * Eij .0)).com.5. // proceed while skipping interaction terms which equal 1.5. else Xij = dXi[i] * dXi[j] .0) . e12p0= e11p0 * Eij . e3p0 = Eij * e2p0 . * dEi[i] * sqrt(dEi[i]) .5. . Distributed by Thomson Reuters (Scientific) LLC.0) * pow((pow(dEi[i].0) * pow(dEi[j]. e12p5= e12p0 * e0p5 .0) k5p0 += Xij * (pow(dKij[i][j].0 . e0p5 = sqrt(Eij) . if (dUij[i][j] != 1.0)).0) * pow(dKi[j].techstreet.0. e9p5 = e7p5 * e2p0 . No further reproduction or networking is permitted. j < iNCC .0) u5p0 += Xij * (pow(dUij[i][j].0 * dXi[i] * dXi[j] . 69 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.i < iNCC . Gij = dGij[i][j] * (dGi[i] + dGi[j]) / 2. e4p5 = Eij * e3p5 . // calculate terms required for second virial coefficient. B Eij = dEij[i][j] * sqrt(dEi[i] * dEi[j]) . if (dGij[i][j] != 1.0 if (dKij[i][j] != 1. j++) { if (i != j) Xij = 2.0) . under license from the American Gas Associatio for (i=0 .5. e3p5 = e3p0 * e0p5 .5. www.5) .0) .1.0) * ((dGi[i] + dGi[j]) / 2. . e11p0= e4p5 * e4p5 * e2p0 .5) .1.5. { k2p5 u2p5 dW q1p0 dF .1. for (j=i .0.0) * pow((pow(dKi[i]. e6p0 = e3p0 * e3p0 . 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]) . e7p5 = e4p5 * Eij * e2p0 .0) dW += Xij * (dGij[i][j] .

com. . 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[6] = adBcoef[6] + s3 * dQi[i] * dQi[j] * e0p5 . .0) * pow(dKi[j]. under license from the American Gas Associatio s3 = Xij * pow((pow(dKi[i]. adBcoef[7] = adBcoef[7] + s3 * dSi[i] * dSi[j] * e7p5 . adBcoef[2] = adBcoef[2] + s3 * Eij . adBcoef[3] = adBcoef[3] + s3 * e3p5 . 0. 0. adBcoef[15] = adBcoef[15] + s3 * dQi[i] * dQi[j] * e2p0 adBcoef[16] = adBcoef[16] + s3 * e2p0 . dQp2 = q1p0 * q1p0 . } . adBcoef[9] = adBcoef[9] + s3 * dWi[i] * dWi[j] * e6p0 . www. adBcoef[14] = adBcoef[14] + s3 * e3p0 . i < 18 .techstreet.5) .6) . // grab the first 18 constants from table 4. No further reproduction or networking is permitted. 0.2) . adBcoef[5] = adBcoef[5] + s3 * Gij * e4p5 . . .} adBcoef[0] = adBcoef[0] + s3 . Distributed by Thomson Reuters (Scientific) LLC. adBcoef[17] = adBcoef[17] + s3 * e11p0 . 3. } // final products of chardl are mixture size parameter K. dU = pow((u5p0 + u2p5 * u2p5). adBcoef[1] = adBcoef[1] + s3 * e0p5 . energy parameter U. completing Bnij for (i=0 .3)). adBcoef[8] = adBcoef[8] + s3 * dSi[i] * dSi[j] * e9p5 . // and quadrupole parameter Q dKp3 = pow((k5p0 + k2p5 * k2p5). // 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. adBcoef[4] = adBcoef[4] + s3 * Gij / e0p5 . i++) adBcoef[i] *= adAn[i] .

t4p0 = t2p0 * t2p0 . t12p5 . t9p5. t12p5 = t12p0 * t0p5 .techstreet. . t2p0 = dT * dT .0 . . . t12p0. . t7p5 = t6p0 * dT * t0p5 . double t7p5. t4p5 = dT * t3p5 . . www. t11p0 . // pre-calculate powers of T t0p5 = sqrt(dT) . double t1p5. . // 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 . t3p5. t3p5 = t3p0 * t0p5 . t9p5 = t7p5 * t2p0 . / / / * / / / / / t0p5 dT . t1p5 = dT * t0p5 . t4p5. t6p0.0 dB = ddBdT = dd2BdT2 = 0. t2p0. t3p0.void Detail::bvir(void) { // variables local to function double t0p5. t4p0 . under license from the American Gas Associatio * Revisions : **************************************************************************/ . . t3p0 = dT * t2p0 . t3p5 t0p5 t4p5 t0p5 t7p5 t9p5 t6p0 . t12p0 = t9p5 * t0p5 * t2p0 . t11p0 = t4p5 * t4p5 * t2p0 . 71 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. t6p0 = t3p0 * t3p0 . Distributed by Thomson Reuters (Scientific) LLC. No further reproduction or networking is permitted.com. int i . // reset B and partial devivatives to 0. double Bx[18] .

B for (i= 0. www. wrt T for (i= 0. i++) { if (adUn[i]) ddBdT += Bx[i] / dT . i++) { dB += Bx[i] . i < 18. Distributed by Thomson Reuters (Scientific) LLC.= = = = = = = = adBcoef[10] adBcoef[11] adBcoef[12] adBcoef[13] adBcoef[14] adBcoef[15] adBcoef[16] adBcoef[17] / / * / / / / / t12p0 .com. i < 18. // calculate terms for second derivative of B. } // sign change here ddBdT = -ddBdT . t2p0 . t6p0 . } // calculate terms for first derivative of B. i < 18.techstreet. } // 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. i < 18. changes exponent of T for (i= 0. t12p5 . } // sum up the pieces of first derivative of B // note div by dT. i++) { if (adUn[i]) Bx[i] *= adUn[i] . wrt T for (i= 0. t11p0 . under license from the American Gas Associatio Bx[10] Bx[11] Bx[12] Bx[13] Bx[14] Bx[15] Bx[16] Bx[17] . t3p0 . t2p0 . // sum up the pieces for second virial coefficient. No further reproduction or networking is permitted.0) . t2p0 . i++) { if (adUn[i] && adUn[i] != -1.0) Bx[i] *= (adUn[i] + 1.

} .com.0) dd2BdT2 += Bx[i] / t2p0 . thereby changing the exponent of T // loop will ignore Bx[0] which is = 0.} // Detail::bvir() 73 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 for (i= 0. i++) { if (adUn[i] && adUn[i] != -1.techstreet. Distributed by Thomson Reuters (Scientific) LLC. www. No further reproduction or networking is permitted. under license from the American Gas Associatio // note division by dT. i < 18.

tr22p0 = tr * tr21p0 . tr1p5. */ // calculate adFn(12) through adFn(57) // adFn(0)-adFn(11) do not contribute to csm terms tr = dT / (dU) . tr9p0 = tr * tr8p0 .techstreet. tr6p0 = tr * tr5p0 .8 FORTRAN listing. tr5p0 = tr * tr4p0 . www. tr6p0 . // retaining as much of the original content as possible // variables local to function double tr0p5. tr13p0 = tr6p0 * tr7p0 . tr4p0 = tr * tr3p0 .com. tr21p0 . tr3p0 = tr * tr2p0 . tr2p0 = tr * tr . tr3p0. Distributed by Thomson Reuters (Scientific) LLC. tr . tr9p0. tr7p0 = tr * tr6p0 . double tr22p0. tr0p5 = sqrt(tr) . tr21p0 = tr9p0 * tr9p0 * tr3p0 . tr5p0. tr11p0 = tr6p0 * tr5p0 . double tr7p0. tr13p0. 74 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. under license from the American Gas Associatio /************************************************************************** * Function : Detail::temp() * Arguments : void * Returns : void * Purpose : computes temperature-dependent quantities * Revisions : **************************************************************************/ . tr11p0. tr1p5 = tr * tr0p5 . tr8p0. tr4p0. tr23p0. No further reproduction or networking is permitted. /* calculate second virial coefficient B bvir() . tr2p0. tr23p0 = tr * tr22p0 . tr8p0 = tr * tr7p0 .void Detail::temp(void) { // Note: this function was ported from the AGA Report No.

techstreet.com. tr3p0 . tr8p0 . tr0p5 . tr7p0 . dQp2 / tr23p0 . Distributed by Thomson Reuters (Scientific) LLC. dQp2 / tr2p0 . 75 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. tr0p5 . tr21p0 . tr2p0 . dQp2 / tr3p0 . tr22p0 . tr21p0 . dF * tr . tr6p0 . dF * tr . tr2p0 . 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] . dQp2 / tr8p0 . dQp2 * tr0p5 . tr23p0 . tr0p5 . tr4p0 .= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 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] * / / * / / * / . dW / tr . / / / * * * * * * / * * * * / * * . dW / tr9p0 . dQp2 / tr22p0 . tr11p0 . No further reproduction or networking is permitted. / / * / / / / * / * / * * / dF * tr6p0 . tr6p0 . dQp2 * tr0p5 . dQp2 / tr9p0 . tr1p5 . www. tr2p0 . tr9p0 . dW / tr7p0 . tr . dF * tr13p0 . dW / tr4p0 . dW / tr23p0 . tr4p0 . dW / tr5p0 .

techstreet. epsp = 1. xdenom. delprv.e-6 . y1my2. tr . epsr = 1. double delx. /************************************************************************** * Function : Detail::ddetail() * Arguments : AGA10STRUCT * * Returns : void * Purpose : calculates density * Revisions : **************************************************************************/ // Note: this function was ported from the AGA Report No. tr3p0 . // call subroutine braket to bracket density solution braket(ptAGA10) . xnumer.com. x3. www. 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() . boundn . No further reproduction or networking is permitted. epsr. delbis. double y2my3.* / * / * dW / tr7p0 . // 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.0 . y3my1. i . dRho =0. // retaining as much of the original content as possible void Detail::ddetail(AGA10STRUCT *ptAGA10) { int imax. // initialize convergence tolerances imax = 150 . dQp2 . epsmin . y3 . delmin.e-6 . dW .e-7 . double x1. Distributed by Thomson Reuters (Scientific) LLC. sgndel . x2. y1.8 FORTRAN listing. y2. double epsp. epsmin = 1.

}

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

dP . Distributed by Thomson Reuters (Scientific) LLC. dRho = x2 . pdetail(x2) .} } relable variables for next iteration x1new = x2old. under license from the American Gas Associatio // // x1 y1 . y2 x2 = x2 + delx . www. = y2 .techstreet. y1new=y2old = x2 . // next iteration values for x2.com. No further reproduction or networking is permitted. y2 = dPCalc . // ddetail: maximum number of iterations exceeded ptAGA10->lStatus=MAX_NUM_OF_ITERATIONS_EXCEEDED . // Detail::ddetail() 80 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.

videal . it < imax . under license from the American Gas Associatio /************************************************************************** * Function : Detail::braket() * Arguments : AGA10STRUCT * * Returns : void * Purpose : brackets density solution * Revisions : **************************************************************************/ . No further reproduction or networking is permitted.15 / videal . } else { rho2 = 1.0 .95 / (videal + dB) .com. rho1 = 0.8 FORTRAN listing. rhomax = 1. double rho1. // initialize imax = 200 . double del.0 / dKp3 .0 * rhomax . // retaining as much of the original content as possible void Detail::braket(AGA10STRUCT *ptAGA10) { // variables local to function int imax.0 .// Note: this function was ported from the AGA Report No. p2 . p1. if (fabs(dB) < (0. www. 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.techstreet. if (dT > 1. } del = rho2 / 20. it . rhomax.2593 * dU) rhomax = 20. Distributed by Thomson Reuters (Scientific) LLC.167 * videal)) { rho2 = 0. rho2.0 . videal = RGASKJ * dT / dP . // start iterative density search loop for (it = 0. p1 = 0.

com. dPRhoH = p2 . under license from the American Gas Associatio { . www. return. No further reproduction or networking is permitted. dPRhoL = p1 . } else if (p2 > p1) { if (ptAGA10->lStatus == MAX_DENSITY_IN_BRAKET_EXCEEDED) del *= 2. ptAGA10->lStatus = NORMAL . rho2 = rho1 + del . since p2 is less than // some previous pressure ptAGA10->lStatus = NEGATIVE_DENSITY_DERIVATIVE. return. Distributed by Thomson Reuters (Scientific) LLC. p1 = p2 . p2 = dPCalc .0 . rho2 = rho1 + del . // 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 .} // density in braket exceeds maximum allowable density ptAGA10->lStatus = MAX_DENSITY_IN_BRAKET_EXCEEDED .0 . // calculate pressure p2 at density rho2 pdetail(rho2) .01 * (rhomax . } else { // lStatus= NEGATIVE_DENSITY_DERIVATIVEindicates that // pressure has a negative density derivative. continue . } 82 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. continue .rho1) + (dP / (RGASKJ * dT)) / 20. dRho = rho1. del = 0. dRhoH = rho2 .techstreet. rho1 = rho2 .

No further reproduction or networking is permitted. return . . given D and T. www. dRho = rho2 .} // Detail::braket() /************************************************************************** * Function : Detail::pdetail() * Arguments : double * Returns : void * Purpose : calculates pressure. Calls zdetail() * Revisions : **************************************************************************/ void Detail::pdetail(double dD) { dPCalc = zdetail(dD) * dD * RGASKJ * dT .com.techstreet. Distributed by Thomson Reuters (Scientific) LLC. } // Detail::pdetail() 83 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 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 .

4. No further reproduction or networking is permitted. D2. D1 . D1 . D1 .0 + (adFn[20] + adFn[21] + adFn[22]) * D2 * (2. . D5.com. D9.4.2. D6.0 .0 * D3 * exp3) + (adFn[13] + adFn[14] + adFn[15]) * D1 * (exp2 . D3.4.0 * D2 * exp2) + (adFn[16] + adFn[17]) * D1 * (exp4 .0 . // 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 . .2.0 + (adFn[28] + adFn[29]) * D3 * (3. D1 . D7. D4.0 + dB * d + adFn[12] * D1 * (exp3 . Distributed by Thomson Reuters (Scientific) LLC. exp(-D1) exp(-D2) exp(-D3) exp(-D4) .0 * D2) * exp2 84 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 .techstreet.0 * D4 * exp4) + (adFn[18] + adFn[19]) * D2 * 2.3. .0 .0 . exp2. D1 .double Detail::zdetail(double d) { // variables local to function double D1. D1 . exp1.0 * D2) * exp2 + (adFn[23] + adFn[24] + adFn[25]) * D2 * (2.1.1. under license from the American Gas Associatio /************************************************************************** * Function : Detail::zdetail() * Arguments : double * Returns : void * Purpose : calculates compressibility * Revisions : **************************************************************************/ . exp4 . D1 .0 .0 .0 * D4) * exp4 + adFn[27] * D3 * 3. D8. // the following expression for Z was adopted from FORTRAN example in AGA8 dZ = 1.0 * D4) * exp4 + adFn[26] * D2 * (2.2. D1 .1. exp3.0 .D1) * exp1 + (adFn[30] + adFn[31]) * D3 * (3. www.

0 .0 * D2) * exp2 adFn[43]) * D4 * (4.0 * D4) * exp4 D6 * 6. D4.0 * D2) * exp2 D7 * 7. No further reproduction or networking is permitted.0 * D2) * exp2 .0 D6 * (6.0 . D2. exp3.0 . // 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 .0 . D1 . under license from the American Gas Associatio + + + + + + + + + + + + + + + . int i . return dZ . exp1.2.0 . Distributed by Thomson Reuters (Scientific) LLC. double D1. D9.4.0 * D4) * exp4 adFn[38]) * D4 * 4.2.0 D7 * (7.0 .2. // D1 D2 D3 D4 set up = dKp3 = D1 * = D2 * = D3 * powers of reduced density * d .2.0 * D3) * exp3 adFn[35] + adFn[36]) * D3 * (3. D1 . D3.} (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.techstreet.0 * D2) * exp2 adFn[48]) * D5 * (5. D5.4.3.2. exp2.0 .0 . D7.0 * D2) * exp2 adFn[57]) * D9 * (9.0 .0 * D2) * exp2 D8 * (8.2. D6.0 .0 adFn[40] + adFn[41]) * D4 * (4.0 .4.0 * D4) * exp4 D5 * 5.D1) * exp1 adFn[55]) * D8 * (8.0 adFn[46]) * D5 * (5. D1 . D8. 85 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. exp4 . www.com.

. += fx[15] . .(fx[17] * tmp) .2. tmp = (1. No further reproduction or networking is permitted. } } // initial part of equation ddZdT = d * ddBdT . .0 * D2) * exp2 86 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // create terms uC*T^-(un+1) from coefficients we've already computed (An[n]) for (i=12. += fx[14] . .0 * D4) * exp4 .(fx[12] * (1.0 . ddZdT = ddZdT .(fx[16] * tmp) . . under license from the American Gas Associatio D5 D6 D7 D8 D9 . ddZdT += fx[16] .3.0 . . i++) { if (adUn[i] && adFn[i]) { fx[i] = (adFn[i] * adUn[i] * D1) / dT. .(fx[13] * tmp)) .(fx[14] * tmp) .= = = = = exp1 exp2 exp3 exp4 D4 D5 D6 D7 D8 = = = = * * * * * D1 D1 D1 D1 D1 .0 * D3) * exp3) .(fx[18] + fx[19]) * D1 * 2.0 * D2) * exp2 . www. i < 58.com.techstreet.4.(fx[21] + fx[22]) * D1 * (2. exp(-D1) exp(-D2) exp(-D3) exp(-D4) . for whom fn = 1 if (dF) ddZdT += fx[12] . } else { fx[i] = 0. += (fx[13] .2. // n=13 evaluates to zero except for hydrogen.0 . ddZdT += fx[17] .(fx[15] * tmp) .0 .0 . Distributed by Thomson Reuters (Scientific) LLC. tmp = ddZdT ddZdT ddZdT (1.0 .

0 * D2) * exp2 fx[56] * D8 * (9.3.D1) * exp1 (fx[30] + fx[31]) * D2 * (3.0 .0 .2.0 .0 .2.techstreet.0 .0 * D4) * exp4 fx[37] * D3 * 4.4.D1) * exp1 fx[54] * D7 * (8.0 .0 .0 .0 fx[52] * D6 * (7.0 * D3) * exp3 (fx[34] + fx[35] + fx[36]) * D2 * (3.0 * D4) * exp4 fx[26] * D1 * (2.2. No further reproduction or networking is permitted.0 * D4) * exp4 fx[27] * D2 * 3.0 * D2) * exp2 (fx[42] + fx[43]) * D3 * (4.2.2. www.2.0 . return ddZdT .4.0 * D2) * exp2 fx[53] * D7 * (8.0 (fx[39] + fx[40] + fx[41]) * D3 * (4.0 fx[50] * D5 * (6.0 * D2) * exp2 .0 (fx[45] + fx[46]) * D4 * (5.4.0 .4.0 .0 * D2) * exp2 (fx[32] + fx[33]) * D2 * (3.0 * D2) * exp2 fx[51] * D6 * 7.4.0 .com. // Detail::dDdT() 87 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 .0 (fx[28] + fx[29]) * D2 * (3.2.0 * D2) * exp2 (fx[47] + fx[48]) * D4 * (5.0 . under license from the American Gas Associatio - .0 * D4) * exp4 fx[49] * D5 * 6.} (fx[23] + fx[24] + fx[25]) * D1 * (2. Distributed by Thomson Reuters (Scientific) LLC.0 .0 * D4) * exp4 fx[44] * D4 * 5.

D2. D2 = D1 * D1 . D4 = D3 * D1 . D3 = D2 * D1 . exp3 = exp(-D3) .com. D3. www. D5 = D4 * D1 . D6.0)) / (dT * dT) . D8 = D7 * D1 . D7 = D6 * D1 . i < 58. exp2. // set up powers of reduced density D1 = dKp3 * d . D8. exp1. i++) { if (adUn[i] && adFn[i]) { fx[i] = (adFn[i] * D1 * adUn[i] * (adUn[i] + 1. D9 = D8 * D1 .double Detail::d2ZdT2(double d) { // variables local to function double tmp . No further reproduction or networking is permitted. } else { fx[i] = 0. D5. exp2 = exp(-D2) . D6 = D5 * D1 . Distributed by Thomson Reuters (Scientific) LLC. D7. } 88 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 . D9. exp3. exp1 = exp(-D1) . // create terms uC*T^-(un+1) from coefficients we've already computed (An[n]) for (i=12. D4. exp4 = exp(-D4) . int i . 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 : **************************************************************************/ . exp4 . double D1.techstreet.

0 * D4) * exp4 fx[26] * D1 * (2.0 fx[50] * D5 * (6.0 * D4) * exp4 .0 (fx[39] + fx[40] + fx[41]) * D3 * (4.com.0 .0 .D1) * exp1 (fx[30] + fx[31]) * D2 * (3.4.0 .2. return dd2ZdT2 .0 * D3) * exp3) .2.4.0 (fx[28] + fx[29]) * D2 * (3.0 * D4) * exp4 fx[37] * D3 * 4.0 .0 .0 .// initial part of equation dd2ZdT2 = d * dd2BdT2 .4. tmp = (1.0 * D2) * exp2 fx[51] * D6 * 7.0 .0 .0 * D2) * exp2 (fx[47] + fx[48]) * D4 * (5.0 * D2) * exp2 (fx[23] + fx[24] + fx[25]) * D1 * (2. dd2ZdT2 += -fx[17] + (fx[17] * tmp) .0 .0 .0 . under license from the American Gas Associatio } .2. dd2ZdT2 += -fx[16] + (fx[16] * tmp) . for whom fn = 1 if (dF) dd2ZdT2 += fx[12] . No further reproduction or networking is permitted.0 dd2ZdT2 += dd2ZdT2 += dd2ZdT2 += . tmp = (1. Distributed by Thomson Reuters (Scientific) LLC. 89 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 .0 * D2) * exp2 (fx[42] + fx[43]) * D3 * (4.2.0 * D4) * exp4 fx[49] * D5 * 6.0 .0 * -fx[13] -fx[14] -fx[15] D2) * exp2 .0 . + (fx[14] * tmp) .3.0 * D4) * exp4 fx[27] * D2 * 3.0 .0 .0 * D2) * exp2 fx[56] * D8 * (9.4. + (fx[13] * tmp) .4.0 . // n=13 evaluates to zero except for hydrogen.0 * D4) * exp4 fx[44] * D4 * 5.0 * D2) * exp2 fx[53] * D7 * (8.2.0 * D2) * exp2 .0 (fx[45] + fx[46]) * D4 * (5.(fx[12] * (1.0 (fx[21] + fx[22]) * D1 * (2. + (fx[15] * tmp) .0 .4.2.2.2.techstreet.0 * D3) * exp3 (fx[34] + fx[35] + fx[36]) * D2 * (3. www.D1) * exp1 fx[54] * D7 * (8.3.0 * D2) * exp2 (fx[32] + fx[33]) * D2 * (3. dd2ZdT2 + + + + + + + + + + + + + + + + + + + + + = dd2ZdT2 + (fx[18] + fx[19]) * D1 * 2.2.0 fx[52] * D6 * (7.

D4 = D3 * D1 . D3 = D2 * D1 . exp4 . D6.com. www. exp1 = exp(-D1) .techstreet. Additional speed optimization is possible. D8 = D7 * D1 . D2. temp2. each term is evaluated individually rather than through looping through tables. under license from the American Gas Associatio } . D7 = D6 * D1 . Distributed by Thomson Reuters (Scientific) LLC. Temporary storage is used to hold portions of complex equations and to facilitate debugging. i < 58. D4. D8. D7. exp4 = exp(-D4) . D5 = D4 * D1 . exp1. double Detail::dZdD(double d) { double temp. int i . D2 = D1 * D1 . exp3 = exp(-D3) . D5.// 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. D6 = D5 * D1 . temp1. exp3. i++) { 90 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // create terms uC*T^-(un+1) from coefficients we've already computed (An[n]) for (i=12. exp2 = exp(-D2) . temp3. D3. D9 = D8 * D1 . No further reproduction or networking is permitted. double D1. // set up powers of reduced density D1 = dKp3 * d . exp2. D9.

ddZdD += fx[18] * temp .20 temp = 4.4. for whom fn = 1 if (dF) { temp1 = -9.0 * D6. temp = temp1 + temp2 + temp3 .. www.3.0 * D2) * exp2 .0 * D2.0 * D2) * 2.0 .0 * D1 .0 . simplifying where possible // n=13 evaluates to zero except for hydrogen. ddZdD += -fx[17] + fx[17] * temp . under license from the American Gas Associatio } . Distributed by Thomson Reuters (Scientific) LLC. temp2 = (1.23 temp1 = -4.com. temp2 = (2.0 * D4 * exp4 . // initial part of equation ddZdD = dB / dKp3 .0 * D3 * exp3 . temp2 = (1.16 temp1 = -4. // n = 17. No further reproduction or networking is permitted.0 * D1 * exp2 . ddZdD += -fx[16] + fx[16] * temp . temp3 = -temp2 * 3.0 * D2 * exp2 ..0 * D4 . // n = 19. 91 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only..0 * D4) * exp4 . temp3 = -temp2 * 4.2. temp = temp1 + temp2 + temp3 .0 . temp3 = -temp2 * 2. // n = 21.. temp2 = (1. ddZdD += -fx[13] + fx[13] * temp .0 * D3) * exp3 . } // n = 14.0 . ddZdD += -fx[12] + fx[12] * temp .techstreet.fx[i] = adFn[i] .0 * D3 * exp2 . ddZdD += -fx[15] + fx[15] * temp .18 temp1 = -16. // evaluate all remaining terms. ddZdD += fx[19] * temp . ddZdD += -fx[14] + fx[14] * temp .2. temp = temp1 + temp2 + temp3 .

. Distributed by Thomson Reuters (Scientific) LLC.27 temp1 = -16.temp3 .0 * D4 * exp2 .0 * D4) * 2. under license from the American Gas Associatio temp3 = -temp2 * D2. ddZdD += fx[24] * temp .com. temp2 = (3.0 . temp = temp1 + temp2 + ddZdD += fx[20] * temp ddZdD += fx[21] * temp ddZdD += fx[22] * temp . ddZdD += fx[28] * temp . 92 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 * D2 * exp1 .0 .4.0 . temp = temp1 + temp2 + temp3 .0 * D4 * exp2 . ddZdD += fx[32] * temp . temp2 = (3.30 temp = -D3 * exp1 + (3. // n = 33.0 * D3) * 3. ddZdD += fx[31] * temp .3. temp3 = -(3. temp2 = (2. temp3 = -(3.2. // n = 29.0 * D2) * 2.0 * D2 .0 * D1 * exp4 .. ddZdD += fx[27] * temp .3.0 . // n = 24. ddZdD += fx[23] * temp .0 * D5 * exp3 .0 * D5 * exp4 .techstreet.. temp -= (3.0 * D5 * exp3 . ddZdD += fx[33] * temp ..34 temp1 = -9. . ddZdD += fx[29] * temp .0 .0 . www. temp = temp1 + temp2 + temp3 . . ddZdD += fx[25] * temp . ddZdD += fx[30] * temp .0 * D2 * exp3 .0 * D3) * 3. temp = temp1 + temp2 + temp3 . // n = 28 temp = 9.0 * D4 . // n = 31.D1) * D3 * exp1 . No further reproduction or networking is permitted.0 * D2) * 3.2. temp3 = -temp2 * 2.D1) * 3.0 .0 * D2 * exp2 . .32 temp1 = -4. ddZdD += fx[26] * temp .

. temp -= (5.0 * D5 * exp2 .0 .0 * exp2 . ddZdD += fx[43] * temp .4.0 * D6 * exp2 + (5. temp = temp1 + temp2 + temp3 .0 . Distributed by Thomson Reuters (Scientific) LLC.2. // n = 45 temp = 25.2.com. temp3 = -(3. ddZdD += fx[39] * temp ..// n = 38. temp3 = -(4.0 .0 * D4) * 3.0 * D3 * exp4 . ddZdD += fx[34] * temp .4.0 * D4 * exp2 .0 * D2 * exp4 .44 temp = -16.2.0 * D2) * D6 * 2.0 * D2) * 2.0 * D3 . // n = 43.0 . ddZdD += fx[44] * temp .0 .0 .. ddZdD += fx[46] * temp .49 93 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. temp -= (4.0 * exp4 . under license from the American Gas Associatio // n = 35. temp2 = (4. www. ddZdD += fx[37] * temp .0 .0 * D6 * exp4 .2. ddZdD += fx[42] * temp .0 * D4 .0 * D5 * exp2 .0 * D4) * D7 * 4.4.0 * D7 * exp4 + (4. temp = temp1 + temp2 + temp3 . // n = 46. ddZdD += fx[36] * temp .37 temp1 = -16..0 * D4) * D6 * 4.0 * D2) * 5.42 temp1 = -4.. ddZdD += fx[40] * temp .0 * D3 * exp2 .39 temp = 16. ddZdD += fx[38] * temp . ddZdD += fx[41] * temp . ddZdD += fx[35] * temp . No further reproduction or networking is permitted.0 * D2) * 4. .techstreet. // n = 48..0 * D4) * 4.4.0 * exp4 .0 . temp2 = (3. ddZdD += fx[45] * temp .47 temp = -4. // n = 40.

0 * D2) * D7 * 2.0 * D2) * 8.0 .0 * D7 * exp2 + (6.2. temp -= (8. // n = 51 temp = -4. ddZdD += fx[52] * temp .0 * D5 * exp2 .0 * D7 * exp1 . temp -= (8.0 . ddZdD += fx[47] * temp .0 * D8 * exp2 + (7. // n = 53 temp = -4.2.0 * D4) * 5.0 .0 . ddZdD += fx[53] * temp .2. No further reproduction or networking is permitted. under license from the American Gas Associatio temp = -16.0 * D6 .0 * D2) * 7.2.0 * D4) * D8 * 4.0 * D8 * exp1 + (8.D1) * D8 * exp1 .0 * exp2 . // n = 57.0 .0 * D2) * 6.0 * D8 * exp4 + (5.0 * D6 * exp2 . // n = 55.0 * D1 * D8 * exp2 + (8.techstreet.0 .2.4.0 .0 .4. ddZdD *= dKp3 .0 * D2 * D8 * exp2 + (9..0 * D2) * D8 * 2. ddZdD += fx[51] * temp . // n = 54 temp = -1. ddZdD += fx[57] * temp . Distributed by Thomson Reuters (Scientific) LLC. temp -= (9.0 * exp2 .0 .0 * D2) * D2 * D8 * 2.0 * D4 * exp4 . www. // n = 52 temp = 49.56 temp = -4.0 * D8 * exp2 .2.0 * exp4 .0 * D5 .0 .2.0 . ddZdD += fx[49] * temp . .0 * exp2 . temp -= (6.D1) * 8.// n = 50 temp = 36. ddZdD += fx[56] * temp .0 * D2) * D8 * 2. ddZdD += fx[50] * temp . ddZdD += fx[54] * temp .com.. temp -= (7.2. ddZdD += fx[48] * temp .0 * D1 * exp2 .0 .0 * D2) * 9.58 temp = -4. 94 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 * D7 * exp2 . ddZdD += fx[55] * temp . temp -= (5.

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

const double dMWair = 28.void Detail::relativedensity(AGA10STRUCT *ptAGA10) { double dBX.12527 + 5. } // calculate ideal gas and real gas relative densities ptAGA10->dRD_Ideal = ptAGA10->dMrx / dMWair .com. // calculate second virial coefficient for air dBX = -0. dZa . No further reproduction or networking is permitted.96256 .6.0 + (dBX * dP) / (RGASKJ * ptAGA10->dTb) . // Detail::relativedensity() 96 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. ptAGA10->dRD_Real = ptAGA10->dRD_Ideal * (dZa / ptAGA10->dZb) . Distributed by Thomson Reuters (Scientific) LLC. www.91e-4 * ptAGA10->dTb . // calculate compressibility of air dZa = 1.62e-7 * ptAGA10->dTb * ptAGA10->dTb . 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 : **************************************************************************/ .techstreet.

#ifndef _THERM_H #define _THERM_H #include "aga10. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ . double dMrxold . kJ/kg.h" #include "detail.com. under license from the American Gas Associatio /************************************************************************* * File : therm. double dTold . in kg/m3 // partial deriv of P wrt D // partial deriv of P wrt T // ideal gas specific entropy.11. No further reproduction or networking is permitted. double dRho . in Pascals // molar density.B. www. Detail *) . double dPdT .7 2002. // runs an object based on this class 97 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. in Kelvins // current pressure. double dSi . in moles/dm3 // mass density.K // temperature previously used // mixture molar mass previously used // private methods double CpiMolar(AGA10STRUCT *) . // current temperature.h * Description : Header file for class 'Therm' * See therm. double dD . double dPdD .techstreet.cpp for implementation of this class * Version : ver 1. double dP . Distributed by Thomson Reuters (Scientific) LLC. protected: public: Therm(void) . // default constructor // default destructor void Run(AGA10STRUCT *.h" class Therm { private: // member data double dT . ~Therm() .17 * Author : W.

www. double. 0. Detail *) . // set the number of points for quadrature const int GK_points = 5 . No further reproduction or networking is permitted. // estimates P & T.43339539412924719080. // real gas specific enthalpy double S(AGA10STRUCT *.21908636251598204295.14945134915058059038.com. Detail *) . 0. 0. // specific heat capacities + k_ideal + H + S double H(AGA10STRUCT *. given H & S } . 98 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. Detail *) .29552422471475286217. under license from the American Gas Associatio double Ho(AGA10STRUCT *) . double.// Other data used by Therm class // Roots and Weights for gaussian quadrature const long double GK_root[5] = { 0.97390652851717172008 }. Distributed by Thomson Reuters (Scientific) LLC. const long double GK_weight[5] = { 0.techstreet. // real gas specific entropy void HS_Mode(AGA10STRUCT *. 0. Detail *. . // ideal gas enthalpy double So(AGA10STRUCT *) .26926671930999634918. 0. // ideal gas entropy void CprCvrHS(AGA10STRUCT *.14887433898163121088. 0. 0.066671344308688137179 }.86506336668898451073.67940956829902440263. bool) . 0.

0.0. 7.38159.72.2255. -60. 869.4178. 22.402. 8. 100. 1481.02441.40013. coefC. 0. coefG.0.1601.320.0.95587. 100.0847.7675. 57. 90. 100. 0.39.0.0.4010}.0615}. 775.6225.23. -62.66789. 735.9417. 0. 6.847. coefF. coefE. 38.0.0.5366}.371.85539.0.0.7143. 80.27078. {-56072. 100.0.08380.73.801. 768.899.5. {-103353.-2. coefK } .19749}.0426}. 0. 100. 6.1.0. 0. 1.0.2164. 0.24989}. -7.0. 100.4. 69. 0. coefH. -44. 0. 90.0.88457.96237.32. 6.4. 40.0. 100.151. 0.0. {-91505. Distributed by Thomson Reuters (Scientific) LLC.91921.1. enthalpy and entropy const double ThermConstants[NUMBEROFCOMPONENTS[11] = .43.-22. www. { 20.0.0.68645.0.2028. 46. 30. 100.5014.-10.09.0. 4.95454. 3. 0.4556.749019.588.21752.564.792. 0. 0. 63.7621. 1156.0.0629.14.0. 802. -106. 100.0.-24. { 0. 500.645. 6.78.656.48.-680. {-72674.0. 43.49823}. 1718. 1740.22.6599.0. 100. 2572.4.518. 0. 9.0.56373.05. 984. {-5565. #endif 99 1 cal(IT) = 4. 1. 1. 1787. 0.8198}. 2. 0.0.2732. // enumerations for indexing of coefficients enum CoefficientList{ coefA = 0. 1154.98.0.0.0.45.44724.-11. 6. 55. 272.33458.94680. 0. {-133564. 4. 0. 2.96302.3819.6776}}.98. 17. 0.06.0.0.0.0. 433. 100. 752.com.58. 100. 100. 1019.5789. 74. {-10085. . 122. 1454.173.291318.0.0. 0.190.81.49. 100. 0.8143. 1669.34. 34. 100. 2. 100.0.4029. 100. 100.446.0.94821}. 1611. 2522. {-3497.55. 2.0.7307.14319. 100. 100. 100. coefI.-13.0.31595. 1037. -92. 47.60. -3. -138.7342.1341}.0.8.0.6941. 2197. 100.0587.205.78980. coefB.0.81381}. 100.-0. 100.0. {-37524. coefD.272892. 1654. 2.63. 1701.0. 2.5012.6598. 100.9680..85. 8. -24. 0. 6.0. {-13773. {-72387. 0. 37.001.0.5. 4.0. 7.-2. { 0.2.0. 100. 814. 7.562.0.-20. . 6.006}.0. -77. 786.05010. 8. 785. 111. 18. {-2753.0. 100.0.0.3410.2474}.51551}. 247.0.0.95854. 1541. 0. 21. 100.0. 100. 2584. {-83845. 500. 100. 26. {-109674.-530. 1020.0. 802.069. 0.0. 3. 0. -122.13290.53990.1840 J Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 559.846.15. 1070.2197}.{{-29776.23387}..738. 13.1840 .58.510. 2.0. 1102. 808.22. 69. 0. 9.3668. 0.56429.0.0.0..174.49. 1719.0. {-94982.0.2062. 0. 1792.6383. under license from the American Gas Associatio //equation constants for ideal gas heat capacity. 58.444}. 100.0. 0. 3674.0. // conversion constant for thermochemical calories to Joules: const double CalTH = 4. 0. 2. 100. 0. 6. coefJ. 843. 100. No further reproduction or networking is permitted. 24. 100. 0.198. 0.9680.0.98139.149}. 100. {-122599. 38. -46.0.0. 0. 5..5015. 0. 662.0.-0.096774.3861. 1646.443.9027.0164}.253. {-3495. 42. 80. 7.13.97183.1938}. 100.0. 813. 781.-0. 0.techstreet.

#include #include #include #include "aga10.h" <math. Ho(). No further reproduction or networking is permitted. coth(). } // Therm::Therm() 100 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.h> /************************************************************************** * Function : Therm::Therm() * Arguments : void * Returns : * Purpose : default constructor * Revisions : **************************************************************************/ Therm::Therm(void) { // initialize 3 history-sensitive variables dSi = 0.techstreet.0 .11.com. S() * Version: ver 1. entropy. CpiMolar().B.h" "therm.7 2002. * CprCvrHS().17 * Author: W.h" "detail. dTold = 0. dMrxold = 0. sound speed * Contains the functions: * Therm(). under license from the American Gas Associatio /************************************************************************* * File: therm. HS_Mode(). H(). Distributed by Thomson Reuters (Scientific) LLC.0 . * heat capacity.0 . ~Therm(). www.cpp * Description: Contains thermodynamic functions for the meter object. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ . Run(). So(). enthalpy.

just a utility for this * file. No further reproduction or networking is permitted. under license from the American Gas Associatio /************************************************************************** * Function : Therm::~Therm() * Arguments : * Returns : default destructor * Purpose : void * Revisions : **************************************************************************/ .com. Distributed by Thomson Reuters (Scientific) LLC. used in Ho calculations * Revisions : * Notes : Not a Therm object class member. } // coth() 101 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.Therm::~Therm() { } // Therm::~Therm() /************************************************************************** * Function : coth() * Arguments : double * Returns : double * Purpose : calculate hyperbolic cotangent. The C++ language has no intrinsic support for * hyperbolic cotangent **************************************************************************/ double coth (double x) { return cosh(x)/sinh(x). www.techstreet.

com. Detail * * Returns : void * Purpose : overall execution control. which is SOS^2 c = (x / y) * z . cp. www. top level math for SOS and k * Revisions : **************************************************************************/ . // speed of sound ptAGA10->dSOS = sqrt(c) . y. No further reproduction or networking is permitted. // 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. Distributed by Thomson Reuters (Scientific) LLC. z = ptAGA10->dZf + ptAGA10->dDf * ptD->ddZdD . under license from the American Gas Associatio /************************************************************************** * Function : Therm::Run() * Arguments : AGA10STRUCT *. z . specific enthalpy and entropy CprCvrHS(ptAGA10.techstreet. // calculate c. return . 102 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. for clarity and ease of debugging x = ptAGA10->dk * RGAS * 1000.void Therm::Run(AGA10STRUCT *ptAGA10. // solve c in three steps. // ratio of real gas specific heats ptAGA10->dk = ptAGA10->dCp / ptAGA10->dCv . // calculate the real gas isentropic exponent // using expression functionally equivalent to Equation 3. x. y = ptAGA10->dMrx .2 ptAGA10->dKappa = (c * ptAGA10->dRhof) / ptAGA10->dPf .0 * ptAGA10->dTf . Detail *ptD) { // local variables double c. ptD) .

double Dx. HT. double DT. int i . McFall * Notes : For continuity.0 . Lee. the original constants and eqn's have been * retained. use intermediate variable T T = ptAGA10->dTf . // calculate heat capacity for each component for (i= 0. i< NUMBEROFCOMPONENTS.com.0 . Distributed by Thomson Reuters (Scientific) LLC.techstreet. . Hx. JT . // DT FT HT calculate species intermediate = ThermConstants[i][coefD] / T = ThermConstants[i][coefF] / T = ThermConstants[i][coefH] / T terms . * Revisions : **************************************************************************/ double Therm::CpiMolar(AGA10STRUCT *ptAGA10) { double Cp = 0.// Therm::Run() /************************************************************************** * Function : Therm::CpiMolar() * Arguments : AGA10STRUCT * * Returns : double * Purpose : Calculate constant pressure ideal gas molar heat capacity * in (J/mol-K). 103 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. under license from the American Gas Associatio } . . double Cpx . FT. Conversion from thermochemical calories(th) to * Joules is applied after the primary calculations are complete. double T . No further reproduction or networking is permitted. i++) { // skip species whose concentration is zero if (ptAGA10->adMixture[i] <= 0. // initialize Cp of species to zero Cpx = 0. // to maximize readability of this section. Fx.0) continue . www. applying eqns from Aly. Jx .

// Therm::CpiMolar() 104 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.com. // add this contribution to the sum Cp += Cpx .// Dx Fx Hx Jx use intermediate terms to avoid redundant calcs = DT/sinh(DT) . } // convert from cal(th)/mol-K to J/mol-K Cp *= CalTH . 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 .techstreet. . } return Cp . Distributed by Thomson Reuters (Scientific) LLC. . . = HT/sinh(HT) . = FT/cosh(FT) . = JT/cosh(JT) . // use current mole fraction to weight the contribution Cpx *= ptAGA10->adMixture[i]. under license from the American Gas Associatio JT = ThermConstants[i][coefJ] / T . No further reproduction or networking is permitted. www. .

tanhFT = tanh(FT) .0 . double Hx . the original constants and eqn's have been * retained. Conversion from thermochemical calories(th) to * Joules is applied after the primary calculations are complete. double cothDT. www. // DT FT HT JT calculate species intermediate = ThermConstants[i][coefD] / T = ThermConstants[i][coefF] / T = ThermConstants[i][coefH] / T = ThermConstants[i][coefJ] / T terms . use intermediate variable T T = ptAGA10->dTf . for (i= 0.0 . cothDT = coth(DT) . i++) { // skip species whose concentration is zero if (ptAGA10->adMixture[i] <= 0. JT . * Revisions : **************************************************************************/ . FT. int i .double Therm::Ho(AGA10STRUCT *ptAGA10) { double H = 0.com. Hx = 0. 105 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. i< NUMBEROFCOMPONENTS. tanhJT = tanh(JT) . 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. Hx += ThermConstants[i][coefA] .techstreet. tanhFT. // to maximize readability of this section. . cothHT = coth(HT) . . double T . tanhJT .0) continue . No further reproduction or networking is permitted. cothHT. . double DT. Distributed by Thomson Reuters (Scientific) LLC. HT.

No further reproduction or networking is permitted.+= += -= += -= ThermConstants[i][coefB] ThermConstants[i][coefC] ThermConstants[i][coefE] ThermConstants[i][coefG] ThermConstants[i][coefI] * * * * * T . tanhFT. } // return in J/kg return H * 1. } // add this contribution to the sum H += Hx . ThermConstants[i][coefD] ThermConstants[i][coefF] ThermConstants[i][coefH] ThermConstants[i][coefJ] // use current mole fraction to weight the contribution Hx *= ptAGA10->adMixture[i]. Distributed by Thomson Reuters (Scientific) LLC. cothHT. Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // convert from kJ/kg-mol to J/kg H /= ptAGA10->dMrx .techstreet.com. // convert from cal(th)/g-mol to kJ/kg-mol H *= CalTH . tanhJT. www. under license from the American Gas Associatio Hx Hx Hx Hx Hx . // Therm::Ho() 106 * * * * cothDT.e3.

com. cothHT. 107 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. FT. double Smixing = 0.0 . use intermediate variable T T = ptAGA10->dTf . the original constants and eqn's have been * retained. // DT FT HT JT calculate species intermediate = ThermConstants[i][coefD] / T = ThermConstants[i][coefF] / T = ThermConstants[i][coefH] / T = ThermConstants[i][coefJ] / T terms .techstreet. i++) { // skip species whose concentration is zero if (ptAGA10->adMixture[i] <= 0. JT .0 . www. int i . sinhHT. * Revisions : **************************************************************************/ . coshFT. tanhFT = tanh(FT) . for (i= 0. double Sx . cothDT = coth(DT) .0 . . Distributed by Thomson Reuters (Scientific) LLC. // to improve readability of this section. Conversion from thermochemical calories(th) to * Joules is applied after the primary calculations are complete. Sx = 0. coshJT . No further reproduction or networking is permitted. . double sinhDT. double T . double cothDT. * The entropy of mixing is also calculated in this function. double DT. . i< NUMBEROFCOMPONENTS.double Therm::So(AGA10STRUCT *ptAGA10) { double S = 0. tanhJT . HT. 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. tanhFT.0) continue .

. // convert from kJ/kg mol-K to kJ/kg-K S /= ptAGA10->dMrx . // Therm::So() 108 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.techstreet.sinhDT coshFT sinhHT coshJT Sx Sx Sx Sx Sx Sx += += += -= += -= = = = = sinh(DT) cosh(FT) sinh(HT) cosh(JT) . No further reproduction or networking is permitted. } // add this contribution to the sum S += Sx .e3. } // return in J/kg-K return S * 1. // add the entropy of mixing S += Smixing . . . } Smixing *= -RGAS . (DT * cothDT (FT * tanhFT (HT * cothHT (JT * tanhJT - log(sinhDT)) log(coshFT)) log(sinhHT)) log(coshJT)) . * * * * * log(T) . www. // use current mole fraction to weight the contribution Sx *= ptAGA10->adMixture[i]. tanhJT = tanh(JT) . . // convert cal(th)/mol-K basis to to kJ/kg mol-K S *= CalTH . i< NUMBEROFCOMPONENTS. Distributed by Thomson Reuters (Scientific) LLC. i++) { if (ptAGA10->adMixture[i]) Smixing += ptAGA10->adMixture[i] * log(ptAGA10->adMixture[i]) . under license from the American Gas Associatio cothHT = coth(HT) . . // calculate entropy of mixing for (i= 0. . .com. ThermConstants[i][coefK] ThermConstants[i][coefB] ThermConstants[i][coefC] ThermConstants[i][coefE] ThermConstants[i][coefG] ThermConstants[i][coefI] .

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

0 . // get Z at D ptD->zdetail(x) .void Therm::CprCvrHS(AGA10STRUCT *ptAGA10. No further reproduction or networking is permitted. double a. double Cp. // calculate ideal gas specific heat capacity at constant pressure in J/kgK ptAGA10->dCpi = (Cp * 1000. Detail * * Returns : void * Purpose : reasonably efficient group calculation of Cp. x .0 + GK_root[i]) / 2. i++) { // set calculation point at + abscissa x = ptAGA10->dDf * (1. Distributed by Thomson Reuters (Scientific) LLC.com. i < GK_points. b. H and S * Revisions : **************************************************************************/ . Si . // find ideal gas entropy Si = So(ptAGA10) . int i . Cvr. // find ideal gas enthalpy ptAGA10->dHo = Ho(ptAGA10) . Sinc = 0.techstreet. double Sinc . Hinc = 0. // find ideal gas Cp Cp = CpiMolar(ptAGA10) .0) / ptAGA10->dMrx . 110 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0 . www. applying Gauss-Kronrod quadrature for ( i= 0. // integrate partial derivatives from D=0 to D=D. Cpr . Cv. double Hinc . Detail *ptD) { double Cvinc.0 .0 . // initialize integrals to zero Cvinc = 0. under license from the American Gas Associatio /************************************************************************** * Function : Therm::CprCvrHS() * Arguments : AGA10STRUCT *.

} // gather contributions Hinc += GK_weight[i] * Cvinc += GK_weight[i] * Sinc += GK_weight[i] * at . applying weighting factor ptD->ddZdT / x .techstreet.1. Distributed by Thomson Reuters (Scientific) LLC. cancelling appropriate terms 111 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // calculate 1st and 2nd partial derivatives of Z wrt T ptD->dZdT(x) .abscissa. // calculate dPdD. (2. at T dPdD = RGAS * ptAGA10->dTf * b . // get Z at D ptD->zdetail(x) . ptD->d2ZdT2(x) . // complete Cv molar Cvr = Cp .GK_root[i]) / 2.0) / x . ptD->d2ZdT2(x) .0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x .0 + ptAGA10->dTf * Cvinc * 0. // intermediate values for Cp.RGAS * (1. ptD->d2ZdT2(ptAGA10->dDf) . ptD->dZdT(ptAGA10->dDf) . // set calculation point at . www. at D dPdT = RGAS * ptAGA10->dDf * a . containing 2 partial derivatives a =(ptAGA10->dZf + ptAGA10->dTf * ptD->ddZdT) .0) / x . No further reproduction or networking is permitted. the partial derivative of P wrt D.5 * ptAGA10->dDf) .0 . // return Z and partial derivatives to full molar density ptD->zdetail(ptAGA10->dDf) . (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT . . // calculate dPdT.abscissa x = ptAGA10->dDf * (1. // equation completing molar Cp.0 .1. (2. under license from the American Gas Associatio ptD->dZdT(x) . b =(ptAGA10->dZf + ptAGA10->dDf * ptD->ddZdD) . applying weighting factor ptD->ddZdT / x .0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x .// gather contributions Hinc += GK_weight[i] * Cvinc += GK_weight[i] * Sinc += GK_weight[i] * at + abscissa.com. (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT . the partial derivative of P wrt T.

com.// change from molar to mass basis Cpr /= ptAGA10->dMrx . // calculate specific entropy ptAGA10->dS = Si – 1000. www.0 . Cvr /= ptAGA10->dMrx . Distributed by Thomson Reuters (Scientific) LLC. // Therm::CprCvrHS() 112 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.1.0 * RGAS * (log(ptAGA10->dPf/101325.ptAGA10->dTf * Hinc * 0. . // convert from joules/kgK to kilojoules/kgK // calculate specific enthalpy ptAGA10->dH = ptAGA10->dHo + 1000. } return . // write to the data stucture ptAGA10->dCv = Cvr * 1000.5 * ptAGA10->dDf) / ptAGA10->dMrx .0) . under license from the American Gas Associatio Cpr = Cvr + RGAS * ((a * a)/b) .0 . No further reproduction or networking is permitted.log(ptAGA10->dZf) + Sinc * 0.0 .techstreet.0 * RGAS * ptAGA10->dTf * (ptAGA10->dZf .5 * ptAGA10->dDf) / ptAGA10->dMrx . ptAGA10->dCp = Cpr * 1000.

under license from the American Gas Associatio /************************************************************************** * Function : Therm::HS_Mode() * Arguments : AGA10STRUCT *.5 . tmax . tmin. pmin = px * 0. set the input parm * bGuess to false. No further reproduction or networking is permitted. www. j .This function has a role in the * calculation of C*. double h0. The initial guess allows the search function to be more * aggressive and. double S. two approaches are supported by this example. typically. px. * If. Distributed by Thomson Reuters (Scientific) LLC. tmax = t1 * 1. pmax = px * 2. // s0and h0 are our real gas reference points s0 = S . double delta1. bool bGuess) { double s0. Detail *ptD. you have a basis for guessing P & T (plenum conditions of a * critical flow nozzle. double tolerance = 0. for example) set P & T via AGA10STRUCT and set * bGuess = true. 113 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.void Therm::HS_Mode(AGA10STRUCT *ptAGA10. h1. t1.com. s2. * * Revisions : **************************************************************************/ . thus specifying a conservative search approach. h2. faster. double H. however. pmin. double. double.001 . p1. p2. pmax . * Solution based on a doubly-nested trial & error algorithm and Newton's * method. * * For illustrative purpose. s1. * with or without prior estimates. // calling function specifies whether search parameters are supplied thru ptAGA10 or unknown if (bGuess) { t1 = ptAGA10->dTf . h0 = H . p0. px = ptAGA10->dPf .0 . t2. delta2 . * If you are starting without advance knowledge of P & T.1 . Detail *. bool * Returns : void * Purpose : Calculates a pressure & temperature from known enthalpy & entropy. t0.techstreet.// convergence tolerance (used for both H and S searches) int i.

techstreet.0 . under license from the American Gas Associatio } else { . = 10000. // close enough? 114 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. j < MAX_NUM_OF_ITERATIONS. searching for T & P // run the calculation with initial guesses ptD->Run(ptAGA10) . ptD) .s0. 1013250. s2 = this->S(ptAGA10. = T_MAX . www. // 10 atmospheres // 10 kPa // set the temperature differential t2 = t1 + 10. // reset one bracket p2 = px * 0. = P_MAX .s0 . j++) { ptAGA10->dPf = p2 . p1 = px .0 .s2) / s0 . ptD->Run(ptAGA10) . No further reproduction or networking is permitted.h0. Pf h1 = this->H(ptAGA10. ptD) . i++) { ptAGA10->dTf = t2 . /////////////////////////////////////////// // begin double trial-and-error.67 . // outer loop: search for a t2 which will satisfy constant enthalpy for ( i= 0.1x the upper bracket ptAGA10->dPf = p1 . // h1 is difference between h given and h@Tf. // inside loop: search for a p2 which will satisfy constant entropy for (j= 0.} tmin = t1 * 0. ptD->Run(ptAGA10) . = T_MIN . s1 = this->S(ptAGA10. // calculate our proportional change delta2 = fabs(s1 . generic limits t1 = px = pmax pmin tmax tmin 273. i < MAX_NUM_OF_ITERATIONS.1 .0 . Distributed by Thomson Reuters (Scientific) LLC. ptD) .com.// set other bracket to 0.15 . // use arbitrary.

www. ptD) . No further reproduction or networking is permitted. // close enough? if (delta1 < tolerance && i > 0) break . h2 = this->H(ptAGA10. ptAGA10->dTf = t2 . // check if we've created an unrealistic temperature if (t2 >= tmax ) t2 = tmax .h0 .h0 . // calc enthalpy at guessed P & current iter T h2 = this->H(ptAGA10.} // if // p1 s1 (delta2 < tolerance) break . // revise our estimate to t2 t0 = t2 .s1) . = (p1 * s2 .p2 * s1) / (s2 .h1) . ptD->Run(ptAGA10) . } // check for failure to converge if (j >= MAX_NUM_OF_ITERATIONS) ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED . check for negative pressure and clamp to pmin for safety (p2 <= pmin) p2 = pmin . revise our estimate to p2 = p2 . under license from the American Gas Associatio if // p0 p2 // if { . // revise t2. // calculate our proportional change delta1 = fabs(h1 . 115 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. if necessary if (t2 <= tmin ) { t2 = t0 + 10.techstreet.t2 * h1) / (h2 .h2) / h0 . = s2 .com. t2 = (t1 * h2 . check if we've created an unrealistic pressure (p2 >= pmax ) p2 = pmax . ptD) .0 . Distributed by Thomson Reuters (Scientific) LLC. swap values = p0 .

i++) { // calculate 1st and 2nd partial derivatives of Z wrt T x = ptAGA10->dDf * (1.0 .t1 = t0 .com. ptD->d2ZdT2(x) . ptD->dZdT(x) . under license from the American Gas Associatio } .0 . Detail * * Returns : double * Purpose : real gas specific enthalpy * Revisions : **************************************************************************/ double Therm::H(AGA10STRUCT *ptAGA10. www. // find ideal gas enthalpy ptAGA10->dHo = Ho(ptAGA10) . applying Gauss-Kronrod quadrature for ( i= 0. // integrate partial derivatives from D=0 to D=D. 116 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. Hinc += GK_weight[i] * ptD->ddZdT / x . if (i == 10) break. No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC.0 + GK_root[i]) / 2. double x . // initialize integral Hinc = 0. ptD->zdetail(x) . Detail *ptD) { double Hinc . 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 *.techstreet. i < GK_points. int i .

0 . // calculate specific enthalpy ptAGA10->dH = ptAGA10->dHo + 1000.GK_root[i]) / 2. www. ptD->dZdT(x) . Distributed by Thomson Reuters (Scientific) LLC.0 . ptD->zdetail(x) . . under license from the American Gas Associatio x = ptAGA10->dDf * (1.techstreet. ptD->d2ZdT2(x) .5 * ptAGA10->dDf) / ptAGA10->dMrx .com.1. } return(ptAGA10->dH) .ptAGA10->dTf * Hinc * 0. ptD->zdetail(ptAGA10->dDf) . ptD->d2ZdT2(ptAGA10->dDf) .} Hinc += GK_weight[i] * ptD->ddZdT / x .0 . // 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. ptD->dZdT(ptAGA10->dDf) .0 * RGAS * ptAGA10->dTf * (ptAGA10->dZf .

int i .0 + GK_root[i]) / 2. www.techstreet.0 . under license from the American Gas Associatio /************************************************************************** * Function : Therm::S() * Arguments : AGA10STRUCT *. Detail *ptD) { double Sinc . } Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT . i++) { // calculate 1st and 2nd partial derivatives of Z wrt T x = ptAGA10->dDf * (1. ptD->zdetail(x) .0) / x . ptD->d2ZdT2(x) . ptD->d2ZdT2(ptAGA10->dDf) . applying Gauss-Kronrod quadrature for ( i= 0.0 . // reset Z and partial deivatives dZdT and d2ZdT2 ptD->zdetail(ptAGA10->dDf) .0 . x = ptAGA10->dDf * (1. ptD->d2ZdT2(x) .double Therm::S(AGA10STRUCT *ptAGA10.1. 118 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT .0 .1. i < GK_points.GK_root[i]) / 2. ptD->dZdT(x) . ptD->dZdT(x) . Detail * * Returns : double * Purpose : real gas specific entropy * Revisions : **************************************************************************/ . double x .com. if (i == 10) break. // initialize integral Sinc = 0. ptD->dZdT(ptAGA10->dDf) . // integrate partial derivatives from D=0 to D=D. ptD->zdetail(x) . Distributed by Thomson Reuters (Scientific) LLC.0) / x . No further reproduction or networking is permitted.

Distributed by Thomson Reuters (Scientific) LLC. } . No further reproduction or networking is permitted. } return(ptAGA10->dS) . www.techstreet.5 * ptAGA10->dDf) / ptAGA10->dMrx . // Therm::S() 119 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.// calculate specific entropy ptAGA10->dS = dSi .0 * RGAS * (log(ptAGA10->dPf/101325. dMrxold = ptAGA10->dMrx . but only if temperature or composition have changed if (ptAGA10->dTf != dTold || ptAGA10->dMrx != dMrxold) { dSi = So(ptAGA10) .com. dTold = ptAGA10->dTf .1000.0) . under license from the American Gas Associatio // find ideal gas entropy.log(ptAGA10->dZf) + Sinc * 0.

Distributed by Thomson Reuters (Scientific) LLC.7 2002.B. * Project : AGA10 DLL * Version : ver 1. DWORD fdwReason. PVOID pvReserved) { return TRUE .techstreet. } 120 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.dll * and is only required for Windows DLL creation.17 * Author : W.11.#include <windows. Peterson * Revisions: * Copyright (c) 2002 American Gas Association * **************************************************************************/ . No further reproduction or networking is permitted. www.h> /* win32 DLL startup code */ int WINAPI DLLMain(HINSTANCE hInst.cpp * Purpose : This file contains the startup code for aga10. under license from the American Gas Associatio /************************************************************************* * * File : entry.com.

File Description Version Author Revisions Copyright (c) : script1.com.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH.12. www.0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG 121 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.2. // #include "resource.S.B.7.2 2002. Peterson : 2002 American Gas Association //Microsoft Developer Studio generated resource script.0 PRODUCTVERSION 1.2. Distributed by Thomson Reuters (Scientific) LLC.techstreet. No further reproduction or networking is permitted. SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1.rc : resource script for aga10 dll : 1.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. under license from the American Gas Associatio // // // // // // .7. // #include "afxres.05 : W.7.

12. "aga10\0" VALUE "FileVersion". "2002.com. "aga10. "AGA10. 7.DLL\0" VALUE "ProductVersion". 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". "1. 1200 END END . Distributed by Thomson Reuters (Scientific) LLC. "1.#endif // !_MAC #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 122 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 2. "Copyright © 2002 American Gas Association\0" VALUE "LegalTrademarks". www. "\0" VALUE "OriginalFilename". 0x409. 0\0" VALUE "InternalName". "aga10\0" VALUE "LegalCopyright". No further reproduction or networking is permitted. "American Gas Association\0" VALUE "FileDescription".techstreet. "Post-Ballot Version\0" VALUE "CompanyName". 7. "\0" VALUE "ProductName". 2.05 Build\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation".dll\0" VALUE "PrivateBuild". 0\0" VALUE "SpecialBuild".

Distributed by Thomson Reuters (Scientific) LLC.h\0" END . No further reproduction or networking is permitted.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif // English (U. under license from the American Gas Associatio 1 TEXTINCLUDE DISCARDABLE BEGIN "resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED 123 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.techstreet.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource.2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.com. www.

com.org.aga. No further reproduction or networking is permitted. 124 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.techstreet. Distributed by Thomson Reuters (Scientific) LLC. A2. www.The code begins on the following page.2 File Group 2 — Example Windows Application Code . www. under license from the American Gas Association (AGA).

cpp * Version : 1.h * Description : function prototypes and defines for aga10win.com. www. under license from the American Gas Associatio /************************************************************************* * File : aga10win. No further reproduction or networking is permitted. Peterson * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ .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.h> #include <commdlg.17 * Author : W.techstreet.11.7 2002.#ifndef _AGA10WIN_H #define _AGA10WIN_H #include <windows. Distributed by Thomson Reuters (Scientific) LLC.B.

Distributed by Thomson Reuters (Scientific) LLC.com.techstreet. www.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. 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 .

void EnthalpyDlgHelp(HWND) . UINT. BOOL FileSaveDlg (HWND. PSTR. void PressureDlgHelp(HWND) . void FileInitialize (HWND) . under license from the American Gas Associatio #define #define #define #define #define #define #define #define #define #define #define #define #define #define . void DensityDlgHelp(HWND) . void SOSDlgHelp(HWND) . www. BOOL FileOpenDlg (HWND.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. LPARAM) . PSTR) . #endif 127 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.com. PSTR) . No further reproduction or networking is permitted. Distributed by Thomson Reuters (Scientific) LLC. PSTR.techstreet. void EntropyDlgHelp(HWND) . void TemperatureDlgHelp(HWND) . WPARAM.

long int lPb_unit . /* unit of measure for flowing pressure */ long int lTb_unit . www. static char szBuffer[FIELD40] . Peterson * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ . No further reproduction or networking is permitted. */ */ /* declare one application instance */ HINSTANCE hInst .h" /* create pointer to a data structure for exchanging data with aga10. PSTR.11. char szTitleName[_MAX_FNAME + _MAX_EXT] .0 . /* unit of measure for base temperature */ long int lTf_unit .h bool FileRead(HWND. /* global variables for strings. AGA10STRUCT *) . /* unit of measure for base pressure */ long int lPf_unit .techstreet. filenames. under license from the American Gas Associatio /************************************************************************* * File : aga10win.B.7 2002. 128 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. /* unit of measure for density at base conditions */ long int lRhof_unit . /* unit of measure for flowing temperature */ long int lRhob_unit . /* unit of measure for specific enthalpy */ long int lEntropy_unit . etc static char szAppName[] = "aga10win" .17 * Author : W.dll * Supports Windows dialog box and file operations * Version : 1. bool FileWrite(HWND. /* global variables for units of measure and critical flow coefficient C* */ double total = 0. AGA10STRUCT *) .dll static AGA10STRUCT *A10 .com. /* unit of measure for density at flowing conditions */ long int lSOS_unit .#include "aga10win. AGA10STRUCT *). Distributed by Thomson Reuters (Scientific) LLC.h" #include "aga10. char szFileName[_MAX_PATH] . /* unit of measure for specific entropy */ // prototypes for support functions not prototyped in aga10win. /* unit of measure for speed of sound */ long int lEnthalpy_unit . PSTR. void ReadInputs(HWND.cpp * Description : Simple Win32 program demonstrating use of aga10.

www. wndclass. WNDCLASSEX wndclass . AGA10STRUCT *) . "aga10win". wndclass. wndclass. PSTR szCmdLine. /* create a dialog box */ hWnd = CreateDialog (hInstance. /* set window class properties */ wndclass.hIconSm = LoadIcon (hInstance. wndclass. PSTR. int iCmdShow) { HWND hWnd . wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1) . /* start the application's message pump */ 129 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. HINSTANCE.com. AGA10STRUCT *) . void WriteOutputs(HWND. wndclass. under license from the American Gas Associatio void WriteInputs(HWND. wndclass.cbSize = sizeof (wndclass) . MSG msg .techstreet.hIcon = LoadIcon (hInstance.hCursor = LoadCursor (NULL. void SetDefaults(AGA10STRUCT *) . 0.cbClsExtra = 0 . szAppName) .style = CS_HREDRAW | CS_VREDRAW. Distributed by Thomson Reuters (Scientific) LLC. wndclass. /* register the class */ RegisterClassEx (&wndclass) . wndclass. int * Returns : int * Purpose : Every Windows application has a WinMain() * Revisions : **************************************************************************/ int WINAPI WinMain (HINSTANCE hInstance. wndclass. wndclass. .lpfnWndProc = WndProc .hbrBackground = (HBRUSH) (COLOR_BTNFACE+1) . NULL) .cbWndExtra = DLGWINDOWEXTRA . szAppName) . IDC_ARROW) . No further reproduction or networking is permitted. HINSTANCE hPrevInstance./************************************************************************** * Function : WinMain() * Arguments : HINSTANCE.lpszClassName = szAppName .hInstance = hInstance .

LPARAM lParam) { int i = 0 . DispatchMessage(&msg) . double temp . } return msg. 0. /* initialize calculation library */ AGA10_Init() .techstreet.com. 0)) { TranslateMessage(&msg) ./************************************************************************** * Function : WndProc() * Arguments : HWND. /* initialize file data */ FileInitialize (hwnd) . /* set the defaults for this application */ SetDefaults(A10) .wParam . 130 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. . UINT. /* create an object at the pointer we have already defined */ if (NULL == (A10 = new AGA10STRUCT)) return TRUE . WPARAM. www. UINT iMsg. switch (iMsg) { case WM_CREATE : /* get application instance */ hInst = ((LPCREATESTRUCT) lParam)->hInstance . WPARAM wParam. under license from the American Gas Associatio } while (GetMessage (&msg. Distributed by Thomson Reuters (Scientific) LLC. No further reproduction or networking is permitted. LPARAM * Returns : LRESULT * Purpose : One and only window process for this app * Revisions : **************************************************************************/ LRESULT CALLBACK WndProc (HWND hwnd. return FALSE . NULL.

szAppName. A10) . under license from the American Gas Associatio case WM_COMMAND : /* refresh the input data. SetDlgItemText (hwnd.". triggered by focus change */ if (lParam && HIWORD (wParam) == EN_KILLFOCUS) { ReadInputs(hwnd.9999 || temp > 1. A10) .") . Distributed by Thomson Reuters (Scientific) LLC. IDC_LSTATUS. lstrcpy(szBuffer. Pf out of range.0001) { MessageBox (hwnd.0 . +/. } 131 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. if (temp < 0. for (i = 0 . SetDlgItemText (hwnd.com. // ensure the compositions adds up before proceeding // find the current sum of fractions temp = 0. "Error. WriteInputs(hwnd. return FALSE . szBuffer) . "Error. IDC_LSTATUS. MB_OK | MB_ICONERROR) ."Error. Pf out of range. szBuffer) . szAppName. } . MB_OK | MB_ICONERROR) . lstrcpy(szBuffer. i++) temp += A10->adMixture[i] . i < NUMBEROFCOMPONENTS . "Press Calculate") . szBuffer) .0. A10) . lstrcpy(szBuffer. Composition <> 100%. Composition must total 100%. No further reproduction or networking is permitted. } // ensure the pressure is acceptable before proceeding if (A10->dPf < P_MIN || A10->dPf > P_MAX) { MessageBox (hwnd./* decode WM_COMMAND messages */ switch (LOWORD (wParam)) { case IDOK : /* refresh input fields */ ReadInputs(hwnd.") .01%". return FALSE . return FALSE ."Error.techstreet. www. IDC_LSTATUS. WriteInputs(hwnd. SetDlgItemText (hwnd. A10) .

". // find the current sum of fractions for (i = 0 ."Error.0 . szAppName. i++) A10->adMixture[i] = 0. 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. lstrcpy(szBuffer. return FALSE . case IDC_CLEAR : /* zero out the composition and then display it */ for (i = 0 .0) . szBuffer) . case IDC_NORMALIZE : // normalize the composition to equal 1.0) A10->adMixture[i] /= temp .0 . 132 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // write the adjusted values to the screen WriteInputs(hwnd. i++) if (A10->adMixture[i] > 0. "Error.0000 ReadInputs(hwnd. temp = 0. A10) . IDC_LSTATUS. i < NUMBEROFCOMPONENTS . A10) .com. return FALSE . SetDlgItemText (hwnd. MB_OK | MB_ICONERROR) ./* indicate that a calculation has begun */ lstrcpy(szBuffer.techstreet. A10) . i < NUMBEROFCOMPONENTS . A10) . Tf out of range. // adjust each non-zero entry by the required proportion for (i = 0 . SetDlgItemText (hwnd. return FALSE . WriteInputs(hwnd. Tf out of range. */ /* write the outputs to the dialog box */ WriteOutputs(hwnd.") . www. IDC_LSTATUS. szBuffer) . i < NUMBEROFCOMPONENTS . i++) temp += A10->adMixture[i] . } . Distributed by Thomson Reuters (Scientific) LLC. No further reproduction or networking is permitted. return FALSE . 0. "Calculation In Progress") . /* run the sound speed AND C* calculation Crit(A10.

return FALSE . IDOK. // send a message back to this proc. return FALSE . under license from the American Gas Associatio case IDCANCEL : /* start tear-down process */ SendMessage(hwnd. szFileName. WM_COMMAND. IDOK. WM_CLOSE. szTitleName.case IDRETRY : // reset the defaults SetDefaults(A10) .0L) . requesting a calculation SendMessage(hwnd."Could not read file. sizeof (szTitleName)) . szTitleName. Distributed by Thomson Reuters (Scientific) LLC. A10) . No further reproduction or networking is permitted. WM_COMMAND. case CM_FILEOPEN : // standard Windows file operations GetFileTitle (szFileName. requesting a calculation SendMessage(hwnd.techstreet. A10) . A10)) { MessageBox(hwnd. // Write the new values to the window WriteInputs(hwnd. szTitleName. // display the input data to the screen WriteInputs(hwnd. if (FileOpenDlg (hwnd. } } else return FALSE . MB_OK | MB_ICONSTOP) . 0. case CM_FILESAVE : // standard Windows file operations GetFileTitle (szFileName. szFileName. www. szTitleName)) { if (!FileRead (hwnd. . if (szFileName[0]) 133 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.0L) .com.0L) . // send a message back to this proc. return FALSE . sizeof (szTitleName)) .".

} return FALSE . szTitleName.exe and AGA10.techstreet. under license from the American Gas Associatio { . szFileName. No further reproduction or networking is permitted. 2002". A10)) { return 1 .dll (c) American Gas Association.com. A10)) { return TRUE . szTitleName. MB_OK | MB_ICONSTOP) . } } return FALSE ."Could not write file."Could not write file.". } else { MessageBox(hwnd. return FALSE . szFileName. www.". sizeof (szTitleName)) . case WM_CLOSE : 134 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. "AGA10win. } else { MessageBox(hwnd. MB_OK | MB_ICONSTOP) . szAppName. szFileName. szTitleName)) { if (FileWrite (hwnd. if (FileSaveDlg (hwnd. // fall through case CM_FILESAVEAS : // standard Windows file operations GetFileTitle (szFileName.} if (FileWrite(hwnd. Distributed by Thomson Reuters (Scientific) LLC. case CM_HELPABOUT : MessageBox (hwnd. szTitleName. } return FALSE . MB_OK | MB_ICONINFORMATION) .

// remove the AGA10STRUCT object from memory delete A10 .techstreet. No further reproduction or networking is permitted. return FALSE . } } return DefWindowProc (hwnd. under license from the American Gas Associatio /* un-initialize the calculation library */ AGA10_UnInit() . 135 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.com. case WM_DESTROY : /* final message exhange with Windows during shut-down */ PostQuitMessage (0) . . iMsg. return FALSE . Distributed by Thomson Reuters (Scientific) LLC. /* request Windows to terminate the app */ DestroyWindow (hwnd) . www. lParam) . wParam.

lpstrFile = NULL . www. static char szExt[] = "sos" . ofn. ofn.lpstrFilter = szFilter . ofn.lpstrCustomFilter = NULL . . ofn.sos)\0*. No further reproduction or networking is permitted. ofn.nMaxFileTitle = _MAX_FNAME + _MAX_EXT .hwndOwner = hWnd .sos\0" .11.#include "aga10.nMaxFile = _MAX_PATH . // populate a OPENFILENAME structure ofn. under license from the American Gas Associatio /************************************************************************* * File : file. ofn.lStructSize = sizeof (OPENFILENAME) ofn. /************************************************************************** * Function : FileInitialize() * Arguments : HWND * Returns : void * Purpose : Prepares for Windows file access * Revisions : **************************************************************************/ void FileInitialize (HWND hWnd) { /* set file filters.lpstrFileTitle = NULL .cpp * Description : Supports file access to AGA10 functions * Author : W. ofn. Distributed by Thomson Reuters (Scientific) LLC. ofn. ofn.hInstance = NULL . assign the filename extension 'sos' for files of this type */ static char szFilter[] = "AGA10 Files (*.17 * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ .h" // declare a Windows-defined structure for file names static OPENFILENAME ofn . 136 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.techstreet.nMaxCustFilter = 0 . Peterson * Version : 1.nFilterIndex = 0 .7 2002.B.com.

NULL NULL .lpstrInitialDir ofn. PSTR pstrFileName. } return GetOpenFileName (&ofn) . PSTR pstrTitleName) { ofn.lpstrFileTitle = pstrTitleName .lpfnHook ofn.lCustData ofn. /************************************************************************** * Function : FileOpenDlg() * Arguments : HWND. . PSTR pstrFileName. 0 .lpstrFile = pstrFileName .Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT . PSTR * Returns : BOOL * Purpose : Access common controls for file-open operation * Revisions : **************************************************************************/ BOOL FileOpenDlg (HWND hWnd. /************************************************************************** * Function : FileSaveDlg() * Arguments : HWND.nFileExtension ofn.lpTemplateName . www. . 0 .com. ofn.Flags ofn.lpstrDefExt ofn. PSTR * Returns : BOOL * Purpose : Access common controls for file-save operation * Revisions : **************************************************************************/ BOOL FileSaveDlg (HWND hWnd. under license from the American Gas Associatio } ofn. PSTR. ofn. szExt 0L .= = = = = = = = = NULL NULL 0 . No further reproduction or networking is permitted. PSTR pstrTitleName) 137 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.techstreet. ofn.hwndOwner = hWnd . .lpstrTitle ofn. PSTR.nFileOffset ofn. . Distributed by Thomson Reuters (Scientific) LLC.

lpstrFile ofn.Flags = = = = hWnd .sos file into a AGA10STRUCT * Revisions : **************************************************************************/ bool FileRead(HWND hWnd. if it exists if (NULL == (file = fopen (pstrFileName. // open the file in binary mode. return false .com. www. OFN_OVERWRITEPROMPT return GetSaveFileName (&ofn) .lpstrFileTitle ofn. 1. AGA10STRUCT * Returns : bool * Purpose : Reads contents of a . . sizeof (AGA10STRUCT). /************************************************************************** * Function : FileRead() * Arguments : HWND. pstrFileName .techstreet. "rb"))) return false . pstrTitleName .} ofn. // read one (only) data structure if (fread(A10. PSTR pstrFileName. No further reproduction or networking is permitted. // set file position to beginning rewind(file) . } 138 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.hwndOwner ofn. return true. Distributed by Thomson Reuters (Scientific) LLC. under license from the American Gas Associatio { . PSTR. AGA10STRUCT *A10) { FILE *file . } else { // some problem encountered fclose (file) . file)) { fclose (file) .

// set file position to beginning rewind(file) . // open the file in binary mode. No further reproduction or networking is permitted./************************************************************************** * Function : FileWrite() * Arguments : HWND.com. 1. create if necessary if (NULL == (file = fopen (pstrFileName. return false . under license from the American Gas Associatio } . Distributed by Thomson Reuters (Scientific) LLC. PSTR. PSTR pstrFileName. sizeof (AGA10STRUCT). } else { // problem encountered. file)) { fclose (file) .techstreet. } 139 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. www.vos file * Revisions : **************************************************************************/ bool FileWrite(HWND hWnd. close and return 'false' fclose (file) . return true. } // write one (only) data structure if (fwrite(A10. AGA10STRUCT *A10) { FILE *file . "wb"))) return false . AGA10STRUCT * Returns : bool * Purpose : Writes contents of a AGA10STRUCT into a .

under license from the American Gas Associatio /************************************************************************* * File : dlghlp.techstreet. extern double total . extern long int lTb_unit .h" /* variables declared externally */ extern HINSTANCE hInst . /************************************************************************** * Function : WriteInputs() * Arguments : HWND * Returns : void * Purpose : Function for writing the input fields of the main window * Notes : Uses non-portable. extern long int lSOS_unit .11.7 2002. extern long int lRhof_unit . extern long int lTf_unit . www. extern long int lRhob_unit .cpp * Description : Helper functions for aga10win main dialog box * Version : 1. AGA10STRUCT *A10) { HWND hListBox. * Revisions : **************************************************************************/ void WriteInputs(HWND hDlg.h" #include "aga10. Distributed by Thomson Reuters (Scientific) LLC. No further reproduction or networking is permitted. 140 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. run-time library function _gcvt() * for converting strings to double precision floats. extern long int lPb_unit . extern long int lEnthalpy_unit . Peterson * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ . extern long int lPf_unit . /* a local buffer for text strings */ static char szBuffer[FIELD40] .com.17 * Author : W.#include "aga10win.B. extern long int lEntropy_unit .

case MEGAPASCAL : Pbx = A10->dPb * 1. break . /* calculate Pf in specified unit of measure */ switch (lPf_unit) { case KILOPASCAL : Pfx = A10->dPf * 1.0e-3 . } case PSI : Pfx = A10->dPf / 6894.75729 .75729 . Tfx .0e-3 . break . Distributed by Thomson Reuters (Scientific) LLC. Tbx.com. . case MEGAPASCAL : Pfx = A10->dPf * 1. break . double Pbx.15 . under license from the American Gas Associatio int i . Pfx. case FAHRENHEIT : 141 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only./* calculate Pb in specified unit of measure */ switch (lPb_unit) { case KILOPASCAL : Pbx = A10->dPb * 1. break .techstreet. } case PSI : Pbx = A10->dPb / 6894. No further reproduction or networking is permitted.273.0e-6 .0e-6 . break . /* calculate Tb in specified unit of measure */ switch (lTb_unit) { case CELSIUS : Tbx = A10->dTb . www.

IDC_PB.8 . under license from the American Gas Associatio Tbx = (A10->dTb * 1.459. case KELVIN : Tfx = A10->dTf . SetDlgItemText // Pf _gcvt (Pfx. Distributed by Thomson Reuters (Scientific) LLC. szBuffer). SetDlgItemText // Tf _gcvt (Tfx. . break . /* calculate Tf in specified unit of measure */ switch (lTf_unit) { case CELSIUS : Tfx = A10->dTf .techstreet.67 . 9.case KELVIN : Tbx = A10->dTb .459. szBuffer). break . 9. // Pb _gcvt (Pbx. No further reproduction or networking is permitted. szBuffer). break . szBuffer) . SetDlgItemText // Tb _gcvt (Tbx. www.com.67 . szBuffer) . IDC_PF. (hDlg. 9. IDC_TB. break .15 . } case RANKINE : Tfx = A10->dTf * 1. } case RANKINE : Tbx = A10->dTb * 1. 9.8) .8) . (hDlg. 142 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. (hDlg. case FAHRENHEIT : Tfx = (A10->dTf * 1. break .8 .273. szBuffer) . szBuffer).

0. szBuffer). szBuffer). SetDlgItemText (hDlg.143 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. SetDlgItemText (hDlg. szBuffer) . _gcvt (A10->adMixture[XiHe] * 100. szBuffer). _gcvt (A10->adMixture[XiNC10] * 100.0. szBuffer). SetDlgItemText (hDlg. 9. SetDlgItemText (hDlg. IDC_XIC2. _gcvt (A10->adMixture[XiN2] * 100. szBuffer) . IDC_XIIC4.0. _gcvt (A10->adMixture[XiNC5] * 100. szBuffer) .0. 9. szBuffer).0. _gcvt (A10->adMixture[XiH2S] * 100. IDC_XIN2. 9. SetDlgItemText (hDlg. 9. IDC_XIC3. _gcvt (A10->adMixture[XiNC6] * 100. IDC_XICO2. IDC_XINC9. szBuffer) . _gcvt (A10->adMixture[XiIC5] * 100. 9. 9.0.0. SetDlgItemText (hDlg. szBuffer). SetDlgItemText (hDlg. IDC_XICO. _gcvt (A10->adMixture[XiC2] * 100. szBuffer). 9. szBuffer) . SetDlgItemText (hDlg. szBuffer) . SetDlgItemText (hDlg.0. 9.com.0. szBuffer). IDC_XIH2S. _gcvt (A10->adMixture[XiNC7] * 100. IDC_TF. szBuffer). IDC_XINC4. szBuffer) . _gcvt (A10->adMixture[XiCO2] * 100. 9.0. szBuffer). _gcvt (A10->adMixture[XiH2] * 100. SetDlgItemText (hDlg. SetDlgItemText (hDlg. _gcvt (A10->adMixture[XiH2O] * 100. szBuffer) . szBuffer) . szBuffer) . IDC_XIC1. szBuffer) . SetDlgItemText (hDlg. szBuffer). szBuffer) . _gcvt (A10->adMixture[XiCO] * 100. szBuffer) . szBuffer). szBuffer) . IDC_XINC5. 9. szBuffer) . _gcvt (A10->adMixture[XiC3] * 100. _gcvt (A10->adMixture[XiNC8] * 100. SetDlgItemText (hDlg. szBuffer).0. _gcvt (A10->adMixture[XiNC9] * 100. IDC_XIO2. 9. szBuffer). szBuffer) . _gcvt (A10->adMixture[XiO2] * 100. IDC_XIH2O.0. _gcvt (A10->adMixture[XiNC4] * 100.0. No further reproduction or networking is permitted. szBuffer). . IDC_XINC6. szBuffer). // composition _gcvt (A10->adMixture[XiC1] * 100. 9. 9. szBuffer) . 9. IDC_XINC10. szBuffer). Distributed by Thomson Reuters (Scientific) LLC. szBuffer). szBuffer). 9. under license from the American Gas Associatio SetDlgItemText (hDlg.0.0.0. SetDlgItemText (hDlg. szBuffer). 9. IDC_XINC7. SetDlgItemText (hDlg. IDC_XIH2.0.techstreet.0. www. SetDlgItemText (hDlg. 9. SetDlgItemText (hDlg. szBuffer) . 9. SetDlgItemText (hDlg. IDC_XINC8. _gcvt (A10->adMixture[XiIC4] * 100. szBuffer) . SetDlgItemText (hDlg.0. 9. 9. IDC_XIIC5. szBuffer) .0.

0)) TemperatureDlgHelp(hListBox) . szBuffer) . LoadString(hInst. CB_SELECTSTRING. LoadString(hInst. 0. SendMessage(hListBox. i<NUMBEROFCOMPONENTS. IDC_PF_U) . total = 0. lTf_unit. szBuffer. total * 100.techstreet. -1. _gcvt (A10->adMixture[XiAr] * 100. CB_GETCOUNT. if (!SendMessage(hListBox. SendMessage(hListBox. hListBox = GetDlgItem(hDlg. IDC_PB_U) . lRhob_unit. szBuffer).0)) PressureDlgHelp(hListBox) . FIELD40) . hListBox = GetDlgItem(hDlg. hListBox = GetDlgItem(hDlg. CB_GETCOUNT. sprintf(szBuffer. 0. CB_GETCOUNT. 144 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 9. IDC_SOS_U) . FIELD40) . CB_SELECTSTRING. 0. LoadString(hInst.0)) DensityDlgHelp(hListBox) .(LONG)(LPSTR)szBuffer) .0)) SOSDlgHelp(hListBox) . CB_SELECTSTRING.6f". SendMessage(hListBox. CB_GETCOUNT. IDC_RHOB_U) . IDC_RHOF_U) . IDC_XIHE. IDC_XIAR.0)) PressureDlgHelp(hListBox) .com.(LONG)(LPSTR)szBuffer) . CB_GETCOUNT. 0. 0. lTb_unit. if (!SendMessage(hListBox. CB_SELECTSTRING. if (!SendMessage(hListBox. if (!SendMessage(hListBox.(LONG)(LPSTR)szBuffer) . IDC_TF_U) . FIELD40) . LoadString(hInst. CB_GETCOUNT. No further reproduction or networking is permitted. szBuffer. LoadString(hInst. hListBox = GetDlgItem(hDlg. FIELD40) . -1. 0. if (!SendMessage(hListBox. FIELD40) . IDC_TOTAL.(LONG)(LPSTR)szBuffer) . if (!SendMessage(hListBox. 0. "%6. i++) total += A10->adMixture[i]. -1.0) . SendMessage(hListBox. lSOS_unit. hListBox = GetDlgItem(hDlg. SendMessage(hListBox. SendMessage(hListBox. lPb_unit. FIELD40) .0 . SetDlgItemText (hDlg. szBuffer. CB_GETCOUNT. IDC_TB_U) .for (i=0. Distributed by Thomson Reuters (Scientific) LLC. LoadString(hInst. if (!SendMessage(hListBox.(LONG)(LPSTR)szBuffer) .0)) DensityDlgHelp(hListBox) . . szBuffer. lRhof_unit.0. szBuffer. FIELD40) . hListBox = GetDlgItem(hDlg. lPf_unit. CB_SELECTSTRING. szBuffer) . szBuffer.(LONG)(LPSTR)szBuffer) . LoadString(hInst. -1. SetDlgItemText(hDlg. under license from the American Gas Associatio SetDlgItemText (hDlg.0)) TemperatureDlgHelp(hListBox) . szBuffer. hListBox = GetDlgItem(hDlg. www. -1. -1. szBuffer) . CB_SELECTSTRING.

techstreet. CB_SELECTSTRING.(LONG)(LPSTR)szBuffer) . break . Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. IDC_ENTROPY_U) . szBuffer. CB_SELECTSTRING. 0. No further reproduction or networking is permitted. * Revisions : **************************************************************************/ void WriteOutputs(HWND hDlg. AGA10STRUCT *A10) { double Rhofx. if (!SendMessage(hListBox. IDC_ENTHALPY_U) . CB_SELECTSTRING.0) /* calculate SOS in specified unit of measure switch (lSOS_unit) { 145 */ . under license from the American Gas Associatio SendMessage(hListBox.com.0)) EnthalpyDlgHelp(hListBox) . LoadString(hInst. LoadString(hInst. } hListBox = GetDlgItem(hDlg. SOSx. if (!SendMessage(hListBox. CB_GETCOUNT. CB_GETCOUNT. } */ case LBMPERCUBICFOOT : Rhofx = (A10->dRhof / 0. run-time library function _gcvt() * for converting strings to double precision floats.(LONG)(LPSTR)szBuffer) . SendMessage(hListBox. -1.hListBox = GetDlgItem(hDlg.45359237) * pow(0. -1. FIELD40) . 3. . 0. Distributed by Thomson Reuters (Scientific) LLC.3048. szBuffer. lEnthalpy_unit. Enthalpyx. www. /************************************************************************** * Function : WriteInputs() * Arguments : HWND * Returns : void * Purpose : Function for writing the input fields of the main window * Notes : Uses non-portable. SendMessage(hListBox. lEntropy_unit. FIELD40) . Entropyx .0)) EntropyDlgHelp(hListBox) . -1. /* calculate Rhof in specified unit of measure switch (lRhof_unit) { case KGPERCUBICMETRE : Rhofx = A10->dRhof .(LONG)(LPSTR)szBuffer) .

) * 4. 9. } case BTUPERLBM : Enthalpyx = A10->dH / ((5000. IDC_SOS. szBuffer) . . szBuffer).001 . break . szBuffer) . szBuffer). 9. No further reproduction or networking is permitted.1868) . szBuffer). www.techstreet./9. _gcvt (A10->dZb. IDC_RHOF. szBuffer) .3048 . break . /* write the outputs to the window */ _gcvt (Rhofx.001 . _gcvt (A10->dZf. SetDlgItemText (hDlg. /* calculate specific entropy in specified unit of measure switch (lEntropy_unit) { case KJPERKGK : Entropyx = A10->dS * 0.1868) . 9. } */ case BTUPERLBMF : Entropyx = A10->dS / (1. Distributed by Thomson Reuters (Scientific) LLC.} case FOOTPERSECOND : SOSx = A10->dSOS / 0. _gcvt (SOSx.0e3 * 4. /* calculate specific enthalpy in specified unit of measure switch (lEnthalpy_unit) { case KJPERKG : Enthalpyx = A10->dH * 0. IDC_ZB. SetDlgItemText (hDlg. 9. 146 */ Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. SetDlgItemText (hDlg. under license from the American Gas Associatio case METREPERSECOND : SOSx = A10->dSOS .com. szBuffer). break .

szBuffer) . IDC_KAPPA. . szBuffer). IDC_MRX. IDC_H. szBuffer). szBuffer) . 9. SetDlgItemText (hDlg. under license from the American Gas Associatio SetDlgItemText (hDlg. IDC_ZF. IDC_S. No further reproduction or networking is permitted. szBuffer) .001. 9. SetDlgItemText (hDlg.001. SetDlgItemText (hDlg. SetDlgItemText (hDlg. szBuffer) . 9.techstreet.001. szBuffer) . _gcvt (Enthalpyx. szBuffer). szBuffer) . IDC_DF. SetDlgItemText (hDlg. SetDlgItemText (hDlg. _gcvt (A10->dRD_Real. szBuffer). 9. szBuffer) . _gcvt (A10->dMrx. SetDlgItemText (hDlg. _gcvt (A10->dRD_Ideal. szBuffer). 147 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. _gcvt (A10->dHo * 0. szBuffer). szBuffer). _gcvt (Entropyx. szBuffer). _gcvt (A10->dKappa.com. 9. 9. www. SetDlgItemText (hDlg. szBuffer) . IDC_RD_IDEAL. IDC_CPI. SetDlgItemText (hDlg. Distributed by Thomson Reuters (Scientific) LLC. szBuffer) . IDC_RD_REAL. szBuffer). szBuffer). IDC_CV. _gcvt (A10->dCp * 0. szBuffer) . szBuffer). szBuffer). _gcvt (A10->dCpi * 0. 9._gcvt (A10->dFpv. IDC_HO. szBuffer) . SetDlgItemText (hDlg. 9. _gcvt (A10->dk. 9. IDC_FPV. SetDlgItemText (hDlg. IDC_CP. 9. SetDlgItemText (hDlg. 9. 9. szBuffer) . SetDlgItemText (hDlg. szBuffer). szBuffer) . _gcvt (A10->dDf. szBuffer) . 9. IDC_K.001. _gcvt (A10->dCv * 0.

10). IDC_LSTATUS.techstreet. www. SetDlgItemText (hDlg. } . int iSelection. SetDlgItemText (hDlg. IDC_CSTAR. under license from the American Gas Associatio // reality check included for C* if (A10->dCstar > 0. "Calculation Completed") . } */ /************************************************************************** * Function : ReadInputs() * Arguments : HWND * Returns : void * Purpose : Function for reading the input fields of the main window * Revisions : **************************************************************************/ void ReadInputs(HWND hDlg.3 && A10->dCstar < 1.com. szBuffer) .3) { _gcvt (A10->dCstar. int i . //Pb 148 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. SetDlgItemText (hDlg. SetDlgItemText (hDlg.} /* update status indicator. szBuffer) . "Cannot Solve!") . szBuffer) . No further reproduction or networking is permitted. } else { lstrcpy(szBuffer. based on return codes if (A10->lStatus == 9000) { lstrcpy(szBuffer. IDC_LSTATUS. AGA10STRUCT *A10) { HWND hListBox. IDC_CSTAR. szBuffer). Distributed by Thomson Reuters (Scientific) LLC. szBuffer. szBuffer) . char * stopstr. 9. } else { _ltoa (A10->lStatus.

149 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. IDC_PF_U) . case 1 : lPb_unit = MEGAPASCAL . under license from the American Gas Associatio GetDlgItemText(hDlg. 0. IDC_TB. &stopstr) * 6894.0) . switch (iSelection) { case 0 : lPb_unit = KILOPASCAL . A10->dPf = strtod(szBuffer.0) . IDC_PB_U) . IDC_PB. break . iSelection = SendMessage(hListBox. switch (iSelection) { case 0 : lPf_unit = KILOPASCAL . CB_GETCURSEL. FIELD30) .com. break . break . } //Tb GetDlgItemText(hDlg. 0. FIELD30) .0e6 . hListBox = GetDlgItem(hDlg. szBuffer. CB_GETCURSEL. No further reproduction or networking is permitted. case 2 : lPf_unit = PSI . } . &stopstr) * 1. case 2 : lPb_unit = PSI . iSelection = SendMessage(hListBox.75729 . IDC_PF. iSelection = SendMessage(hListBox. hListBox = GetDlgItem(hDlg. A10->dPf = strtod(szBuffer. hListBox = GetDlgItem(hDlg. &stopstr) * 6894. www. 0.//Pf GetDlgItemText(hDlg. szBuffer. Distributed by Thomson Reuters (Scientific) LLC. &stopstr) * 1. case 1 : lPf_unit = MEGAPASCAL .0e3 . A10->dPf = strtod(szBuffer.75729 . A10->dPb = strtod(szBuffer. &stopstr) * 1. A10->dPb = strtod(szBuffer.techstreet. IDC_TB_U) . szBuffer. A10->dPb = strtod(szBuffer.0e3 . FIELD30) .0) . &stopstr) * 1.0e6 . break . CB_GETCURSEL.

IDC_TF. = RANKINE . CB_GETCURSEL. = KELVIN . &stopstr) + 273.0) .67) / 1.8. case 3 : lTb_unit A10->dTb } . = FAHRENHEIT . A10->dTf = strtod(szBuffer. case 2 : lTb_unit A10->dTb break . No further reproduction or networking is permitted. = strtod(szBuffer. switch (iSelection) { case 0 : lTf_unit = CELSIUS . case 3 : lTf_unit = RANKINE . case 1 : lTb_unit A10->dTb break . A10->dTf = (strtod(szBuffer. Distributed by Thomson Reuters (Scientific) LLC.= CELSIUS . under license from the American Gas Associatio switch (iSelection) { case 0 : lTb_unit A10->dTb break . = (strtod(szBuffer. iSelection = SendMessage(hListBox. break . szBuffer.8 . hListBox = GetDlgItem(hDlg. &stopstr) + 459. case 1 : lTf_unit = FAHRENHEIT . break . FIELD30) . &stopstr) . &stopstr) / 1. 150 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. 0. A10->dTf = strtod(szBuffer.15. = strtod(szBuffer.techstreet. IDC_TF_U) . &stopstr) + 273. &stopstr) + 459. case 2 : lTf_unit = KELVIN .67) / 1. www. break . &stopstr) .8 . //Tf GetDlgItemText(hDlg. &stopstr) / 1.8. A10->dTf = strtod(szBuffer.com. = strtod(szBuffer.15.

com. switch (iSelection) { case 0 : lRhof_unit = KGPERCUBICMETRE . iSelection = SendMessage(hListBox. IDC_RHOF_U) . case 1 : lEnthalpy_unit = BTUPERLBM . } //Enthalpy hListBox = GetDlgItem(hDlg.techstreet. IDC_SOS_U) . switch (iSelection) { case 0 : lSOS_unit = METREPERSECOND . Distributed by Thomson Reuters (Scientific) LLC. CB_GETCURSEL. switch (iSelection) { case 0 : lEnthalpy_unit = KJPERKG . IDC_ENTROPY_U) . 0. www. break .0) . 0. CB_GETCURSEL.0) . } //Entropy hListBox = GetDlgItem(hDlg. break . CB_GETCURSEL. under license from the American Gas Associatio } . case 1 : lRhof_unit = LBMPERCUBICFOOT . break . IDC_ENTHALPY_U) . case 1 : lSOS_unit = FOOTPERSECOND . iSelection = SendMessage(hListBox. 0. No further reproduction or networking is permitted. 0.0) . iSelection = SendMessage(hListBox. } //SOS hListBox = GetDlgItem(hDlg.0) . CB_GETCURSEL.//Rhof hListBox = GetDlgItem(hDlg. iSelection = SendMessage(hListBox. 151 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.

szBuffer. GetDlgItemText(hDlg. szBuffer. szBuffer. FIELD30) . A10->adMixture[XiNC6] = strtod(szBuffer. A10->adMixture[XiH2O] = strtod(szBuffer.techstreet.IDC_XICO. FIELD30) . GetDlgItemText(hDlg. A10->adMixture[XiIC5] = strtod(szBuffer. GetDlgItemText(hDlg. GetDlgItemText(hDlg. GetDlgItemText(hDlg.IDC_XIH2. GetDlgItemText(hDlg. FIELD30) . FIELD30) . FIELD30) . &stopstr) * 0. szBuffer.01 .IDC_XIH2S. A10->adMixture[XiO2] = strtod(szBuffer. Distributed by Thomson Reuters (Scientific) LLC.01 .IDC_XIH2O. No further reproduction or networking is permitted.01 .IDC_XIC2. 152 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.IDC_XIC1. A10->adMixture[XiH2] = strtod(szBuffer. A10->adMixture[XiIC4] = strtod(szBuffer.IDC_XIC3. szBuffer.01 . szBuffer. FIELD30) . szBuffer. FIELD30) . case 1 : lEntropy_unit = BTUPERLBMF . FIELD30) . &stopstr) * 0. FIELD30) . A10->adMixture[XiC3] = strtod(szBuffer. szBuffer. &stopstr) * 0. &stopstr) * 0. FIELD30) . GetDlgItemText(hDlg. GetDlgItemText(hDlg.01 . &stopstr) * 0. A10->adMixture[XiH2S] = strtod(szBuffer. FIELD30) . A10->adMixture[XiCO2] = strtod(szBuffer. under license from the American Gas Associatio switch (iSelection) { case 0 : lEntropy_unit = KJPERKGK . FIELD30) . szBuffer. break .// composition GetDlgItemText(hDlg. GetDlgItemText(hDlg.01 . &stopstr) * 0. } . GetDlgItemText(hDlg. &stopstr) * 0. GetDlgItemText(hDlg. A10->adMixture[XiCO] = strtod(szBuffer. szBuffer.01 . GetDlgItemText(hDlg. &stopstr) * 0.01 . szBuffer.IDC_XICO2. A10->adMixture[XiNC4] = strtod(szBuffer. &stopstr) * 0. FIELD30) . A10->adMixture[XiNC5] = strtod(szBuffer. A10->adMixture[XiC2] = strtod(szBuffer.IDC_XIO2. &stopstr) * 0. A10->adMixture[XiN2] = strtod(szBuffer. FIELD30) .IDC_XINC4. szBuffer.01 . &stopstr) * 0. &stopstr) * 0.01 .IDC_XINC7.IDC_XIN2.IDC_XINC6. GetDlgItemText(hDlg. szBuffer. www.01 .IDC_XIIC5.com. A10->adMixture[XiC1] = strtod(szBuffer. FIELD30) .IDC_XINC5.IDC_XIIC4. GetDlgItemText(hDlg. &stopstr) * 0. &stopstr) * 0. FIELD30) . GetDlgItemText(hDlg.01 .01 . szBuffer.01 . szBuffer. szBuffer.01 . &stopstr) * 0.

GetDlgItemText(hDlg. FIELD30) . . i++) total += A10->adMixture[i]. A10->adMixture[XiAr] = strtod(szBuffer. i<NUMBEROFCOMPONENTS. GetDlgItemText(hDlg. SendMessage(hListBox.0) .IDC_XINC10. www. under license from the American Gas Associatio A10->adMixture[XiNC7] = strtod(szBuffer. "%6. &stopstr) * 0. No further reproduction or networking is permitted. FIELD40) . A10->adMixture[XiNC10] = strtod(szBuffer. FIELD30) .01 . FIELD40) .IDC_XINC8. sprintf(szBuffer.IDC_XIAR. MEGAPASCAL.IDC_XINC9. &stopstr) * 0.01 . LoadString(hInst. SetDlgItemText(hDlg. SendMessage(hListBox. szBuffer. szBuffer. FIELD30) . total * 100. 1. szBuffer. &stopstr) * 0. IDC_TOTAL.com. FIELD30) . /************************************************************************** * Function : PressureDlgHelp() * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into pressure * drop-list controls * Revisions : **************************************************************************/ void PressureDlgHelp(HWND hListBox) { LoadString(hInst. A10->adMixture[XiNC8] = strtod(szBuffer. szBuffer. szBuffer. LoadString(hInst. GetDlgItemText(hDlg.01 .01 . (LONG)(LPSTR) szBuffer) .techstreet. KILOPASCAL. CB_INSERTSTRING.IDC_XIHE. &stopstr) * 0. &stopstr) * 0.01 . szBuffer) .total = 0. Distributed by Thomson Reuters (Scientific) LLC. CB_INSERTSTRING. } /************************************************************************** * Function : TemperatureDlgHelp() 153 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. szBuffer. FIELD30) . SendMessage(hListBox. CB_INSERTSTRING. A10->adMixture[XiNC9] = strtod(szBuffer. (LONG)(LPSTR) szBuffer) . 0. FIELD40) .} // sum up the mole fractions for (i=0.01 .0. &stopstr) * 0. PSI. GetDlgItemText(hDlg. (LONG)(LPSTR) szBuffer) . 2. GetDlgItemText(hDlg. szBuffer. szBuffer. A10->adMixture[XiHe] = strtod(szBuffer.6f".

com. (LONG)(LPSTR) LoadString(hInst. szBuffer. KGPERCUBICMETRE. SendMessage(hListBox. LBMPERCUBICFOOT. LoadString(hInst. 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. FIELD40) . SendMessage(hListBox. 0. KELVIN. szBuffer. FIELD40) . FAHRENHEIT. CELSIUS. (LONG)(LPSTR) szBuffer) . CB_INSERTSTRING. szBuffer) . szBuffer) . FIELD40) . Distributed by Thomson Reuters (Scientific) LLC.techstreet. szBuffer) . SendMessage(hListBox. under license from the American Gas Associatio * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into temperature * drop-list controls * Revisions : **************************************************************************/ . SendMessage(hListBox. 1. CB_INSERTSTRING. CB_INSERTSTRING. (LONG)(LPSTR) szBuffer) . szBuffer. SendMessage(hListBox. szBuffer. (LONG)(LPSTR) LoadString(hInst. CB_INSERTSTRING. 0. FIELD40) . SendMessage(hListBox. RANKINE. 3. www. } /************************************************************************** * Function : SOSDlgHelp() * Arguments : HWND 154 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. FIELD40) . (LONG)(LPSTR) LoadString(hInst. No further reproduction or networking is permitted. (LONG)(LPSTR) } szBuffer) .void TemperatureDlgHelp(HWND hListBox) { LoadString(hInst. szBuffer. CB_INSERTSTRING. FIELD40) . CB_INSERTSTRING. 1. 2.

(LONG)(LPSTR) szBuffer) . LoadString(hInst. (LONG)(LPSTR) szBuffer) . (LONG)(LPSTR) szBuffer) . szBuffer. (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. FIELD40) . 1. Distributed by Thomson Reuters (Scientific) LLC. under license from the American Gas Associatio * Returns : void * Purpose : Helper function for loading strings into SOS * drop-list controls * Revisions : **************************************************************************/ .com. CB_INSERTSTRING. SendMessage(hListBox. CB_INSERTSTRING. 1. BTUPERLBM. SendMessage(hListBox. No further reproduction or networking is permitted. SendMessage(hListBox. FIELD40) . METREPERSECOND. szBuffer. FOOTPERSECOND. KJPERKG. SendMessage(hListBox. 0.void SOSDlgHelp(HWND hListBox) { LoadString(hInst. FIELD40) . FIELD40) . 0. CB_INSERTSTRING.techstreet. www. 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. CB_INSERTSTRING. szBuffer. LoadString(hInst.

} . A10->adMixture[XiO2] = 0.0. A10->adMixture[XiNC7] = 0. A10->adMixture[XiIC5] = 0. szBuffer. 156 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. A10->adMixture[XiC3] = 0.0 . /* 15 C */ A10->dPf = 4000000. /* 9000 is status code for 'ok' */ A10->bForceUpdate = true. under license from the American Gas Associatio void EntropyDlgHelp(HWND hListBox) { LoadString(hInst./************************************************************************** * Function : SetDefaults() * Arguments : void * Returns : void * Purpose : initializes AGA10STRUCT and units of measure * Revisions : **************************************************************************/ void SetDefaults(AGA10STRUCT *A10) { A10->lStatus = 9000 . /* ensures that full calculation is performed */ A10->dPb = 101325. SendMessage(hListBox. CB_INSERTSTRING.0.000393. SendMessage(hListBox. A10->adMixture[XiH2O] = 0. A10->adMixture[XiNC8] = 0. A10->adMixture[XiC2] = 0. A10->adMixture[XiCO2] = 0.0.15.045279.com.004676. www. 0.001037. A10->adMixture[XiNC6] = 0. No further reproduction or networking is permitted.0. A10->adMixture[XiNC4] = 0. LoadString(hInst. KJPERKGK. CB_INSERTSTRING.0 . Distributed by Thomson Reuters (Scientific) LLC. A10->adMixture[XiCO] = 0. /* 1 atm */ A10->dTb = 288. FIELD40) . BTUPERLBMF.000443. /* 4 MPa */ A10->dTf = 283. A10->adMixture[XiH2] = 0.031284.techstreet.*/ A10->adMixture[XiN2] = 0. /* AMARILLO example composition. /* 10 C */ A10->adMixture[XiC1] = 0. A10->adMixture[XiIC4] = 0.906724.000321. A10->adMixture[XiH2S] = 0.15.0. (LONG)(LPSTR) szBuffer) .0.00828. FIELD40) . (LONG)(LPSTR) szBuffer) . 1. szBuffer.. A10->adMixture[XiNC5] = 0..0.001563.

lEnthalpy_unit = KJPERKG .com. lRhof_unit = KGPERCUBICMETRE . A10->adMixture[XiAr] = 0. under license from the American Gas Associatio A10->adMixture[XiNC9] = 0. 157 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. A10->adMixture[XiHe] = 0. lTb_unit = CELSIUS .0.0. lTf_unit = CELSIUS .} /* reset units of measure */ lPb_unit = KILOPASCAL . .0. www. lSOS_unit = METREPERSECOND . lPf_unit = KILOPASCAL .techstreet. lEntropy_unit = KJPERKGK . Distributed by Thomson Reuters (Scientific) LLC. lRhob_unit = KGPERCUBICMETRE .0. No further reproduction or networking is permitted. A10->adMixture[XiNC10] = 0.

// 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.com.File Description Version Author Revisions Copyright (c) : resource. www. Peterson : 2002 American Gas Association //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file.11.17 : W. No further reproduction or networking is permitted.7 2002.B. under license from the American Gas Associatio // // // // // // .techstreet. Distributed by Thomson Reuters (Scientific) LLC.h : header file used for Windows resource file : 1.

www. AGA10WIN ICON DISCARDABLE "aga10win. under license from the American Gas Associatio // // // // // // .11.ico" 159 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. // #define APSTUDIO_HIDDEN_SYMBOLS #include "windows.File Description Version Author Revisions Copyright (c) : aga10win. No further reproduction or networking is permitted.com.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U. 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.techstreet.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. Peterson : 2002 American Gas Association //Microsoft Developer Studio generated resource script. Distributed by Thomson Reuters (Scientific) LLC.h" #undef APSTUDIO_HIDDEN_SYMBOLS #include "aga10win.rc : resource script for aga10win’s interface : 1.B.17 : W.7 2002. // #include "resource.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH.

259.44.154.14.55.44.44.44.14.14 PUSHBUTTON "Clear Mixture".44.44.AGA10WIN DIALOGEX 0.ES_AUTOHSCROLL EDITTEXT IDC_XICO2.44.44.14.44.70.ES_AUTOHSCROLL EDITTEXT IDC_XIIC4.ES_AUTOHSCROLL COMBOBOX IDC_PB_U.153.70.44.ES_AUTOHSCROLL EDITTEXT IDC_XIAR.ES_AUTOHSCROLL EDITTEXT IDC_XIIC5.ES_AUTOHSCROLL EDITTEXT IDC_XIC1.14.ES_AUTOHSCROLL EDITTEXT IDC_XIH2S.55.107.98.259.88.60.44.44.124. Distributed by Thomson Reuters (Scientific) LLC.ES_AUTOHSCROLL EDITTEXT IDC_XINC4.60.14.197.196.20 EDITTEXT IDC_PB.55.44.33.44. www.ES_AUTOHSCROLL EDITTEXT IDC_XINC9.14.14.ES_AUTOHSCROLL EDITTEXT IDC_XINC7.216.14.ES_AUTOHSCROLL EDITTEXT IDC_XINC5.44.ES_AUTOHSCROLL EDITTEXT IDC_XINC10.98.14.ES_AUTOHSCROLL EDITTEXT IDC_XIO2.14.34.69. 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.89.ES_AUTOHSCROLL EDITTEXT IDC_XIC2.14.15.14.44.14. under license from the American Gas Associatio ///////////////////////////////////////////////////////////////////////////// // // Dialog // . 0. 575.ES_AUTOHSCROLL EDITTEXT IDC_XIN2.44.47.105.CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_TB.55.16.ES_AUTOHSCROLL EDITTEXT IDC_XIC3.ES_AUTOHSCROLL EDITTEXT IDC_XIH2O.215.CBS_DROPDOWNLIST | CBS_SORT | 160 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.259.16.259.14.154.259.44.51.34.ES_AUTOHSCROLL EDITTEXT IDC_XINC8.44.259.149.52.153.ES_AUTOHSCROLL EDITTEXT IDC_XINC6.259.14.14.60.IDC_CLEAR.techstreet.34.55.154.87.44.52.14.14.44.60. No further reproduction or networking is permitted.125.60.ES_AUTOHSCROLL EDITTEXT IDC_XICO.106.55.34.55.123.14.ES_AUTOHSCROLL COMBOBOX IDC_TB_U.44.153.153. "MS Sans Serif" BEGIN EDITTEXT IDC_XIHE.ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_XIH2.14.com.44.14.14.

37.8.22.115.IDC_STATIC. under license from the American Gas Associatio EDITTEXT COMBOBOX .NOT WS_GROUP "n-Hexane".8.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.282.115.147.282.IDC_STATIC.20.ES_AUTOHSCROLL IDC_PF_U.NOT WS_GROUP "n-Octane".IDC_STATIC.146.15.8.259.8.22.8.27.NOT WS_GROUP "Hydrogen".19.175 "Helium".8.219.8.21.NOT WS_GROUP "Water".191.NOT WS_GROUP "CO".IDCANCEL.32.199.IDC_STATIC.89.73.NOT WS_GROUP "n-Heptane".50.24.14.IDC_STATIC.ES_AUTOHSCROLL IDC_TF_U.SS_SUNKEN | NOT WS_GROUP "Gas Temperature and Absolute Pressure".NOT WS_GROUP "Nitrogen".12.8.8.44.IDC_STATIC.28.NOT WS_GROUP "O2".NOT WS_GROUP "i-Butane".215.8.NOT WS_GROUP "n-Pentane".218.32.24. 322.215.22.18.91.109.CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP "Calculate".NOT WS_GROUP "i-Pentane".60. Distributed by Thomson Reuters (Scientific) LLC.182.IDC_STATIC.55.31.8.218.128.IDRETRY.IDC_STATIC.15.IDC_STATIC.8.108.8.8 "Pf".IDC_STATIC.254.116.21.IDC_STATIC.115.60.116.IDOK.NOT WS_GROUP "TOTAL".71.8.72.92.219.5.8.116.196.NOT WS_GROUP "Static".28.30.21.128.255.10.IDC_STATIC.NOT WS_GROUP "Ethane".8 "Tf".IDC_STATIC.55.217.8. No further reproduction or networking is permitted.110.28.199.IDC_STATIC.IDC_STATIC.8.116.217.NOT WS_GROUP "CO2".282.29.IDC_STATIC.34.8.8.IDC_STATIC.NOT WS_GROUP "n-Butane".IDC_STATIC.18.8 "Tb".8.61.IDC_STATIC.IDC_STATIC.NOT WS_GROUP "Methane".44.WS_GROUP "Composition (Mole Percent)".IDC_STATIC.8.322.30.com.50.14.8.IDC_STATIC.37.137.44.12.IDC_STATIC.NOT WS_GROUP "H2S".techstreet.CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_TF.8 161 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.126.219.11.10.213.IDC_STATIC.IDC_STATIC.IDC_STATIC.NOT WS_GROUP "n-Nonane".32.218.56 "Pb".NOT WS_GROUP "n-Decane".24.55.IDC_STATIC.219.196.27.50.3.IDC_TOTAL.23.20 "Initialize". www.6.22.191.60.IDC_STATIC.177.8.32.60.20 "Quit".NOT WS_GROUP "Propane".218.11.176.8.36.NOT WS_GROUP "Argon".34.

422.83.NOT WS_GROUP "0". 107.128.IDC_MRX.216.IDC_STATIC.348.8 "0".IDC_STATIC.IDC_STATIC.8 "Mass Density".201.8.IDC_STATIC.NOT WS_GROUP "0".50.348.20.50.50.422.173.60.68.IDC_KAPPA.422.422.50.69.8.32.IDC_S.40.IDC_STATIC.232.422.8 "kJ/kg-K".techstreet.67.348.348.IDC_RHOF.98.8 "Isentropic Exponent". Distributed by Thomson Reuters (Scientific) LLC.422.50.8.IDC_STATIC.8 "Cp (real gas)".8.264.NOT WS_GROUP "0".IDC_STATIC.NOT WS_GROUP "0".50.IDC_STATIC.IDC_RD_IDEAL.24.8.8.186.NOT WS_GROUP "0".483.8 "Specific Enthalpy".422.422.422.NOT WS_GROUP "0".IDC_ZF.IDC_STATIC.NOT WS_GROUP "0".143.187.422.62.8 162 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.3.348.50.NOT WS_GROUP "0".LTEXT "Calculation Results".232.42.46.IDC_ZB.201.IDC_LSTATUS.IDC_CV.8 "Enthalpy (ideal gas)".NOT WS_GROUP "0".280.8 "kJ/kg-K".348.IDC_STATIC.348.IDC_STATIC.8 "Specific Entropy".348.280.53.483.280.8 "0".348.8 "Cp (ideal gas)".NOT WS_GROUP "moles/dm3".IDC_CP.IDC_STATIC.26.IDC_STATIC.50.IDC_STATIC.40.24.128.171.422.8 "RD (ideal gas)".83.248.143.IDC_STATIC.10.8.348.50.50.8.IDC_H.422.216.50.53.NOT WS_GROUP "0".IDC_STATIC.13.422.216.IDC_DF.50.234.348. www.348.8.22.43.8 "Cp/Cv".158.NOT WS_GROUP "0".8.52.IDC_HO.44.IDC_SOS.348.8.8 "Cv (real gas)".8.8.8.8 "Fpv".IDC_STATIC.37.44.113.348.8 "Zb".IDC_STATIC.264.IDC_K.52. No further reproduction or networking is permitted.8 "Molar Mass".8 "kJ/kg".8 "Zf".26.55.IDC_STATIC.422.157.NOT WS_GROUP "0".348.348.IDC_STATIC.8.106.99.422.8 "RD (real gas)".NOT WS_GROUP "0".348.98.306 "Speed of Sound".IDC_FPV.IDC_STATIC.113.IDC_RD_REAL.com.483.422.422.483.8.334.50.IDC_STATIC.8.56.50.248.NOT WS_GROUP "0".259.NOT WS_GROUP "Press Initialize Button to Begin". 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 .8 "Molar Density".8.IDC_CPI.NOT WS_GROUP "0".50.232.

43. under license from the American Gas Associatio LTEXT LTEXT LTEXT COMBOBOX .CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP "Current Status".248.60.149.IDC_NORMALIZE.80.CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_ENTROPY_U.IDC_CSTAR.h""\r\n" "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""aga10win.58.IDC_STATIC.247.37.482.40.482.IDC_STATIC.80.8 "0".482.21.111.39.27 "Normalize".com.CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_ENTHALPY_U.80.39.5.348.8 "C*".82.482.IDC_STATIC.422.CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_RHOF_U.8 IDC_SOS_U.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""windows.10.118.80.20 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.483.322. No further reproduction or networking is permitted.26.techstreet.44.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.COMBOBOX COMBOBOX COMBOBOX END GROUPBOX PUSHBUTTON "kJ/kg-K".66. Distributed by Thomson Reuters (Scientific) LLC. www.

7. Distributed by Thomson Reuters (Scientific) LLC.0. under license from the American Gas Associatio #endif . No further reproduction or networking is permitted.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. 5 RIGHTMARGIN. 309 END END #endif // APSTUDIO_INVOKED #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1.techstreet. 568 BOTTOMMARGIN.7.// APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN "AGA10WIN". DIALOG BEGIN LEFTMARGIN.0 PRODUCTVERSION 1. www.com.

.. "aga10win. "1.. "\0" VALUE "OriginalFilename". MENUITEM "E&xit". "\0" VALUE "ProductName".techstreet.#endif // !_MAC ///////////////////////////////////////////////////////////////////////////// // // Menu // IDR_MENU1 MENU DISCARDABLE BEGIN POPUP "&File" BEGIN MENUITEM "&Open. MENUITEM "Save &As. MENUITEM "&Save. Distributed by Thomson Reuters (Scientific) LLC. "2002. 0.. "aga10win\0" VALUE "ProductVersion".. "1. "Copyright © 2002 American Gas Association\0" VALUE "LegalTrademarks". 0\0" VALUE "InternalName". 1200 END . 7. 0. "Post Ballot Version\0" VALUE "CompanyName". under license from the American Gas Associatio END BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments". 0\0" VALUE "SpecialBuild". "aga10win\0" VALUE "FileVersion".11..". END CM_FILEOPEN CM_FILESAVE CM_FILESAVEAS IDCANCEL 165 Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only.". "American Gas Association\0" VALUE "FileDescription".17 Build\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation".". 0x409. www.exe\0" VALUE "PrivateBuild". No further reproduction or networking is permitted. 7. "aga10win\0" VALUE "LegalCopyright".com.

techstreet. Distributed by Thomson Reuters (Scientific) LLC. www. under license from the American Gas Associatio END POPUP "&Help" BEGIN MENUITEM "&About".S. 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.com.) 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.

// .com. under license from the American Gas Associatio ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource.///////////////////////////////////////////////////////////////////////////// #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.techstreet. Distributed by Thomson Reuters (Scientific) LLC. www.

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

) This proposal is not original material.S. Section/Paragraph :____________________________________________________________ 2. diagrams. PROPOSAL TO REVISE AGA REPORT NO. thought or research and. Date: ___________________ Signature (Required) _________________________________ FOR OFFI C EUSE LY ON Log #__ _________ ____ _____ Date ec’d _ ____ ___ ________ R_ Copyrighted material licensed to YPFB Corporacion on 2014-06-25 for licensee's use only. or identification of wording to be deleted. 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. If supplementary material (photographs..) 5.) is included. N. This proposal is original material. etc.com. use underscore to denote wording to be inserted (inserted wording) and strike-through to denote wording to be deleted (deleted wording). under license from the American Gas Association (AGA). Fax: (202) 824-7082 Name:__________________________________________________________________________ Company:_______________________________________________________________________ Address:________________________________________________________________________ Phone: ___________________ Fax:____________________E-mail________________________ Please Indicate Organization Represented (if any):_____________________________________ 1. use separate sheet if needed): [Proposed text should be in legislative format. 4th Floor Washington. give the specific reason for your proposal including copies of tests.e. Proposal (include proposed new or revised wording.aga. etc. royalty-free rights in copyright. Distributed by Thomson Reuters (Scientific) LLC.A. www. reports. you may be required to submit sufficient copies for all members of reviewing committees or task forces. (Note: Original material is considered to be the submitter’s own idea based on or as a result of his/her own experience. is not copied from another source.. www.10 . DC 20001 U. Statement of Problem and Substantiation for Proposal (use separate sheet if needed): (State the problem that will be resolved by your recommendation.W. including non-exclusive. No further reproduction or networking is permitted..Send to: Operations and Engineering Section American Gas Association 400 North Capitol St.] 4. i. I hereby grant the American Gas Association the non-exclusive.org. its source (if known) is as follows: ____________ ________________________________________________________________________________ Type or print legibly. to the best of his/her knowledge. research papers.techstreet. royalty-free rights. Proposal Recommends: (check one): new text revised text deleted text 3.