This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. AGA Report No. 10 Speed of Sound in Natural Gas and Other Related Hydrocarbon Gases December 04, 2002 Post-Ballot Draft Prepared by Transmission Measurement Committee 1 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Table Of Contents Forward 1 Introduction 1.1 Scope 1.2 Background 1.3 Field of Application 1.4 Types of Properties 1.5 Types of Gases 1.6 Types of Conditions 2 Uncertainty 3 Calculations 3.1 Symbols 3.2 Overview of Calculation Method and Sequence 3.3 Compliance 3.4 Equations for Speed of Sound 3.5 Critical Flow Factor Determination 4 Characteristics of Typical Gases 5 References 6 Computation Flow Charts 7 Calculation Output for Program Verification 7.1 Detailed Output Results for Program Development 7.1.1 Detailed Output Result #1 7.1.2 Detailed Output Result #2 7.1.3 Detailed Output Result #3 7.2 Tabled Results for Compliance Checking and Program Development APPENDIX A C++ Language Example Implementation 1.0 Overview of Computer Code 1.1 File Group 1 Calculation Library 1.2 File Group 2 Example Windows Application 2 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 1. Introduction 1.1 Scope This document contains information for precise computation of sound speed in natural gas and other related hydrocarbon gases. Procedures are included for computation of several related gas properties, including heat capacity, enthalpy, entropy and the critical flow coefficient, C*. The methods in this document are extensions to Compressibility Factors for Natural Gas and Other Hydrocarbon Gases, AGA Transmission Measurement Committee Report No. 8, 2nd Edition, 2nd Printing (1994). This document contains excerpts from Report No. 8, but intentionally does not reproduce the full report. Similarly, the methods for computing the critical flow coefficient, C*, are based on the information in appendix E of ASME/ANSI MFC-7M-1987. Users are referred to this source for background and pertinent references. Procedures for computing other natural gas properties such as volumetric heating value and relative density fall outside of the scope of this report and are not included. 1.2 Background This is the first AGA document on speed of sound. It is based on a large database of high accuracy basic physical property research data obtained through research sponsored by the Gas Research Institute in cooperation with the American Gas Association, the American Petroleum Institute and Groupe Europeen de Recherches Gazieres (GERG). The methods presented in this AGA document utilize high accuracy calculation procedures and related equations of state already implemented by AGA, API and ISO. For continuity and ease of application, the original AGA Report No. 8 solution methods have been carried forward with little change. Computer code development for Report No. 10 will be modest and incremental to most existing AGA Report No. 8 implementations. 1.3 Field of Application High accuracy sound speed information is needed in a variety of gas flow measurement applications, such as ultrasonic meters and critical flow nozzles, as well as analytical applications such as transducers and densitometers. This report provides the information needed to compute the speed of sound in natural gas and related hydrocarbon gases. The equations utilized are consistent 3 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. with AGA Report No. 8, API MPMS Chapter 14.2 and ISO Standard 12213 Part 2. 1.4 Types of Properties The methods in this document may be used to compute a number of gas properties including speed of sound, enthalpy, entropy, heat capacity and critical flow coefficient. In conjunction with the methods in AGA Report No. 8, procedures can be developed to support a variety of applications including sonic nozzles, compressor efficiency, and heat exchanger calculations. 1.5 Types of Gases This report is intended for natural gases and other related hydrocarbon gases. Table 1 identifies the ranges of gas characteristics for which this report can be used. The normal range column gives the range of gas characteristics for which the average expected uncertainty corresponds to the uncertainties identified in Figure 1. The expanded range of gas characteristics has an uncertainty, which is expected to be higher, especially outside of region 1 of Figure 1. The use of this report for computations of the physical properties of gases with component mole percentages outside the ranges given in Table 1 is not recommended. An accepted database for water, heavy hydrocarbons and hydrogen sulfide in natural gases is not presently available for determinations of uncertainties of calculated gas properties. Therefore, as a practical matter, the only limitation is that the calculation is for the gas phase. Thus, the limits are the water dew point for mole percent water, the hydrocarbon dew point for mole percent heavy hydrocarbons, and pure hydrogen sulfide. The presentation of methods for calculations using the various heavy hydrocarbon fraction characterization methods used in the hydrocarbon industry is beyond the scope of this report. 4 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Table 1 Range of Gas Mixture Characteristics Consistent with this Report Quantity Normal Range Expanded Range Relative Density * 0.554 to 0.87 0.07 to 1.52 Gross Heating Value ** 477 to 1150 Btu/scf 0 to 1800 Btu/scf Gross Heating Value *** 18.7 to 45.1 MJ/m3 0 to 66 MJ/m3 Mole Percent Methane 45.0 to 100.0 0 to 100.0 Mole Percent Nitrogen 0 to 50.0 0 to 100.0 Mole Percent Carbon Dioxide 0 to 30.0 0 to 100.0 Mole Percent Ethane 0 to 10.0 0 to 100.0 Mole Percent Propane 0 to 4.0 0 to 12.0 Mole Percent Total Butanes 0 to 1.0 0 to 6.0 Mole Percent Total Pentanes 0 to 0.3 0 to 4.0 Mole Percent Hexanes Plus 0 to 0.2 0 to Dew Point Mole Percent Helium 0 to 0.2 0 to 3.0 Mole Percent Hydrogen 0 to 10.0 0 to 100.0 Mole Percent Carbon Monoxide 0 to 3.0 0 to 3.0 Mole Percent Argon # 0 to 1.0 Mole Percent Oxygen # 0 to 21.0 Mole Percent Water 0 to 0.05 0 to Dew Point Mole Percent Hydrogen Sulfide 0 to 0.02 0 to 100.0 * Reference Conditions: Relative Density at 60° F, 14.73 psia. ** Reference Conditions: Combustion at 60° F, 14.73 psia; density at 60° F, 14.73 psia. *** Reference Conditions: Combustion at 25° C, 0.101325 MPa; density at 0° C, 0.101325 MPa. # The normal range is considered to be zero for these compounds. 1.6 Types of Conditions This report is only valid for the gas phase. The methods can be applied for temperatures from -130° C to 200° C (-200° F to 400° F) at pressures up to 138 MPa (20,000 psia). Application at extreme conditions should be verified by other means (e.g., experimental verification). Use of the calculation method is not recommended within the vicinity of the critical point. For pipeline quality gas, this is usually not a constraint because operating conditions near the critical point generally are not encountered. 5 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Temperature, °C -130 -60 -8 62 120 200 20000 140 Region 4 1.0% 10000 70 Pressure, MPa 0.5% Pressure, psia Region 3 2500 0.3% 17 Region 2 1750 0.1% 12 Region 1 -200 Figure 1 2.0 -80 17 143 Temperature, °F 250 400 Targeted Uncertainty for Natural Gas Speed of Sound Using the AGA Report No. 10 Method Uncertainty The uncertainty of calculated speed of sound depends on natural gas temperature, pressure and composition. The uncertainties of speed of sound methods were evaluated by comparing calculated values to experimentally measured speed of sound from NIST Monograph 178 [7]. Calculations were compared with experimental measured values for 17 gravimetrically prepared natural gas mixtures, listed in Table 2, over the range 250 K and 350 K (-10° F and 165° F) and pressures up to 17 MPa (2500 psia). Some of the gas mixtures included in the uncertainty analysis are outside of the range of Table 1. The measurements conducted demonstrate that the uncertainty in the speed of sound is within 0.1% for Gulf Coast, Amarillo and Ekofisk gases for pressures up to 12 MPa (1750 psia) and temperatures between 250 K and 350 K (-10° F and 165° F). 6 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The uncertainty in the speed of sound is also within 0.1% for other gas mixtures whose characteristics fall within the normal range of Table 1. Higher levels of uncertainty are indicated for gases outside of the normal range of Table 1. Statistical analyses of the differences between calculated and experimental values were performed to evaluate the uncertainties in the calculated speed of sound values. Statistics were calculated using the following equations where N is the number of data points: Wdiff = Wcalc − Wexp x100 Wexp (2.1) BIAS = 1 N åWdiff ,i N i =1 (2.2) AAD = [ ] 1 1 N 2 2 ( ) W å diff ,i N i =1 (2.3) é 1 (Wdiff ,i − BIAS )2 ùú Std .Dev. = ê å ë N − 1 i =1 û N 1 2 (2.4) Where: Wdiff = relative percentage difference between calculated and experimental speed of sound th Wdiff,i = Wdiff for i data point Wcalc = calculated speed of sound Wexp = experimental speed of sound AAD = average absolute deviation BIAS = bias Std.Dev. = Standard deviation 7 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Table 2 Gas Mixture Characteristics Included In Statistical Analysis Gas Methane Nitrogen No. Carbon Dioxide Ethane Propane Isobutane Normal Isopentane Normal Normal Butane Pentane Hexane 2 0.94985 0 0 0.05015 0 0 0 0 0 0 3 0.84992 0 0 0.15008 0 0 0 0 0 0 4 0.68526 0 0 0.31474 0 0 0 0 0 0 5 0.50217 0 0 0.49783 0 0 0 0 0 0 6 0.34524 0 0 0.65476 0 0 0 0 0 0 7 0.90016 0 0 0 0.09984 0 0 0 0 0 8 0.95114 0.04886 0 0 0 0 0 0 0 0 9 0.8513 0.1487 0 0 0 0 0 0 0 0 10 0.71373 0.28627 0 0 0 0 0 0 0 0 11 0.94979 0 0.05021 0 0 0 0 0 0 0 12 0.85026 0 0.14974 0 0 0 0 0 0 0 13 0.69944 0 0.30056 0 0 0 0 0 0 0 14 0 0.49593 0.50407 0 0 0 0 0 0 0 15 0.96561 0.00262 0.00597 0.01829 0.0041 0.00098 0.00098 0.00046 0.00032 0.00067 16 0.90708 0.03113 0.005 0.04491 0.00815 0.00106 0.00141 0.00065 0.00027 0.00034 17 0.8398 0.00718 0.00756 0.13475 0.00943 0.0004 0.00067 0.00013 0.00008 0 18 0.74348 0.00537 0.01028 0.12005 0.08251 0 0.03026 0 0.00575 0.0023 Table 3 Statistical Analysis of the Differences between Calculated and Experimental Speed of Sound Values for 17 Natural Gas Mixtures Gas No. No. Points AAD % 2 80 0.021 3 67 0.079 4 95 0.600 5 78 0.418 6 72 0.086 7 76 0.327 8 81 0.021 9 87 0.024 10 97 0.025 11 80 0.026 12 71 0.024 13 90 0.096 14 65 0.148 15 83 0.030 16 82 0.031 17 91 0.094 18 44 0.148 Bias % Std Dev % -0.026 0.026 0.016 0.133 0.317 1.094 0.103 0.803 -0.011 0.127 0.144 0.721 -0.037 0.026 -0.036 0.029 -0.023 0.033 -0.053 0.038 -0.041 0.039 -0.009 0.184 0.230 0.205 -0.045 0.040 -0.026 0.051 0.001 0.153 0.068 0.224 8 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 3.0 Calculations 3.1 Symbols ∂ B ∂T First partial derivative of B wrt T ∂ 2 B ∂T 2 Second partial derivative of B wrt T ∂Z ∂T ∂ 2 Z ∂T 2 First partial derivative of Z wrt T Second partial derivative of Z wrt T ∂Z ∂ρ First partial derivative of Z wrt ρ ρ κ B Cp Cpo Cv H Ho Mr P R S So T W Xi Z 3.2 Molar density Isentropic exponent Second virial coefficient Constant pressure heat capacity (real gas) Constant pressure heat capacity (ideal gas) Constant volume heat capacity (real gas) Enthalpy (real gas) Enthalpy (ideal gas) Molar mass Absolute pressure Universal gas constant Entropy (real gas) Entropy (ideal gas) Temperature Speed of sound Mole fraction of ith component Compressibility Factor Overview of Calculation Method and Sequence The speed of sound is related to the compressibility of a gas and can be computed from its fundamental physical property relationships. The information contained in this report, in combination with the information provided in AGA Report No. 8, is needed to implement the AGA speed of sound calculation. The method used in this report utilizes a detail characterization of the gas composition, i.e., a representative gas analysis. As such, implementation is 9 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. limited to methods provided in the AGA Report No. 8 Detail Characterization Method. The reliability of calculation results is dependent on the reliability of the gas composition data, temperature data and, to a lesser extent, pressure data. Except where noted, all computations are performed in metric units. For conversions to other unit systems, users are referred to applicable documents by NIST[10] and the Canadian Standards Association[11]. Pure fluid ideal gas heat capacities, enthalpies and entropies are computed from equations given by Aly and Lee[3], with the additions given by McFall[2]. The originally published constants and units of measure have been preserved for this set of equations, necessitating conversion from thermochemical calories to joules. In this document, all references to the Btu refer to the International Table Btu (Btu(IT)). In the appendix to this report, real gas heat capacity, enthalpy and entropy are solved through numerical integration, applying gaussian quadrature. Alternative solution methods are feasible but users are advised to carefully evaluate the potential impact on accuracy and robustness. Several partial derivatives are solved during computation. Three of these ( ∂Z ∂T , ∂ 2 Z ∂T 2 , ∂Z ∂ρ ) are solved using the approach given in AGA Report No. 8 for subroutine ‘ZDETAIL’. Two other derivatives, ∂B ∂T and ∂ 2 B ∂T 2 are solved as minor additions to subroutine ‘B’, also given in AGA Report No. 8. The general procedure for computing speed of sound at the flowing or operating condition of interest is: 1. Input the operating temperature (T), operating pressure (P) and gas analysis. 2. Calculate the molar mass of the mixture. 3. Calculate the compressibility and density of the fluid at the conditions of interest. 4. Calculate the ideal gas constant pressure heat capacity at the operating temperature. 5. Calculate the real gas constant volume heat capacity at the operating conditions. 6. Calculate the real gas constant pressure heat capacity at the operating conditions. 7. Calculate the ratio of heat capacities, Cp/Cv, at the operating conditions. 8. Calculate the speed of sound, based on the results of the preceding steps. 9. Calculate the isentropic exponent, κ. 10 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 3.3 Compliance To be compliant with this AGA Report, a computational solution by this or any other method must demonstrate agreement within 50 parts per million of the sound speeds given in Section 7.2, Table 6a (English units) or Table 6b (Metric units). Other tables of computed values are given in Section 7 for computational checks but a compliance level is not specified. 11 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 3.4 Equations for Speed of Sound The speed of sound is derived from thermodynamic relationships[1-9]. The relationships include the compressibility factor, density, ratio of specific heats, molar mass and the partial derivative of the compressibility factor with respect to the density at a constant temperature. The basic speed of sound relation can be expressed as: éæ c p öæ RT öæ æ ∂Z ö ö ù ÷÷ç Z + ρ çç ÷÷ ÷ú W = êçç ÷÷çç ç ÷ è ∂ρ øT øúû êëè cv øè M r øè 0.5 (3.1) The isentropic exponent may be expressed in terms of its relationship to the speed of sound: κ =W 2 Mr ZRT (3.2) The quantities Cv and Cp are the constant volume and constant pressure heat capacities of the gas. ρé ìï T æ ∂ 2Z ö 2 æ ∂Z ö ù üï cv = c Po − R í1 + T ò ê çç 2 ÷÷ + ç ÷ údρ ý ρ ∂T ø ρ ρ è ∂T ø ρ úû ï ïî 0ê ë è þ (3.3) éæ ∂P ö ù êç ÷ ú æ T ö êëè ∂T ø ρ úû c p = cv + çç 2 ÷÷ è ρ ø éæ ∂P ö ù êçç ÷÷ ú êëè ∂ρ ø T úû 2 (3.4a) or, expressed in terms of compressibility, 12 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. c p = cv + R é æ ∂Z ö ù êZ + T ç ÷ ú è ∂T ø ρ ûú ëê 2 é æ ∂Z ö ù ê Z + ρ çç ÷÷ ú è ∂ρ ø T ûú ëê (3.4b) Note that the ideal gas specific heat ratio, C po , real gas specific heat ratio, o Cp , Cv Cv and the isentropic exponent, κ, are related but separate quantities. In certain gas industry applications, the ratio of ideal gas specific heats is assumed to be synonymous with the isentropic exponent. The pure fluid constant pressure ideal gas heat capacity is computed as: 2 2 2 é F /T ù é H /T ù é J /T ù é D /T ù + Eê + Gê + Iê C = B + Cê ú ú ú ú ë sinh (D / T ) û ë cosh( F / T ) û ë sinh( H / T ) û ë cosh( J / T ) û 2 o P (3.5) The pure fluid ideal gas enthalpy is computed as: H o = A + BT + CD coth (D / T ) − EF tanh( F / T ) + GH coth( H / T ) − IJ tanh( J / T ) (3.6) The real gas enthalpy is computed as: ρ é T æ ∂Z ö ù H = H + RT ê(Z − 1) − ò ç ÷∂ρ ú ρ è ∂T ø ûú 0 ëê o (3.7) 13 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The pure fluid ideal gas entropy is computed as: S o = K + B ln(T ) + C [( D / T ) coth( D / T ) − ln(sinh( D / T ))] − E[( F / T ) tanh( F / T ) − ln(cosh( F / T ))] + G[( H / T ) coth( H / T ) − ln(sinh( H / T ))] − I [( J / T ) tanh( J / T ) − ln(cosh( J / T ))] (3.8) The entropy of mixing is computed as: N S mixing = − R å X i ln ( X i ) i =1 (3.9) The real gas entropy is computed as: æ (Z − 1) T æ ∂Z ö ö P S = S + S mixing − R ln( o ) − R ò çç + ç ÷ ÷÷∂ρ ρ ρ è ∂T ø ø ZP 0è ρ o (3.10) where Po = 0.101325 MPa 14 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The coefficients for computing the ideal gas constant pressure heat capacity, enthalpy and entropy are given in Table 4. In this table, the unit of measure for energy is the thermochemical calorie (1 cal(th) = 4.184 J). Table 4 Component Calculation Coefficients for Heat Capacity, Enthalpy and Entropy A B C D E F G H I J K (cal/mol) (cal/mol-K) (cal/molK) (K) (cal/mol-K) (K) (cal/molK) (K) (cal/molK) (K) (cal/mol-K) Methane -29776.4 7.95454 43.9417 1037.09 1.56373 813.205 -24.9027 1019.98 -10.1601 1070.14 -20.0615 Nitrogen -3495.34 6.95587 0.272892 662.738 -0.291318 -680.562 1.78980 1740.06 0 100 4.49823 Carbon Dioxide 20.7307 6.96237 2.68645 500.371 -2.56429 -530.443 3.91921 500.198 2.13290 2197.22 5.81381 Ethane -37524.4 7.98139 24.3668 752.320 3.53990 272.846 8.44724 1020.13 -13.2732 869.510 -22.4010 Propane -56072.1 8.14319 37.0629 735.402 9.38159 247.190 13.4556 1454.78 -11.7342 984.518 -24.0426 Water -13773.1 7.97183 6.27078 2572.63 2.05010 1156.72 0 100 0 100 -3.24989 Hydrogen Sulfide -10085.4 7.94680 -0.0838 433.801 2.85539 843.792 6.31595 1481.43 -2.88457 1102.23 -0.51551 Hydrogen -5565.6 6.66789 2.33458 2584.98 0.749019 559.656 0 100 0 100 -7.94821 Carbon Monoxide -2753.49 6.95854 2.02441 1541.22 0.096774 3674.81 0 100 0 100 6.23387 Oxygen -3497.45 6.96302 2.40013 2522.05 2.21752 1154.15 0 100 0 100 9.19749 Isobutane -72387 17.8143 58.2062 1787.39 40.7621 808.645 0 100 0 100 -44.1341 Normal Butane -72674.8 18.6383 57.4178 1792.73 38.6599 814.151 0 100 0 100 -46.1938 Isopentane -91505.5 21.3861 74.3410 1701.58 47.0587 775.899 0 100 0 100 -60.2474 Normal Pentane -83845.2 22.5012 69.5789 1719.58 46.2164 802.174 0 100 0 100 -62.2197 Normal Hexane -94982.5 26.6225 80.3819 1718.49 55.6598 802.069 0 100 0 100 -77.5366 Normal Heptane -103353 30.4029 90.6941 1669.32 63.2028 786.001 0 100 0 100 -92.0164 Normal Octane -109674 34.0847 100.253 1611.55 69.7675 768.847 0 100 0 100 -106.149 Normal Nonane -122599 38.5014 111.446 1646.48 80.5015 781.588 0 100 0 100 -122.444 Normal Decane -133564 42.7143 122.173 1654.85 90.2255 785.564 0 100 0 100 -138.006 Helium 0.0 4.968 0 100 0 100 0 100 0 100 1.8198 Argon 0.0 4.968 0 100 0 100 0 100 0 100 8.6776 15 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The basic equation for the compressibility factor, from AGA Report No. 8, is: Z =1+ ( ) ( 18 58 DB * −u n − D C T + Cn*T − u n bn − cn kn D k n Dbn exp − cn D k n å å n 3 K n =13 n =13 ) (3.11) where * B = å a nT −un åå xi x j Eijun (K i K j )2 Bnij 18 N n =1 i =1 j =1 N 3 (3.12) The first partial derivative of Z with respect to T is: 18 D æ ∂B ö æ ∂Z ö * −(u +1) ç ÷ = 3 ç ÷ + D å u n C nT n ∂ ∂ T T K è ød è ød n =13 58 ( ) ( − å u n C n*T −(un +1) bn − cn k n D kn D bn exp − cn D k n n =13 ) (3.13) where 18 N N 3 æ ∂B ö u − (u +1) * ç ÷ = −å un anT n åå xi x j Eij n (K i K j )2 Bnij è ∂T ø d n =1 i =1 j =1 (3.14) The second partial derivative of Z with respect to T is: 18 æ ∂ 2Z ö D æ ∂ 2B ö çç 2 ÷÷ = 3 çç 2 ÷÷ − D å u n (u n + 1)C n*T −(un +2 ) n =13 è ∂T ø d K è ∂T ø d 58 ( ) ( + å u n (u n + 1)C n*T −(un + 2 ) bn − cn k n D kn D bn exp − cn D k n n =13 ) (3.15) where N N 18 3 æ ∂ 2B ö * çç 2 ÷÷ = å un (un + 1)anT − (u n + 2 ) åå xi x j Eiju n (K i K j )2 Bnij i =1 j =1 è ∂T ø d n =1 (3.16) 16 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The first partial derivative of Z with respect to ρ is: 18 ìé B æ ∂Z ö ù 58 çç ÷÷ = K 3 íê 3 − å C n*T −un ú + å C n*T −un − cn k n2 D (kn −1) D bn exp − cn D kn n =13 û n=13 è ∂ρ øT îë K ( 58 ) ( ( ) ( ) ( + å C n*T −un bn − cn k n D k n bn D (bn −1) exp − cn D kn n =13 ) ( ( ) ) ) 58 ü − å C n*T −un bn − cn k n D kn D bn cn k n D (kn −1) exp − cn D kn ý n =13 þ (3.17) 4 Critical Flow Factor Determination The critical flow factor can be determined from an iterative procedure whereby the energy and entropy balances are solved around a converging nozzle with a throat velocity that is sonic. Applying procedures listed in the appendix of ASME standard MFC-7M [5], thermodynamic changes are predicted for the acceleration of gas from the plenum to the throat of a critical flow nozzle. An assumption is made of onedimensional flow, isentropic and adiabatic. The method may be implemented to account for non-zero gas velocity in the plenum. 5 Characteristics of Typical Gases This section contains graphical representations of thermodynamic properties relevant to this document. The graphs are intended as an aid to familiarity with concepts, not as a substitute for the equations given elsewhere in this report. Five different gas mixtures are explored, in terms of speed of sound, critical flow coefficient and isentropic exponent. Each characteristic is mapped, as a function of pressure and/or temperature. 17 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The gas mixtures below match the examples given in AGA Report No. 8, Second Edition. The Amarillo, Gulf Coast, Ekofisk, High N2 and High CO2 mixtures represent a range of commercial quality natural gases found throughout the industry. Component Gulf Coast Amarillo Ekofisk High N2 High CO2 Methane 96.5222 90.6724 85.9063 81.4410 81.2110 Nitrogen 0.2595 3.1284 1.0068 13.4650 5.7020 Carbon Dioxide 0.5956 0.4676 1.4954 0.9850 7.5850 Ethane 1.8186 4.5279 8.4919 3.3000 4.3030 Propane 0.4596 0.8280 2.3015 0.6050 0.8950 Isobutane 0.0977 0.1037 0.3486 0.1000 0.1510 Normal Butane 0.1007 0.1563 0.3506 0.1040 0.1520 Isopentane 0.0473 0.0321 0.0509 0.0000 0.0000 Normal Pentane 0.0324 0.0443 0.0480 0.0000 0.0000 Normal Hexane 0.0664 0.0393 0.000 0.0000 0.0000 Table 5 Composition of Typical Gases 18 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 1500 1450 sound speed (ft/s) 1400 Gulf Coast Amarillo Ekofisk High N2 High CO2 1350 1300 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 Ekofisk High N2 High CO2 410 400 390 380 370 360 0.0 10.0 20.0 30.0 40.0 50.0 temperature (degrees C) Figure 2b Sound Speed at 8.27 MPa as a Function of Temperature 19 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 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 sound speed (m/s) 410 400 Gulf Coast Amarillo Ekofisk High N2 High CO2 390 380 370 360 350 0 1 2 3 4 5 6 7 8 9 absolute pressure (MPa) Figure 3b Sound Speed at 0° C as a Function of Pressure 20 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 0.78 0.77 0.76 0.75 Gulf Coast Amarillo Ekofisk High N2 High CO2 C* 0.74 0.73 0.72 0.71 0.7 0.69 30 50 70 90 110 130 temperature (degrees F) Figure 4a Critical Flow Coefficent, C*, at 1000 psia as a Function of Stagnation Temperature 0.780 0.770 0.760 0.750 Gulf Coast Amarillo Ekofisk High N2 High CO2 C* 0.740 0.730 0.720 0.710 0.700 0.690 0.0 10.0 20.0 30.0 40.0 50.0 60.0 temperature (degrees C) Figure 4b Critical Flow Coefficent, C*, at 6.9 MPa as a Function of StagnationTemperature 21 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 1.5 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 9.00 absolute pressure (MPa) Figure 5b Isentropic Exponent at 0° C as a Function of Pressure 22 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 5 References [1] K.E. Starling and J.L. Savidge, Compressibility Factors of Natural Gas and Other Related Hydrocarbon Gases, A.G.A. Transmission Measurement Committee Report No. 8, Second Edition, Second Printing, July, 1994. [2] R. L. McFall, Sonic Nozzle Flow Calculations for Natural Gas Using A Generalized Equation of State, M.S. Thesis, The University Of Oklahoma Graduate College, 1984. [3] F.A. Aly and L.L. Lee, Self-Consistent Equations for Calculating the Ideal Gas Heat Capacity, Enthalpy and Entropy, Fluid Phase Equilibria, 6 (1981) 169-179. [4] L.M. Ryan, Sonic Nozzle Mass Flow Calculations, Kaybob South No. 3 Meter Prover, Internal Document, Nova Corporation, August 1994. [5] The American Society of Mechanical Engineers, ASME/ANSI MFC-7M-1987, 1987. [6] J.L. Savidge, S.W. Beyerlein, and E.W. Lemmon, Technical Reference Document for the 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] Canadian Standards Association, Canadian Standards Association Metric Practice Guide, 2000: Z234.1-00. 23 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 6 Computation Flow Charts Extending the calculation process of AGA Report No. 8, the method for calculating speed of sound, enthalpy and entropy can be summarized by the following flowchart. color codes begin original AGA 8 algorithm initialize tables of constants new function for Cp (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, W 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 new AGA8 function d2ZdT2 AGA8 function relative density new AGA8 function dZdD Figure 6 Flowchart of Sound Speed Calculation Procedure 24 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The calculation sequence for the critical flow function C* is an extension of the algorithms for sound speed, enthalpy and entropy. begin compute enthalpy, entropy and sound speed at plenum compute enthalpy and sound speed at throat compute temperature and pressure, given new enthalpy and constant entropy find a pressure which satisfies a given entropy and temperature find a temperature which 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 25 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 7 Calculation Output for Program Verification 7.1 Detailed Output Results for Program Development The following three calculation scenarios provide detailed intermediate and output data for specific sets of input conditions. The purpose of this data set is to facilitate computer program development. 7.1.1 Detailed Output Result #1 Input Composition Pressure : : Pure Methane 8.000 MPa (1160.3019 psia) Temperature : 20.0° C (68.0° F) Output Molar Density : Molar Mass : Compressibility Factor : ∂Z ∂T 3.79174963 moles/dm3 16.0430000 kg/kg-mol : 0.865613011 0.001370797803 ∂ 2 Z ∂T 2 ∂Z ∂ρ ∂ B ∂T : -1.08884683127e-005 : -0.02602812374 : 0.000396764069 : -3.34719916156e-006 ∂ 2 B ∂T 2 Cp (ideal gas) : Cp (real gas) : Cv (real gas) : Isentropic exponent : Sound Speed : Specific Enthalpy : Specific Entropy : C* : 2.21437395 kJ/kg-K 2.86910318 kJ/kg-K 1.78350108 kJ/kg-K 1.42527799 432.944437 m/s 528.977205 kJ/kg 9.09475139 kJ/kg-K 0.732987437 26 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 7.1.2 Detailed Output Result #2 Input Composition Pressure : : Amarillo 4.000 MPa (580.15095 psia) Temperature : 10.0° C (50° F) Output Molar Density : Molar Mass : Compressibility Factor : ∂Z ∂T 1.87396178 moles/dm3 17.5955109 kg/kg-mol : 0.90666330 0.00084934112 ∂ 2 Z ∂T 2 ∂Z ∂ρ ∂ B ∂T : -7.3766250161e-6 : -0.0442939010 : 0.00047962844 : -4.2808097391e-006 ∂ 2 B ∂T 2 Cp (ideal gas) : Cp (real gas) : Cv (real gas) : Isentropic exponent : Sound Speed : Specific Enthalpy : Specific Entropy : C* : 2.06018714 kJ/kg-K 2.40008811 kJ/kg-K 1.64511520 kJ/kg-K 1.32535394 400.972536 m/s 499.296977 kJ/kg 9.02299618 kJ/kg-K 0.704302274 27 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 7.1.3 Detailed Output Result #3 Input Composition : Hypothetical 21 Component Mixture Methane Nitrogen Carbon Dioxide Ethane Propane Water Hydrogen Sulfide Hydrogen Carbon Monoxide Oxygen i-Butane n-Butane i-Pentane n-Pentane n-Hexane n-Heptane n-Octane n-Nonane n-Decane Helium Argon Pressure : Temperature : 86.29 2.0 0.50 5.0 3.0 0.01 0.1 0.01 0.01 0.02 1.10 0.90 0.35 0.25 0.20 0.10 0.05 0.02 0.01 0.04 0.04 6.000 MPa (870.2264 psia) 40.0° C (104.0° F) Output Molar Density : Molar Mass : Compressibility Factor : ∂Z ∂T 2.62533592 moles/dm3 19.4780144 kg/kg-mol : 0.877763047 0.00110251388 ∂ 2 Z ∂T 2 ∂Z ∂ρ ∂ B ∂T : -8.7236464045e-006 : -0.0375423163 : 0.0004594320 : -3.776948019e-006 ∂ 2 B ∂T 2 Cp (ideal gas) : Cp (real gas) : Cv (real gas) : Isentropic exponent : Sound Speed : Specific Enthalpy : Specific Entropy : C* : 2.08298699 kJ/kg-K 2.55641833 kJ/kg-K 1.73699984 kJ/kg-K 1.30648621 391.528389 m/s 508.00420 kJ/kg 8.51434681 kJ/kg-K 0.710708883 28 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 7.2 Tabled Results for Compliance Checking and Program Development The following tables were generated with the alogrithms described in this report. The numerical resolution provided is suitable for compliance checking but does not reflect the uncertainties inherent in the solution method itself. The compliance criteria given in section 3.2 of this document refer only to the results given below in Tables 6a and 6b. 29 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Speed of Sound (W) English units Temperature Pressure Speed of Sound (ft/s) F 32 32 32 32 32 32 32 32 psia 14.73 100 200 400 600 800 1000 1200 Gulf Coast 1376.597 1366.745 1355.642 1335.321 1318.413 1306.276 1300.594 1303.310 Amarillo 1342.938 1332.778 1321.304 1300.228 1282.605 1269.889 1263.899 1266.743 Ekofisk 1292.325 1279.700 1265.215 1237.817 1213.748 1195.063 1184.617 1186.056 High N2 1310.350 1302.556 1293.922 1278.667 1266.847 1259.523 1257.912 1263.309 High CO2 1265.813 1255.856 1244.570 1223.691 1205.990 1192.885 1186.169 1187.957 50 50 50 50 50 50 50 50 14.73 100 200 400 600 800 1000 1200 1399.778 1391.213 1381.650 1364.443 1350.531 1340.972 1337.006 1339.995 1365.493 1356.638 1346.728 1328.825 1314.261 1304.165 1299.870 1302.842 1313.880 1302.733 1290.049 1266.410 1246.097 1230.700 1222.250 1223.155 1332.486 1325.815 1318.509 1305.883 1296.509 1291.207 1290.879 1296.448 1287.058 1278.371 1268.612 1250.851 1236.186 1225.721 1220.765 1222.771 100 100 100 100 100 100 100 100 14.73 100 200 400 600 800 1000 1200 1460.830 1455.126 1448.935 1438.390 1430.716 1426.462 1426.212 1430.551 1424.940 1418.987 1412.505 1401.389 1393.186 1388.482 1387.900 1392.061 1370.746 1362.902 1354.172 1338.541 1325.949 1317.221 1313.273 1315.055 1390.875 1386.697 1382.301 1375.317 1371.076 1369.996 1372.500 1378.986 1343.132 1337.269 1330.855 1319.748 1311.372 1306.299 1305.135 1308.491 130 130 130 130 130 130 130 130 14.73 100 200 400 600 800 1000 1200 1495.370 1490.996 1486.351 1478.794 1473.848 1471.893 1473.315 1478.487 1458.605 1454.003 1449.093 1441.021 1435.600 1433.233 1434.333 1439.294 1403.004 1396.704 1389.791 1377.738 1368.490 1362.617 1360.724 1363.406 1423.961 1420.941 1417.877 1413.428 1411.448 1412.219 1416.016 1423.092 1374.940 1370.392 1365.511 1357.384 1351.750 1349.001 1349.538 1353.747 Table 6a 30 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Speed of Sound (W) Metric units Temperature Pressure Speed of Sound (m/s) C 0 0 0 0 0 0 0 0 MPa 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 Gulf Coast 419.5867 416.5839 413.1998 407.0058 401.8523 398.1531 396.4209 397.2489 Amarillo 409.3274 406.2307 402.7334 396.3094 390.9379 387.0622 385.2363 386.1033 Ekofisk 393.9008 390.0524 385.6374 377.2867 369.9503 364.2551 361.0712 361.5100 High N2 399.3948 397.0190 394.3874 389.7378 386.1351 383.9027 383.4116 385.0567 High CO2 385.8198 382.7850 379.3451 372.9809 367.5856 363.5914 361.5444 362.0892 10 10 10 10 10 10 10 10 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 426.6523 424.0418 421.1270 415.8822 411.6419 408.7283 407.5195 408.4305 416.2024 413.5034 410.4828 405.0260 400.5867 397.5095 396.2005 397.1062 400.4707 397.0729 393.2070 386.0018 379.8104 375.1172 372.5418 372.8175 406.1417 404.1083 401.8816 398.0332 395.1759 393.5599 393.4601 395.1572 392.2953 389.6475 386.6731 381.2593 376.7896 373.5999 372.0890 372.7007 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 445.2610 443.5224 441.6354 438.4214 436.0821 434.7855 434.7095 436.0321 434.3217 432.5074 430.5315 427.1435 424.6432 423.2094 423.0320 424.3002 417.8034 415.4124 412.7517 407.9873 404.1493 401.4891 400.2857 400.8288 423.9387 422.6653 421.3253 419.1965 417.9039 417.5749 418.3379 420.3148 409.3866 407.5996 405.6445 402.2592 399.7063 398.1599 397.8052 398.8279 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 455.7889 454.4556 453.0398 450.7364 449.2290 448.6331 449.0665 450.6429 444.5827 443.1802 441.6836 439.2233 437.5708 436.8495 437.1847 438.6969 427.6358 425.7152 423.6082 419.9346 417.1157 415.3258 414.7486 415.5661 434.0233 433.1027 432.1689 430.8128 430.2093 430.4443 431.6017 433.7584 419.0817 417.6954 416.2077 413.7308 412.0134 411.1754 411.3391 412.6220 Table 6b 31 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Critical Flow Coefficient (C*) English Units Temperature Pressure C* F 32 32 32 32 32 32 32 32 psia 14.73 100 200 400 600 800 1000 1200 Gulf Coast 0.670417 0.675541 0.681844 0.695500 0.710734 0.727755 0.746747 0.767596 Amarillo 0.669863 0.675065 0.681589 0.695774 0.711681 0.729555 0.749611 0.771751 Ekofisk 0.667375 0.673485 0.681097 0.697897 0.717468 0.740770 0.767156 0.798146 High N2 0.671600 0.676352 0.682164 0.694621 0.708285 0.723243 0.739544 0.756775 High CO2 0.670255 0.675744 0.682419 0.697193 0.713849 0.732690 0.753948 0.777601 50 50 50 50 50 50 50 50 14.73 100 200 400 600 800 1000 1200 0.669873 0.674358 0.679953 0.691938 0.705083 0.719491 0.735236 0.751996 0.669189 0.673917 0.679608 0.692034 0.705721 0.720788 0.737325 0.755020 0.666598 0.672034 0.678754 0.693445 0.709959 0.729277 0.750218 0.774151 0.670993 0.675235 0.680394 0.691341 0.703174 0.715923 0.729588 0.743905 0.669556 0.674450 0.680355 0.693279 0.707576 0.723392 0.740840 0.759633 100 100 100 100 100 100 100 100 14.73 100 200 400 600 800 1000 1200 0.667905 0.671300 0.675397 0.683874 0.692961 0.702570 0.712829 0.723242 0.667144 0.670641 0.674866 0.683630 0.693044 0.703021 0.713688 0.724557 0.663869 0.668316 0.673183 0.683511 0.694685 0.706747 0.719707 0.733378 0.669223 0.672365 0.676043 0.683878 0.692103 0.700698 0.709787 0.718835 0.667476 0.671094 0.675470 0.684666 0.694475 0.704905 0.715930 0.727355 130 130 130 130 130 130 130 130 14.73 100 200 400 600 800 1000 1200 0.666606 0.669465 0.672895 0.680003 0.687336 0.695076 0.703241 0.711526 0.665350 0.668756 0.672289 0.679624 0.687314 0.695346 0.703692 0.712298 0.662451 0.665798 0.670296 0.678807 0.687851 0.697432 0.707531 0.718088 0.667998 0.670639 0.673795 0.680297 0.686925 0.693870 0.701146 0.708427 0.665680 0.669192 0.672851 0.680458 0.688452 0.696821 0.705538 0.714547 Table 7a 32 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Critical Flow Coefficient (C*) Metric Units Temperature Pressure C* C 0 0 0 0 0 0 0 0 MPa 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 Gulf Coast 0.670417 0.675541 0.681844 0.695500 0.710734 0.727755 0.746747 0.767596 Amarillo 0.669863 0.675065 0.681589 0.695774 0.711681 0.729555 0.749611 0.771751 Ekofisk 0.667375 0.673485 0.681097 0.697897 0.717468 0.740770 0.767156 0.798146 High N2 0.671600 0.676352 0.682164 0.694621 0.708285 0.723243 0.739544 0.756775 High CO2 0.670255 0.675744 0.682419 0.697193 0.713849 0.732690 0.753948 0.777601 10 10 10 10 10 10 10 10 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 0.669873 0.674358 0.679953 0.691938 0.705083 0.719491 0.735236 0.751996 0.669189 0.673917 0.679608 0.692034 0.705721 0.720788 0.737325 0.755020 0.666598 0.672034 0.678754 0.693445 0.709959 0.729277 0.750218 0.774151 0.670993 0.675235 0.680394 0.691341 0.703174 0.715923 0.729588 0.743905 0.669556 0.674450 0.680355 0.693279 0.707576 0.723392 0.740840 0.759633 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 0.667905 0.671300 0.675397 0.683874 0.692961 0.702570 0.712829 0.723242 0.667144 0.670641 0.674866 0.683630 0.693044 0.703021 0.713688 0.724557 0.663869 0.668316 0.673183 0.683511 0.694685 0.706747 0.719707 0.733378 0.669223 0.672365 0.676043 0.683878 0.692103 0.700698 0.709787 0.718835 0.667476 0.671094 0.675470 0.684666 0.694475 0.704905 0.715930 0.727355 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 0.666606 0.669465 0.672895 0.680003 0.687336 0.695076 0.703241 0.711526 0.665350 0.668756 0.672289 0.679624 0.687314 0.695346 0.703692 0.712298 0.662451 0.665798 0.670296 0.678807 0.687851 0.697432 0.707531 0.718088 0.667998 0.670639 0.673795 0.680297 0.686925 0.693870 0.701146 0.708427 0.665680 0.669192 0.672851 0.680458 0.688452 0.696821 0.705538 0.714547 Table 7b 33 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Isentropic Exponent (κ κ) English Units Temperature Pressure Isentropic Exponent F 32 32 32 32 32 32 32 32 psia 14.73 100 200 400 600 800 1000 1200 Gulf Coast 1.305655 1.306753 1.309207 1.318742 1.336248 1.364448 1.406731 1.467046 Amarillo 1.301604 1.302437 1.304616 1.313783 1.331335 1.360274 1.404366 1.468004 Ekofisk 1.286355 1.285530 1.285824 1.291748 1.307683 1.338425 1.390576 1.472470 High N2 1.312895 1.315093 1.318859 1.330968 1.350659 1.380034 1.421522 1.477732 High CO2 1.303308 1.304100 1.306240 1.315401 1.333142 1.362646 1.407936 1.473756 50 50 50 50 50 50 50 50 14.73 100 200 400 600 800 1000 1200 1.301927 1.303386 1.306168 1.315861 1.332420 1.357804 1.394331 1.444570 1.297762 1.298975 1.301500 1.310837 1.327375 1.353264 1.391058 1.443593 1.282196 1.281857 1.282621 1.288893 1.303641 1.330207 1.372867 1.436681 1.309313 1.311802 1.315805 1.327887 1.346517 1.373215 1.409667 1.457613 1.299415 1.300595 1.303089 1.312423 1.329108 1.355410 1.394037 1.448015 100 100 100 100 100 100 100 100 14.73 100 200 400 600 800 1000 1200 1.290446 1.292600 1.295972 1.305799 1.320395 1.340624 1.367416 1.401707 1.286086 1.288045 1.291213 1.300745 1.315252 1.335680 1.363040 1.398353 1.269898 1.270578 1.272307 1.279297 1.292024 1.311904 1.340524 1.379548 1.298338 1.301364 1.305760 1.317578 1.333960 1.355575 1.383107 1.417209 1.287777 1.289724 1.292886 1.302444 1.317060 1.337718 1.365478 1.401410 130 130 130 130 130 130 130 130 14.73 100 200 400 600 800 1000 1200 1.283014 1.285431 1.289002 1.298767 1.312465 1.330650 1.353891 1.382745 1.278619 1.280867 1.284263 1.293772 1.307379 1.325687 1.349315 1.378866 1.262233 1.263345 1.265466 1.272716 1.284661 1.302202 1.326299 1.357915 1.291253 1.294468 1.298971 1.310547 1.325890 1.345425 1.369567 1.398701 1.280429 1.282679 1.286084 1.295641 1.309355 1.327855 1.351784 1.381773 Table 8a 34 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Isentropic Exponent (κ κ) Metric Units Temperature Pressure Isentropic Exponent C 0 0 0 0 0 0 0 0 MPa 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 Gulf Coast 1.305655 1.306753 1.309207 1.318742 1.336248 1.364448 1.406731 1.467046 Amarillo 1.301604 1.302437 1.304616 1.313783 1.331335 1.360274 1.404366 1.468004 Ekofisk 1.286355 1.285530 1.285824 1.291748 1.307683 1.338425 1.390576 1.472470 High N2 1.312895 1.315093 1.318859 1.330968 1.350659 1.380034 1.421522 1.477732 High CO2 1.303308 1.304100 1.306240 1.315401 1.333142 1.362646 1.407936 1.473756 10 10 10 10 10 10 10 10 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 1.301927 1.303386 1.306168 1.315861 1.332420 1.357804 1.394331 1.444570 1.297762 1.298975 1.301500 1.310837 1.327375 1.353264 1.391058 1.443593 1.282196 1.281857 1.282621 1.288893 1.303641 1.330207 1.372867 1.436681 1.309313 1.311802 1.315805 1.327887 1.346517 1.373215 1.409667 1.457613 1.299415 1.300595 1.303089 1.312423 1.329108 1.355410 1.394037 1.448015 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 1.290446 1.292600 1.295972 1.305799 1.320395 1.340624 1.367416 1.401707 1.286086 1.288045 1.291213 1.300745 1.315252 1.335680 1.363040 1.398353 1.269898 1.270578 1.272307 1.279297 1.292024 1.311904 1.340524 1.379548 1.298338 1.301364 1.305760 1.317578 1.333960 1.355575 1.383107 1.417209 1.287777 1.289724 1.292886 1.302444 1.317060 1.337718 1.365478 1.401410 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 1.283014 1.285431 1.289002 1.298767 1.312465 1.330650 1.353891 1.382745 1.278619 1.280867 1.284263 1.293772 1.307379 1.325687 1.349315 1.378866 1.262233 1.263345 1.265466 1.272716 1.284661 1.302202 1.326299 1.357915 1.291253 1.294468 1.298971 1.310547 1.325890 1.345425 1.369567 1.398701 1.280429 1.282679 1.286084 1.295641 1.309355 1.327855 1.351784 1.381773 Table 8b 35 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Constant Pressure Heat Capacity (Cp) English Units Temperature Pressure Heat Capacity (BTU/Lbm-F) F 32 32 32 32 32 32 32 32 Psia 14.73 100 200 400 600 800 1000 1200 Gulf Coast 0.506950 0.518114 0.532186 0.563920 0.601144 0.644486 0.693897 0.747987 Amarillo 0.488994 0.500128 0.514205 0.546124 0.583864 0.628144 0.678904 0.734493 Ekofisk 0.477059 0.489423 0.505335 0.542691 0.589308 0.647377 0.717702 0.796947 High N2 0.448710 0.458100 0.469826 0.495794 0.525400 0.558743 0.595435 0.634328 High CO2 0.432120 0.442493 0.455646 0.485648 0.521447 0.563887 0.613040 0.667301 50 50 50 50 50 50 50 50 14.73 100 200 400 600 800 1000 1200 0.511648 0.521749 0.534357 0.562282 0.594169 0.630235 0.670243 0.713203 0.493747 0.503814 0.516412 0.544440 0.576644 0.613283 0.654098 0.697959 0.482430 0.493600 0.507791 0.540281 0.579264 0.625738 0.679782 0.739439 0.452580 0.461077 0.471596 0.494533 0.520103 0.548245 0.578580 0.610298 0.436334 0.445689 0.457424 0.483658 0.514021 0.548845 0.587951 0.630260 100 100 100 100 100 100 100 100 14.73 100 200 400 600 800 1000 1200 0.526964 0.534780 0.544344 0.564789 0.586982 0.610810 0.635996 0.662074 0.509059 0.516831 0.526357 0.546775 0.569016 0.592965 0.618330 0.644607 0.499361 0.507931 0.518543 0.541706 0.567593 0.596203 0.627234 0.659951 0.465094 0.471676 0.479681 0.496606 0.514686 0.533765 0.553580 0.573759 0.449703 0.456882 0.465695 0.484641 0.505364 0.527779 0.551626 0.576432 130 130 130 130 130 130 130 130 14.73 100 200 400 600 800 1000 1200 0.537585 0.544378 0.552620 0.569986 0.588468 0.607928 0.628141 0.648786 0.519568 0.526314 0.534509 0.551812 0.570272 0.589748 0.610004 0.630697 0.510761 0.518166 0.527238 0.546667 0.567808 0.590549 0.614615 0.639530 0.473714 0.479439 0.486349 0.500775 0.515928 0.531665 0.547787 0.564040 0.458758 0.464972 0.472531 0.488524 0.505642 0.523762 0.542670 0.562046 Table 9a 36 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Constant Pressure Heat Capacity (Cp) Metric Units Temperature Pressure Heat Capacity (kJ/kg-K) C 0 0 0 0 0 0 0 0 MPa 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 Gulf Coast 2.12250 2.16924 2.22816 2.36102 2.51687 2.69833 2.90521 3.13167 Amarillo 2.04732 2.09394 2.15287 2.28651 2.44452 2.62991 2.84243 3.07517 Ekofisk 1.99735 2.04912 2.11574 2.27214 2.46732 2.71044 3.00487 3.33666 High N2 1.87866 1.91797 1.96707 2.07579 2.19974 2.33935 2.49297 2.65581 High CO2 1.80920 1.85263 1.90770 2.03331 2.18319 2.36088 2.56667 2.79386 10 10 10 10 10 10 10 10 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 2.14217 2.18446 2.23725 2.35416 2.48767 2.63867 2.80617 2.98604 2.06722 2.10937 2.16212 2.27946 2.41429 2.56769 2.73858 2.92222 2.01984 2.06660 2.12602 2.26205 2.42526 2.61984 2.84611 3.09588 1.89486 1.93044 1.97448 2.07051 2.17757 2.29539 2.42240 2.55520 1.82684 1.86601 1.91514 2.02498 2.15210 2.29790 2.46163 2.63877 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 2.20629 2.23902 2.27906 2.36466 2.45758 2.55734 2.66279 2.77197 2.13133 2.16387 2.20375 2.28924 2.38236 2.48262 2.58883 2.69884 2.09073 2.12661 2.17104 2.26802 2.37640 2.49618 2.62610 2.76308 1.94726 1.97481 2.00833 2.07919 2.15489 2.23477 2.31773 2.40221 1.88282 1.91287 1.94977 2.02909 2.11586 2.20971 2.30955 2.41340 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 2.25076 2.27920 2.31371 2.38642 2.46380 2.54527 2.62990 2.71634 2.17533 2.20357 2.23788 2.31033 2.38761 2.46916 2.55396 2.64060 2.13845 2.16946 2.20744 2.28879 2.37730 2.47251 2.57327 2.67758 1.98334 2.00732 2.03625 2.09665 2.16009 2.22598 2.29347 2.36152 1.92073 1.94674 1.97839 2.04535 2.11702 2.19289 2.27205 2.35317 Table 9b 37 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Constant Volume Heat Capacity (Cv) English Units Temperature Pressure Heat Capacity (BTU/Lbm-F) F 32 32 32 32 32 32 32 32 psia 14.73 100 200 400 600 800 1000 1200 Gulf Coast 0.387265 0.389480 0.392083 0.397320 0.402606 0.407916 0.413161 0.418161 Amarillo 0.374671 0.376927 0.379584 0.384949 0.390400 0.395913 0.401382 0.406590 Ekofisk 0.369665 0.372301 0.375442 0.381940 0.388807 0.396052 0.403474 0.410529 High N2 0.340975 0.342837 0.345015 0.349356 0.353668 0.357921 0.362048 0.365939 High CO2 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 38 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Constant Volume Heat Capacity (Cv) Metric Units Temperature Pressure Heat Capacity (kJ/kg-K) C 0 0 0 0 0 0 0 0 MPa 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 Gulf Coast 1.62140 1.63067 1.64157 1.66350 1.68563 1.70786 1.72982 1.75076 Amarillo 1.56867 1.57812 1.58924 1.61171 1.63453 1.65761 1.68050 1.70231 Ekofisk 1.54772 1.55875 1.57190 1.59911 1.62786 1.65819 1.68926 1.71880 High N2 1.42760 1.43539 1.44451 1.46268 1.48074 1.49854 1.51582 1.53212 High CO2 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 39 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Specific Enthalpy (H) English Units Temperature Pressure Specific Enthalpy (BTU/Lbm) F 32 32 32 32 32 32 32 32 psia 14.73 100 200 400 600 800 1000 1200 Gulf Coast 235.100 232.112 228.542 221.187 213.549 205.649 197.538 189.316 Amarillo 224.943 221.980 218.437 211.127 203.517 195.628 187.514 179.284 Ekofisk 214.460 211.209 207.298 199.136 190.486 181.334 171.728 161.838 High N2 208.312 205.820 202.855 196.788 190.553 184.182 177.726 171.266 High CO2 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 40 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Specific Enthalpy (H) Metric Units Temperature Pressure Specific Enthalpy (kJ/kg) C 0 0 0 0 0 0 0 0 MPa 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 Gulf Coast 546.844 539.892 531.588 514.481 496.716 478.339 459.473 440.350 Amarillo 523.217 516.325 508.084 491.081 473.381 455.030 436.157 417.015 Ekofisk 498.833 491.272 482.175 463.189 443.069 421.782 399.440 376.436 High N2 484.533 478.738 471.841 457.729 443.227 428.407 413.391 398.364 High CO2 459.592 453.262 445.684 430.014 413.648 396.615 379.027 361.122 10 10 10 10 10 10 10 10 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 568.165 561.658 553.912 538.051 521.728 505.006 488.000 470.894 543.788 537.339 529.657 513.906 497.665 480.999 464.030 446.955 518.918 511.849 503.381 485.854 467.518 448.404 428.640 408.514 503.399 497.978 491.546 478.456 465.106 451.568 437.948 424.391 477.771 471.853 464.795 450.300 435.314 419.889 404.135 388.235 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 628.530 623.056 616.587 603.503 590.269 576.947 563.621 550.392 602.072 596.653 590.244 577.273 564.140 550.910 537.670 524.527 575.982 570.051 563.012 548.672 534.024 519.136 504.114 489.105 556.738 552.187 546.822 536.022 525.169 514.319 503.543 492.919 529.272 524.307 518.432 506.527 494.453 482.269 470.053 457.906 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 0.101560 0.689476 1.378951 2.757903 4.136854 5.515806 6.894757 8.273709 665.666 660.701 654.851 643.082 631.261 619.440 607.687 596.077 637.956 633.042 627.249 615.590 603.870 592.146 580.487 568.970 611.220 605.845 599.490 586.631 573.614 560.505 547.388 534.369 589.489 585.366 580.520 570.810 561.111 551.471 541.941 532.579 560.964 556.465 551.160 540.470 529.709 518.930 508.195 497.576 Table 11b 41 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Specific Entropy (S) English Units Temperature Pressure Specific Entropy (BTU/Lbm.F) F 32 32 32 32 32 32 32 32 psia 14.73 100 200 400 600 800 1000 1200 Gulf Coast 2.65254 2.42183 2.33472 2.24200 2.18272 2.13682 2.09807 2.06387 Amarillo 2.57924 2.35881 2.27545 2.18651 2.12944 2.08507 2.04751 2.01424 Ekofisk 2.47804 2.27075 2.19178 2.10654 2.05079 2.00651 1.96814 1.93348 High N2 2.45345 2.24586 2.16770 2.08491 2.03239 1.99209 1.95845 1.92906 High CO2 2.34134 2.14561 2.07147 1.99218 1.94110 1.90123 1.86732 1.83717 50 50 50 50 50 50 50 50 14.73 100 200 400 600 800 1000 1200 2.67085 2.44052 2.35389 2.26225 2.20420 2.15972 2.12258 2.09010 2.59691 2.37686 2.29398 2.20611 2.15029 2.10738 2.07144 2.03996 2.49529 2.28842 2.20999 2.12601 2.07179 2.02938 1.99323 1.96103 2.46965 2.26239 2.18463 2.10271 2.05118 2.01198 1.97954 1.95142 2.35695 2.16157 2.08788 2.00960 1.95971 1.92122 1.88888 1.86045 100 100 100 100 100 100 100 100 14.73 100 200 400 600 800 1000 1200 2.71941 2.48992 2.40431 2.31491 2.25936 2.21762 2.18345 2.15411 2.64379 2.42458 2.34272 2.25710 2.20379 2.16365 2.13073 2.10242 2.54119 2.33524 2.25797 2.17655 2.12531 2.08632 2.05400 2.02594 2.51257 2.30600 2.22910 2.14903 2.09951 2.06249 2.03234 2.00659 2.39838 2.20377 2.13104 2.05484 2.00730 1.97143 1.94195 1.91656 130 130 130 130 130 130 130 130 14.73 100 200 400 600 800 1000 1200 2.74720 2.51808 2.43295 2.34453 2.29004 2.24942 2.21643 2.18830 2.67064 2.45181 2.37041 2.28577 2.23352 2.19451 2.16277 2.13568 2.56756 2.36202 2.28526 2.20496 2.15494 2.11727 2.08638 2.05981 2.53707 2.33083 2.25431 2.17506 2.12641 2.09029 2.06107 2.03627 2.42209 2.22783 2.15552 2.08024 2.03368 1.99887 1.97050 1.94624 Table 12a 42 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Specific Entropy (S) Metric Units Temperature Pressure Specific Entropy (kJ/kg.K) C 0 0 0 0 0 0 0 0 Mpa 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 Gulf Coast 11.10565 10.13971 9.77499 9.38682 9.13863 8.94642 8.78422 8.64101 Amarillo 10.79876 9.87588 9.52686 9.15449 8.91553 8.72979 8.57249 8.43324 Ekofisk 10.37505 9.50716 9.17655 8.81967 8.58626 8.40087 8.24023 8.09508 High N2 10.27211 9.40298 9.07574 8.72910 8.50920 8.34049 8.19962 8.07660 High CO2 9.80271 8.98322 8.67282 8.34085 8.12699 7.96008 7.81809 7.69184 10 10 10 10 10 10 10 10 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 11.18231 10.21797 9.85526 9.47157 9.22856 9.04231 8.88680 8.75084 10.87272 9.95144 9.60442 9.23656 9.00284 8.82317 8.67272 8.54090 10.44727 9.58115 9.25280 8.90116 8.67417 8.49660 8.34524 8.21044 10.33995 9.47216 9.14659 8.80362 8.58786 8.42377 8.28793 8.17019 9.86807 9.05007 8.74154 8.41379 8.20490 8.04377 7.90838 7.78935 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 37.77778 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 11.38563 10.42478 10.06638 9.69207 9.45950 9.28474 9.14167 9.01883 11.06904 10.15122 9.80851 9.45004 9.22682 9.05876 8.92092 8.80241 10.63946 9.77719 9.45366 9.11279 8.89826 8.73499 8.59967 8.48219 10.51961 9.65476 9.33279 8.99756 8.79023 8.63523 8.50899 8.40117 10.04154 9.22675 8.92222 8.60322 8.40417 8.25399 8.13057 8.02423 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 54.44444 0.10156 0.68948 1.37895 2.75790 4.13685 5.51581 6.89476 8.27371 11.50197 10.54271 10.18625 9.81607 9.58792 9.41787 9.27973 9.16197 11.18145 10.26522 9.92444 9.57008 9.35129 9.18795 9.05508 8.94166 10.74985 9.88932 9.56794 9.23171 9.02230 8.86460 8.73526 8.62402 10.62220 9.75870 9.43836 9.10654 8.90284 8.75162 8.62930 8.52544 10.14082 9.32750 9.02475 8.70955 8.51462 8.36885 8.25007 8.14853 Table 12b 43 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. APPENDIX A 1.0 C++ Language Example Implementation Overview of Computer Code Two groups of computer code are included in Appendix A. The first group of computer files demonstrates a C++ implementation of the AGA speed of sound calculation method. The primary goals of this implementation are clarity and compatibility with AGA Report No. 8. Consideration has also been given to secondary objectives of speed and efficiency. The second group of files may be used to create a Windows-based example application for testing or demonstrating. 1.1 File Group 1 Calculation Library File Group 1 is limited to mathematical calculations. No user interface is provided at this level but, recognizing the large community of Windows developers, support has been included for the creation of a Win32 DLL (dynamic link library). The C++ implementation in this report is derived from an implementation in the FORTRAN programming language, as it appeared in the 1994 printing of AGA Report No. 8. Much of the original program structure and nomenclature was preserved for traceability and ease of conversion. Differences exist due to the syntax and grammar associated with each programming language but the code is not strongly idiomatic to the C++ language. Conversion to ANSI C or other computer languages is feasible. Files included in Group 1 are: • aga10.h header file for aga 10 data structures, macros and prototypes • aga10.cpp c++ source code for overall execution control • detail.h header file for ‘detail’ class • detail.cpp ‘detail’ class implementation • therm.h header file for ‘therm’ class • therm.cpp ‘therm’ class implementation • entry.cpp Windows DLL entry code • script1.rc Windows resource script; version information As implemented, external processes communicate with the library through a single function call. The calling function supplies a pointer argument to a custom structure (defined in aga10.h) containing input as well as output data. 44 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Overview of Classes and Key Functions In the C++ programming language, data and functions are typically grouped in structures called classes. Two classes were created for this implementation. The Detail class is responsible for density-related computations. The Therm class is designed for additional thermodynamic calculations, including speed of sound. The Detail and Therm classes are designed for efficient repeated operation. Any number of calculations can be executed between the creation and deletion of these objects. Detail Class The Detail class contains all the data and methods required to compute gas compressibility and density related parameters. Those familiar with AGA Report No. 8 will note strong resemblance between this code and the original FORTRAN ‘Detail Characterization Method’. Several important design features were carried over to the C++ version, including the density search procedure. Extending the original functionality, the Detail class contains the new functions for solving the partial derivatives of Z and the second virial coefficient, B. Therm Class The Therm class contains data and functions for calculating heat capacity, enthalpy, entropy and the speed of sound. In typical calculations involving the speed of sound, the user provides the process pressure, temperature and gas composition. For other calculations, such as those for critical flow nozzles, the Therm class supports a method of estimating pressure and temperature from enthalpy and entropy. In the course of its execution, the Therm class calls the Detail class to perform densityrelated work. Function SOS() Function, SOS() is responsible for basic execution and memory management. It creates an object of each required class, launches calculations supported by the classes, and then removes the objects from memory. Function Crit() Function Crit() provides the same basic services of SOS(), but also estimates the critical flow function, C*, an important parameter for critical flow calculations. 45 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Crit() relies on support function HS_Mode() to predict gas pressure and temperature from enthalpy and entropy. HS_Mode() uses a nested algorithm and Newton’s Method to converge upon pressures and temperatures which satisfy given enthalpy and entropy states. Crit() imposes a significantly larger computing burden than SOS() and is recommended only for situations where C* is required. As implented in this Appendix, function Crit() will accept gas velocity at the plenum as an optional input. The gas velocity is used to refine the estimate of enthalpy at the plenum. 1.2 File Group 2 Example Windows Application The second set of code examples is intended as an example of applying a calculation DLL in an application with a graphical user interface. A simple Win32 application can be created with this code. The application requires basic Win32 support, supported widely by vendors of software development systems. This implementation was created with Microsoft Visual C++, version 6 (SP5). The interface consists of one non-modal dialog box and basic file operations, tested under the following Windows operating systems: Windows 95, 98, NT 4.0 (SP6), Windows XP. Through a conventional dialog-based interface, the user may: • collect user-defined inputs (keyed directly or loaded from file) • requests a calculation to be performed • observe and/or save the calculation output File operations consist of reading and writing AGA10STRUCT structures in binary format. Standard Windows and C++ run-time library process are used for file access. 46 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. The application interacts with aga10.dll in the following ways: • • • • initialization via DLL function AGA10_Init() de-initialization via DLL function AGA10_UnInit() creation of an AGA10STRUCT structure for exchanging data launching calculations by calling DLL function Crit() or SOS() The files included in this group are: • • • • • aga10win.h aga10win.cpp dlghlp.cpp file.cpp aga10win.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 47 AGA Report No. 10, Speed of Sound in Natural Gas This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. File Group #1 - Calculation Code 49 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File: aga10.h * Description: function prototypes and defines for aga10.cpp * Version: ver 1.7 2002.11.17 * Author: W.B. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ #ifndef _AGA10_H #define _AGA10_H /* Windows-specific export macro and header #include */ #if WIN32 #define DllExport __declspec (dllexport) #include <windows.h> #else #define DllExport #endif /* other includes */ #include <strstream> #include <iostream> #include <fstream> #include <iomanip> #include <math.h> /* status codes */ #define NORMAL #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 */ 50 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. #define MAX_NUM_OF_ITERATIONS 100 /* default tolerance limits */ #define P_CHG_TOL 0.001 /* 0.001 Pa */ #define T_CHG_TOL 0.001 /* 0.001 of a Kelvin */ /* maximum allowable P & T */ const double P_MAX = 1.379e8 ; const double P_MIN = 0.0 ; const double T_MAX = 473.15 ; const double T_MIN = 143.0 ; // maximum pressure (Pa) ~= 20,000 psi // maximum pressure = 0 // maximum temperature (K) ~= 392 F // maximum temperature (K) ~= -200 F /* universal gas constant, in two configurations */ #define RGASKJ 8.314510e-3 /* in kJ mol^-1 K^-1 */ #define RGAS 8.314510 /* in J mol^-1 K^-1 */ /* the main data structure used by this library */ typedef struct tagAGA10STRUCT { /* corresponds to the control group in meter classes */ long lStatus ; /* calculation status */ bool bForceUpdate; /* signal to perform full calculation */ double adMixture[NUMBEROFCOMPONENTS] ; /* Composition in mole fraction */ double dPb ; /* Contract base Pressure (Pa) */ double dTb ; /* Contract base temperature (K) */ double dPf ; /* Absolute Pressure (Pa) */ double dTf ; /* Flowing temperature (K) */ // basic output from AGA 8 Detail method double dMrx ; /* mixture molar mass */ double dZb ; /* compressibility at contract base condition */ double dZf ; /* compressibility at flowing condition */ double dFpv ; /* supercompressibility */ double dDb ; /* molar density at contract base conditions (moles/dm3) */ double dDf ; /* molar density at flowing conditions (moles/dm3) */ double dRhob ; /* mass density at contract base conditions (kg/m3) */ double dRhof ; /* mass density at flowing conditions (kg/m3) */ double dRD_Ideal ; /* ideal gas relative density */ double dRD_Real ; /* real gas relative density */ // additional output double dHo ; /* ideal gas specific enthalpy */ 51 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. double dH ; double dS ; double dCpi ; double dCp ; double dCv ; double dk ; double dKappa ; double dSOS ; double dCstar ; } AGA10STRUCT ; /* real gas specific enthalpy (J/kg) */ /* real gas specific entropy (J/kg-mol.K)*/ /* ideal gas constant pressure heat capacity (J/kg-mol.K)*/ /* real gas constant pressure heat capacity (J/kg-mol.K)*/ /* real gas constant volume heat capacity (J/kg-mol.K)*/ /* ratio of specific heats */ /* isentropic exponent, denoted with Greek letter kappa */ /* speed of sound (m/s) */ /* critical flow factor C* */ /* enumerations for tracking gas components */ enum gascomp{ XiC1=0, XiN2, XiCO2, XiC2, XiC3, XiH2O, XiH2S, XiH2, XiCO, XiO2, XiIC4, XiNC4, XiIC5, XiNC5, XiNC6, XiNC7, XiNC8, XiNC9, XiNC10, XiHe, XiAr } ; /* FUNCTION PROTOTYPES */ /* prototypes for initialization */ DllExport int AGA10_Init(void) ; DllExport int AGA10_UnInit(void) ; /* initialize library */ /* un-initialize library */ /* function prototype for basic SOS calculation */ DllExport double SOS(AGA10STRUCT *) ; /* function prototype for a C* calculation */ DllExport double Crit(AGA10STRUCT *, double) ; #endif 52 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File: aga10.cpp * Description: Manages overall process of calculating speed of sound * or C*; creates and uses objects based on Detail and Therm classes * Contains the following functions: * AGA10_Init(), AGA10_UnInit(), SOS(), Crit(), Cperf(), CRi() * Version: ver 1.7 2002.11.17 * Author: W.B. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ #include "aga10.h" #include "therm.h" #include "detail.h" // Create file-scope pointers to objects we will need; one of Therm class // and one of Detail class. static Therm *ptTherm ; static Detail *ptDetail ; /************************************************************************** * Function : AGA10_Init() * Arguments : void * Returns : int * Purpose : Initializes library; creates required objects * Revisions : **************************************************************************/ DllExport int AGA10_Init(void) { // create object for calculating density if (NULL == (ptDetail = new Detail)) { return MEMORY_ALLOCATION_ERROR ; } // create object for calculating thermodynamic properties 53 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. if (NULL == (ptTherm = new Therm)) { return MEMORY_ALLOCATION_ERROR ; } } return AGA10_INITIALIZED ; // AGA10_Init /************************************************************************** * Function : AGA10_UnInit() * Arguments : void * Returns : int * Purpose : Un-initializes library; deletes objects * Revisions : **************************************************************************/ DllExport int AGA10_UnInit(void) { // delete the objects (if they exist) if (ptDetail) delete ptDetail ; if (ptTherm) delete ptTherm ; return 0 ; } // AGA10_UnInit /************************************************************************** * Function : SOS() * Arguments : Pointers to external AGA10 data struct * Returns : double * Purpose : calculates speed of sound and other parameters * Revisions : **************************************************************************/ DllExport double SOS(AGA10STRUCT *ptAGA10) { // check if library is ready; initialize if necessary if (NULL == ptDetail || NULL == ptTherm) { AGA10_UnInit() ; 54 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. AGA10_Init() ; } // Call function to calculate densities and thermodynamic properties ptTherm->Run(ptAGA10, ptDetail) ; // the basic sound speed calculation doesn't calculate C*; initialize to zero ptAGA10->dCstar = 0.0 ; } // return the speed of sound to caller return ptAGA10->dSOS ; // VOS() /************************************************************************** * Function : Crit() * Arguments : Pointers to external AGA10 data struct, Detail and Therm * objects and a double precision float (gas velocity in plenum) * Returns : double * Purpose : calculates C* * Revisions : **************************************************************************/ DllExport double Crit(AGA10STRUCT *ptAGA10, double dPlenumVelocity) { // variables local to function double DH, DDH, S, H; double tolerance = 1.0 ; double R, P, T, Z ; int i ; // check objects for readiness; try to initialize if not if (NULL == ptDetail || NULL == ptTherm) { AGA10_UnInit() ; if (AGA10_INITIALIZED != AGA10_Init()) { ptAGA10->lStatus = MEMORY_ALLOCATION_ERROR ; return 0.0 ; } 55 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } // begin by calculating densities and thermodynamic properties ptTherm->Run(ptAGA10, ptDetail) ; // DH is enthalpy change from plenum to throat; this is our initial guess DH = (ptAGA10->dSOS * ptAGA10->dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0 ; // trap plenum conditions before we alter the data stucture's contents S = ptAGA10->dS ; H = ptAGA10->dH ; R = ptAGA10->dRhof ; P = ptAGA10->dPf ; Z = ptAGA10->dZf ; T = ptAGA10->dTf ; // initialize delta of DH to an arbitrary value outside of // convergence tolerance DDH = 10.0 ; // Via simple repetition, search for a pressure, temperature and sound speed // at a nozzle throat which provide constant enthalpy, given the entropy known // at the plenum. Abort if loop executes more than 100 times without convergence. for (i = 1; i < MAX_NUM_OF_ITERATIONS; i++) { // calculate P and T to satisfy H and S ptTherm->HS_Mode(ptAGA10, ptDetail, H - DH, S, true) ; // calculate new thermo, including SOS ptTherm->Run(ptAGA10, ptDetail) ; // hold DH for tolerance check DDH = DH ; // recalculate DH DH = (ptAGA10->dSOS * ptAGA10->dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0 ; // end loop if tolerance reached if (fabs(DDH - DH) < tolerance) break ; } 56 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // C* is the real gas critical flow constant (not to be confused with Cperf or CRi) ptAGA10->dCstar = (ptAGA10->dRhof * ptAGA10->dSOS) / sqrt(R * P * Z) ; // put the original plenum pressure and temperature back ptAGA10->dPf = P ; ptAGA10->dTf = T ; // restore fluid props to plenum conditions ptTherm->Run(ptAGA10, ptDetail) ; } // return the critical flow function to caller return ptAGA10->dCstar ; // Crit() /************************************************************************** * Function : Cperf() * Arguments : pointer to external AGA10 data struct * Returns : double * Purpose : calculates isentropic perfect gas critical flow function * Revisions : **************************************************************************/ double Cperf(AGA10STRUCT *ptAGA10) { double k, root, exponent ; k = ptAGA10->dKappa ; root = 2.0 / (k + 1.0) ; exponent = (k + 1.0) / (k - 1.0) ; } // isentropic perfect gas critical flow function C*i return(sqrt(k * pow(root, exponent))) ; // Cperf 57 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : CRi() * Arguments : pointer to external AGA10 data struct * Returns : double * Purpose : calculates isentropic real gas critical flow function CRi * Revisions : **************************************************************************/ double CRi(AGA10STRUCT *ptAGA10) { return (Cperf(ptAGA10) / sqrt(ptAGA10->dZf)) ; } // CRi() 58 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File : detail.h * Description: Header file for the 'Detail' class * See 'detail.cpp' for the implementation. * Version : ver 1.7 2002.11.17 * Author : W.B. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ #ifndef _DETAIL_H #define _DETAIL_H #include "aga10.h" class Detail { private: // member data int iNCC ; // number of components int aiCID[21] ; // component IDs // five history variables are used to improve efficiency during repeated calculations double dOldMixID ; // mixture ID from previous calc double dOldPb ; // Pb from previous calc double dOldTb ; // Tb from previous calc double dOldPf ; // Pf from previous calc double dOldTf ; // Tf from previous calc // EOS parameters from table 4, column 1 double adAn[58] ; double adUn[58] ; // characterization parameters from table 5 double dMri[21] ; // molecular weight of ith component double dEi[21] ; // characteristic energy parameter for ith component double dKi[21] ; // size parameter for ith component - m^3/kg-mol ^1/3 double dGi[21] ; // orientation parameter double dQi[21] ; // quadrupole parameter double dFi[21] ; // high temperature parameter 59 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. double dSi[21] ; double dWi[21] ; // dipole parameter // association parameter double dEij[21][21] ; double dUij[21][21] ; double dKij[21][21] ; double dGij[21][21] ; // virial coefficient energy binary interaction parm // binary interaction parameter for conformal energy // binary interaction parameter for size // binary interaction parameter for orientation double adTable6Eij[21][21] ; double adTable6Uij[21][21] ; double adTable6Kij[21][21] ; double adTable6Gij[21][21] ; // Table 6 constants // Table 6 constants // Table 6 constants // Table 6 constants double adTable5Qi[21] ; // table 5 constants double adTable5Fi[21] ; // table 5 constants double adTable5Si[21] ; // table 5 constants double adTable5Wi[21] ; // table 5 constants double dXi[21] ; // mole fraction of component i double dPCalc ; // pressure calculated by pdetail() double dT ; double dP ; // current temperature // current pressure double dRhoTP ; double dB ; double adBcoef[18] ; double adFn[58] ; double fx[58] ; // molar density at T & P // 2nd virial coefficient, B // 18 coefficients to calculate B // function for coefficients of density // modified coefficients used for 3 derivs double dU ; double dKp3 ; double dW ; double dQp2 ; double dF ; // mixture energy parameter // mixture size parameter ^3 // mixture orientation parameter // mixture quadrupole parameter ^2 // high temperature parameter double dRho ; double dRhoL ; double dRhoH ; // molar density // low density used in braket function // high density used in braket function 60 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. double dPRhoL ; double dPRhoH ; // low pressure used in braket function // high pressure used in braket function // private class methods bool compositionchange(AGA10STRUCT *) ; // compares new composition to old void table() ; // sets up Table 4 and 6 characterization parms void paramdl() ; // Table 5 and binary interaction parms void chardl(AGA10STRUCT *) ; // calculates composition dependent quantities void bvir() ; // calculates the 2nd virial coefficient void temp() ; // calculates temperature dependent quantities void braket(AGA10STRUCT *) ; // brackets density solutions void pdetail(double) ; // calculates pressure as a function of P and T void ddetail(AGA10STRUCT *) ; // calculates a density, given pressure & temperature void relativedensity(AGA10STRUCT *) ; // calculates mass density protected: public: Detail(void) ; ~Detail() ; // default constructor // default destructor // public functions to support advanced fluid property calculations double zdetail(double) ; // calculates compressibility factor double dZdT(double) ; // calculates 1st partial derivative of Z wrt T double d2ZdT2(double) ; // calculates 2st partial derivative of Z wrt T double dZdD(double) ; // calculates 1st partial derivative of Z wrt D // public variables also used for advanced fluid property calculations double dZ ; // current compressibility double ddZdT ; // first partial derivative of Z wrt T double dd2ZdT2 ; // second partial derivative of Z wrt T double ddZdD ; // first partial derivative of Z wrt molar density double ddBdT ; // first partial derivative of B wrt T double dd2BdT2 ; // second partial derivative of B wrt T // the Run() command launches a full calculation sequence void Run(AGA10STRUCT *) ; } ; #endif 61 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File : detail.cpp * Description: This file contains functions implementing * AGA Report No.8 1994 - Detail Method, plus new features * required for AGA Report No. 10 * Contains the functions: * Detail(), ~Detail(), compositionchange(), Run(), table(), * paramdl(), chardl(), braket(), bvir(), temp(), ddetail(), * pdetail(), zdetail(), relativedensity(), dZdT(), d2ZdT2(), * dZdD() * Version : ver 1.7 2002.11.17 * Author : W.B. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ #include "aga10.h" #include "detail.h" #include <math.h> /************************************************************************** * Function : Detail::Detail() * Arguments : void * Returns : * Purpose : default constructor; includes initialization of * history-sensitive variables & data tables 4 and 6 * Revisions : **************************************************************************/ Detail::Detail(void) { // initialize history-sensitive variables dOldMixID = 0.0 ; // mixture ID from previous calc dOldPb = 0.0 ; // base pressure from previous calc dOldTb = 0.0 ; // base temperature from previous calc dOldPf = 0.0 ; // flowing pressure from previous calc dOldTf = 0.0 ; // flowing temperature from previous calc // initialize gas component array used within this class for (int i=0 ;i<NUMBEROFCOMPONENTS ;i++) dXi[i] = 0 ; 62 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } // function table() populates tables of static constants table() ; // Detail::Detail() /************************************************************************** * Function : Detail::~Detail() * Arguments : * Returns : * Purpose : default destructor * Revisions : **************************************************************************/ Detail::~Detail() { } // Detail::~Detail() /************************************************************************** * Function : Detail::compositionchange() * Arguments : AGA10STRUCT * * Returns : void * Purpose : Compares new composition to old by creating a semi-unique * numerical ID. It is possible but very unlikely that 2 * sequential & different compositions will produce the same ID * Revisions : **************************************************************************/ bool Detail::compositionchange(AGA10STRUCT *ptAGA10) { double dMixID = 0.0 ; int i ; // generate the numerical ID for the composition for (i=0 ; i<NUMBEROFCOMPONENTS ; i++) dMixID += ((i+2) * ptAGA10->adMixture[i]) ; // update the history variable, if different from previous if (dMixID != dOldMixID) { dOldMixID = dMixID ; return true ; 63 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } else { } return false; } // Detail::compositionchange() /************************************************************************** * Function : Detail::Run() * Arguments : AGA10STRUCT * * Returns : void * Purpose : public method to coordinate and run the full calc sequence * Revisions : **************************************************************************/ void Detail::Run(AGA10STRUCT *ptAGA10) { int i ; // Check for gas composition change ptAGA10->bForceUpdate = (ptAGA10->bForceUpdate || compositionchange(ptAGA10)) ; // assign component IDs and values if (ptAGA10->bForceUpdate) { iNCC = -1 ; for (i=0 ;i<NUMBEROFCOMPONENTS ;i++) { if (ptAGA10->adMixture[i] > 0.0) { iNCC = iNCC + 1 ; aiCID[iNCC] = i ; dXi[iNCC] = ptAGA10->adMixture[i] ; } } iNCC = iNCC +1 ; // calculate composition dependent quantities; ported from original // FORTRAN functions paramdl() and chardl() 64 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. paramdl() ; chardl(ptAGA10) ; } // evaluate T & P dependent parms at base pressure and temperature, // but only if necessary if ((fabs(ptAGA10->dPb - dOldPb) > P_CHG_TOL)|| (fabs(ptAGA10->dTb - dOldTb) > T_CHG_TOL)|| (ptAGA10->bForceUpdate)) { dP = ptAGA10->dPb * 1.0e-6 ; // AGA 8 uses MPa internally dT = ptAGA10->dTb ; // calculate temperature dependent parms temp() ; // determine molar density ddetail(ptAGA10) ; ptAGA10->dDb = dRho ; // determine compressibility ptAGA10->dZb = zdetail(dRho) ; // calculate mass density dRhoTP = (dP * ptAGA10->dMrx) / (ptAGA10->dZb * RGASKJ * dT) ; // calculate relative density relativedensity(ptAGA10) ; // copy density to data structure member ptAGA10->dRhob = dRhoTP ; // update history and clear the ForceUpdate flag dOldTb = ptAGA10->dTb ; dOldPb = ptAGA10->dPb ; ptAGA10->bForceUpdate = true ; } // repeat the process using flowing conditions // begin by loading P & T from data structure // AGA 8 uses MPa internally; converted from Pa here dP = ptAGA10->dPf * 1.0e-6 ; dT = ptAGA10->dTf ; // check whether to calculate temperature dependent parms if ((fabs(ptAGA10->dTf - dOldTf) > T_CHG_TOL)||(ptAGA10->bForceUpdate)) 65 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. { // if temperature has changed, we must follow through temp() ; // force ForceUpdate flag to true ptAGA10->bForceUpdate = true ; } // check whether to calculate other parms if ((fabs(ptAGA10->dPf - dOldPf) > P_CHG_TOL)||(ptAGA10->bForceUpdate)) { // determine molar density ddetail(ptAGA10) ; ptAGA10->dDf = dRho ; // determine compressibility ptAGA10->dZf = zdetail(dRho) ; // calculate mass density dRhoTP = (dP * ptAGA10->dMrx) / (ptAGA10->dZf * RGASKJ * dT) ; // copy density to data structure member ptAGA10->dRhof = dRhoTP ; // update history dOldTf = ptAGA10->dTf ; dOldPf = ptAGA10->dPf ; } // calculate legacy factor Fpv // NOTE: as implemented here, Fpv is not constrained to 14.73 psi and 60F if ((ptAGA10->dZb > 0.0) && (ptAGA10->dZf > 0.0)) { ptAGA10->dFpv = sqrt(ptAGA10->dZb / ptAGA10->dZf) ; } else // if either Zb or Zf is zero at this point, we have a serious unexpected problem { ptAGA10->dFpv = ptAGA10->dZb = ptAGA10->dZf = 0.0 ; ptAGA10->lStatus = GENERAL_CALCULATION_FAILURE ; } } // we are now up to date; toggle off the update flag ptAGA10->bForceUpdate = false ; // Detail::Run() 66 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Detail::table() * Arguments : void * Returns : void * Purpose : builds tables of constants * Revisions : **************************************************************************/ // // // // // // // // // // Tables 4 and 6 are filled only during object initialization. component ID's, mapped to each species supported by AGA Report#8 1 - methane 8 - hydrogen 15 - n-hexane 2 - nitrogen 9 - carbon monoxide 16 - n-heptane 3 - carbon dioxide 10 - oxygen 17 - n-octane 4 - ethane 11 - i-butane 18 - n-nonane 5 - propane 12 - n-butane 19 - n-decane 6 - water 13 - i-pentane 20 - helium 7 - hydrogen sulfide 14 - n-pentane 21 - argon void Detail::table(void) { int j, k ; // 58 constants from table 4 - column A(n) adAn[0] = 0.153832600 ; adAn[1] = 1.341953000 ; adAn[2] = -2.998583000 ; adAn[3] = -0.048312280 ; adAn[4] = 0.375796500 ; adAn[5] = -1.589575000 ; adAn[6] = -0.053588470 ; adAn[7] = 0.886594630 ; adAn[8] = -0.710237040 ; adAn[9] = -1.471722000 ; adAn[10] = 1.321850350 ; adAn[11] = -0.786659250 ; adAn[12] = 2.29129E-09 ; 67 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. adAn[13] = 0.157672400 ; adAn[14] = -0.436386400 ; adAn[15] = -0.044081590 ; adAn[16] = -0.003433888 ; adAn[17] = 0.032059050 ; adAn[18] = 0.024873550 ; adAn[19] = 0.073322790 ; adAn[20] = -0.001600573 ; adAn[21] = 0.642470600 ; adAn[22] = -0.416260100 ; adAn[23] = -0.066899570 ; adAn[24] = 0.279179500 ; adAn[25] = -0.696605100 ; adAn[26] = -0.002860589 ; adAn[27] = -0.008098836 ; adAn[28] = 3.150547000 ; adAn[29] = 0.007224479 ; adAn[30] = -0.705752900 ; adAn[31] = 0.534979200 ; adAn[32] = -0.079314910 ; adAn[33] = -1.418465000 ; adAn[34] = -5.99905E-17 ; adAn[35] = 0.105840200 ; adAn[36] = 0.034317290 ; adAn[37] = -0.007022847 ; adAn[38] = 0.024955870 ; adAn[39] = 0.042968180 ; adAn[40] = 0.746545300 ; adAn[41] = -0.291961300 ; adAn[42] = 7.294616000 ; adAn[43] = -9.936757000 ; adAn[44] = -0.005399808 ; adAn[45] = -0.243256700 ; adAn[46] = 0.049870160 ; adAn[47] = 0.003733797 ; adAn[48] = 1.874951000 ; adAn[49] = 0.002168144 ; adAn[50] = -0.658716400 ; adAn[51] = 0.000205518 ; adAn[52] = 0.009776195 ; 68 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. adAn[53] = -0.020487080 ; adAn[54] = 0.015573220 ; adAn[55] = 0.006862415 ; adAn[56] = -0.001226752 ; adAn[57] = 0.002850908 ; // 58 constants from table 4 - column Un adUn[0] = 0.0 ; adUn[1] = 0.5 ; adUn[2] = 1.0 ; adUn[3] = 3.5 ; adUn[4] = -0.5 ; adUn[5] = 4.5 ; adUn[6] = 0.5 ; adUn[7] = 7.5 ; adUn[8] = 9.5 ; adUn[9] = 6.0 ; adUn[10] = 12.0; adUn[11] = 12.5; adUn[12] = -6.0; adUn[13] = 2.0 ; adUn[14] = 3.0 ; adUn[15] = 2.0 ; adUn[16] = 2.0 ; adUn[17] = 11.0; adUn[18] = -0.5 ; adUn[19] = 0.5 ; adUn[20] = 0.0 ; adUn[21] = 4.0 ; adUn[22] = 6.0 ; adUn[23] = 21.0; adUn[24] = 23.0; adUn[25] = 22.0; adUn[26] = -1.0 ; adUn[27] = -0.5 ; adUn[28] = 7.0 ; adUn[29] = -1.0 ; adUn[30] = 6.0 ; adUn[31] = 4.0 ; adUn[32] = 1.0 ; 69 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. adUn[33] = 9.0 ; adUn[34] = -13.0; adUn[35] = 21.0; adUn[36] = 8.0 ; adUn[37] = -0.5 ; adUn[38] = 0.0 ; adUn[39] = 2.0 ; adUn[40] = 7.0 ; adUn[41] = 9.0 ; adUn[42] = 22.0; adUn[43] = 23.0; adUn[44] = 1.0 ; adUn[45] = 9.0 ; adUn[46] = 3.0 ; adUn[47] = 8.0 ; adUn[48] = 23.0; adUn[49] = 1.5 ; adUn[50] = 5.0 ; adUn[51] = -0.5 ; adUn[52] = 4.0 ; adUn[53] = 7.0 ; adUn[54] = 3.0 ; adUn[55] = 0.0 ; adUn[56] = 1.0 ; adUn[57] = 0.0 ; // Most of the tables are filled with 1.0 or 0.0 // It is up to us to set non-zero values for (j=0 ; j < NUMBEROFCOMPONENTS ; j++) { for (k=j ; k < NUMBEROFCOMPONENTS ; k++) { adTable6Eij[j][k] = 1.0 ; adTable6Uij[j][k] = 1.0 ; adTable6Kij[j][k] = 1.0 ; adTable6Gij[j][k] = 1.0 ; } } 70 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // Lnsert the 132 items of non-zero and non-1.0 data // This looks more cumbersome than it is, considering table 6 has 1764 members adTable6Eij[0][1] = 0.971640 ; adTable6Eij[0][2] = 0.960644 ; adTable6Eij[0][4] = 0.994635 ; adTable6Eij[0][5] = 0.708218 ; adTable6Eij[0][6] = 0.931484 ; adTable6Eij[0][7] = 1.170520 ; adTable6Eij[0][8] = 0.990126 ; adTable6Eij[0][10] = 1.019530 ; adTable6Eij[0][11] = 0.989844 ; adTable6Eij[0][12] = 1.002350 ; adTable6Eij[0][13] = 0.999268 ; adTable6Eij[0][14] = 1.107274 ; adTable6Eij[0][15] = 0.880880 ; adTable6Eij[0][16] = 0.880973 ; adTable6Eij[0][17] = 0.881067 ; adTable6Eij[0][18] = 0.881161 ; adTable6Eij[1][2] = 1.022740 ; adTable6Eij[1][3] = 0.970120 ; adTable6Eij[1][4] = 0.945939 ; adTable6Eij[1][5] = 0.746954 ; adTable6Eij[1][6] = 0.902271 ; adTable6Eij[1][7] = 1.086320 ; adTable6Eij[1][8] = 1.005710 ; adTable6Eij[1][9] = 1.021000 ; adTable6Eij[1][10] = 0.946914 ; adTable6Eij[1][11] = 0.973384 ; adTable6Eij[1][12] = 0.959340 ; adTable6Eij[1][13] = 0.945520 ; adTable6Eij[2][3] = 0.925053 ; adTable6Eij[2][4] = 0.960237 ; adTable6Eij[2][5] = 0.849408 ; adTable6Eij[2][6] = 0.955052 ; adTable6Eij[2][7] = 1.281790 ; adTable6Eij[2][8] = 1.500000 ; adTable6Eij[2][10] = 0.906849 ; adTable6Eij[2][11] = 0.897362 ; adTable6Eij[2][12] = 0.726255 ; 71 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. adTable6Eij[2][13] = 0.859764 ; adTable6Eij[2][14] = 0.855134 ; adTable6Eij[2][15] = 0.831229 ; adTable6Eij[2][16] = 0.808310 ; adTable6Eij[2][17] = 0.786323 ; adTable6Eij[2][18] = 0.765171 ; adTable6Eij[3][4] = 1.022560 ; adTable6Eij[3][5] = 0.693168 ; adTable6Eij[3][6] = 0.946871 ; adTable6Eij[3][7] = 1.164460 ; adTable6Eij[3][11] = 1.013060 ; adTable6Eij[3][13] = 1.005320 ; adTable6Eij[4][7] = 1.034787 ; adTable6Eij[4][11] = 1.004900 ; adTable6Eij[6][14] = 1.008692 ; adTable6Eij[6][15] = 1.010126 ; adTable6Eij[6][16] = 1.011501 ; adTable6Eij[6][17] = 1.012821 ; adTable6Eij[6][18] = 1.014089 ; adTable6Eij[7][8] = 1.100000 ; adTable6Eij[7][10] = 1.300000 ; adTable6Eij[7][11] = 1.300000 ; adTable6Uij[0][1] = 0.886106 ; adTable6Uij[0][2] = 0.963827 ; adTable6Uij[0][4] = 0.990877 ; adTable6Uij[0][6] = 0.736833 ; adTable6Uij[0][7] = 1.156390 ; adTable6Uij[0][11] = 0.992291 ; adTable6Uij[0][13] = 1.003670 ; adTable6Uij[0][14] = 1.302576 ; adTable6Uij[0][15] = 1.191904 ; adTable6Uij[0][16] = 1.205769 ; adTable6Uij[0][17] = 1.219634 ; adTable6Uij[0][18] = 1.233498 ; adTable6Uij[1][2] = 0.835058 ; adTable6Uij[1][3] = 0.816431 ; adTable6Uij[1][4] = 0.915502 ; adTable6Uij[1][6] = 0.993476 ; adTable6Uij[1][7] = 0.408838 ; adTable6Uij[1][11] = 0.993556 ; 72 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. adTable6Uij[2][3] = 0.969870 ; adTable6Uij[2][6] = 1.045290 ; adTable6Uij[2][8] = 0.900000 ; adTable6Uij[2][14] = 1.066638 ; adTable6Uij[2][15] = 1.077634 ; adTable6Uij[2][16] = 1.088178 ; adTable6Uij[2][17] = 1.098291 ; adTable6Uij[2][18] = 1.108021 ; adTable6Uij[3][4] = 1.065173 ; adTable6Uij[3][6] = 0.971926 ; adTable6Uij[3][7] = 1.616660 ; adTable6Uij[3][10] = 1.250000 ; adTable6Uij[3][11] = 1.250000 ; adTable6Uij[3][12] = 1.250000 ; adTable6Uij[3][13] = 1.250000 ; adTable6Uij[6][14] = 1.028973 ; adTable6Uij[6][15] = 1.033754 ; adTable6Uij[6][16] = 1.038338 ; adTable6Uij[6][17] = 1.042735 ; adTable6Uij[6][18] = 1.046966 ; adTable6Kij[0][1] = 1.003630 ; adTable6Kij[0][2] = 0.995933 ; adTable6Kij[0][4] = 1.007619 ; adTable6Kij[0][6] = 1.000080 ; adTable6Kij[0][7] = 1.023260 ; adTable6Kij[0][11] = 0.997596 ; adTable6Kij[0][13] = 1.002529 ; adTable6Kij[0][14] = 0.982962 ; adTable6Kij[0][15] = 0.983565 ; adTable6Kij[0][16] = 0.982707 ; adTable6Kij[0][17] = 0.981849 ; adTable6Kij[0][18] = 0.980991 ; adTable6Kij[1][2] = 0.982361 ; adTable6Kij[1][3] = 1.007960 ; adTable6Kij[1][6] = 0.942596 ; adTable6Kij[1][7] = 1.032270 ; adTable6Kij[2][3] = 1.008510 ; adTable6Kij[2][6] = 1.007790 ; adTable6Kij[2][14] = 0.910183 ; adTable6Kij[2][15] = 0.895362 ; 73 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } adTable6Kij[2][16] = 0.881152 ; adTable6Kij[2][17] = 0.867520 ; adTable6Kij[2][18] = 0.854406 ; adTable6Kij[3][4] = 0.986893 ; adTable6Kij[3][6] = 0.999969 ; adTable6Kij[3][7] = 1.020340 ; adTable6Kij[6][14] = 0.968130 ; adTable6Kij[6][15] = 0.962870 ; adTable6Kij[6][16] = 0.957828 ; adTable6Kij[6][17] = 0.952441 ; adTable6Kij[6][18] = 0.948338 ; adTable6Gij[0][2] = 0.807653 ; adTable6Gij[0][7] = 1.957310 ; adTable6Gij[1][2] = 0.982746 ; adTable6Gij[2][3] = 0.370296 ; adTable6Gij[2][5] = 1.673090 ; // Detail::table() /************************************************************************** * Function : Detail::paramdl() * Arguments : void * Returns : void * Purpose : sets up characterization & binary interaction parameters * Revisions : **************************************************************************/ void Detail::paramdl(void) { int j, k ; // table 5 parameters; declared locally to this function const double adTable5Mri[NUMBEROFCOMPONENTS] = {16.0430, 28.0135, 44.0100, 30.0700, 44.0970, 18.0153, 34.0820, 2.0159, 28.0100, 31.9988, 58.1230, 58.1230, 72.1500, 72.1500, 86.1770, 100.2040,114.2310,128.2580,142.2850,4.0026, 39.9480} ; 74 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. const double adTable5Ei[NUMBEROFCOMPONENTS] = {151.318300, 99.737780, 241.960600, 244.166700, 298.118300, 514.015600, 296.355000, 26.957940, 105.534800, 122.766700, 324.068900, 337.638900, 365.599900, 370.682300, 402.636293, 427.722630, 450.325022, 470.840891, 489.558373, 2.610111, 119.629900} ; const double adTable5Ki[NUMBEROFCOMPONENTS] = {0.4619255, 0.4479153, 0.4557489, 0.5279209, 0.5837490, 0.3825868, 0.4618263, 0.3514916, 0.4533894, 0.4186954, 0.6406937, 0.6341423, 0.6738577, 0.6798307, 0.7175118, 0.7525189, 0.7849550, 0.8152731, 0.8437826, 0.3589888, 0.4216551} ; const double adTable5Gi[NUMBEROFCOMPONENTS] = {0.000000,0.027815,0.189065,0.079300,0.141239, 0.332500,0.088500,0.034369,0.038953,0.021000, 0.256692,0.281835,0.332267,0.366911,0.289731, 0.337542,0.383381,0.427354,0.469659,0.000000, 0.000000} ; // most of the table 5 parameters are zero for (j=0 ; j < NUMBEROFCOMPONENTS ; j++) { adTable5Qi[j] = 0.0 ; adTable5Fi[j] = 0.0 ; adTable5Si[j] = 0.0 ; adTable5Wi[j] = 0.0 ; } // a small number of exceptions adTable5Qi[2] = 0.690000 ; adTable5Qi[5] = 1.067750 ; adTable5Qi[6] = 0.633276 ; adTable5Fi[7] = 1.0000 ; 75 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. adTable5Si[5] = 1.5822 ; adTable5Si[6] = 0.3900 ; adTable5Wi[5] = 1.0000 ; // setup characterization parameters for non-zero components for (j=iNCC-1 ; j >= 0 ; j--) { dMri[j] = adTable5Mri[aiCID[j]] ; dKi[j] = adTable5Ki[aiCID[j]] ; } for (j=0 ; j < iNCC ; j++) { dGi[j] = adTable5Gi[aiCID[j]] ; dEi[j] = adTable5Ei[aiCID[j]] ; } for (j=0 ; j < iNCC ; j++) { dQi[j] = adTable5Qi[aiCID[j]] ; dFi[j] = 0.0 ; if (aiCID[j] == 7) dFi[j] = adTable5Fi[7] ; dSi[j] = adTable5Si[aiCID[j]] ; dWi[j] = adTable5Wi[aiCID[j]] ; } } // Binary interaction parameters for arrays: eij, kij, wij, uij for (j=0 ; j < iNCC ; j++) { for (k=j ; k < iNCC ; k++) { dUij[j][k] = adTable6Uij[aiCID[j]][aiCID[k]] ; dKij[j][k] = adTable6Kij[aiCID[j]][aiCID[k]] ; dEij[j][k] = adTable6Eij[aiCID[j]][aiCID[k]] ; dGij[j][k] = adTable6Gij[aiCID[j]][aiCID[k]] ; } } // Detail::paramdl() 76 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Detail::chardl() * Arguments : AGA10STRUCT * * Returns : void * Purpose : computes composition-dependent quantities * Revisions : **************************************************************************/ void Detail::chardl(AGA10STRUCT *ptAGA10) { // variables local to function int i,j ; double tmfrac, k5p0, k2p5, u5p0, u2p5, q1p0 ; double Xij, Eij, Gij, e0p5, e2p0, e3p0, e3p5, e4p5, e6p0 ; double e7p5,e9p5,e12p0,e12p5 ; double e11p0, s3 ; // normalize mole fractions and calculate molar mass tmfrac = 0.0 ; for (j=0 ; j < iNCC ; j++) { tmfrac = tmfrac + dXi[j] ; } for (j=0 ; j < iNCC ; j++) { dXi[j] = dXi[j]/tmfrac ; } // reset virial coefficients for (j=0 ; j < 18 ; j++) { adBcoef[j] = 0.0 ; } // initialize a key subset of the local variables k5p0 = 0.0 ; 77 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. k2p5 = 0.0 ; u5p0 = 0.0 ; u2p5 = 0.0 ; dW = 0.0 ; q1p0 = 0.0 ; dF = 0.0 ; // calculate gas molecular weight ptAGA10->dMrx = 0.0 ; for (j=0 ; j < iNCC ; j++) { ptAGA10->dMrx = ptAGA10->dMrx + dXi[j] * dMri[j] ; } // calculate the composition-dependent quantities, applying a nested loop for (i=0 ; i < iNCC ; i++) { k2p5 = k2p5 + dXi[i] * dKi[i] * dKi[i] * sqrt(dKi[i]) ; u2p5 = u2p5 + dXi[i] * dEi[i] * dEi[i] * sqrt(dEi[i]) ; dW = dW + dXi[i] * dGi[i] ; q1p0 = q1p0 + dXi[i] * dQi[i] ; dF = dF + dXi[i] * dXi[i] * dFi[i] ; for (j=i ; j < iNCC ; j++) { if (i != j) Xij = 2.0 * dXi[i] * dXi[j] ; else Xij = dXi[i] * dXi[j] ; // proceed while skipping interaction terms which equal 1.0 if (dKij[i][j] != 1.0) k5p0 += Xij * (pow(dKij[i][j],5.0) - 1.0) * pow((pow(dKi[i],5.0) * pow(dKi[j],5.0)),0.5) ; if (dUij[i][j] != 1.0) u5p0 += Xij * (pow(dUij[i][j],5.0) - 1.0) * pow((pow(dEi[i],5.0) * pow(dEi[j],5.0)),0.5) ; if (dGij[i][j] != 1.0) dW += Xij * (dGij[i][j] - 1.0) * ((dGi[i] + dGi[j]) / 2.0) ; 78 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // calculate terms required for second virial coefficient, B Eij = dEij[i][j] * sqrt(dEi[i] * dEi[j]) ; Gij = dGij[i][j] * (dGi[i] + dGi[j]) / 2.0 ; e0p5 = sqrt(Eij) ; e2p0 = Eij * Eij ; e3p0 = Eij * e2p0 ; e3p5 = e3p0 * e0p5 ; e4p5 = Eij * e3p5 ; e6p0 = e3p0 * e3p0 ; e11p0= e4p5 * e4p5 * e2p0 ; e7p5 = e4p5 * Eij * e2p0 ; e9p5 = e7p5 * e2p0 ; e12p0= e11p0 * Eij ; e12p5= e12p0 * e0p5 ; s3 = Xij * pow((pow(dKi[i], 3.0) * pow(dKi[j],3)), 0.5) ; adBcoef[0] = adBcoef[0] + s3 ; adBcoef[1] = adBcoef[1] + s3 * e0p5 ; adBcoef[2] = adBcoef[2] + s3 * Eij ; adBcoef[3] = adBcoef[3] + s3 * e3p5 ; adBcoef[4] = adBcoef[4] + s3 * Gij / e0p5 ; adBcoef[5] = adBcoef[5] + s3 * Gij * e4p5 ; adBcoef[6] = adBcoef[6] + s3 * dQi[i] * dQi[j] * e0p5 ; adBcoef[7] = adBcoef[7] + s3 * dSi[i] * dSi[j] * e7p5 ; adBcoef[8] = adBcoef[8] + s3 * dSi[i] * dSi[j] * e9p5 ; adBcoef[9] = adBcoef[9] + s3 * dWi[i] * dWi[j] * e6p0 ; adBcoef[10] = adBcoef[10]+ s3 * dWi[i] * dWi[j] * e12p0 ; adBcoef[11] = adBcoef[11]+ s3 * dWi[i] * dWi[j] * e12p5 ; adBcoef[12] = adBcoef[12] + s3 * dFi[i] * dFi[j] / e6p0 ; adBcoef[13] = adBcoef[13] + s3 * e2p0 ; adBcoef[14] = adBcoef[14] + s3 * e3p0 ; adBcoef[15] = adBcoef[15] + s3 * dQi[i] * dQi[j] * e2p0 ; adBcoef[16] = adBcoef[16] + s3 * e2p0 ; adBcoef[17] = adBcoef[17] + s3 * e11p0 ; } } 79 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // grab the first 18 constants from table 4, completing Bnij for (i=0 ; i < 18 ; i++) adBcoef[i] *= adAn[i] ; } // final products of chardl are mixture size parameter K, energy parameter U, // and quadrupole parameter Q dKp3 = pow((k5p0 + k2p5 * k2p5), 0.6) ; dU = pow((u5p0 + u2p5 * u2p5), 0.2) ; dQp2 = q1p0 * q1p0 ; // Detail::chardl() /************************************************************************** * Function : Detail::bvir() * Arguments : void * Returns : void * Purpose : computes 2nd virial coefficient & partial derivs thereof * Revisions : **************************************************************************/ void Detail::bvir(void) { // variables local to function double t0p5, t2p0, t3p0, t3p5, t4p5, t6p0, t11p0 ; double t7p5, t9p5, t12p0, t12p5 ; double t1p5, t4p0 ; double Bx[18] ; int i ; // reset B and partial devivatives to 0.0 dB = ddBdT = dd2BdT2 = 0.0 ; // pre-calculate powers of T t0p5 = sqrt(dT) ; t2p0 = dT * dT ; t3p0 = dT * t2p0 ; t3p5 = t3p0 * t0p5 ; t4p5 = dT * t3p5 ; t6p0 = t3p0 * t3p0 ; 80 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. t11p0 = t4p5 * t4p5 * t2p0 ; t7p5 = t6p0 * dT * t0p5 ; t9p5 = t7p5 * t2p0 ; t12p0 = t9p5 * t0p5 * t2p0 ; t12p5 = t12p0 * t0p5 ; t1p5 = dT * t0p5 ; t4p0 = t2p0 * t2p0 ; // coefficients for B Bx[0] = adBcoef[0] ; Bx[1] = adBcoef[1] / t0p5 ; Bx[2] = adBcoef[2] / dT ; Bx[3] = adBcoef[3] / t3p5 ; Bx[4] = adBcoef[4] * t0p5 ; Bx[5] = adBcoef[5] / t4p5 ; Bx[6] = adBcoef[6] / t0p5 ; Bx[7] = adBcoef[7] / t7p5 ; Bx[8] = adBcoef[8] / t9p5 ; Bx[9] = adBcoef[9] / t6p0 ; Bx[10] = adBcoef[10] / t12p0 ; Bx[11] = adBcoef[11] / t12p5 ; Bx[12] = adBcoef[12] * t6p0 ; Bx[13] = adBcoef[13] / t2p0 ; Bx[14] = adBcoef[14] / t3p0 ; Bx[15] = adBcoef[15] / t2p0 ; Bx[16] = adBcoef[16] / t2p0 ; Bx[17] = adBcoef[17] / t11p0 ; // sum up the pieces for second virial coefficient, B for (i= 0; i < 18; i++) { dB += Bx[i] ; } // calculate terms for first derivative of B, wrt T for (i= 0; i < 18; i++) { if (adUn[i]) Bx[i] *= adUn[i] ; } 81 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // sum up the pieces of first derivative of B // note div by dT; changes exponent of T for (i= 0; i < 18; i++) { if (adUn[i]) ddBdT += Bx[i] / dT ; } // sign change here ddBdT = -ddBdT ; // calculate terms for second derivative of B, wrt T for (i= 0; i < 18; i++) { if (adUn[i] && adUn[i] != -1.0) Bx[i] *= (adUn[i] + 1.0) ; } // sum up the pieces of second derivative of B // note division by dT, thereby changing the exponent of T // loop will ignore Bx[0] which is = 0.0 for (i= 0; i < 18; i++) { if (adUn[i] && adUn[i] != -1.0) dd2BdT2 += Bx[i] / t2p0 ; } } // Detail::bvir() 82 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Detail::temp() * Arguments : void * Returns : void * Purpose : computes temperature-dependent quantities * Revisions : **************************************************************************/ void Detail::temp(void) { // Note: this function was ported from the AGA Report No.8 FORTRAN listing, // retaining as much of the original content as possible // variables local to function double tr0p5, tr1p5, tr2p0, tr3p0, tr4p0, tr5p0, tr6p0 ; double tr7p0, tr8p0, tr9p0, tr11p0, tr13p0, tr21p0 ; double tr22p0, tr23p0, tr ; /* calculate second virial coefficient B bvir() ; */ // calculate adFn(12) through adFn(57) // adFn(0)-adFn(11) do not contribute to csm terms tr = dT / (dU) ; tr0p5 = sqrt(tr) ; tr1p5 = tr * tr0p5 ; tr2p0 = tr * tr ; tr3p0 = tr * tr2p0 ; tr4p0 = tr * tr3p0 ; tr5p0 = tr * tr4p0 ; tr6p0 = tr * tr5p0 ; tr7p0 = tr * tr6p0 ; tr8p0 = tr * tr7p0 ; tr9p0 = tr * tr8p0 ; tr11p0 = tr6p0 * tr5p0 ; tr13p0 = tr6p0 * tr7p0 ; tr21p0 = tr9p0 * tr9p0 * tr3p0 ; tr22p0 = tr * tr21p0 ; tr23p0 = tr * tr22p0 ; 83 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. adFn[12] = adAn[12] * dF * tr6p0 ; adFn[13] = adAn[13] / tr2p0 ; adFn[14] = adAn[14] / tr3p0 ; adFn[15] = adAn[15] * dQp2 / tr2p0 ; adFn[16] = adAn[16] / tr2p0 ; adFn[17] = adAn[17] / tr11p0 ; adFn[18] = adAn[18] * tr0p5 ; adFn[19] = adAn[19] / tr0p5 ; adFn[20] = adAn[20] ; adFn[21] = adAn[21] / tr4p0 ; adFn[22] = adAn[22] / tr6p0 ; adFn[23] = adAn[23] / tr21p0 ; adFn[24] = adAn[24] * dW / tr23p0 ; adFn[25] = adAn[25] * dQp2 / tr22p0 ; adFn[26] = adAn[26] * dF * tr ; adFn[27] = adAn[27] * dQp2 * tr0p5 ; adFn[28] = adAn[28] * dW / tr7p0 ; adFn[29] = adAn[29] * dF * tr ; adFn[30] = adAn[30] / tr6p0 ; adFn[31] = adAn[31] * dW / tr4p0 ; adFn[32] = adAn[32] * dW / tr ; adFn[33] = adAn[33] * dW / tr9p0 ; adFn[34] = adAn[34] * dF * tr13p0 ; adFn[35] = adAn[35] / tr21p0 ; adFn[36] = adAn[36] * dQp2 / tr8p0 ; adFn[37] = adAn[37] * tr0p5 ; adFn[38] = adAn[38] ; adFn[39] = adAn[39] / tr2p0 ; adFn[40] = adAn[40] / tr7p0 ; adFn[41] = adAn[41] * dQp2 / tr9p0 ; adFn[42] = adAn[42] / tr22p0 ; adFn[43] = adAn[43] / tr23p0 ; adFn[44] = adAn[44] / tr ; adFn[45] = adAn[45] / tr9p0 ; adFn[46] = adAn[46] * dQp2 / tr3p0 ; adFn[47] = adAn[47] / tr8p0 ; adFn[48] = adAn[48] * dQp2 / tr23p0 ; adFn[49] = adAn[49] / tr1p5 ; adFn[50] = adAn[50] * dW / tr5p0 ; 84 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } adFn[51] = adAn[51] * dQp2 * tr0p5 ; adFn[52] = adAn[52] / tr4p0 ; adFn[53] = adAn[53] * dW / tr7p0 ; adFn[54] = adAn[54] / tr3p0 ; adFn[55] = adAn[55] * dW ; adFn[56] = adAn[56] / tr ; adFn[57] = adAn[57] * dQp2 ; // Detail::temp() /************************************************************************** * Function : Detail::ddetail() * Arguments : AGA10STRUCT * * Returns : void * Purpose : calculates density * Revisions : **************************************************************************/ // Note: this function was ported from the AGA Report No.8 FORTRAN listing, // retaining as much of the original content as possible void Detail::ddetail(AGA10STRUCT *ptAGA10) { int imax, i ; double epsp, epsr, epsmin ; double x1, x2, x3, y1, y2, y3 ; double delx, delprv, delmin, delbis, xnumer, xdenom, sgndel ; double y2my3, y3my1, y1my2, boundn ; // initialize convergence tolerances imax = 150 ; epsp = 1.e-6 ; epsr = 1.e-6 ; epsmin = 1.e-7 ; dRho =0.0 ; // call subroutine braket to bracket density solution braket(ptAGA10) ; 85 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // check value of "lStatus" returned from subroutine braket if (ptAGA10->lStatus == MAX_NUM_OF_ITERATIONS_EXCEEDED || ptAGA10->lStatus == NEGATIVE_DENSITY_DERIVATIVE) { return ; } // set up to start Brent's method // x is the independent variable, y the dependent variable // delx is the current iteration change in x // delprv is the previous iteration change in x x1 = dRhoL ; x2 = dRhoH ; y1 = dPRhoL - dP ; y2 = dPRhoH - dP ; delx = x1 - x2 ; delprv = delx ; // solution is bracketed between x1 and x2 // a third point x3 is introduced for quadratic interpolation x3 = x1 ; y3 = y1 ; for (i=0 ; i < imax ; i++) { // y3 must be opposite in sign from y2 so solution between x2,x3 if (y2 * y3 > 0.0) { x3 = x1 ; y3 = y1 ; delx = x1 - x2 ; delprv = delx ; } // y2 must be value of y closest to y=0.0, then x2new=x2old+delx if (fabs(y3) < fabs(y2)) { x1 = x2 ; x2 = x3 ; 86 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. x3 = x1 ; y1 = y2 ; y2 = y3 ; y3 = y1 ; } // delmin is minimum allowed step size for unconverged iteration delmin = epsmin * fabs(x2) ; // if procedure is not converging or if delprv is less than delmin // use bisection instead // delbis = 0.5d0*(x3 - x2) is the bisection delx delbis = 0.5 * (x3 - x2) ; // tests to select numerical method for current iteration if (fabs(delprv) < delmin || fabs(y1) < fabs(y2)) { // use bisection delx = delbis ; delprv = delbis ; } else { if (x3 != x1) { // use inverse quadratic interpolation y2my3 = y2 - y3 ; y3my1 = y3 - y1 ; y1my2 = y1 - y2 ; xdenom = -(y1my2) * (y2my3) * (y3my1) ; xnumer = x1 * y2 * y3 * (y2my3) + x2 * y3 * y1 * (y3my1) + x3 * y1 * y2 * (y1my2) - x2 * xdenom ; } else { 87 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // use inverse linear interpolation xnumer = (x2-x1)*y2 ; xdenom = y1-y2 ; } // before calculating delx check delx=xnumer/xdenom is not out of bounds if (2.0 * fabs(xnumer) < fabs(delprv * xdenom)) { // procedure converging, use interpolation delprv = delx ; delx = xnumer / xdenom ; } else { // procedure diverging, use bisection delx = delbis ; delprv = delbis ; } } // check for convergence if ((fabs(y2) < epsp * dP) && (fabs(delx) < epsr * fabs(x2))) { dRho = x2 + delx ; return ; } // when unconverged, abs(delx) must be greater than delmin // minimum allowed magnitude of change in x2 is 1.0000009*delmin // sgndel, the sign of change in x2 is sign of delbis if (fabs(delx) < delmin) { sgndel = delbis / fabs(delbis) ; delx = 1.0000009 * sgndel * delmin ; delprv = delx ; } // final check to insure that new x2 is in range of old x2 and x3 // boundn is negative if new x2 is in range of old x2 and x3 boundn = delx * (x2 + delx - x3) ; 88 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. if (boundn > 0.0) { // procedure stepping out of bounds, use bisection delx = delbis ; delprv = delbis ; } // relable variables for next iteration // x1new = x2old, y1new=y2old x1 = x2 ; y1 = y2 ; // next iteration values for x2, y2 x2 = x2 + delx ; pdetail(x2) ; y2 = dPCalc - dP ; } } // ddetail: maximum number of iterations exceeded ptAGA10->lStatus=MAX_NUM_OF_ITERATIONS_EXCEEDED ; dRho = x2 ; // Detail::ddetail() 89 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Detail::braket() * Arguments : AGA10STRUCT * * Returns : void * Purpose : brackets density solution * Revisions : **************************************************************************/ // Note: this function was ported from the AGA Report No.8 FORTRAN listing, // retaining as much of the original content as possible void Detail::braket(AGA10STRUCT *ptAGA10) { // variables local to function int imax, it ; double del, rhomax, videal ; double rho1, rho2, p1, p2 ; // initialize imax = 200 ; rho1 = 0.0 ; p1 = 0.0 ; rhomax = 1.0 / dKp3 ; if (dT > 1.2593 * dU) rhomax = 20.0 * rhomax ; videal = RGASKJ * dT / dP ; if (fabs(dB) < (0.167 * videal)) { rho2 = 0.95 / (videal + dB) ; } else { rho2 = 1.15 / videal ; } del = rho2 / 20.0 ; // start iterative density search loop for (it = 0; it < imax ; it++) { 90 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. if (rho2 > rhomax && ptAGA10->lStatus != MAX_DENSITY_IN_BRAKET_EXCEEDED) { // density in braket exceeds maximum allowable density ptAGA10->lStatus = MAX_DENSITY_IN_BRAKET_EXCEEDED ; del = 0.01 * (rhomax - rho1) + (dP / (RGASKJ * dT)) / 20.0 ; rho2 = rho1 + del ; continue ; } // calculate pressure p2 at density rho2 pdetail(rho2) ; p2 = dPCalc ; // test value of p2 relative to p and relative to p1 if (p2 > dP) { // the density root is bracketed (p1<p and p2>p) dRhoL = rho1 ; dPRhoL = p1 ; dRhoH = rho2 ; dPRhoH = p2 ; ptAGA10->lStatus = NORMAL ; return; } else if (p2 > p1) { if (ptAGA10->lStatus == MAX_DENSITY_IN_BRAKET_EXCEEDED) del *= 2.0 ; rho1 = rho2 ; p1 = p2 ; rho2 = rho1 + del ; continue ; } else { // lStatus= NEGATIVE_DENSITY_DERIVATIVEindicates that // pressure has a negative density derivative, since p2 is less than // some previous pressure ptAGA10->lStatus = NEGATIVE_DENSITY_DERIVATIVE; dRho = rho1; 91 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. return; } } // maximum number of iterations exceeded if we fall through the bottom ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED ; dRho = rho2 ; return ; } // Detail::braket() /************************************************************************** * Function : Detail::pdetail() * Arguments : double * Returns : void * Purpose : calculates pressure, given D and T. Calls zdetail() * Revisions : **************************************************************************/ void Detail::pdetail(double dD) { dPCalc = zdetail(dD) * dD * RGASKJ * dT ; } // Detail::pdetail() 92 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Detail::zdetail() * Arguments : double * Returns : void * Purpose : calculates compressibility * Revisions : **************************************************************************/ double Detail::zdetail(double d) { // variables local to function double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ; // powers of reduced density D1 = dKp3 * d ; D2 = D1 * D1 ; D3 = D2 * D1 ; D4 = D3 * D1 ; D5 = D4 * D1 ; D6 = D5 * D1 ; D7 = D6 * D1 ; D8 = D7 * D1 ; D9 = D8 * D1 ; exp1 = exp(-D1) ; exp2 = exp(-D2) ; exp3 = exp(-D3) ; exp4 = exp(-D4) ; // the following expression for Z was adopted from FORTRAN example in AGA8 dZ = 1.0 + dB * d + adFn[12] * D1 * (exp3 - 1.0 - 3.0 * D3 * exp3) + (adFn[13] + adFn[14] + adFn[15]) * D1 * (exp2 - 1.0 - 2.0 * D2 * exp2) + (adFn[16] + adFn[17]) * D1 * (exp4 - 1.0 - 4.0 * D4 * exp4) + (adFn[18] + adFn[19]) * D2 * 2.0 + (adFn[20] + adFn[21] + adFn[22]) * D2 * (2.0 - 2.0 * D2) * exp2 + (adFn[23] + adFn[24] + adFn[25]) * D2 * (2.0 - 4.0 * D4) * exp4 + adFn[26] * D2 * (2.0 - 4.0 * D4) * exp4 + adFn[27] * D3 * 3.0 + (adFn[28] + adFn[29]) * D3 * (3.0 - D1) * exp1 93 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. + (adFn[30] + adFn[31]) * D3 * (3.0 - 2.0 * D2) * exp2 + (adFn[32] + adFn[33]) * D3 * (3.0 - 3.0 * D3) * exp3 + (adFn[34] + adFn[35] + adFn[36]) * D3 * (3.0 - 4.0 * D4) * exp4 + (adFn[37] + adFn[38]) * D4 * 4.0 + (adFn[39] + adFn[40] + adFn[41]) * D4 * (4.0 - 2.0 * D2) * exp2 + (adFn[42] + adFn[43]) * D4 * (4.0 - 4.0 * D4) * exp4 + adFn[44] * D5 * 5.0 + (adFn[45] + adFn[46]) * D5 * (5.0 - 2.0 * D2) * exp2 + (adFn[47] + adFn[48]) * D5 * (5.0 - 4.0 * D4) * exp4 + adFn[49] * D6 * 6.0 + adFn[50] * D6 * (6.0 - 2.0 * D2) * exp2 + adFn[51] * D7 * 7.0 + adFn[52] * D7 * (7.0 - 2.0 * D2) * exp2 + adFn[53] * D8 * (8.0 - D1) * exp1 + (adFn[54] + adFn[55]) * D8 * (8.0 - 2.0 * D2) * exp2 + (adFn[56] + adFn[57]) * D9 * (9.0 - 2.0 * D2) * exp2 ; } return dZ ; // Detail::zdetail() /************************************************************************** * Function : Detail::dZdT() * Arguments : double * Returns : double * Purpose : calculates the first partial derivative of Z wrt T * Revisions : **************************************************************************/ double Detail::dZdT(double d) { // variables local to function double tmp ; int i ; double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ; // set up powers of reduced density D1 = dKp3 * d ; D2 = D1 * D1 ; 94 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. D3 = D2 * D1 ; D4 = D3 * D1 ; D5 = D4 * D1 ; D6 = D5 * D1 ; D7 = D6 * D1 ; D8 = D7 * D1 ; D9 = D8 * D1 ; exp1 = exp(-D1) ; exp2 = exp(-D2) ; exp3 = exp(-D3) ; exp4 = exp(-D4) ; // create terms uC*T^-(un+1) from coefficients we've already computed (An[n]) for (i=12; i < 58; i++) { if (adUn[i] && adFn[i]) { fx[i] = (adFn[i] * adUn[i] * D1) / dT; } else { fx[i] = 0.0 ; } } // initial part of equation ddZdT = d * ddBdT ; // n=13 evaluates to zero except for hydrogen, for whom fn = 1 if (dF) ddZdT += fx[12] - (fx[12] * (1.0 - 3.0 * D3) * exp3) ; tmp = (1.0 - 2.0 * D2) * exp2 ; ddZdT += (fx[13] - (fx[13] * tmp)) ; ddZdT += fx[14] - (fx[14] * tmp) ; ddZdT += fx[15] - (fx[15] * tmp) ; tmp = (1.0 - 4.0 * D4) * exp4 ; ddZdT += fx[16] - (fx[16] * tmp) ; ddZdT += fx[17] - (fx[17] * tmp) ; 95 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. ddZdT = ddZdT - (fx[18] + fx[19]) * D1 * 2.0 - (fx[21] + fx[22]) * D1 * (2.0 - 2.0 * D2) * exp2 - (fx[23] + fx[24] + fx[25]) * D1 * (2.0 - 4.0 * D4) * exp4 - fx[26] * D1 * (2.0 - 4.0 * D4) * exp4 - fx[27] * D2 * 3.0 - (fx[28] + fx[29]) * D2 * (3.0 - D1) * exp1 - (fx[30] + fx[31]) * D2 * (3.0 - 2.0 * D2) * exp2 - (fx[32] + fx[33]) * D2 * (3.0 - 3.0 * D3) * exp3 - (fx[34] + fx[35] + fx[36]) * D2 * (3.0 - 4.0 * D4) * exp4 - fx[37] * D3 * 4.0 - (fx[39] + fx[40] + fx[41]) * D3 * (4.0 - 2.0 * D2) * exp2 - (fx[42] + fx[43]) * D3 * (4.0 - 4.0 * D4) * exp4 - fx[44] * D4 * 5.0 - (fx[45] + fx[46]) * D4 * (5.0 - 2.0 * D2) * exp2 - (fx[47] + fx[48]) * D4 * (5.0 - 4.0 * D4) * exp4 - fx[49] * D5 * 6.0 - fx[50] * D5 * (6.0 - 2.0 * D2) * exp2 - fx[51] * D6 * 7.0 - fx[52] * D6 * (7.0 - 2.0 * D2) * exp2 - fx[53] * D7 * (8.0 - D1) * exp1 - fx[54] * D7 * (8.0 - 2.0 * D2) * exp2 - fx[56] * D8 * (9.0 - 2.0 * D2) * exp2 ; } return ddZdT ; // Detail::dDdT() 96 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Detail::d2ZdT2() * Arguments : double * Returns : double * Purpose : calculates the second partial derivative of Z wrt T * Revisions : **************************************************************************/ double Detail::d2ZdT2(double d) { // variables local to function double tmp ; int i ; double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ; // set up powers of reduced density D1 = dKp3 * d ; D2 = D1 * D1 ; D3 = D2 * D1 ; D4 = D3 * D1 ; D5 = D4 * D1 ; D6 = D5 * D1 ; D7 = D6 * D1 ; D8 = D7 * D1 ; D9 = D8 * D1 ; exp1 = exp(-D1) ; exp2 = exp(-D2) ; exp3 = exp(-D3) ; exp4 = exp(-D4) ; // create terms uC*T^-(un+1) from coefficients we've already computed (An[n]) for (i=12; i < 58; i++) { if (adUn[i] && adFn[i]) { fx[i] = (adFn[i] * D1 * adUn[i] * (adUn[i] + 1.0)) / (dT * dT) ; } else { fx[i] = 0.0 ; 97 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } } // initial part of equation dd2ZdT2 = d * dd2BdT2 ; // n=13 evaluates to zero except for hydrogen, for whom fn = 1 if (dF) dd2ZdT2 += fx[12] - (fx[12] * (1.0 - 3.0 * D3) * exp3) ; tmp = (1.0 - 2.0 * D2) * exp2 ; dd2ZdT2 += -fx[13] + (fx[13] * tmp) ; dd2ZdT2 += -fx[14] + (fx[14] * tmp) ; dd2ZdT2 += -fx[15] + (fx[15] * tmp) ; tmp = (1.0 - 4.0 * D4) * exp4 ; dd2ZdT2 += -fx[16] + (fx[16] * tmp) ; dd2ZdT2 += -fx[17] + (fx[17] * tmp) ; dd2ZdT2 = dd2ZdT2 + (fx[18] + fx[19]) * D1 * 2.0 + (fx[21] + fx[22]) * D1 * (2.0 - 2.0 * D2) * exp2 + (fx[23] + fx[24] + fx[25]) * D1 * (2.0 - 4.0 * D4) * exp4 + fx[26] * D1 * (2.0 - 4.0 * D4) * exp4 + fx[27] * D2 * 3.0 + (fx[28] + fx[29]) * D2 * (3.0 - D1) * exp1 + (fx[30] + fx[31]) * D2 * (3.0 - 2.0 * D2) * exp2 + (fx[32] + fx[33]) * D2 * (3.0 - 3.0 * D3) * exp3 + (fx[34] + fx[35] + fx[36]) * D2 * (3.0 - 4.0 * D4) * exp4 + fx[37] * D3 * 4.0 + (fx[39] + fx[40] + fx[41]) * D3 * (4.0 - 2.0 * D2) * exp2 + (fx[42] + fx[43]) * D3 * (4.0 - 4.0 * D4) * exp4 + fx[44] * D4 * 5.0 + (fx[45] + fx[46]) * D4 * (5.0 - 2.0 * D2) * exp2 + (fx[47] + fx[48]) * D4 * (5.0 - 4.0 * D4) * exp4 + fx[49] * D5 * 6.0 + fx[50] * D5 * (6.0 - 2.0 * D2) * exp2 + fx[51] * D6 * 7.0 + fx[52] * D6 * (7.0 - 2.0 * D2) * exp2 + fx[53] * D7 * (8.0 - D1) * exp1 + fx[54] * D7 * (8.0 - 2.0 * D2) * exp2 + fx[56] * D8 * (9.0 - 2.0 * D2) * exp2 ; 98 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } return dd2ZdT2 ; // Detail::d2ZdT2() /************************************************************************** * Function : Detail::dZdD() * Arguments : double * Returns : double * Purpose : calculates the first partial derivative of Z wrt D * Revisions : **************************************************************************/ // For efficiency and continuity with AGA 8 code example, each term // is evaluated individually rather than through looping through tables. // Temporary storage is used to hold portions of complex equations and // to facilitate debugging. Additional speed optimization is possible. double Detail::dZdD(double d) { double temp, temp1, temp2, temp3; int i ; double D1, D2, D3, D4, D5, D6, D7, D8, D9, exp1, exp2, exp3, exp4 ; // set up powers of reduced density D1 = dKp3 * d ; D2 = D1 * D1 ; D3 = D2 * D1 ; D4 = D3 * D1 ; D5 = D4 * D1 ; D6 = D5 * D1 ; D7 = D6 * D1 ; D8 = D7 * D1 ; D9 = D8 * D1 ; exp1 = exp(-D1) ; exp2 = exp(-D2) ; exp3 = exp(-D3) ; exp4 = exp(-D4) ; 99 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // create terms uC*T^-(un+1) from coefficients we've already computed (An[n]) for (i=12; i < 58; i++) { fx[i] = adFn[i] ; } // initial part of equation ddZdD = dB / dKp3 ; // evaluate all remaining terms, simplifying where possible // n=13 evaluates to zero except for hydrogen, for whom fn = 1 if (dF) { temp1 = -9.0 * D3 * exp3 ; temp2 = (1.0 - 3.0 * D3) * exp3 ; temp3 = -temp2 * 3.0 * D6; temp = temp1 + temp2 + temp3 ; ddZdD += -fx[12] + fx[12] * temp ; } // n = 14..16 temp1 = -4.0 * D2 * exp2 ; temp2 = (1.0 - 2.0 * D2) * exp2 ; temp3 = -temp2 * 2.0 * D2; temp = temp1 + temp2 + temp3 ; ddZdD += -fx[13] + fx[13] * temp ; ddZdD += -fx[14] + fx[14] * temp ; ddZdD += -fx[15] + fx[15] * temp ; // n = 17..18 temp1 = -16.0 * D4 * exp4 ; temp2 = (1.0 - 4.0 * D4) * exp4 ; temp3 = -temp2 * 4.0 * D4 ; temp = temp1 + temp2 + temp3 ; ddZdD += -fx[16] + fx[16] * temp ; ddZdD += -fx[17] + fx[17] * temp ; // n = 19..20 temp = 4.0 * D1 ; ddZdD += fx[18] * temp ; ddZdD += fx[19] * temp ; 100 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // n = 21..23 temp1 = -4.0 * D3 * exp2 ; temp2 = (2.0 - 2.0 * D2) * 2.0 * D1 * exp2 ; temp3 = -temp2 * D2; temp = temp1 + temp2 + temp3 ; ddZdD += fx[20] * temp ; ddZdD += fx[21] * temp ; ddZdD += fx[22] * temp ; // n = 24..27 temp1 = -16.0 * D5 * exp4 ; temp2 = (2.0 - 4.0 * D4) * 2.0 * D1 * exp4 ; temp3 = -temp2 * 2.0 * D4 ; temp = temp1 + temp2 + temp3 ; ddZdD += fx[23] * temp ; ddZdD += fx[24] * temp ; ddZdD += fx[25] * temp ; ddZdD += fx[26] * temp ; // n = 28 temp = 9.0 * D2 ; ddZdD += fx[27] * temp ; // n = 29..30 temp = -D3 * exp1 + (3.0 - D1) * 3.0 * D2 * exp1 ; temp -= (3.0 - D1) * D3 * exp1 ; ddZdD += fx[28] * temp ; ddZdD += fx[29] * temp ; // n = 31..32 temp1 = -4.0 * D4 * exp2 ; temp2 = (3.0 - 2.0 * D2) * 3.0 * D2 * exp2 ; temp3 = -(3.0 - 2.0 * D2) * 2.0 * D4 * exp2 ; temp = temp1 + temp2 + temp3 ; ddZdD += fx[30] * temp ; ddZdD += fx[31] * temp ; // n = 33..34 temp1 = -9.0 * D5 * exp3 ; 101 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. temp2 = (3.0 - 3.0 * D3) * 3.0 * D2 * exp3 ; temp3 = -(3.0 - 3.0 * D3) * 3.0 * D5 * exp3 ; temp = temp1 + temp2 + temp3 ; ddZdD += fx[32] * temp ; ddZdD += fx[33] * temp ; // n = 35..37 temp1 = -16.0 * D6 * exp4 ; temp2 = (3.0 - 4.0 * D4) * 3.0 * D2 * exp4 ; temp3 = -(3.0 - 4.0 * D4) * D6 * 4.0 * exp4 ; temp = temp1 + temp2 + temp3 ; ddZdD += fx[34] * temp ; ddZdD += fx[35] * temp ; ddZdD += fx[36] * temp ; // n = 38..39 temp = 16.0 * D3 ; ddZdD += fx[37] * temp ; ddZdD += fx[38] * temp ; // n = 40..42 temp1 = -4.0 * D5 * exp2 ; temp2 = (4.0 - 2.0 * D2) * 4.0 * D3 * exp2 ; temp3 = -(4.0 - 2.0 * D2) * 2.0 * D5 * exp2 ; temp = temp1 + temp2 + temp3 ; ddZdD += fx[39] * temp ; ddZdD += fx[40] * temp ; ddZdD += fx[41] * temp ; // n = 43..44 temp = -16.0 * D7 * exp4 + (4.0 - 4.0 * D4) * 4.0 * D3 * exp4 ; temp -= (4.0 - 4.0 * D4) * D7 * 4.0 * exp4 ; ddZdD += fx[42] * temp ; ddZdD += fx[43] * temp ; // n = 45 temp = 25.0 * D4 ; ddZdD += fx[44] * temp ; // n = 46..47 102 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. temp = -4.0 * D6 * exp2 + (5.0 - 2.0 * D2) * 5.0 * D4 * exp2 ; temp -= (5.0 - 2.0 * D2) * D6 * 2.0 * exp2 ; ddZdD += fx[45] * temp ; ddZdD += fx[46] * temp ; // n = 48..49 temp = -16.0 * D8 * exp4 + (5.0 - 4.0 * D4) * 5.0 * D4 * exp4 ; temp -= (5.0 - 4.0 * D4) * D8 * 4.0 * exp4 ; ddZdD += fx[47] * temp ; ddZdD += fx[48] * temp ; // n = 50 temp = 36.0 * D5 ; ddZdD += fx[49] * temp ; // n = 51 temp = -4.0 * D7 * exp2 + (6.0 - 2.0 * D2) * 6.0 * D5 * exp2 ; temp -= (6.0 - 2.0 * D2) * D7 * 2.0 * exp2 ; ddZdD += fx[50] * temp ; // n = 52 temp = 49.0 * D6 ; ddZdD += fx[51] * temp ; // n = 53 temp = -4.0 * D8 * exp2 + (7.0 - 2.0 * D2) * 7.0 * D6 * exp2 ; temp -= (7.0 - 2.0 * D2) * D8 * 2.0 * exp2 ; ddZdD += fx[52] * temp ; // n = 54 temp = -1.0 * D8 * exp1 + (8.0 - D1) * 8.0 * D7 * exp1 ; temp -= (8.0 - D1) * D8 * exp1 ; ddZdD += fx[53] * temp ; // n = 55..56 temp = -4.0 * D1 * D8 * exp2 + (8.0 - 2.0 * D2) * 8.0 * D7 * exp2 ; temp -= (8.0 - 2.0 * D2) * D8 * 2.0 * D1 * exp2 ; ddZdD += fx[54] * temp ; ddZdD += fx[55] * temp ; 103 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // n = 57..58 temp = -4.0 * D2 * D8 * exp2 + (9.0 - 2.0 * D2) * 9.0 * D8 * exp2 ; temp -= (9.0 - 2.0 * D2) * D2 * D8 * 2.0 * exp2 ; ddZdD += fx[56] * temp ; ddZdD += fx[57] * temp ; ddZdD *= dKp3 ; } return ddZdD ; // Detail::dZdD() 104 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Detail::relativedensity() * Arguments : AGA10STRUCT * * Returns : void * Purpose : calculates relative density via methods listed in AGA 8 * Revisions : **************************************************************************/ void Detail::relativedensity(AGA10STRUCT *ptAGA10) { double dBX, dZa ; const double dMWair = 28.96256 ; // calculate second virial coefficient for air dBX = -0.12527 + 5.91e-4 * ptAGA10->dTb - 6.62e-7 * ptAGA10->dTb * ptAGA10->dTb ; // calculate compressibility of air dZa = 1.0 + (dBX * dP) / (RGASKJ * ptAGA10->dTb) ; } // calculate ideal gas and real gas relative densities ptAGA10->dRD_Ideal = ptAGA10->dMrx / dMWair ; ptAGA10->dRD_Real = ptAGA10->dRD_Ideal * (dZa / ptAGA10->dZb) ; // Detail::relativedensity() 105 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File : therm.h * Description : Header file for class 'Therm' * See therm.cpp for implementation of this class * Version : ver 1.7 2002.11.17 * Author : W.B. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ #ifndef _THERM_H #define _THERM_H #include "aga10.h" #include "detail.h" class Therm { private: // member data double dT ; double dP ; double dD ; double dRho ; double dPdD ; double dPdT ; double dSi ; double dTold ; double dMrxold ; // current temperature, in Kelvins // current pressure, in Pascals // molar density, in moles/dm3 // mass density, in kg/m3 // partial deriv of P wrt D // partial deriv of P wrt T // ideal gas specific entropy, kJ/kg.K // temperature previously used // mixture molar mass previously used // private methods double CpiMolar(AGA10STRUCT *) ; protected: public: Therm(void) ; ~Therm() ; // default constructor // default destructor 106 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. void Run(AGA10STRUCT *, Detail *) ; // runs an object based on this class double Ho(AGA10STRUCT *) ; // ideal gas enthalpy double So(AGA10STRUCT *) ; // ideal gas entropy void CprCvrHS(AGA10STRUCT *, Detail *) ; // specific heat capacities + k_ideal + H + S double H(AGA10STRUCT *, Detail *) ; // real gas specific enthalpy double S(AGA10STRUCT *, Detail *) ; // real gas specific entropy void HS_Mode(AGA10STRUCT *, Detail *, double, double, bool) ; // estimates P & T, given H & S } ; // Other data used by Therm class // Roots and Weights for gaussian quadrature const long double GK_root[5] = { 0.14887433898163121088, 0.43339539412924719080, 0.67940956829902440263, 0.86506336668898451073, 0.97390652851717172008 }; const long double GK_weight[5] = { 0.29552422471475286217, 0.26926671930999634918, 0.21908636251598204295, 0.14945134915058059038, 0.066671344308688137179 }; // set the number of points for quadrature const int GK_points = 5 ; 107 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. //equation constants for ideal gas heat capacity, enthalpy and entropy const double ThermConstants[NUMBEROFCOMPONENTS[11] = {{-29776.4, 7.95454, 43.9417, 1037.09, 1.56373, 813.205, -24.9027, 1019.98,-10.1601, 1070.14,-20.0615}, {-3495.34, 6.95587, 0.272892, 662.738,-0.291318,-680.562, 1.78980, 1740.06, 0.0, 100.0, 4.49823}, { 20.7307, 6.96237, 2.68645, 500.371,-2.56429,-530.443, 3.91921, 500.198, 2.13290, 2197.22, 5.81381}, {-37524.4, 7.98139, 24.3668, 752.320, 3.53990, 272.846, 8.44724, 1020.13,-13.2732, 869.510,-22.4010}, {-56072.1, 8.14319, 37.0629, 735.402, 9.38159, 247.190, 13.4556, 1454.78,-11.7342, 984.518,-24.0426}, {-13773.1, 7.97183, 6.27078, 2572.63, 2.05010, 1156.72, 0.0, 100.0, 0.0, 100.0, -3.24989}, {-10085.4, 7.94680,-0.08380, 433.801, 2.85539, 843.792, 6.31595, 1481.43,-2.88457, 1102.23,-0.51551}, {-5565.60, 6.66789, 2.33458, 2584.98, .749019, 559.656, 0.0, 100.0, 0.0, 100.0, -7.94821}, {-2753.49, 6.95854, 2.02441, 1541.22, .096774, 3674.81, 0.0, 100.0, 0.0, 100.0, 6.23387}, {-3497.45, 6.96302, 2.40013, 2522.05, 2.21752, 1154.15, 0.0, 100.0, 0.0, 100.0, 9.19749}, {-72387.0, 17.8143, 58.2062, 1787.39, 40.7621, 808.645, 0.0, 100.0, 0.0, 100.0, -44.1341}, {-72674.8, 18.6383, 57.4178, 1792.73, 38.6599, 814.151, 0.0, 100.0, 0.0, 100.0, -46.1938}, {-91505.5, 21.3861, 74.3410, 1701.58, 47.0587, 775.899, 0.0, 100.0, 0.0, 100.0, -60.2474}, {-83845.2, 22.5012, 69.5789, 1719.58, 46.2164, 802.174, 0.0, 100.0, 0.0, 100.0, -62.2197}, {-94982.5, 26.6225, 80.3819, 1718.49, 55.6598, 802.069, 0.0, 100.0, 0.0, 100.0, -77.5366}, {-103353., 30.4029, 90.6941, 1669.32, 63.2028, 786.001, 0.0, 100.0, 0.0, 100.0, -92.0164}, {-109674., 34.0847, 100.253, 1611.55, 69.7675, 768.847, 0.0, 100.0, 0.0, 100.0, -106.149}, {-122599., 38.5014, 111.446, 1646.48, 80.5015, 781.588, 0.0, 100.0, 0.0, 100.0, -122.444}, {-133564., 42.7143, 122.173, 1654.85, 90.2255, 785.564, 0.0, 100.0, 0.0, 100.0, -138.006}, { 0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 1.8198}, { 0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 8.6776}}; // enumerations for indexing of coefficients enum CoefficientList{ coefA = 0, coefB, coefC, coefD, coefE, coefF, coefG, coefH, coefI, coefJ, coefK } ; // conversion constant for thermochemical calories to Joules: const double CalTH = 4.1840 ; #endif 108 1 cal(IT) = 4.1840 J This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File: therm.cpp * Description: Contains thermodynamic functions for the meter object. * heat capacity, enthalpy, entropy, sound speed * Contains the functions: * Therm(), ~Therm(), Run(), coth(), CpiMolar(), Ho(), So(), * CprCvrHS(), HS_Mode(), H(), S() * Version: ver 1.7 2002.11.17 * Author: W.B. Peterson * Revisions: * Copyright (c) 2002 American Gas Association **************************************************************************/ #include "aga10.h" #include "detail.h" #include "therm.h" #include <math.h> /************************************************************************** * Function : Therm::Therm() * Arguments : void * Returns : * Purpose : default constructor * Revisions : **************************************************************************/ Therm::Therm(void) { // initialize 3 history-sensitive variables dSi = 0.0 ; dTold = 0.0 ; dMrxold = 0.0 ; } // Therm::Therm() 109 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Therm::~Therm() * Arguments : * Returns : default destructor * Purpose : void * Revisions : **************************************************************************/ Therm::~Therm() { } // Therm::~Therm() /************************************************************************** * Function : coth() * Arguments : double * Returns : double * Purpose : calculate hyperbolic cotangent; used in Ho calculations * Revisions : * Notes : Not a Therm object class member, just a utility for this * file. The C++ language has no intrinsic support for * hyperbolic cotangent **************************************************************************/ double coth (double x) { return cosh(x)/sinh(x); } // coth() 110 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Therm::Run() * Arguments : AGA10STRUCT *, Detail * * Returns : void * Purpose : overall execution control; top level math for SOS and k * Revisions : **************************************************************************/ void Therm::Run(AGA10STRUCT *ptAGA10, Detail *ptD) { // local variables double c, x, y, z ; // first run basic set of functions within AGA 8 (1994) Detail Method ptD->Run(ptAGA10) ; // find first partial derivative of Z wrt D ptD->dZdD(ptAGA10->dDf) ; // find real gas cv, cp, specific enthalpy and entropy CprCvrHS(ptAGA10, ptD) ; // ratio of real gas specific heats ptAGA10->dk = ptAGA10->dCp / ptAGA10->dCv ; // solve c in three steps, for clarity and ease of debugging x = ptAGA10->dk * RGAS * 1000.0 * ptAGA10->dTf ; y = ptAGA10->dMrx ; z = ptAGA10->dZf + ptAGA10->dDf * ptD->ddZdD ; // calculate c, which is SOS^2 c = (x / y) * z ; // speed of sound ptAGA10->dSOS = sqrt(c) ; // calculate the real gas isentropic exponent // using expression functionally equivalent to Equation 3.2 ptAGA10->dKappa = (c * ptAGA10->dRhof) / ptAGA10->dPf ; 111 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } return ; // Therm::Run() /************************************************************************** * Function : Therm::CpiMolar() * Arguments : AGA10STRUCT * * Returns : double * Purpose : Calculate constant pressure ideal gas molar heat capacity * in (J/mol-K), applying eqns from Aly, Lee, McFall * Notes : For continuity, the original constants and eqn's have been * retained. Conversion from thermochemical calories(th) to * Joules is applied after the primary calculations are complete. * Revisions : **************************************************************************/ double Therm::CpiMolar(AGA10STRUCT *ptAGA10) { double Cp = 0.0 ; double Cpx ; double DT, FT, HT, JT ; double Dx, Fx, Hx, Jx ; double T ; int i ; // to maximize readability of this section, use intermediate variable T T = ptAGA10->dTf ; // calculate heat capacity for each component for (i= 0; i< NUMBEROFCOMPONENTS; i++) { // skip species whose concentration is zero if (ptAGA10->adMixture[i] <= 0.0) continue ; // initialize Cp of species to zero Cpx = 0.0 ; // calculate species intermediate terms DT = ThermConstants[i][coefD] / T ; 112 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. FT = ThermConstants[i][coefF] / T ; HT = ThermConstants[i][coefH] / T ; JT = ThermConstants[i][coefJ] / T ; // use intermediate terms to avoid redundant calcs Dx = DT/sinh(DT) ; Fx = FT/cosh(FT) ; Hx = HT/sinh(HT) ; Jx = JT/cosh(JT) ; Cpx += ThermConstants[i][coefB] ; Cpx += ThermConstants[i][coefC] * Dx * Dx ; Cpx += ThermConstants[i][coefE] * Fx * Fx ; Cpx += ThermConstants[i][coefG] * Hx * Hx ; Cpx += ThermConstants[i][coefI] * Jx * Jx ; // use current mole fraction to weight the contribution Cpx *= ptAGA10->adMixture[i]; // add this contribution to the sum Cp += Cpx ; } // convert from cal(th)/mol-K to J/mol-K Cp *= CalTH ; } return Cp ; // Therm::CpiMolar() 113 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Therm::Ho() * Arguments : AGA10STRUCT * * Returns : double * Purpose : Calculate ideal gas specific enthalpy (J/kg) * Notes : For continuity, the original constants and eqn's have been * retained. Conversion from thermochemical calories(th) to * Joules is applied after the primary calculations are complete. * Revisions : **************************************************************************/ double Therm::Ho(AGA10STRUCT *ptAGA10) { double H = 0.0 ; double Hx ; double DT, FT, HT, JT ; double cothDT, tanhFT, cothHT, tanhJT ; double T ; int i ; // to maximize readability of this section, use intermediate variable T T = ptAGA10->dTf ; for (i= 0; i< NUMBEROFCOMPONENTS; i++) { // skip species whose concentration is zero if (ptAGA10->adMixture[i] <= 0.0) continue ; Hx = 0.0 ; // calculate species intermediate terms DT = ThermConstants[i][coefD] / T ; FT = ThermConstants[i][coefF] / T ; HT = ThermConstants[i][coefH] / T ; JT = ThermConstants[i][coefJ] / T ; cothDT = coth(DT) ; tanhFT = tanh(FT) ; cothHT = coth(HT) ; tanhJT = tanh(JT) ; 114 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Hx += ThermConstants[i][coefA] ; Hx += ThermConstants[i][coefB] * T ; Hx += ThermConstants[i][coefC] * ThermConstants[i][coefD] * cothDT; Hx -= ThermConstants[i][coefE] * ThermConstants[i][coefF] * tanhFT; Hx += ThermConstants[i][coefG] * ThermConstants[i][coefH] * cothHT; Hx -= ThermConstants[i][coefI] * ThermConstants[i][coefJ] * tanhJT; // use current mole fraction to weight the contribution Hx *= ptAGA10->adMixture[i]; // add this contribution to the sum H += Hx ; } // convert from cal(th)/g-mol to kJ/kg-mol H *= CalTH ; // convert from kJ/kg-mol to J/kg H /= ptAGA10->dMrx ; } // return in J/kg return H * 1.e3; // Therm::Ho() 115 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Therm::So() * Arguments : AGA10STRUCT * * Returns : double * Purpose : ideal gas specific entropy (J/kg-K) * Notes : For continuity, the original constants and eqn's have been * retained. Conversion from thermochemical calories(th) to * Joules is applied after the primary calculations are complete. * The entropy of mixing is also calculated in this function. * Revisions : **************************************************************************/ double Therm::So(AGA10STRUCT *ptAGA10) { double S = 0.0 ; double Smixing = 0.0 ; double Sx ; double DT, FT, HT, JT ; double cothDT, tanhFT, cothHT, tanhJT ; double sinhDT, coshFT, sinhHT, coshJT ; double T ; int i ; // to improve readability of this section, use intermediate variable T T = ptAGA10->dTf ; for (i= 0; i< NUMBEROFCOMPONENTS; i++) { // skip species whose concentration is zero if (ptAGA10->adMixture[i] <= 0.0) continue ; Sx = 0.0 ; // calculate species intermediate terms DT = ThermConstants[i][coefD] / T ; FT = ThermConstants[i][coefF] / T ; HT = ThermConstants[i][coefH] / T ; JT = ThermConstants[i][coefJ] / T ; cothDT = coth(DT) ; 116 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. tanhFT = tanh(FT) ; cothHT = coth(HT) ; tanhJT = tanh(JT) ; sinhDT = sinh(DT) ; coshFT = cosh(FT) ; sinhHT = sinh(HT) ; coshJT = cosh(JT) ; Sx += ThermConstants[i][coefK] ; Sx += ThermConstants[i][coefB] * log(T) ; Sx += ThermConstants[i][coefC] * (DT * cothDT - log(sinhDT)) ; Sx -= ThermConstants[i][coefE] * (FT * tanhFT - log(coshFT)) ; Sx += ThermConstants[i][coefG] * (HT * cothHT - log(sinhHT)) ; Sx -= ThermConstants[i][coefI] * (JT * tanhJT - log(coshJT)) ; // use current mole fraction to weight the contribution Sx *= ptAGA10->adMixture[i]; // add this contribution to the sum S += Sx ; } // convert cal(th)/mol-K basis to to kJ/kg mol-K S *= CalTH ; // calculate entropy of mixing for (i= 0; i< NUMBEROFCOMPONENTS; i++) { if (ptAGA10->adMixture[i]) Smixing += ptAGA10->adMixture[i] * log(ptAGA10->adMixture[i]) ; } Smixing *= -RGAS ; // add the entropy of mixing S += Smixing ; // convert from kJ/kg mol-K to kJ/kg-K S /= ptAGA10->dMrx ; // return in J/kg-K 117 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. } return S * 1.e3; // Therm::So() 118 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Therm::CprCvrHS() * Arguments : AGA10STRUCT *, Detail * * Returns : void * Purpose : reasonably efficient group calculation of Cp, Cv, H and S * Revisions : **************************************************************************/ void Therm::CprCvrHS(AGA10STRUCT *ptAGA10, Detail *ptD) { double Cvinc, Cvr, Cpr ; double Hinc ; double Sinc ; double Cp, Si ; double a, b, x ; int i ; // initialize integrals to zero Cvinc = 0.0 ; Hinc = 0.0 ; Sinc = 0.0 ; // find ideal gas Cp Cp = CpiMolar(ptAGA10) ; // find ideal gas enthalpy ptAGA10->dHo = Ho(ptAGA10) ; // find ideal gas entropy Si = So(ptAGA10) ; // calculate ideal gas specific heat capacity at constant pressure in J/kgK ptAGA10->dCpi = (Cp * 1000.0) / ptAGA10->dMrx ; // integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature for ( i= 0; i < GK_points; i++) { // set calculation point at + abscissa x = ptAGA10->dDf * (1.0 + GK_root[i]) / 2.0 ; // get Z at D 119 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. ptD->zdetail(x) ; ptD->dZdT(x) ; ptD->d2ZdT2(x) ; // gather contributions at + abscissa; applying weighting factor Hinc += GK_weight[i] * ptD->ddZdT / x ; Cvinc += GK_weight[i] * (2.0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x ; Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ; // set calculation point at - abscissa x = ptAGA10->dDf * (1.0 - GK_root[i]) / 2.0 ; // get Z at D ptD->zdetail(x) ; // calculate 1st and 2nd partial derivatives of Z wrt T ptD->dZdT(x) ; ptD->d2ZdT2(x) ; // gather contributions at - abscissa; applying weighting factor Hinc += GK_weight[i] * ptD->ddZdT / x ; Cvinc += GK_weight[i] * (2.0 * ptD->ddZdT + ptAGA10->dTf * ptD->dd2ZdT2) / x ; Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ; } // return Z and partial derivatives to full molar density ptD->zdetail(ptAGA10->dDf) ; ptD->dZdT(ptAGA10->dDf) ; ptD->d2ZdT2(ptAGA10->dDf) ; // complete Cv molar Cvr = Cp - RGAS * (1.0 + ptAGA10->dTf * Cvinc * 0.5 * ptAGA10->dDf) ; // intermediate values for Cp, containing 2 partial derivatives a =(ptAGA10->dZf + ptAGA10->dTf * ptD->ddZdT) ; b =(ptAGA10->dZf + ptAGA10->dDf * ptD->ddZdD) ; // calculate dPdT, the partial derivative of P wrt T, at D dPdT = RGAS * ptAGA10->dDf * a ; // calculate dPdD, the partial derivative of P wrt D, at T dPdD = RGAS * ptAGA10->dTf * b ; 120 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // equation completing molar Cp, cancelling appropriate terms Cpr = Cvr + RGAS * ((a * a)/b) ; // change from molar to mass basis Cpr /= ptAGA10->dMrx ; Cvr /= ptAGA10->dMrx ; // write to the data stucture ptAGA10->dCv = Cvr * 1000.0 ; ptAGA10->dCp = Cpr * 1000.0 ; // convert from joules/kgK to kilojoules/kgK // calculate specific enthalpy ptAGA10->dH = ptAGA10->dHo + 1000.0 * RGAS * ptAGA10->dTf * (ptAGA10->dZf - 1.0 - ptAGA10->dTf * Hinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ; // calculate specific entropy ptAGA10->dS = Si – 1000.0 * RGAS * (log(ptAGA10->dPf/101325.0) - log(ptAGA10->dZf) + Sinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ; } return ; // Therm::CprCvrHS() 121 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Therm::HS_Mode() * Arguments : AGA10STRUCT *, Detail *, double, double, bool * Returns : void * Purpose : Calculates a pressure & temperature from known enthalpy & entropy, * with or without prior estimates.This function has a role in the * calculation of C*. * Solution based on a doubly-nested trial & error algorithm and Newton's * method. * * For illustrative purpose, two approaches are supported by this example. * If you are starting without advance knowledge of P & T, set the input parm * bGuess to false, thus specifying a conservative search approach. * If, however, you have a basis for guessing P & T (plenum conditions of a * critical flow nozzle, for example) set P & T via AGA10STRUCT and set * bGuess = true. The initial guess allows the search function to be more * aggressive and, typically, faster. * * Revisions : **************************************************************************/ void Therm::HS_Mode(AGA10STRUCT *ptAGA10, Detail *ptD, double H, double S, bool bGuess) { double s0, s1, s2, t0, t1, t2, tmin, tmax ; double h0, h1, h2, p0, p1, p2, px, pmin, pmax ; double delta1, delta2 ; double tolerance = 0.001 ;// convergence tolerance (used for both H and S searches) int i, j ; // s0and h0 are our real gas reference points s0 = S ; h0 = H ; // calling function specifies whether search parameters are supplied thru ptAGA10 or unknown if (bGuess) { t1 = ptAGA10->dTf ; px = ptAGA10->dPf ; pmax = px * 2.0 ; pmin = px * 0.1 ; 122 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. tmax = t1 * 1.5 ; tmin = t1 * 0.67 ; } else { // use arbitrary, generic limits t1 = 273.15 ; px = 1013250.0 ; pmax = P_MAX ; pmin = 10000.0 ; tmax = T_MAX ; tmin = T_MIN ; // 10 atmospheres // 10 kPa } // set the temperature differential t2 = t1 + 10.0 ; /////////////////////////////////////////// // begin double trial-and-error, searching for T & P // run the calculation with initial guesses ptD->Run(ptAGA10) ; // h1 is difference between h given and h@Tf, Pf h1 = this->H(ptAGA10, ptD) - h0; // outer loop: search for a t2 which will satisfy constant enthalpy for ( i= 0; i < MAX_NUM_OF_ITERATIONS; i++) { ptAGA10->dTf = t2 ; p1 = px ; // reset one bracket p2 = px * 0.1 ;// set other bracket to 0.1x the upper bracket ptAGA10->dPf = p1 ; ptD->Run(ptAGA10) ; s1 = this->S(ptAGA10, ptD) - s0; // inside loop: search for a p2 which will satisfy constant entropy for (j= 0; j < MAX_NUM_OF_ITERATIONS; j++) { ptAGA10->dPf = p2 ; ptD->Run(ptAGA10) ; s2 = this->S(ptAGA10, ptD) - s0 ; // calculate our proportional change 123 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. delta2 = fabs(s1 - s2) / s0 ; // close enough? if (delta2 < tolerance) break ; // revise our estimate to p2 p0 = p2 ; p2 = (p1 * s2 - p2 * s1) / (s2 - s1) ; // check for negative pressure and clamp to pmin for safety if (p2 <= pmin) { p2 = pmin ; } // check if we've created an unrealistic pressure if (p2 >= pmax ) p2 = pmax ; // swap values p1 = p0 ; s1 = s2 ; } // check for failure to converge if (j >= MAX_NUM_OF_ITERATIONS) ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED ; // calc enthalpy at guessed P & current iter T h2 = this->H(ptAGA10, ptD) - h0 ; // calculate our proportional change delta1 = fabs(h1 - h2) / h0 ; // close enough? if (delta1 < tolerance && i > 0) break ; // revise our estimate to t2 t0 = t2 ; t2 = (t1 * h2 - t2 * h1) / (h2 - h1) ; // check if we've created an unrealistic temperature if (t2 >= tmax ) t2 = tmax ; // revise t2, if necessary if (t2 <= tmin ) { t2 = t0 + 10.0 ; 124 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. ptAGA10->dTf = t2 ; ptD->Run(ptAGA10) ; h2 = this->H(ptAGA10, ptD) - h0 ; } t1 = t0 ; h1 = h2 ; } } // check for failure to converge if (i >= MAX_NUM_OF_ITERATIONS) ptAGA10->lStatus = MAX_NUM_OF_ITERATIONS_EXCEEDED ; // Therm::HS_Mode() /************************************************************************** * Function : Therm::H() * Arguments : AGA10STRUCT *, Detail * * Returns : double * Purpose : real gas specific enthalpy * Revisions : **************************************************************************/ double Therm::H(AGA10STRUCT *ptAGA10, Detail *ptD) { double Hinc ; double x ; int i ; // initialize integral Hinc = 0.0 ; // find ideal gas enthalpy ptAGA10->dHo = Ho(ptAGA10) ; // integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature for ( i= 0; i < GK_points; i++) { // calculate 1st and 2nd partial derivatives of Z wrt T x = ptAGA10->dDf * (1.0 + GK_root[i]) / 2.0 ; ptD->zdetail(x) ; ptD->dZdT(x) ; 125 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. ptD->d2ZdT2(x) ; Hinc += GK_weight[i] * ptD->ddZdT / x ; if (i == 10) break; x = ptAGA10->dDf * (1.0 - GK_root[i]) / 2.0 ; ptD->zdetail(x) ; ptD->dZdT(x) ; ptD->d2ZdT2(x) ; Hinc += GK_weight[i] * ptD->ddZdT / x ; } ptD->zdetail(ptAGA10->dDf) ; ptD->dZdT(ptAGA10->dDf) ; ptD->d2ZdT2(ptAGA10->dDf) ; // calculate specific enthalpy ptAGA10->dH = ptAGA10->dHo + 1000.0 * RGAS * ptAGA10->dTf * (ptAGA10->dZf - 1.0 - ptAGA10->dTf * Hinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ; } return(ptAGA10->dH) ; // Therm::H() 126 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************** * Function : Therm::S() * Arguments : AGA10STRUCT *, Detail * * Returns : double * Purpose : real gas specific entropy * Revisions : **************************************************************************/ double Therm::S(AGA10STRUCT *ptAGA10, Detail *ptD) { double Sinc ; double x ; int i ; // initialize integral Sinc = 0.0 ; // integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature for ( i= 0; i < GK_points; i++) { // calculate 1st and 2nd partial derivatives of Z wrt T x = ptAGA10->dDf * (1.0 + GK_root[i]) / 2.0 ; ptD->zdetail(x) ; ptD->dZdT(x) ; ptD->d2ZdT2(x) ; Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ; if (i == 10) break; x = ptAGA10->dDf * (1.0 - GK_root[i]) / 2.0 ; ptD->zdetail(x) ; ptD->dZdT(x) ; ptD->d2ZdT2(x) ; Sinc += GK_weight[i] * (ptD->dZ + ptAGA10 ->dTf * ptD->ddZdT - 1.0) / x ; } // reset Z and partial deivatives dZdT and d2ZdT2 ptD->zdetail(ptAGA10->dDf) ; ptD->dZdT(ptAGA10->dDf) ; 127 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. ptD->d2ZdT2(ptAGA10->dDf) ; // find ideal gas entropy, but only if temperature or composition have changed if (ptAGA10->dTf != dTold || ptAGA10->dMrx != dMrxold) { dSi = So(ptAGA10) ; dTold = ptAGA10->dTf ; dMrxold = ptAGA10->dMrx ; } // calculate specific entropy ptAGA10->dS = dSi - 1000.0 * RGAS * (log(ptAGA10->dPf/101325.0) - log(ptAGA10->dZf) + Sinc * 0.5 * ptAGA10->dDf) / ptAGA10->dMrx ; } return(ptAGA10->dS) ; // Therm::S() 128 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * * File : entry.cpp * Purpose : This file contains the startup code for aga10.dll * and is only required for Windows DLL creation. * Project : AGA10 DLL * Version : ver 1.7 2002.11.17 * Author : W.B. Peterson * Revisions: * Copyright (c) 2002 American Gas Association * **************************************************************************/ #include <windows.h> /* win32 DLL startup code */ int WINAPI DLLMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved) { return TRUE ; } 129 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // // // // // // File : script1.rc Description : resource script for aga10 dll Version : 1.7.2 2002.12.05 Author : W.B. Peterson Revisions : Copyright (c) 2002 American Gas Association //Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,7,2,0 PRODUCTVERSION 1,7,2,0 FILEFLAGSMASK 0x3fL 130 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. #ifdef _DEBUG FILEFLAGS 0x21L #else FILEFLAGS 0x20L #endif FILEOS 0x40004L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments", "Post-Ballot Version\0" VALUE "CompanyName", "American Gas Association\0" VALUE "FileDescription", "aga10\0" VALUE "FileVersion", "1, 7, 2, 0\0" VALUE "InternalName", "aga10\0" VALUE "LegalCopyright", "Copyright © 2002 American Gas Association\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "aga10.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "AGA10.DLL\0" VALUE "ProductVersion", "1, 7, 2, 0\0" VALUE "SpecialBuild", "2002.12.05 Build\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // !_MAC #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE 131 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED 132 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. File Group #2 - Example Windows Application 133 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File : aga10win.h * Description : function prototypes and defines for aga10win.cpp * Version : 1.7 2002.11.17 * Author : W.B. Peterson * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ #ifndef _AGA10WIN_H #define _AGA10WIN_H #include <windows.h> #include <commdlg.h> /* control IDs for windows interface #define IDC_LSTATUS 20 #define IDC_XIC1 21 #define IDC_XIN2 22 #define IDC_XICO2 23 #define IDC_XIC2 24 #define IDC_XIC3 25 #define IDC_XIH2O 26 #define IDC_XIH2S 27 #define IDC_XIH2 28 #define IDC_XICO 29 #define IDC_XIO2 30 #define IDC_XIIC4 31 #define IDC_XINC4 32 #define IDC_XIIC5 33 #define IDC_XINC5 34 #define IDC_XINC6 35 #define IDC_XINC7 36 #define IDC_XINC8 37 #define IDC_XINC9 38 #define IDC_XINC10 39 #define IDC_XIHE 40 #define IDC_XIAR 41 #define IDC_PB 42 */ 134 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. #define IDC_TB #define IDC_PF #define IDC_TF #define IDC_MRX #define IDC_ZB #define IDC_ZF #define IDC_FPV #define IDC_DB #define IDC_DF #define IDC_RHOB #define IDC_RHOF #define IDC_RD_IDEAL #define IDC_RD_REAL #define IDC_HO #define IDC_H #define IDC_S #define IDC_CPI #define IDC_CP #define IDC_CV #define IDC_K #define IDC_KAPPA #define IDC_SOS #define IDC_CSTAR #define IDC_PB_U #define IDC_TB_U #define IDC_PF_U #define IDC_TF_U #define IDC_SOS_U #define IDC_RHOB_U #define IDC_RHOF_U #define IDC_ENTHALPY_U #define IDC_ENTROPY_U #define IDC_TOTAL #define IDC_CLEAR #define IDC_NORMALIZE #define KILOPASCAL #define MEGAPASCAL #define PSI #define KELVIN #define CELSIUS 43 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 135 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. #define RANKINE #define FAHRENHEIT #define KGPERCUBICMETRE #define LBMPERCUBICFOOT #define METREPERSECOND #define FOOTPERSECOND #define KJPERKG #define BTUPERLBM #define KJPERKGK #define BTUPERLBMF #define CM_FILEOPEN #define CM_FILESAVE #define CM_FILESAVEAS #define CM_HELPABOUT #define IDR_MENU1 #define IDC_STATIC 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 (-1) /* buffer sizes */ #define FIELD40 #define FIELD30 40 30 /* function prototypes */ LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; void PressureDlgHelp(HWND) ; void TemperatureDlgHelp(HWND) ; void DensityDlgHelp(HWND) ; void SOSDlgHelp(HWND) ; void EnthalpyDlgHelp(HWND) ; void EntropyDlgHelp(HWND) ; void FileInitialize (HWND) ; BOOL FileOpenDlg (HWND, PSTR, PSTR) ; BOOL FileSaveDlg (HWND, PSTR, PSTR) ; #endif 136 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File : aga10win.cpp * Description : Simple Win32 program demonstrating use of aga10.dll * Supports Windows dialog box and file operations * Version : 1.7 2002.11.17 * Author : W.B. Peterson * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ #include "aga10win.h" #include "aga10.h" /* create pointer to a data structure for exchanging data with aga10.dll static AGA10STRUCT *A10 ; /* global variables for strings, filenames, etc static char szAppName[] = "aga10win" ; static char szBuffer[FIELD40] ; char szFileName[_MAX_PATH] ; char szTitleName[_MAX_FNAME + _MAX_EXT] ; */ */ /* declare one application instance */ HINSTANCE hInst ; /* global variables for units of measure and critical flow coefficient C* */ double total = 0.0 ; long int lPb_unit ; /* unit of measure for base pressure */ long int lPf_unit ; /* unit of measure for flowing pressure */ long int lTb_unit ; /* unit of measure for base temperature */ long int lTf_unit ; /* unit of measure for flowing temperature */ long int lRhob_unit ; /* unit of measure for density at base conditions */ long int lRhof_unit ; /* unit of measure for density at flowing conditions */ long int lSOS_unit ; /* unit of measure for speed of sound */ long int lEnthalpy_unit ; /* unit of measure for specific enthalpy */ long int lEntropy_unit ; /* unit of measure for specific entropy */ // prototypes for support functions not prototyped in aga10win.h bool FileRead(HWND, PSTR, AGA10STRUCT *); bool FileWrite(HWND, PSTR, AGA10STRUCT *) ; 137 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. void ReadInputs(HWND, AGA10STRUCT *) ; void WriteInputs(HWND, AGA10STRUCT *) ; void WriteOutputs(HWND, AGA10STRUCT *) ; void SetDefaults(AGA10STRUCT *) ; /************************************************************************** * Function : WinMain() * Arguments : HINSTANCE, HINSTANCE, PSTR, int * Returns : int * Purpose : Every Windows application has a WinMain() * Revisions : **************************************************************************/ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { HWND hWnd ; MSG msg ; WNDCLASSEX wndclass ; /* set window class properties */ wndclass.cbSize = sizeof (wndclass) ; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = DLGWINDOWEXTRA ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (hInstance, szAppName) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE+1) ; wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1) ; wndclass.lpszClassName = szAppName ; wndclass.hIconSm = LoadIcon (hInstance, szAppName) ; /* register the class */ RegisterClassEx (&wndclass) ; /* create a dialog box */ hWnd = CreateDialog (hInstance, "aga10win", 0, NULL) ; 138 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /* start the application's message pump */ while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage(&msg) ; DispatchMessage(&msg) ; } return msg.wParam ; } /************************************************************************** * Function : WndProc() * Arguments : HWND, UINT, WPARAM, LPARAM * Returns : LRESULT * Purpose : One and only window process for this app * Revisions : **************************************************************************/ LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { int i = 0 ; double temp ; switch (iMsg) { case WM_CREATE : /* get application instance */ hInst = ((LPCREATESTRUCT) lParam)->hInstance ; /* initialize file data */ FileInitialize (hwnd) ; /* initialize calculation library */ AGA10_Init() ; /* create an object at the pointer we have already defined */ if (NULL == (A10 = new AGA10STRUCT)) return TRUE ; /* set the defaults for this application */ 139 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. SetDefaults(A10) ; return FALSE ; case WM_COMMAND : /* refresh the input data, triggered by focus change */ if (lParam && HIWORD (wParam) == EN_KILLFOCUS) { ReadInputs(hwnd, A10) ; WriteInputs(hwnd, A10) ; lstrcpy(szBuffer, "Press Calculate") ; SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ; return FALSE ; } /* decode WM_COMMAND messages */ switch (LOWORD (wParam)) { case IDOK : /* refresh input fields */ ReadInputs(hwnd, A10) ; WriteInputs(hwnd, A10) ; // ensure the compositions adds up before proceeding // find the current sum of fractions temp = 0.0 ; for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++) temp += A10->adMixture[i] ; if (temp < 0.9999 || temp > 1.0001) { MessageBox (hwnd,"Error. Composition must total 100%, +/- 0.01%", szAppName, MB_OK | MB_ICONERROR) ; lstrcpy(szBuffer, "Error. Composition <> 100%.") ; SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ; return FALSE ; } // ensure the pressure is acceptable before proceeding if (A10->dPf < P_MIN || A10->dPf > P_MAX) { MessageBox (hwnd,"Error. Pf out of range.", szAppName, MB_OK | MB_ICONERROR) ; 140 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. lstrcpy(szBuffer, "Error. Pf out of range.") ; SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ; return FALSE ; } // ensure the temperature is acceptable before proceeding if (A10->dTf < T_MIN || A10->dTf > T_MAX) { MessageBox (hwnd,"Error. Tf out of range.", szAppName, MB_OK | MB_ICONERROR) ; lstrcpy(szBuffer, "Error. Tf out of range.") ; SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ; return FALSE ; } /* indicate that a calculation has begun */ lstrcpy(szBuffer, "Calculation In Progress") ; SetDlgItemText (hwnd, IDC_LSTATUS, szBuffer) ; /* run the sound speed AND C* calculation Crit(A10, 0.0) ; */ /* write the outputs to the dialog box */ WriteOutputs(hwnd, A10) ; return FALSE ; case IDC_CLEAR : /* zero out the composition and then display it */ for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++) A10->adMixture[i] = 0.0 ; WriteInputs(hwnd, A10) ; return FALSE ; case IDC_NORMALIZE : // normalize the composition to equal 1.0000 ReadInputs(hwnd, A10) ; temp = 0.0 ; // find the current sum of fractions for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++) temp += A10->adMixture[i] ; // adjust each non-zero entry by the required proportion for (i = 0 ; i < NUMBEROFCOMPONENTS ; i++) 141 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. if (A10->adMixture[i] > 0.0) A10->adMixture[i] /= temp ; // write the adjusted values to the screen WriteInputs(hwnd, A10) ; return FALSE ; case IDCANCEL : /* start tear-down process */ SendMessage(hwnd, WM_CLOSE, 0,0L) ; return FALSE ; case IDRETRY : // reset the defaults SetDefaults(A10) ; // display the input data to the screen WriteInputs(hwnd, A10) ; // send a message back to this proc, requesting a calculation SendMessage(hwnd, WM_COMMAND, IDOK,0L) ; return FALSE ; case CM_FILEOPEN : // standard Windows file operations GetFileTitle (szFileName, szTitleName, sizeof (szTitleName)) ; if (FileOpenDlg (hwnd, szFileName, szTitleName)) { if (!FileRead (hwnd, szFileName, A10)) { MessageBox(hwnd,"Could not read file.", szTitleName, MB_OK | MB_ICONSTOP) ; } } else return FALSE ; // Write the new values to the window WriteInputs(hwnd, A10) ; // send a message back to this proc, requesting a calculation SendMessage(hwnd, WM_COMMAND, IDOK,0L) ; 142 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. return FALSE ; case CM_FILESAVE : // standard Windows file operations GetFileTitle (szFileName, szTitleName, sizeof (szTitleName)) ; if (szFileName[0]) { if (FileWrite(hwnd, szFileName, A10)) { return TRUE ; } else { MessageBox(hwnd,"Could not write file.", szTitleName, MB_OK | MB_ICONSTOP) ; } return FALSE ; } // fall through case CM_FILESAVEAS : // standard Windows file operations GetFileTitle (szFileName, szTitleName, sizeof (szTitleName)) ; if (FileSaveDlg (hwnd, szFileName, szTitleName)) { if (FileWrite (hwnd, szFileName, A10)) { return 1 ; } else { MessageBox(hwnd,"Could not write file.", szTitleName, MB_OK | MB_ICONSTOP) ; } } return FALSE ; case CM_HELPABOUT : MessageBox (hwnd, 143 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. "AGA10win.exe and AGA10.dll (c) American Gas Association, 2002", szAppName, MB_OK | MB_ICONINFORMATION) ; return FALSE ; } return FALSE ; case WM_CLOSE : /* un-initialize the calculation library */ AGA10_UnInit() ; // remove the AGA10STRUCT object from memory delete A10 ; /* request Windows to terminate the app */ DestroyWindow (hwnd) ; return FALSE ; case WM_DESTROY : /* final message exhange with Windows during shut-down */ PostQuitMessage (0) ; return FALSE ; } return DefWindowProc (hwnd, iMsg, wParam, lParam) ; } 144 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File : file.cpp * Description : Supports file access to AGA10 functions * Author : W.B. Peterson * Version : 1.7 2002.11.17 * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ #include "aga10.h" // declare a Windows-defined structure for file names static OPENFILENAME ofn ; /************************************************************************** * Function : FileInitialize() * Arguments : HWND * Returns : void * Purpose : Prepares for Windows file access * Revisions : **************************************************************************/ void FileInitialize (HWND hWnd) { /* set file filters; assign the filename extension 'sos' for files of this type */ static char szFilter[] = "AGA10 Files (*.sos)\0*.sos\0" ; static char szExt[] = "sos" ; // populate a OPENFILENAME structure ofn.lStructSize = sizeof (OPENFILENAME) ofn.hwndOwner = hWnd ; ofn.hInstance = NULL ; ofn.lpstrFilter = szFilter ; ofn.lpstrCustomFilter = NULL ; ofn.nMaxCustFilter = 0 ; ofn.nFilterIndex = 0 ; ofn.lpstrFile = NULL ; ofn.nMaxFile = _MAX_PATH ; ofn.lpstrFileTitle = NULL ; ; 145 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. ofn.nMaxFileTitle ofn.lpstrInitialDir ofn.lpstrTitle ofn.Flags ofn.nFileOffset ofn.nFileExtension ofn.lpstrDefExt ofn.lCustData ofn.lpfnHook ofn.lpTemplateName = _MAX_FNAME + _MAX_EXT = NULL ; = NULL ; = 0 ; = 0 ; = 0 ; = szExt ; = 0L ; = NULL ; = NULL ; ; } /************************************************************************** * Function : FileOpenDlg() * Arguments : HWND, PSTR, PSTR * Returns : BOOL * Purpose : Access common controls for file-open operation * Revisions : **************************************************************************/ BOOL FileOpenDlg (HWND hWnd, PSTR pstrFileName, PSTR pstrTitleName) { ofn.hwndOwner = hWnd ; ofn.lpstrFile = pstrFileName ; ofn.lpstrFileTitle = pstrTitleName ; ofn.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT ; return GetOpenFileName (&ofn) ; } /************************************************************************** * Function : FileSaveDlg() * Arguments : HWND, PSTR, PSTR * Returns : BOOL * Purpose : Access common controls for file-save operation * Revisions : **************************************************************************/ 146 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. BOOL FileSaveDlg (HWND hWnd, PSTR pstrFileName, PSTR pstrTitleName) { ofn.hwndOwner = hWnd ; ofn.lpstrFile = pstrFileName ; ofn.lpstrFileTitle = pstrTitleName ; ofn.Flags = OFN_OVERWRITEPROMPT ; return GetSaveFileName (&ofn) ; } /************************************************************************** * Function : FileRead() * Arguments : HWND, PSTR, AGA10STRUCT * Returns : bool * Purpose : Reads contents of a .sos file into a AGA10STRUCT * Revisions : **************************************************************************/ bool FileRead(HWND hWnd, PSTR pstrFileName, AGA10STRUCT *A10) { FILE *file ; // open the file in binary mode, if it exists if (NULL == (file = fopen (pstrFileName, "rb"))) return false ; // set file position to beginning rewind(file) ; // read one (only) data structure if (fread(A10, sizeof (AGA10STRUCT), 1, file)) { fclose (file) ; return true; } else { // some problem encountered 147 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. fclose (file) ; return false ; } } /************************************************************************** * Function : FileWrite() * Arguments : HWND, PSTR, AGA10STRUCT * Returns : bool * Purpose : Writes contents of a AGA10STRUCT into a .vos file * Revisions : **************************************************************************/ bool FileWrite(HWND hWnd, PSTR pstrFileName, AGA10STRUCT *A10) { FILE *file ; // open the file in binary mode; create if necessary if (NULL == (file = fopen (pstrFileName, "wb"))) return false ; // set file position to beginning rewind(file) ; // write one (only) data structure if (fwrite(A10, sizeof (AGA10STRUCT), 1, file)) { fclose (file) ; return true; } else { // problem encountered; close and return 'false' fclose (file) ; return false ; } } 148 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. /************************************************************************* * File : dlghlp.cpp * Description : Helper functions for aga10win main dialog box * Version : 1.7 2002.11.17 * Author : W.B. Peterson * Revisions : * Copyright (c) 2002 American Gas Association **************************************************************************/ #include "aga10win.h" #include "aga10.h" /* variables declared externally */ extern HINSTANCE hInst ; extern double total ; extern long int lPb_unit ; extern long int lPf_unit ; extern long int lTb_unit ; extern long int lTf_unit ; extern long int lRhob_unit ; extern long int lRhof_unit ; extern long int lSOS_unit ; extern long int lEnthalpy_unit ; extern long int lEntropy_unit ; /* a local buffer for text strings */ static char szBuffer[FIELD40] ; /************************************************************************** * Function : WriteInputs() * Arguments : HWND * Returns : void * Purpose : Function for writing the input fields of the main window * Notes : Uses non-portable, run-time library function _gcvt() * for converting strings to double precision floats. * Revisions : **************************************************************************/ void WriteInputs(HWND hDlg, AGA10STRUCT *A10) { 149 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. HWND hListBox; int i ; double Pbx, Tbx, Pfx, Tfx ; /* calculate Pb in specified unit of measure */ switch (lPb_unit) { case KILOPASCAL : Pbx = A10->dPb * 1.0e-3 ; break ; case MEGAPASCAL : Pbx = A10->dPb * 1.0e-6 ; break ; case PSI : Pbx = A10->dPb / 6894.75729 ; } /* calculate Pf in specified unit of measure */ switch (lPf_unit) { case KILOPASCAL : Pfx = A10->dPf * 1.0e-3 ; break ; case MEGAPASCAL : Pfx = A10->dPf * 1.0e-6 ; break ; case PSI : Pfx = A10->dPf / 6894.75729 ; } /* calculate Tb in specified unit of measure */ switch (lTb_unit) { case CELSIUS : Tbx = A10->dTb - 273.15 ; break ; 150 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. case FAHRENHEIT : Tbx = (A10->dTb * 1.8) - 459.67 ; break ; case KELVIN : Tbx = A10->dTb ; break ; case RANKINE : Tbx = A10->dTb * 1.8 ; } /* calculate Tf in specified unit of measure */ switch (lTf_unit) { case CELSIUS : Tfx = A10->dTf - 273.15 ; break ; case FAHRENHEIT : Tfx = (A10->dTf * 1.8) - 459.67 ; break ; case KELVIN : Tfx = A10->dTf ; break ; case RANKINE : Tfx = A10->dTf * 1.8 ; } // Pb _gcvt (Pbx, 9, szBuffer); SetDlgItemText (hDlg, IDC_PB, szBuffer) ; // Tb _gcvt (Tbx, 9, szBuffer); SetDlgItemText (hDlg, IDC_TB, szBuffer) ; // Pf _gcvt (Pfx, 9, szBuffer); 151 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. SetDlgItemText (hDlg, IDC_PF, szBuffer) ; // Tf _gcvt (Tfx, 9, szBuffer); SetDlgItemText (hDlg, IDC_TF, szBuffer) ; // composition _gcvt (A10->adMixture[XiC1] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIC1, szBuffer) ; _gcvt (A10->adMixture[XiN2] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIN2, szBuffer) ; _gcvt (A10->adMixture[XiCO2] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XICO2, szBuffer) ; _gcvt (A10->adMixture[XiC2] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIC2, szBuffer) ; _gcvt (A10->adMixture[XiC3] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIC3, szBuffer) ; _gcvt (A10->adMixture[XiH2O] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIH2O, szBuffer) ; _gcvt (A10->adMixture[XiH2S] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIH2S, szBuffer) ; _gcvt (A10->adMixture[XiH2] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIH2, szBuffer) ; _gcvt (A10->adMixture[XiCO] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XICO, szBuffer) ; _gcvt (A10->adMixture[XiO2] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIO2, szBuffer) ; _gcvt (A10->adMixture[XiIC4] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIIC4, szBuffer) ; _gcvt (A10->adMixture[XiNC4] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XINC4, szBuffer) ; _gcvt (A10->adMixture[XiIC5] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIIC5, szBuffer) ; _gcvt (A10->adMixture[XiNC5] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XINC5, szBuffer) ; _gcvt (A10->adMixture[XiNC6] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XINC6, szBuffer) ; _gcvt (A10->adMixture[XiNC7] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XINC7, szBuffer) ; _gcvt (A10->adMixture[XiNC8] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XINC8, szBuffer) ; _gcvt (A10->adMixture[XiNC9] * 100.0, 9, szBuffer); 152 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. SetDlgItemText (hDlg, IDC_XINC9, szBuffer) ; _gcvt (A10->adMixture[XiNC10] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XINC10, szBuffer) ; _gcvt (A10->adMixture[XiHe] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIHE, szBuffer) ; _gcvt (A10->adMixture[XiAr] * 100.0, 9, szBuffer); SetDlgItemText (hDlg, IDC_XIAR, szBuffer) ; for (i=0, total = 0.0 ; i<NUMBEROFCOMPONENTS; i++) total += A10->adMixture[i]; sprintf(szBuffer, "%6.6f", total * 100.0) ; SetDlgItemText(hDlg, IDC_TOTAL, szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_PB_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) PressureDlgHelp(hListBox) ; LoadString(hInst, lPb_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_PF_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) PressureDlgHelp(hListBox) ; LoadString(hInst, lPf_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_TB_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) TemperatureDlgHelp(hListBox) ; LoadString(hInst, lTb_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_TF_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) TemperatureDlgHelp(hListBox) ; LoadString(hInst, lTf_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_RHOB_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) DensityDlgHelp(hListBox) ; LoadString(hInst, lRhob_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_RHOF_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) DensityDlgHelp(hListBox) ; LoadString(hInst, lRhof_unit, szBuffer, FIELD40) ; 153 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_SOS_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) SOSDlgHelp(hListBox) ; LoadString(hInst, lSOS_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_ENTHALPY_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) EnthalpyDlgHelp(hListBox) ; LoadString(hInst, lEnthalpy_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; hListBox = GetDlgItem(hDlg, IDC_ENTROPY_U) ; if (!SendMessage(hListBox, CB_GETCOUNT, 0,0)) EntropyDlgHelp(hListBox) ; LoadString(hInst, lEntropy_unit, szBuffer, FIELD40) ; SendMessage(hListBox, CB_SELECTSTRING, -1,(LONG)(LPSTR)szBuffer) ; } /************************************************************************** * Function : WriteInputs() * Arguments : HWND * Returns : void * Purpose : Function for writing the input fields of the main window * Notes : Uses non-portable, run-time library function _gcvt() * for converting strings to double precision floats. * Revisions : **************************************************************************/ void WriteOutputs(HWND hDlg, AGA10STRUCT *A10) { double Rhofx, SOSx, Enthalpyx, Entropyx ; /* calculate Rhof in specified unit of measure switch (lRhof_unit) { case KGPERCUBICMETRE : Rhofx = A10->dRhof ; break ; case LBMPERCUBICFOOT : 154 */ This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. Rhofx = (A10->dRhof / 0.45359237) * pow(0.3048, 3.0) ; } /* calculate SOS in specified unit of measure switch (lSOS_unit) { case METREPERSECOND : SOSx = A10->dSOS ; break ; case FOOTPERSECOND : SOSx = A10->dSOS / 0.3048 */ ; } /* calculate specific enthalpy in specified unit of measure switch (lEnthalpy_unit) { case KJPERKG : Enthalpyx = A10->dH * 0.001 ; break ; */ case BTUPERLBM : Enthalpyx = A10->dH / ((5000./9.) * 4.1868) ; } /* calculate specific entropy in specified unit of measure switch (lEntropy_unit) { case KJPERKGK : Entropyx = A10->dS * 0.001 ; break ; case BTUPERLBMF : Entropyx = A10->dS / (1.0e3 * 4.1868) ; } /* write the outputs to the window */ _gcvt (Rhofx, 9, szBuffer); SetDlgItemText (hDlg, IDC_RHOF, szBuffer) ; 155 */ This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. _gcvt (SOSx, 9, szBuffer); SetDlgItemText (hDlg, IDC_SOS, szBuffer) ; _gcvt (A10->dZb, 9, szBuffer); SetDlgItemText (hDlg, IDC_ZB, szBuffer) ; _gcvt (A10->dZf, 9, szBuffer); SetDlgItemText (hDlg, IDC_ZF, szBuffer) ; _gcvt (A10->dFpv, 9, szBuffer); SetDlgItemText (hDlg, IDC_FPV, szBuffer) ; _gcvt (A10->dDf, 9, szBuffer); SetDlgItemText (hDlg, IDC_DF, szBuffer) ; _gcvt (A10->dRD_Ideal, 9, szBuffer); SetDlgItemText (hDlg, IDC_RD_IDEAL, szBuffer) ; _gcvt (A10->dRD_Real, 9, szBuffer); SetDlgItemText (hDlg, IDC_RD_REAL, szBuffer) ; _gcvt (A10->dMrx, 9, szBuffer); SetDlgItemText (hDlg, IDC_MRX, szBuffer) ; _gcvt (A10->dCpi * 0.001, 9, szBuffer); SetDlgItemText (hDlg, IDC_CPI, szBuffer) ; _gcvt (A10->dCp * 0.001, 9, szBuffer); SetDlgItemText (hDlg, IDC_CP, szBuffer) ; _gcvt (A10->dCv * 0.001, 9, szBuffer); SetDlgItemText (hDlg, IDC_CV, szBuffer) ; _gcvt (A10->dk, 9, szBuffer); SetDlgItemText (hDlg, IDC_K, szBuffer) ; _gcvt (A10->dKappa, 9, szBuffer); SetDlgItemText (hDlg, IDC_KAPPA, szBuffer) ; _gcvt (A10->dHo * 0.001, 9, szBuffer); 156 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. SetDlgItemText (hDlg, IDC_HO, szBuffer) ; _gcvt (Enthalpyx, 9, szBuffer); SetDlgItemText (hDlg, IDC_H, szBuffer) ; _gcvt (Entropyx, 9, szBuffer); SetDlgItemText (hDlg, IDC_S, szBuffer) ; // reality check included for C* if (A10->dCstar > 0.3 && A10->dCstar < 1.3) { _gcvt (A10->dCstar, 9, szBuffer); SetDlgItemText (hDlg, IDC_CSTAR, szBuffer) ; } else { lstrcpy(szBuffer, "Cannot Solve!") ; SetDlgItemText (hDlg, IDC_CSTAR, szBuffer) ; } /* update status indicator, based on return codes if (A10->lStatus == 9000) { lstrcpy(szBuffer, "Calculation Completed") ; SetDlgItemText (hDlg, IDC_LSTATUS, szBuffer) ; } else { _ltoa (A10->lStatus, szBuffer, 10); SetDlgItemText (hDlg, IDC_LSTATUS, szBuffer) ; } */ } /************************************************************************** * Function : ReadInputs() * Arguments : HWND * Returns : void * Purpose : Function for reading the input fields of the main window * Revisions : **************************************************************************/ 157 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. void ReadInputs(HWND hDlg, AGA10STRUCT *A10) { HWND hListBox; int iSelection; int i ; char * stopstr; //Pb GetDlgItemText(hDlg, IDC_PB, szBuffer, FIELD30) ; hListBox = GetDlgItem(hDlg, IDC_PB_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; switch (iSelection) { case 0 : lPb_unit = KILOPASCAL ; A10->dPb = strtod(szBuffer, &stopstr) * 1.0e3 ; break ; case 1 : lPb_unit = MEGAPASCAL ; A10->dPb = strtod(szBuffer, &stopstr) * 1.0e6 ; break ; case 2 : lPb_unit = PSI ; A10->dPb = strtod(szBuffer, &stopstr) * 6894.75729 ; } //Pf GetDlgItemText(hDlg, IDC_PF, szBuffer, FIELD30) ; hListBox = GetDlgItem(hDlg, IDC_PF_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; switch (iSelection) { case 0 : lPf_unit = KILOPASCAL ; A10->dPf = strtod(szBuffer, &stopstr) * 1.0e3 ; break ; case 1 : lPf_unit = MEGAPASCAL ; A10->dPf = strtod(szBuffer, &stopstr) * 1.0e6 ; 158 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. break ; case 2 : lPf_unit = PSI ; A10->dPf = strtod(szBuffer, &stopstr) * 6894.75729 ; } //Tb GetDlgItemText(hDlg, IDC_TB, szBuffer, FIELD30) ; hListBox = GetDlgItem(hDlg, IDC_TB_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; switch (iSelection) { case 0 : lTb_unit = CELSIUS ; A10->dTb = strtod(szBuffer, &stopstr) + 273.15; break ; case 1 : lTb_unit = FAHRENHEIT ; A10->dTb = (strtod(szBuffer, &stopstr) + 459.67) / 1.8 ; break ; case 2 : lTb_unit = KELVIN ; A10->dTb = strtod(szBuffer, &stopstr) ; break ; case 3 : lTb_unit = RANKINE ; A10->dTb = strtod(szBuffer, &stopstr) / 1.8; } //Tf GetDlgItemText(hDlg, IDC_TF, szBuffer, FIELD30) ; hListBox = GetDlgItem(hDlg, IDC_TF_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; switch (iSelection) { case 0 : lTf_unit = CELSIUS ; A10->dTf = strtod(szBuffer, &stopstr) + 273.15; break ; 159 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. case 1 : lTf_unit = FAHRENHEIT ; A10->dTf = (strtod(szBuffer, &stopstr) + 459.67) / 1.8 ; break ; case 2 : lTf_unit = KELVIN ; A10->dTf = strtod(szBuffer, &stopstr) ; break ; case 3 : lTf_unit = RANKINE ; A10->dTf = strtod(szBuffer, &stopstr) / 1.8; } //Rhof hListBox = GetDlgItem(hDlg, IDC_RHOF_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; switch (iSelection) { case 0 : lRhof_unit = KGPERCUBICMETRE ; break ; case 1 : lRhof_unit = LBMPERCUBICFOOT ; } //SOS hListBox = GetDlgItem(hDlg, IDC_SOS_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; switch (iSelection) { case 0 : lSOS_unit = METREPERSECOND ; break ; case 1 : lSOS_unit = FOOTPERSECOND ; } //Enthalpy hListBox = GetDlgItem(hDlg, IDC_ENTHALPY_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; 160 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. switch (iSelection) { case 0 : lEnthalpy_unit = KJPERKG ; break ; case 1 : lEnthalpy_unit = BTUPERLBM ; } //Entropy hListBox = GetDlgItem(hDlg, IDC_ENTROPY_U) ; iSelection = SendMessage(hListBox, CB_GETCURSEL, 0,0) ; switch (iSelection) { case 0 : lEntropy_unit = KJPERKGK ; break ; case 1 : lEntropy_unit = BTUPERLBMF ; } // composition GetDlgItemText(hDlg,IDC_XIC1, szBuffer, FIELD30) ; A10->adMixture[XiC1] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIN2, szBuffer, FIELD30) ; A10->adMixture[XiN2] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XICO2, szBuffer, FIELD30) ; A10->adMixture[XiCO2] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIC2, szBuffer, FIELD30) ; A10->adMixture[XiC2] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIC3, szBuffer, FIELD30) ; A10->adMixture[XiC3] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIH2O, szBuffer, FIELD30) ; A10->adMixture[XiH2O] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIH2S, szBuffer, FIELD30) ; A10->adMixture[XiH2S] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIH2, szBuffer, FIELD30) ; A10->adMixture[XiH2] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XICO, szBuffer, FIELD30) ; A10->adMixture[XiCO] = strtod(szBuffer, &stopstr) * 0.01 ; 161 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. GetDlgItemText(hDlg,IDC_XIO2, szBuffer, FIELD30) ; A10->adMixture[XiO2] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIIC4, szBuffer, FIELD30) ; A10->adMixture[XiIC4] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XINC4, szBuffer, FIELD30) ; A10->adMixture[XiNC4] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIIC5, szBuffer, FIELD30) ; A10->adMixture[XiIC5] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XINC5, szBuffer, FIELD30) ; A10->adMixture[XiNC5] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XINC6, szBuffer, FIELD30) ; A10->adMixture[XiNC6] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XINC7, szBuffer, FIELD30) ; A10->adMixture[XiNC7] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XINC8, szBuffer, FIELD30) ; A10->adMixture[XiNC8] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XINC9, szBuffer, FIELD30) ; A10->adMixture[XiNC9] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XINC10, szBuffer, FIELD30) ; A10->adMixture[XiNC10] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIHE, szBuffer, FIELD30) ; A10->adMixture[XiHe] = strtod(szBuffer, &stopstr) * 0.01 ; GetDlgItemText(hDlg,IDC_XIAR, szBuffer, FIELD30) ; A10->adMixture[XiAr] = strtod(szBuffer, &stopstr) * 0.01 ; // sum up the mole fractions for (i=0,total = 0.0; i<NUMBEROFCOMPONENTS; i++) total += A10->adMixture[i]; sprintf(szBuffer, "%6.6f", total * 100.0) ; SetDlgItemText(hDlg, IDC_TOTAL, szBuffer) ; } /************************************************************************** * Function : PressureDlgHelp() * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into pressure * drop-list controls * Revisions : **************************************************************************/ 162 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. void PressureDlgHelp(HWND hListBox) { LoadString(hInst, KILOPASCAL, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, MEGAPASCAL, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, PSI, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 2, (LONG)(LPSTR) szBuffer) ; } /************************************************************************** * Function : TemperatureDlgHelp() * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into temperature * drop-list controls * Revisions : **************************************************************************/ void TemperatureDlgHelp(HWND hListBox) { LoadString(hInst, CELSIUS, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, FAHRENHEIT, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, KELVIN, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 2, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, RANKINE, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 3, (LONG)(LPSTR) szBuffer) ; } /************************************************************************** * Function : DensityDlgHelp() * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into density * drop-list controls 163 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. * Revisions : **************************************************************************/ void DensityDlgHelp(HWND hListBox) { LoadString(hInst, KGPERCUBICMETRE, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, LBMPERCUBICFOOT, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ; } /************************************************************************** * Function : SOSDlgHelp() * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into SOS * drop-list controls * Revisions : **************************************************************************/ void SOSDlgHelp(HWND hListBox) { LoadString(hInst, METREPERSECOND, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, FOOTPERSECOND, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ; } /************************************************************************** * Function : EnthalpyDlgHelp() * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into enthalpy * drop-list controls * Revisions : **************************************************************************/ void EnthalpyDlgHelp(HWND hListBox) 164 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. { LoadString(hInst, KJPERKG, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, BTUPERLBM, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ; } /************************************************************************** * Function : EntropyDlgHelp() * Arguments : HWND * Returns : void * Purpose : Helper function for loading strings into entropy * drop-list controls * Revisions : **************************************************************************/ void EntropyDlgHelp(HWND hListBox) { LoadString(hInst, KJPERKGK, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 0, (LONG)(LPSTR) szBuffer) ; LoadString(hInst, BTUPERLBMF, szBuffer, FIELD40) ; SendMessage(hListBox, CB_INSERTSTRING, 1, (LONG)(LPSTR) szBuffer) ; } /************************************************************************** * Function : SetDefaults() * Arguments : void * Returns : void * Purpose : initializes AGA10STRUCT and units of measure * Revisions : **************************************************************************/ void SetDefaults(AGA10STRUCT *A10) { A10->lStatus = 9000 ; A10->bForceUpdate = true; A10->dPb = 101325.0 ; A10->dTb = 288.15; A10->dPf = 4000000.0 ; A10->dTf = 283.15; /* 9000 is status code for 'ok' */ /* ensures that full calculation is performed */ /* 1 atm */ /* 15 C */ /* 4 MPa */ /* 10 C */ 165 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. A10->adMixture[XiC1] = 0.906724; A10->adMixture[XiN2] = 0.031284; A10->adMixture[XiCO2] = 0.004676; A10->adMixture[XiC2] = 0.045279; A10->adMixture[XiC3] = 0.00828; A10->adMixture[XiH2O] = 0.0; A10->adMixture[XiH2S] = 0.0; A10->adMixture[XiH2] = 0.0; A10->adMixture[XiCO] = 0.0; A10->adMixture[XiO2] = 0.0; A10->adMixture[XiIC4] = 0.001037; A10->adMixture[XiNC4] = 0.001563; A10->adMixture[XiIC5] = 0.000321; A10->adMixture[XiNC5] = 0.000443; A10->adMixture[XiNC6] = 0.000393; A10->adMixture[XiNC7] = 0.0; A10->adMixture[XiNC8] = 0.0; A10->adMixture[XiNC9] = 0.0; A10->adMixture[XiNC10] = 0.0; A10->adMixture[XiHe] = 0.0; A10->adMixture[XiAr] = 0.0; /* AMARILLO example composition...*/ /* reset units of measure */ lPb_unit = KILOPASCAL ; lPf_unit = KILOPASCAL ; lTb_unit = CELSIUS ; lTf_unit = CELSIUS ; lRhob_unit = KGPERCUBICMETRE ; lRhof_unit = KGPERCUBICMETRE ; lSOS_unit = METREPERSECOND ; lEnthalpy_unit = KJPERKG ; lEntropy_unit = KJPERKGK ; } 166 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // // // // // // File : resource.h Description : header file used for Windows resource file Version : 1.7 2002.11.17 Author : W.B. Peterson Revisions : Copyright (c) 2002 American Gas Association //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by aga10win.rc // // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC #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 167 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. // // // // // // File : aga10win.rc Description : resource script for aga10win’s interface Version : 1.7 2002.11.17 Author : W.B. Peterson Revisions : Copyright (c) 2002 American Gas Association //Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #define APSTUDIO_HIDDEN_SYMBOLS #include "windows.h" #undef APSTUDIO_HIDDEN_SYMBOLS #include "aga10win.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. 168 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. AGA10WIN ICON DISCARDABLE "aga10win.ico" ///////////////////////////////////////////////////////////////////////////// // // Dialog // AGA10WIN DIALOGEX 0, 0, 575, 315 STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT CAPTION "AGA 10 Example Program" MENU IDR_MENU1 CLASS "aga10win" FONT 8, "MS Sans Serif" BEGIN EDITTEXT IDC_XIHE,55,15,44,14,ES_AUTOHSCROLL | WS_GROUP EDITTEXT IDC_XIH2,55,33,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIN2,55,51,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XICO2,55,69,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIH2S,55,87,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIC1,55,105,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIC2,55,123,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIC3,153,16,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIIC4,153,34,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XINC4,153,52,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIIC5,153,70,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XINC5,154,89,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XINC6,154,107,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XINC7,154,125,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XINC8,259,16,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XINC9,259,34,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XINC10,259,52,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIAR,259,70,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIH2O,259,88,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XICO,259,106,44,14,ES_AUTOHSCROLL EDITTEXT IDC_XIO2,259,124,44,14 PUSHBUTTON "Clear Mixture",IDC_CLEAR,47,149,60,20 EDITTEXT IDC_PB,34,196,60,14,ES_AUTOHSCROLL COMBOBOX IDC_PB_U,98,197,60,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP 169 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. EDITTEXT COMBOBOX EDITTEXT COMBOBOX 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 IDC_TB,34,215,60,14,ES_AUTOHSCROLL IDC_TB_U,98,216,60,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_PF,191,196,60,14,ES_AUTOHSCROLL IDC_PF_U,254,196,60,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_TF,191,215,60,14,ES_AUTOHSCROLL IDC_TF_U,255,215,60,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP "Calculate",IDOK,137,282,50,20 "Initialize",IDRETRY,61,282,50,20 "Quit",IDCANCEL,213,282,50,20,WS_GROUP "Composition (Mole Percent)",IDC_STATIC,5,3,322,175 "Helium",IDC_STATIC,21,18,28,8,NOT WS_GROUP "Hydrogen",IDC_STATIC,21,36,32,8,NOT WS_GROUP "Nitrogen",IDC_STATIC,21,55,28,8,NOT WS_GROUP "CO2",IDC_STATIC,22,71,15,8,NOT WS_GROUP "H2S",IDC_STATIC,22,89,15,8,NOT WS_GROUP "Methane",IDC_STATIC,22,108,29,8,NOT WS_GROUP "Ethane",IDC_STATIC,22,126,24,8,NOT WS_GROUP "Propane",IDC_STATIC,116,18,28,8,NOT WS_GROUP "i-Butane",IDC_STATIC,116,37,27,8,NOT WS_GROUP "n-Butane",IDC_STATIC,116,55,30,8,NOT WS_GROUP "i-Pentane",IDC_STATIC,116,72,31,8,NOT WS_GROUP "n-Pentane",IDC_STATIC,115,92,34,8,NOT WS_GROUP "n-Hexane",IDC_STATIC,115,110,32,8,NOT WS_GROUP "n-Heptane",IDC_STATIC,115,128,34,8,NOT WS_GROUP "n-Octane",IDC_STATIC,218,19,30,8,NOT WS_GROUP "n-Nonane",IDC_STATIC,218,37,32,8,NOT WS_GROUP "n-Decane",IDC_STATIC,218,55,32,8,NOT WS_GROUP "Argon",IDC_STATIC,219,73,27,8,NOT WS_GROUP "Water",IDC_STATIC,219,91,23,8,NOT WS_GROUP "CO",IDC_STATIC,219,109,11,8,NOT WS_GROUP "O2",IDC_STATIC,219,128,24,8,NOT WS_GROUP "TOTAL",IDC_STATIC,218,147,24,8,NOT WS_GROUP "Static",IDC_TOTAL,259,146,44,12,SS_SUNKEN | NOT WS_GROUP "Gas Temperature and Absolute Pressure",IDC_STATIC,6,182, 322,56 "Pb",IDC_STATIC,12,199,10,8 170 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. LTEXT LTEXT LTEXT 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 "Tb",IDC_STATIC,11,217,10,8 "Pf",IDC_STATIC,177,199,8,8 "Tf",IDC_STATIC,176,217,8,8 "Calculation Results",IDC_STATIC,334,3,234,306 "Speed of Sound",IDC_STATIC,348,24,52,8 "Zf",IDC_STATIC,348,173,8,8 "Zb",IDC_STATIC,348,158,10,8 "Fpv",IDC_STATIC,348,187,13,8 "Cp (real gas)",IDC_STATIC,348,232,40,8 "Cv (real gas)",IDC_STATIC,348,248,40,8 "Cp/Cv",IDC_STATIC,348,264,22,8 "Isentropic Exponent",IDC_STATIC,348,53,67,8 "Mass Density",IDC_STATIC,348,113,43,8 "Molar Density",IDC_STATIC,348,98,44,8 "Specific Enthalpy",IDC_STATIC,348,68,56,8 "Specific Entropy",IDC_STATIC,348,83,52,8 "Enthalpy (ideal gas)",IDC_STATIC,348,280,62,8 "Cp (ideal gas)",IDC_STATIC,348,216,44,8 "Molar Mass",IDC_STATIC,348,201,37,8 "0",IDC_SOS,422,24,50,8,NOT WS_GROUP "0",IDC_H,422,69,50,8,NOT WS_GROUP "0",IDC_S,422,83,50,8,NOT WS_GROUP "0",IDC_DF,422,99,60,8,NOT WS_GROUP "0",IDC_RHOF,422,113,55,8,NOT WS_GROUP "0",IDC_ZB,422,157,50,8,NOT WS_GROUP "0",IDC_ZF,422,171,50,8,NOT WS_GROUP "0",IDC_FPV,422,186,50,8,NOT WS_GROUP "0",IDC_MRX,422,201,50,8,NOT WS_GROUP "0",IDC_CPI,422,216,50,8,NOT WS_GROUP "0",IDC_HO,422,280,50,8,NOT WS_GROUP "0",IDC_CP,422,232,50,8,NOT WS_GROUP "0",IDC_CV,422,248,50,8,NOT WS_GROUP "0",IDC_K,422,264,50,8,NOT WS_GROUP "0",IDC_KAPPA,422,53,50,8,NOT WS_GROUP "moles/dm3",IDC_STATIC,483,98,32,8 "kJ/kg-K",IDC_STATIC,483,216,26,8 "kJ/kg",IDC_STATIC,483,280,20,8 "RD (ideal gas)",IDC_STATIC,348,128,46,8 "RD (real gas)",IDC_STATIC,348,143,42,8 "0",IDC_RD_IDEAL,422,128,50,8,NOT WS_GROUP 171 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. LTEXT LTEXT LTEXT LTEXT LTEXT LTEXT COMBOBOX COMBOBOX COMBOBOX COMBOBOX GROUPBOX PUSHBUTTON "0",IDC_RD_REAL,422,143,50,8,NOT WS_GROUP "Press Initialize Button to Begin",IDC_LSTATUS,106,259, 107,8 "kJ/kg-K",IDC_STATIC,483,232,26,8 "kJ/kg-K",IDC_STATIC,483,248,26,8 "C*",IDC_STATIC,348,39,10,8 "0",IDC_CSTAR,422,39,58,8 IDC_SOS_U,482,21,80,43,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_RHOF_U,482,111,80,44,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_ENTHALPY_U,482,66,80,40,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP IDC_ENTROPY_U,482,82,80,37,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP "Current Status",IDC_STATIC,5,247,322,27 "Normalize",IDC_NORMALIZE,118,149,60,20 END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""windows.h""\r\n" "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""aga10win.h""\r\n" "\0" END 172 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN "AGA10WIN", DIALOG BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 568 BOTTOMMARGIN, 309 END END #endif // APSTUDIO_INVOKED #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,7,0,0 PRODUCTVERSION 1,7,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x21L #else 173 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. FILEFLAGS 0x20L #endif FILEOS 0x40004L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments", "Post Ballot Version\0" VALUE "CompanyName", "American Gas Association\0" VALUE "FileDescription", "aga10win\0" VALUE "FileVersion", "1, 7, 0, 0\0" VALUE "InternalName", "aga10win\0" VALUE "LegalCopyright", "Copyright © 2002 American Gas Association\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "aga10win.exe\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "aga10win\0" VALUE "ProductVersion", "1, 7, 0, 0\0" VALUE "SpecialBuild", "2002.11.17 Build\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // !_MAC ///////////////////////////////////////////////////////////////////////////// // // Menu // IDR_MENU1 MENU DISCARDABLE BEGIN 174 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. POPUP "&File" BEGIN MENUITEM "&Open...", MENUITEM "&Save...", MENUITEM "Save &As...", MENUITEM "E&xit", END POPUP "&Help" BEGIN MENUITEM "&About", END CM_FILEOPEN CM_FILESAVE CM_FILESAVEAS IDCANCEL CM_HELPABOUT END ///////////////////////////////////////////////////////////////////////////// // // String Table // STRINGTABLE DISCARDABLE BEGIN KILOPASCAL MEGAPASCAL END STRINGTABLE DISCARDABLE BEGIN PSI KELVIN CELSIUS RANKINE FAHRENHEIT KGPERCUBICMETRE LBMPERCUBICFOOT METREPERSECOND FOOTPERSECOND KJPERKG BTUPERLBM KJPERKGK BTUPERLBMF "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" 175 This report is the property of AGA and is part of its process for developing new documents. This report or any of its part shall not be copied, disseminated, cited in literature, presentations or discussions without prior approval from AGA. END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED 176