103 lines
3.9 KiB
C
103 lines
3.9 KiB
C
/*************************************************************************
|
|
|
|
* File: aga10.h
|
|
* Description: function prototypes and defines for aga10.cpp
|
|
* Version: ver 1.7 2002.11.17
|
|
* Author: W.B. Peterson
|
|
|
|
*Revisions:
|
|
|
|
*Copyright (c) 2002 American Gas Association
|
|
**************************************************************************/
|
|
|
|
#ifndef _AGA10_H #define _AGA10_H
|
|
|
|
/* Windows-specific export macro and header #include */ #if WIN32
|
|
|
|
#define DllExport __declspec (dllexport) #include <windows.h>
|
|
#else
|
|
#define DllExport #endif
|
|
|
|
/* other includes */ #include <strstream> #include <iostream> #include <fstream> #include <iomanip> #include <math.h>
|
|
|
|
/* status codes */
|
|
#define NORMAL 9000
|
|
#define AGA10_INITIALIZED 9001
|
|
#define MEMORY_ALLOCATION_ERROR 9002
|
|
#define GENERAL_CALCULATION_FAILURE 9003
|
|
#define MAX_NUM_OF_ITERATIONS_EXCEEDED 9004
|
|
#define NEGATIVE_DENSITY_DERIVATIVE 9005
|
|
#define MAX_DENSITY_IN_BRAKET_EXCEEDED 9006
|
|
/* number of components */
|
|
#define NUMBEROFCOMPONENTS 21
|
|
/* maximum number of tries within search routines */
|
|
|
|
#define MAX_NUM_OF_ITERATIONS 100
|
|
|
|
/* default tolerance limits */
|
|
#define P_CHG_TOL 0.001 /* 0.001 Pa */
|
|
#define T_CHG_TOL 0.001 /* 0.001 of a Kelvin */
|
|
/* maximum allowable P & T */
|
|
const double P_MAX = 1.379e8 ; // maximum pressure (Pa) ~= 20,000 psi
|
|
const double P_MIN = 0.0 ; // maximum pressure = 0
|
|
const double T_MAX = 473.15 ; // maximum temperature (K) ~= 392 F
|
|
const double T_MIN = 143.0 ; // maximum temperature (K) ~= -200 F
|
|
/* universal gas constant, in two configurations */
|
|
#define RGASKJ 8.314510e-3 /* in kJ mol^-1 K^-1 */
|
|
#define RGAS 8.314510 /* in J mol^-1 K^-1 */
|
|
/* the main data structure used by this library */
|
|
typedef struct tagAGA10STRUCT
|
|
{ /* corresponds to the control group in meter classes */
|
|
|
|
long lStatus ; /* calculation status */
|
|
bool bForceUpdate; /* signal to perform full calculation */
|
|
double adMixture[NUMBEROFCOMPONENTS] ; /* Composition in mole fraction */
|
|
double dPb ; /* Contract base Pressure (Pa) */
|
|
double dTb ; /* Contract base temperature (K) */
|
|
double dPf ; /* Absolute Pressure (Pa) */
|
|
double dTf ; /* Flowing temperature (K) */
|
|
// basic output from AGA 8 Detail method
|
|
double dMrx ; /* mixture molar mass */
|
|
double dZb ; /* compressibility at contract base condition */
|
|
double dZf ; /* compressibility at flowing condition */
|
|
double dFpv ; /* supercompressibility */
|
|
double dDb ; /* molar density at contract base conditions (moles/dm3) */
|
|
double dDf ; /* molar density at flowing conditions (moles/dm3) */
|
|
double dRhob ; /* mass density at contract base conditions (kg/m3) */
|
|
double dRhof ; /* mass density at flowing conditions (kg/m3) */
|
|
double dRD_Ideal ; /* ideal gas relative density */
|
|
double dRD_Real ; /* real gas relative density */
|
|
// additional output
|
|
double dHo ; /* ideal gas specific enthalpy */
|
|
double dH ; /* real gas specific enthalpy (J/kg) */
|
|
double dS ; /* real gas specific entropy (J/kg-mol.K)*/
|
|
double dCpi ; /* ideal gas constant pressure heat capacity (J/kg-mol.K)*/
|
|
double dCp ; /* real gas constant pressure heat capacity (J/kg-mol.K)*/
|
|
double dCv ; /* real gas constant volume heat capacity (J/kg-mol.K)*/
|
|
double dk ; /* ratio of specific heats */
|
|
double dKappa ; /* isentropic exponent, denoted with Greek letter kappa */
|
|
double dSOS ; /* speed of sound (m/s) */
|
|
double dCstar ; /* critical flow factor C* */
|
|
} AGA10STRUCT ;
|
|
|
|
|
|
/* enumerations for tracking gas components */ enum gascomp{ XiC1=0, XiN2, XiCO2, XiC2, XiC3,
|
|
|
|
XiH2O, XiH2S, XiH2, XiCO, XiO2, XiIC4, XiNC4, XiIC5, XiNC5, XiNC6, XiNC7, XiNC8, XiNC9, XiNC10, XiHe, XiAr } ;
|
|
|
|
|
|
/* FUNCTION PROTOTYPES */
|
|
|
|
/* prototypes for initialization */
|
|
|
|
int AGA10_Init(void) ; /* initialize library */
|
|
int AGA10_UnInit(void) ; /* un-initialize library */
|
|
|
|
/* function prototype for basic VOS calculation */ double SOS(AGA10STRUCT *) ;
|
|
|
|
/* function prototype for a C* calculation */ double Crit(AGA10STRUCT *, double) ;
|
|
|
|
#endif
|
|
|
|
|