Conflicts: Cantera/Makefile.in Cantera/clib/src/clib_defs.h Cantera/clib/src/ctreactor.cpp Cantera/clib/src/ctstagn.cpp Cantera/clib/src/ctstagn.h Cantera/cxx/Makefile.in Cantera/cxx/demos/combustor/combustor.cpp Cantera/cxx/demos/flamespeed/flamespeed.cpp Cantera/cxx/demos/kinetics1/example_utils.h Cantera/cxx/demos/kinetics1/kinetics1.cpp Cantera/cxx/include/Cantera.h Cantera/cxx/include/Cantera.mak.in Cantera/cxx/include/Cantera_bt.mak.in Cantera/cxx/include/Edge.h Cantera/cxx/include/GRI30.h Cantera/cxx/include/Interface.h Cantera/cxx/include/zerodim.h Cantera/fortran/f77demos/Makefile.in Cantera/fortran/src/Makefile.in Cantera/fortran/src/fct.cpp Cantera/fortran/src/fctxml.cpp Cantera/fortran/src/flib_defs.h Cantera/matlab/Makefile.in Cantera/matlab/cantera/Contents.m Cantera/matlab/setup_winmatlab.py Cantera/matlab/src/ctfunctions.cpp Cantera/matlab/src/ctmatutils.h Cantera/matlab/src/mixturemethods.cpp Cantera/matlab/src/mllogger.h Cantera/matlab/src/phasemethods.cpp Cantera/matlab/src/reactormethods.cpp Cantera/matlab/src/reactornetmethods.cpp Cantera/matlab/src/thermomethods.cpp Cantera/matlab/src/wallmethods.cpp Cantera/matlab/src/xmlmethods.cpp Cantera/python/Cantera/Edge.py Cantera/python/Cantera/Interface.py Cantera/python/Cantera/Phase.py Cantera/python/Cantera/importFromFile.py Cantera/python/Makefile.in Cantera/python/ctml_writer.py Cantera/python/setup.py.in Cantera/python/src/Makefile.in Cantera/python/src/ctkinetics_methods.cpp Cantera/python/src/ctonedim_methods.cpp Cantera/python/src/pylogger.h Cantera/src/Makefile.in Cantera/src/base/config.h.in Cantera/src/base/ctml.cpp Cantera/src/base/ctml.h Cantera/src/base/mdp_allo.cpp Cantera/src/base/mdp_allo.h Cantera/src/base/vec_functions.h Cantera/src/base/xml.cpp Cantera/src/base/xml.h Cantera/src/converters/CKParser.h Cantera/src/converters/Element.h Cantera/src/converters/Reaction.h Cantera/src/converters/RxnSpecies.h Cantera/src/converters/Species.h Cantera/src/converters/ckr_defs.h Cantera/src/converters/ckr_utils.h Cantera/src/equil/BasisOptimize.cpp Cantera/src/equil/Makefile.in Cantera/src/equil/MultiPhase.cpp Cantera/src/equil/vcs_MultiPhaseEquil.cpp Cantera/src/equil/vcs_VolPhase.cpp Cantera/src/equil/vcs_VolPhase.h Cantera/src/equil/vcs_linmaxc.cpp Cantera/src/equil/vcs_phaseStability.cpp Cantera/src/equil/vcs_rxnadj.cpp Cantera/src/equil/vcs_solve.cpp Cantera/src/equil/vcs_solve.h Cantera/src/equil/vcs_solve_TP.cpp Cantera/src/equil/vcs_util.cpp Cantera/src/equil/vcs_xerror.c Cantera/src/kinetics/GasKinetics.cpp Cantera/src/kinetics/GasKinetics.h Cantera/src/kinetics/InterfaceKinetics.cpp Cantera/src/kinetics/InterfaceKinetics.h Cantera/src/kinetics/Kinetics.h Cantera/src/kinetics/ReactionStoichMgr.h Cantera/src/kinetics/RxnRates.h Cantera/src/kinetics/StoichManager.h Cantera/src/numerics/BandMatrix.cpp Cantera/src/numerics/BandMatrix.h Cantera/src/numerics/DAE_Solver.h Cantera/src/numerics/DAE_solvers.cpp Cantera/src/numerics/DenseMatrix.cpp Cantera/src/numerics/DenseMatrix.h Cantera/src/numerics/FuncEval.h Cantera/src/numerics/IDA_Solver.cpp Cantera/src/numerics/IDA_Solver.h Cantera/src/numerics/Integrator.h Cantera/src/numerics/Makefile.in Cantera/src/numerics/NonlinearSolver.cpp Cantera/src/numerics/NonlinearSolver.h Cantera/src/numerics/ResidEval.h Cantera/src/numerics/ResidJacEval.cpp Cantera/src/numerics/ResidJacEval.h Cantera/src/numerics/SquareMatrix.cpp Cantera/src/numerics/SquareMatrix.h Cantera/src/numerics/ctlapack.h Cantera/src/oneD/Domain1D.h Cantera/src/oneD/OneDim.cpp Cantera/src/oneD/OneDim.h Cantera/src/oneD/Resid1D.h Cantera/src/oneD/Solid1D.cpp Cantera/src/oneD/Solid1D.h Cantera/src/oneD/StFlow.cpp Cantera/src/oneD/Surf1D.h Cantera/src/spectra/LineBroadener.h Cantera/src/thermo/Constituents.cpp Cantera/src/thermo/GibbsExcessVPSSTP.cpp Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp Cantera/src/thermo/IonsFromNeutralVPSSTP.h Cantera/src/thermo/LatticePhase.cpp Cantera/src/thermo/LatticeSolidPhase.cpp Cantera/src/thermo/LatticeSolidPhase.h Cantera/src/thermo/Makefile.in Cantera/src/thermo/MargulesVPSSTP.cpp Cantera/src/thermo/MargulesVPSSTP.h Cantera/src/thermo/NasaThermo.h Cantera/src/thermo/PDSS_IonsFromNeutral.cpp Cantera/src/thermo/PDSS_IonsFromNeutral.h Cantera/src/thermo/PDSS_SSVol.cpp Cantera/src/thermo/Phase.cpp Cantera/src/thermo/PseudoBinaryVPSSTP.cpp Cantera/src/thermo/PseudoBinaryVPSSTP.h Cantera/src/thermo/PureFluidPhase.cpp Cantera/src/thermo/ShomateThermo.h Cantera/src/thermo/SimpleThermo.h Cantera/src/thermo/SpeciesThermoFactory.cpp Cantera/src/thermo/State.h Cantera/src/thermo/StoichSubstance.h Cantera/src/thermo/ThermoFactory.cpp Cantera/src/thermo/ThermoPhase.cpp Cantera/src/thermo/ThermoPhase.h Cantera/src/transport/AqueousTransport.cpp Cantera/src/transport/AqueousTransport.h Cantera/src/transport/DustyGasTransport.cpp Cantera/src/transport/DustyGasTransport.h Cantera/src/transport/L_matrix.h Cantera/src/transport/LiquidTransport.cpp Cantera/src/transport/LiquidTransport.h Cantera/src/transport/LiquidTransportData.h Cantera/src/transport/MMCollisionInt.cpp Cantera/src/transport/MMCollisionInt.h Cantera/src/transport/Makefile.in Cantera/src/transport/MixTransport.cpp Cantera/src/transport/MixTransport.h Cantera/src/transport/MultiTransport.cpp Cantera/src/transport/MultiTransport.h Cantera/src/transport/SimpleTransport.cpp Cantera/src/transport/SimpleTransport.h Cantera/src/transport/SolidTransport.cpp Cantera/src/transport/SolidTransport.h Cantera/src/transport/TransportBase.h Cantera/src/transport/TransportFactory.cpp Cantera/src/transport/TransportFactory.h Cantera/src/transport/TransportParams.h Cantera/src/transport/WaterTransport.h Cantera/src/zeroD/FlowDevice.h Cantera/src/zeroD/Reactor.h Cantera/src/zeroD/ReactorBase.cpp Cantera/src/zeroD/ReactorBase.h Cantera/src/zeroD/ReactorNet.h Cantera/src/zeroD/Wall.h Cantera/user/Makefile.in License.rtf Makefile.in apps/bvp/stagnation.cpp configure configure.in data/transport/misc_tran.dat docs/Makefile.in docs/install_examples/README.txt docs/install_examples/cygwin_gcc434_dbg_f2c_numpy.sh docs/install_examples/linux_64_gcc424_dbg_python252_numpy docs/install_examples/linux_64_gcc424_opt_python252_numpy docs/install_examples/mac_gcc401_python251_numpy docs/python/.cvsignore ext/Makefile.in ext/blas/Makefile.in ext/cvode/Makefile.in ext/f2c_blas/Makefile.in ext/f2c_lapack/Makefile.in ext/f2c_math/Makefile.in ext/f2c_math/xersve.c ext/f2c_recipes/Makefile.in ext/lapack/Makefile.in ext/math/Makefile.in ext/recipes/Makefile.in ext/tpx/CarbonDioxide.cpp ext/tpx/Makefile.in ext/tpx/Sub.cpp ext/tpx/utils.cpp preconfig test_problems/ChemEquil_gri_matrix/gri_matrix.cpp test_problems/ChemEquil_gri_pairs/gri_pairs.cpp test_problems/ChemEquil_ionizedGas/ionizedGasEquil.cpp test_problems/ChemEquil_ionizedGas/runtest test_problems/ChemEquil_red1/basopt_red1.cpp test_problems/CpJump/CpJump.cpp test_problems/Makefile.in test_problems/VCSnonideal/Makefile.in test_problems/VCSnonideal/NaCl_equil/HMW_NaCl.xml test_problems/VCSnonideal/NaCl_equil/nacl_equil.cpp test_problems/VPsilane_test/silane_equil.cpp test_problems/cathermo/DH_graph_1/DH_graph_1.cpp test_problems/cathermo/DH_graph_NM/DH_graph_1.cpp test_problems/cathermo/DH_graph_Pitzer/DH_graph_1.cpp test_problems/cathermo/DH_graph_acommon/DH_graph_1.cpp test_problems/cathermo/DH_graph_bdotak/DH_graph_1.cpp test_problems/cathermo/HMW_dupl_test/HMW_NaCl_sp1977_alt.xml test_problems/cathermo/HMW_dupl_test/HMW_dupl_test.cpp test_problems/cathermo/HMW_dupl_test/TemperatureTable.h test_problems/cathermo/HMW_dupl_test/sortAlgorithms.cpp test_problems/cathermo/HMW_dupl_test/sortAlgorithms.h test_problems/cathermo/HMW_graph_CpvT/HMW_NaCl_sp1977_alt.xml test_problems/cathermo/HMW_graph_CpvT/HMW_graph_CpvT.cpp test_problems/cathermo/HMW_graph_CpvT/TemperatureTable.h test_problems/cathermo/HMW_graph_CpvT/sortAlgorithms.cpp test_problems/cathermo/HMW_graph_CpvT/sortAlgorithms.h test_problems/cathermo/HMW_graph_GvI/HMW_NaCl.xml test_problems/cathermo/HMW_graph_GvI/HMW_graph_GvI.cpp test_problems/cathermo/HMW_graph_GvI/TemperatureTable.h test_problems/cathermo/HMW_graph_GvI/sortAlgorithms.cpp test_problems/cathermo/HMW_graph_GvI/sortAlgorithms.h test_problems/cathermo/HMW_graph_GvT/HMW_NaCl_sp1977_alt.xml test_problems/cathermo/HMW_graph_GvT/HMW_graph_GvT.cpp test_problems/cathermo/HMW_graph_GvT/TemperatureTable.h test_problems/cathermo/HMW_graph_GvT/sortAlgorithms.cpp test_problems/cathermo/HMW_graph_GvT/sortAlgorithms.h test_problems/cathermo/HMW_graph_HvT/HMW_NaCl_sp1977_alt.xml test_problems/cathermo/HMW_graph_HvT/HMW_graph_HvT.cpp test_problems/cathermo/HMW_graph_HvT/TemperatureTable.h test_problems/cathermo/HMW_graph_HvT/sortAlgorithms.cpp test_problems/cathermo/HMW_graph_HvT/sortAlgorithms.h test_problems/cathermo/HMW_graph_VvT/HMW_NaCl_sp1977_alt.xml test_problems/cathermo/HMW_graph_VvT/HMW_graph_VvT.cpp test_problems/cathermo/HMW_graph_VvT/TemperatureTable.h test_problems/cathermo/HMW_graph_VvT/sortAlgorithms.cpp test_problems/cathermo/HMW_graph_VvT/sortAlgorithms.h test_problems/cathermo/HMW_test_1/HMW_test_1.cpp test_problems/cathermo/HMW_test_3/HMW_test_3.cpp test_problems/cathermo/Makefile.in test_problems/cathermo/VPissp/ISSPTester.cpp test_problems/cathermo/ims/IMSTester.cpp test_problems/cathermo/issp/ISSPTester.cpp test_problems/cathermo/stoichSubSSTP/TemperatureTable.h test_problems/cathermo/stoichSubSSTP/sortAlgorithms.cpp test_problems/cathermo/stoichSubSSTP/sortAlgorithms.h test_problems/cathermo/stoichSubSSTP/stoichSubSSTP.cpp test_problems/cathermo/testIAPWS/testIAPWSphi.cpp test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp test_problems/cathermo/testWaterTP/testWaterSSTP.cpp test_problems/cathermo/wtWater/wtWater.cpp test_problems/ck2cti_test/Makefile.in test_problems/ck2cti_test/runtest.in test_problems/cxx_ex/Makefile.in test_problems/cxx_ex/equil_example1.cpp test_problems/cxx_ex/example_utils.h test_problems/cxx_ex/kinetics_example1.cpp test_problems/cxx_ex/kinetics_example2.cpp test_problems/cxx_ex/kinetics_example3.cpp test_problems/cxx_ex/runtest test_problems/cxx_ex/rxnpath_example1.cpp test_problems/cxx_ex/transport_example1.cpp test_problems/cxx_ex/transport_example2.cpp test_problems/min_python/Makefile.in test_problems/min_python/minDiamond/Makefile.in test_problems/min_python/negATest/negATest.cpp test_problems/mixGasTransport/runtest test_problems/nasa9_reader/Makefile.in test_problems/nasa9_reader/runtest.in test_problems/negATest/negATest.cpp test_problems/printUtilUnitTest/pUtest.cpp test_problems/pureFluidTest/testPureWater.cpp test_problems/silane_equil/silane_equil.cpp test_problems/surfkin/surfdemo.cpp tools/Makefile.in tools/bin/cvs2cl.pl tools/src/ck2cti.cpp tools/templates/f77/demo_ftnlib.cpp win32/vc7/Sundials/sundials/sundials_config.h win32/vc9/Sundials/SUNDIALS_SHARED/sundials_config.h winconfig.h
366 lines
8.8 KiB
C++
Executable file
366 lines
8.8 KiB
C++
Executable file
/* FILE: CarbonDioxide.cpp
|
|
* DESCRIPTION:
|
|
* representation of substance Carbon Dioxide
|
|
* values and functions are from
|
|
* "Thermodynamic Properties in SI" bu W.C. Reynolds
|
|
* AUTHOR: me@rebeccahhunt.com: GCEP, Stanford University
|
|
*
|
|
*/
|
|
|
|
#include "CarbonDioxide.h"
|
|
#include <math.h>
|
|
#include <string.h>
|
|
|
|
namespace tpx {
|
|
|
|
/*
|
|
* Carbon Dioxide constants
|
|
*/
|
|
static const double Tmn = 216.54; // [K] minimum temperature for which calculations are valid
|
|
static const double Tmx = 1500.0; // [K] maximum temperature for which calculations are valid
|
|
static const double Tc=304.21; // [K] critical temperature
|
|
static const double Roc=464.00; // [kg/m^3] critical density
|
|
static const double To=216.54; // [K] reference Temperature
|
|
static const double R=188.918; // [] gas constant for CO2 J/kg/K
|
|
static const double Gamma=5.0E-6; // [??]
|
|
static const double u0=3.217405E5; // [] internal energy at To
|
|
static const double s0=2.1396056E3; // [] entropy at To
|
|
static const double Tp=250; // [K] ??
|
|
//static const double Pc=7.38350E6; // [Pa] critical pressure
|
|
static const double Pc=7.3817589E6; // Adjusted to fit the actual functional form
|
|
static const double M=44.01; // [kg/kmol] molar density
|
|
|
|
/*
|
|
* array Acarbdi is used by the function named Pp
|
|
*/
|
|
static const double Acarbdi[]={
|
|
2.2488558E-1,
|
|
-1.3717965E2,
|
|
-1.4430214E4,
|
|
-2.9630491E6,
|
|
-2.0606039E8,
|
|
4.5554393E-5,
|
|
7.7042840E-2,
|
|
4.0602371E1,
|
|
4.0029509E-7,
|
|
-3.9436077E-4,
|
|
1.2115286E-10,
|
|
1.0783386E-7,
|
|
4.3962336E-11,
|
|
-3.6505545E4,
|
|
1.9490511E7,
|
|
-2.9186718E9,
|
|
2.4358627E-2,
|
|
-3.7546530E1,
|
|
1.1898141E4
|
|
};
|
|
|
|
|
|
/*
|
|
* array F is used by the function named Psat
|
|
*/
|
|
static const double F[]={
|
|
-6.5412610,
|
|
-2.7914636E-1,
|
|
-3.4716202,
|
|
-3.4989637,
|
|
-1.9770948E1,
|
|
1.3922839E2,
|
|
-2.7670389E2,
|
|
-7.0510251E3
|
|
};
|
|
|
|
|
|
/*
|
|
* array D is used by the function ldens
|
|
*/
|
|
static const double D[]={
|
|
4.6400009E2,
|
|
6.7938129E2,
|
|
1.4776836E3,
|
|
-3.1267676E3,
|
|
3.6397656E3,
|
|
-1.3437098E3
|
|
};
|
|
|
|
|
|
/*
|
|
* array G is used by the function sp
|
|
*/
|
|
static const double G[]={
|
|
8.726361E3,
|
|
1.840040E2,
|
|
1.914025,
|
|
-1.667825E-3,
|
|
7.305950E-7,
|
|
-1.255290E-10,
|
|
3.2174105E5,
|
|
2.1396056E3
|
|
|
|
};
|
|
|
|
/*
|
|
* C returns a multiplier in each term of the sum
|
|
* in P-3, used in conjunction with C in the function Pp
|
|
* j is used to represent which of the values in the summation to calculate
|
|
* j=0 is the second additive in the formula in reynolds
|
|
* j=1 is the third...
|
|
* (this part does not include the multiplier rho^n)
|
|
*/
|
|
double CarbonDioxide::C(int j,double Tinverse, double T2inverse, double T3inverse, double T4inverse) {
|
|
switch(j) {
|
|
case 0 :
|
|
return Acarbdi[0]*T +
|
|
Acarbdi[1] +
|
|
Acarbdi[2] * Tinverse +
|
|
Acarbdi[3] * T2inverse +
|
|
Acarbdi[4] * T3inverse ;
|
|
case 1 :
|
|
return Acarbdi[5] *T +
|
|
Acarbdi[6] +
|
|
Acarbdi[7] * Tinverse ;
|
|
case 2 :
|
|
return Acarbdi[8]*T + Acarbdi[9];
|
|
case 3 :
|
|
return Acarbdi[10]*T + Acarbdi[11];
|
|
case 4 :
|
|
return Acarbdi[12];
|
|
case 5 :
|
|
return Acarbdi[13] *T2inverse +
|
|
Acarbdi[14] *T3inverse +
|
|
Acarbdi[15] *T4inverse;
|
|
case 6 :
|
|
return Acarbdi[16] *T2inverse +
|
|
Acarbdi[17] *T3inverse +
|
|
Acarbdi[18] *T4inverse;
|
|
default :
|
|
return 0.0;
|
|
}
|
|
}
|
|
|
|
/* cprime
|
|
* derivative of C(i)
|
|
*/
|
|
inline double CarbonDioxide::Cprime(int j, double T2inverse, double T3inverse, double T4inverse) {
|
|
|
|
switch(j) {
|
|
case 0 :
|
|
return Acarbdi[0] +
|
|
- Acarbdi[2] * T2inverse +
|
|
-2 * Acarbdi[3] * T3inverse +
|
|
-3 * Acarbdi[4] * T4inverse ;
|
|
case 1 :
|
|
return Acarbdi[5] -
|
|
Acarbdi[7] * T2inverse;
|
|
case 2 :
|
|
return Acarbdi[8] ;
|
|
case 3 :
|
|
return Acarbdi[10] ;
|
|
case 4 :
|
|
return 0;
|
|
case 5 :
|
|
return
|
|
-2 *Acarbdi[13] *T3inverse +
|
|
-3 *Acarbdi[14] *T4inverse +
|
|
-4 *Acarbdi[15]* pow(T,-5);
|
|
case 6 :
|
|
return
|
|
-2 *Acarbdi[16] *T3inverse +
|
|
-3 *Acarbdi[17] *T4inverse +
|
|
-4 *Acarbdi[18] *pow(T,-5);
|
|
default :
|
|
return 0.0;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* I = integral from o-rho { 1/(rho^2) * H(i, rho) d rho }
|
|
* ( see section 2 of Reynolds TPSI )
|
|
*/
|
|
inline double CarbonDioxide::I(int j, double ergho, double Gamma) {
|
|
switch (j) {
|
|
|
|
case 0:
|
|
return Rho;
|
|
case 1:
|
|
return pow(Rho, 2)/2;
|
|
case 2:
|
|
return pow(Rho, 3)/ 3;
|
|
case 3:
|
|
return pow(Rho, 4)/ 4;
|
|
case 4:
|
|
return pow(Rho, 5)/ 5;
|
|
case 5:
|
|
return (1 - ergho ) / double(2 * Gamma);
|
|
case 6:
|
|
return ( 1 - ergho * double( Gamma * pow(Rho,2) + double(1) ) )/ double(2 * Gamma * Gamma);
|
|
default:
|
|
return 0.0;
|
|
}
|
|
}
|
|
|
|
|
|
/* H returns a multiplier in each term of the sum
|
|
* in P-3
|
|
* this is used in conjunction with C in the function Pp
|
|
* this represents the product rho^n
|
|
* i=0 is the second additive in the formula in reynolds
|
|
* i=1 is the third ...
|
|
*/
|
|
double CarbonDioxide::H(int i, double egrho) {
|
|
if (i < 5)
|
|
return pow(Rho,i+2);
|
|
else if (i == 5)
|
|
return pow(Rho,3)*egrho;
|
|
else if (i == 6)
|
|
return pow(Rho,5)*egrho;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* internal energy
|
|
* see Reynolds eqn (15) section 2
|
|
* u = (the integral from T to To of co(T)dT) +
|
|
* sum from i to N ([C(i) - T*Cprime(i)] + uo
|
|
*/
|
|
double CarbonDioxide::up() {
|
|
|
|
double Tinverse = 1.0/T;
|
|
double T2inverse = pow(T, -2);
|
|
double T3inverse = pow(T, -3);
|
|
double T4inverse = pow(T, -4);
|
|
double egrho = exp(-Gamma*Rho*Rho);
|
|
|
|
double sum = 0.0;
|
|
|
|
// Equation C-6 integrated
|
|
sum += G[0]*log(T/To);
|
|
int i;
|
|
for (i=1; i<=5; i++)
|
|
sum += G[i]*(pow(T,i) - pow(To,i))/double(i);
|
|
|
|
|
|
for (i=0; i<=6; i++) {
|
|
sum += I(i,egrho, Gamma) *
|
|
( C(i, Tinverse, T2inverse, T3inverse, T4inverse) - T*Cprime(i,T2inverse, T3inverse, T4inverse) );
|
|
}
|
|
|
|
sum += u0;
|
|
return sum + m_energy_offset;
|
|
|
|
}
|
|
|
|
/*
|
|
* entropy
|
|
* see Reynolds eqn (16) section 2
|
|
*/
|
|
|
|
double CarbonDioxide::sp() {
|
|
//double Tinverse = 1.0/T;
|
|
double T2inverse = pow(T, -2);
|
|
double T3inverse = pow(T, -3);
|
|
double T4inverse = pow(T, -4);
|
|
double egrho = exp(-Gamma*Rho*Rho);
|
|
|
|
double sum = 0.0;
|
|
|
|
for (int i=2; i<=5; i++)
|
|
sum += G[i]*(pow(T,i-1) - pow(To,i-1))/double(i-1);
|
|
|
|
sum += G[1]*log(T/To);
|
|
sum -= G[0]*(1.0/To - 1.0/T);
|
|
|
|
|
|
for (int i=0; i<=6; i++) {
|
|
sum -= Cprime(i,T2inverse, T3inverse, T4inverse)*I(i,egrho,Gamma);
|
|
}
|
|
|
|
sum += s0 - R*log(Rho);
|
|
|
|
return sum + m_entropy_offset;
|
|
}
|
|
|
|
|
|
/*
|
|
* Equation P-3 in Reynolds
|
|
* P - rho - T
|
|
* returns P (pressure)
|
|
*/
|
|
double CarbonDioxide::Pp(){
|
|
double Tinverse = pow(T,-1);
|
|
double T2inverse = pow(T, -2);
|
|
double T3inverse = pow(T, -3);
|
|
double T4inverse = pow(T, -4);
|
|
double egrho = exp(-Gamma*Rho*Rho);
|
|
|
|
double P = Rho*R*T;
|
|
|
|
// when i=0 we are on second sum of equation (where rho^2)
|
|
for(int i=0; i<=6; i++) {
|
|
P += C(i,Tinverse, T2inverse, T3inverse, T4inverse)*H(i,egrho);
|
|
}
|
|
return P;
|
|
}
|
|
|
|
|
|
/*
|
|
* Equation S-2 in Reynolds
|
|
* Pressure at Saturation
|
|
*/
|
|
double CarbonDioxide::Psat(){
|
|
|
|
double log, sum=0,P;
|
|
if ((T < Tmn) || (T > Tc)) {
|
|
std::cout << " error in Psat " << TempError << std::endl;
|
|
set_Err(TempError); // Error("CarbonDioxide::Psat",TempError,T);
|
|
}
|
|
for (int i=1;i<=8;i++)
|
|
sum += F[i-1] * pow((T/Tp -1),double(i-1));
|
|
|
|
log = ((Tc/T)-1)*sum;
|
|
P=exp(log)*Pc;
|
|
|
|
//cout << "Psat is returning " << P << " at T " << T << " and Pc " << Pc << " and Tp " << Tp << endl;
|
|
return P;
|
|
|
|
}
|
|
|
|
/*
|
|
* Equation D2 in Reynolds
|
|
* liquid density, of rho_f
|
|
*/
|
|
double CarbonDioxide::ldens() {
|
|
double xx=1-(T/Tc), sum=0;
|
|
if ((T < Tmn) || (T > Tc)) {
|
|
std::cout << " error in ldens " << TempError << std::endl;
|
|
set_Err(TempError);
|
|
}
|
|
for(int i=1;i<=6;i++)
|
|
sum+=D[i-1]*pow(xx,double(i-1)/3.0);
|
|
|
|
return sum;
|
|
}
|
|
|
|
/*
|
|
* the following functions allow users
|
|
* to get the properties of CarbonDioxide
|
|
* that are not dependent on the state
|
|
*/
|
|
double CarbonDioxide::Tcrit() {return Tc;}
|
|
double CarbonDioxide::Pcrit() {return Pc;}
|
|
double CarbonDioxide::Vcrit() {return 1.0/Roc;}
|
|
double CarbonDioxide::Tmin() {return Tmn;}
|
|
double CarbonDioxide::Tmax() {return Tmx;}
|
|
char * CarbonDioxide::name() {
|
|
return (char *) m_name.c_str() ;
|
|
}
|
|
char * CarbonDioxide::formula() {
|
|
return (char *) m_formula.c_str();
|
|
}
|
|
double CarbonDioxide::MolWt() {return M;}
|
|
|
|
}
|
|
|
|
|
|
|