Cleaned up Doxygen documentation for pure fluid classes
This commit is contained in:
parent
9a4b843d5e
commit
5be3edbd5f
18 changed files with 219 additions and 303 deletions
|
|
@ -1,21 +1,3 @@
|
|||
/*
|
||||
* This is the base substance class from which all substances are derived
|
||||
*
|
||||
* Kate Talmazan: SURF -- July, 1995
|
||||
* original implementation of this class and all derived classes from
|
||||
* formulas given in TPSI. Implementation of P(Rho, T), cv0(T), ldens(T),
|
||||
* and Psat(T) for all substances in TPSI.f
|
||||
*
|
||||
* Dave Goodwin: Fall, 1996
|
||||
* functions for u, h, s, f, g;
|
||||
* functions to set state
|
||||
* error handling
|
||||
* documentation
|
||||
*
|
||||
* Sept., 2001: minor modifications to use with Cantera
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TPX_SUB_H
|
||||
#define TPX_SUB_H
|
||||
|
||||
|
|
@ -53,6 +35,9 @@ enum type { H, S, U, V, P, T };
|
|||
|
||||
const double Undef = 999.1234;
|
||||
|
||||
/*!
|
||||
* Base class from which all pure substances are derived
|
||||
*/
|
||||
class Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -71,42 +56,78 @@ public:
|
|||
m_energy_offset += hoff;
|
||||
}
|
||||
|
||||
// information about a substance:
|
||||
//! @name Information about a substance
|
||||
//! @{
|
||||
|
||||
virtual double MolWt()=0; // molecular weight, kg/kmol
|
||||
virtual double Tcrit()=0; // critical temperature, K
|
||||
virtual double Pcrit()=0; // critical pressure, Pa
|
||||
virtual double Vcrit()=0; // critical specific vol, m^3/kg
|
||||
virtual double Tmin()=0; // min. temp for which equations valid
|
||||
virtual double Tmax()=0; // max. temp for which equations valid
|
||||
virtual char* name() = 0; // name
|
||||
virtual char* formula() = 0; // chemical formula
|
||||
//! Molecular weight [kg/kmol]
|
||||
virtual double MolWt()=0;
|
||||
|
||||
// properties:
|
||||
//! Critical temperature [K]
|
||||
virtual double Tcrit()=0;
|
||||
|
||||
double P(); // pressure, Pa
|
||||
//! Critical pressure [Pa]
|
||||
virtual double Pcrit()=0;
|
||||
|
||||
//! Critical specific volume [m^3/kg]
|
||||
virtual double Vcrit()=0;
|
||||
|
||||
//! Minimum temperature for which the equation of state is valid
|
||||
virtual double Tmin()=0;
|
||||
|
||||
//! Maximum temperature for which the equation of state is valid
|
||||
virtual double Tmax()=0;
|
||||
|
||||
//! Name of the substance
|
||||
virtual char* name() = 0;
|
||||
|
||||
//! Chemical formula for the substance
|
||||
virtual char* formula() = 0;
|
||||
//! @}
|
||||
|
||||
//! @name Properties
|
||||
//! @{
|
||||
|
||||
//! Pressure [Pa]. If two phases are present, return the saturation
|
||||
//! pressure; otherwise return the pressure computed directly from the
|
||||
//! underlying eos.
|
||||
double P();
|
||||
|
||||
//! Temperature [K]
|
||||
double Temp() {
|
||||
return T; // temperature, K
|
||||
return T;
|
||||
}
|
||||
double v() { // specific vol, m^3/kg
|
||||
|
||||
//! Specific volume [m^3/kg]
|
||||
double v() {
|
||||
return prop(propertyFlag::V);
|
||||
}
|
||||
double u() { // int. energy, J/kg
|
||||
|
||||
//! Internal energy [J/kg]
|
||||
double u() {
|
||||
return prop(propertyFlag::U);
|
||||
}
|
||||
double h() { // enthalpy, J/kg
|
||||
|
||||
//! Enthalpy [J/kg]
|
||||
double h() {
|
||||
return prop(propertyFlag::H);
|
||||
}
|
||||
double s() { // entropy, J/kg/K
|
||||
|
||||
//! Entropy [J/kg/K]
|
||||
double s() {
|
||||
return prop(propertyFlag::S);
|
||||
}
|
||||
double f() { // Helmholtz function, J/kg
|
||||
|
||||
//! Helmholtz function [J/kg]
|
||||
double f() {
|
||||
return u() - T*s();
|
||||
}
|
||||
double g() { // Gibbs function, J/kg
|
||||
|
||||
//! Gibbs function [J/kg]
|
||||
double g() {
|
||||
return h() - T*s();
|
||||
}
|
||||
|
||||
//! Specific heat at constant volume [J/kg/K]
|
||||
virtual double cv() {
|
||||
double Tsave = T, dt = 1.e-4*T;
|
||||
set_T(Tsave - dt);
|
||||
|
|
@ -117,6 +138,7 @@ public:
|
|||
return T*(s2 - s1)/(2.0*dt);
|
||||
}
|
||||
|
||||
//! Specific heat at constant pressure [J/kg/K]
|
||||
virtual double cp() {
|
||||
double Tsave = T, dt = 1.e-4*T;
|
||||
double p0 = P();
|
||||
|
|
@ -149,30 +171,49 @@ public:
|
|||
return -(v2 - v1)/((v2 + v1)*dp);
|
||||
}
|
||||
|
||||
// saturation properties
|
||||
//! @}
|
||||
//! @name Saturation Properties
|
||||
//! @{
|
||||
|
||||
double Ps();
|
||||
virtual double dPsdT(); // d(Psat)/dT, Pa/K
|
||||
double Tsat(double p); // saturation temp at p
|
||||
double x(); // vapor mass fraction
|
||||
int TwoPhase(); // =1 if vapor/liquid, 0 otherwise
|
||||
|
||||
//! The derivative of the saturation pressure with respect to temperature.
|
||||
virtual double dPsdT();
|
||||
|
||||
//! Saturation temperature at pressure *p*.
|
||||
double Tsat(double p);
|
||||
|
||||
//! Vapor mass fraction. If T >= Tcrit, 0 is returned for v < Vcrit, and 1
|
||||
//! is returned if v > Vcrit.
|
||||
double x();
|
||||
|
||||
//! Returns 1 if the current state is a liquid/vapor mixture, 0 otherwise
|
||||
int TwoPhase();
|
||||
//! @}
|
||||
|
||||
virtual double Pp()=0;
|
||||
|
||||
//! Enthaply of a single-phase state
|
||||
double hp() {
|
||||
return up() + Pp()/Rho;
|
||||
}
|
||||
|
||||
//! Gibbs function of a single-phase state
|
||||
double gp() {
|
||||
return hp() - T*sp();
|
||||
}
|
||||
|
||||
double prop(propertyFlag::type ijob);
|
||||
void set_TPp(double t0, double p0); // set T and P
|
||||
|
||||
//! set T and P
|
||||
void set_TPp(double t0, double p0);
|
||||
|
||||
// functions to set or change state:
|
||||
//! Function to set or change the state for a property pair *XY* where
|
||||
//! *x0* is the value of first property and *y0* is the value of the
|
||||
//! second property.
|
||||
void Set(PropertyPair::type XY, double x0, double y0);
|
||||
|
||||
protected:
|
||||
|
||||
double T, Rho;
|
||||
double Tslast, Rhf, Rhv;
|
||||
double Pst;
|
||||
|
|
@ -181,20 +222,30 @@ protected:
|
|||
std::string m_name;
|
||||
std::string m_formula;
|
||||
|
||||
//virtual double Xm(int k) { return 1.0;}
|
||||
//virtual int Species() { return 1;}
|
||||
|
||||
virtual double ldens()=0;
|
||||
virtual double Psat()=0; // saturation pressure, Pa
|
||||
|
||||
//! Saturation pressure, Pa
|
||||
virtual double Psat()=0;
|
||||
|
||||
//! Internal energy of a single-phase state
|
||||
virtual double up()=0;
|
||||
|
||||
//! Entropy of a single-phase state
|
||||
virtual double sp()=0;
|
||||
|
||||
virtual int ideal() {
|
||||
return 0; // added 9/2/98; default is false
|
||||
return 0;
|
||||
}
|
||||
|
||||
double vp() {
|
||||
return 1.0/Rho;
|
||||
}
|
||||
|
||||
//! Uses the lever rule to set state in the dome. Returns 1 if in dome,
|
||||
//! 0 if not, in which case state not set.
|
||||
int Lever(int itp, double sat, double val, propertyFlag::type ifunc);
|
||||
|
||||
//! Update saturated liquid and vapor densities and saturation pressure
|
||||
void update_sat();
|
||||
|
||||
private:
|
||||
|
|
@ -216,5 +267,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
* DESCRIPTION:
|
||||
* representation of substance Carbon Dioxide
|
||||
* values and functions are from
|
||||
* "Thermodynamic Properties in SI" bu W.C. Reynolds
|
||||
* "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
* AUTHOR: me@rebeccahhunt.com: GCEP, Stanford University
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CarbonDioxide.h"
|
||||
|
|
@ -33,9 +32,7 @@ static const double Tp=250; // [K] ??
|
|||
static const double Pc=7.38350E6; // [Pa] critical pressure
|
||||
static const double M=44.01; // [kg/kmol] molar density
|
||||
|
||||
/*
|
||||
* array Acarbdi is used by the function named Pp
|
||||
*/
|
||||
// array Acarbdi is used by the function named Pp
|
||||
static const double Acarbdi[]= {
|
||||
2.2488558E-1,
|
||||
-1.3717965E2,
|
||||
|
|
@ -58,10 +55,7 @@ static const double Acarbdi[]= {
|
|||
1.1898141E4
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* array F is used by the function named Psat
|
||||
*/
|
||||
// array F is used by the function named Psat
|
||||
static const double F[]= {
|
||||
-6.5412610,
|
||||
-2.7914636E-1,
|
||||
|
|
@ -73,10 +67,7 @@ static const double F[]= {
|
|||
-7.0510251E3
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* array D is used by the function ldens
|
||||
*/
|
||||
// array D is used by the function ldens
|
||||
static const double D[]= {
|
||||
4.6400009E2,
|
||||
6.7938129E2,
|
||||
|
|
@ -86,10 +77,7 @@ static const double D[]= {
|
|||
-1.3437098E3
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* array G is used by the function sp
|
||||
*/
|
||||
// array G is used by the function sp
|
||||
static const double G[]= {
|
||||
8.726361E3,
|
||||
1.840040E2,
|
||||
|
|
@ -99,14 +87,6 @@ static const double G[]= {
|
|||
-1.255290E-10,
|
||||
};
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
|
|
@ -139,12 +119,8 @@ double CarbonDioxide::C(int j,double Tinverse, double T2inverse, double T3invers
|
|||
}
|
||||
}
|
||||
|
||||
/* cprime
|
||||
* derivative of C(i)
|
||||
*/
|
||||
inline double CarbonDioxide::Cprime(int j, double T2inverse, double T3inverse, double T4inverse)
|
||||
{
|
||||
|
||||
switch (j) {
|
||||
case 0 :
|
||||
return Acarbdi[0] +
|
||||
|
|
@ -175,10 +151,6 @@ inline double CarbonDioxide::Cprime(int j, double T2inverse, double T3inverse, d
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
|
|
@ -202,14 +174,6 @@ inline double CarbonDioxide::I(int j, double ergho, double Gamma)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* 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) {
|
||||
|
|
@ -223,15 +187,8 @@ double CarbonDioxide::H(int i, double egrho)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
|
@ -247,7 +204,6 @@ double CarbonDioxide::up()
|
|||
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));
|
||||
|
|
@ -255,14 +211,8 @@ double CarbonDioxide::up()
|
|||
|
||||
sum += u0;
|
||||
return sum + m_energy_offset;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* entropy
|
||||
* see Reynolds eqn (16) section 2
|
||||
*/
|
||||
|
||||
double CarbonDioxide::sp()
|
||||
{
|
||||
//double Tinverse = 1.0/T;
|
||||
|
|
@ -290,12 +240,6 @@ double CarbonDioxide::sp()
|
|||
return sum + m_entropy_offset;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Equation P-3 in Reynolds
|
||||
* P - rho - T
|
||||
* returns P (pressure)
|
||||
*/
|
||||
double CarbonDioxide::Pp()
|
||||
{
|
||||
double Tinverse = pow(T,-1);
|
||||
|
|
@ -313,14 +257,8 @@ double CarbonDioxide::Pp()
|
|||
return P;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Equation S-2 in Reynolds
|
||||
* Pressure at Saturation
|
||||
*/
|
||||
double CarbonDioxide::Psat()
|
||||
{
|
||||
|
||||
double log, sum=0,P;
|
||||
if ((T < Tmn) || (T > Tc)) {
|
||||
throw TPX_Error("CarbonDixoide::Psat",
|
||||
|
|
@ -338,10 +276,6 @@ double CarbonDioxide::Psat()
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* Equation D2 in Reynolds
|
||||
* liquid density, of rho_f
|
||||
*/
|
||||
double CarbonDioxide::ldens()
|
||||
{
|
||||
double xx=1-(T/Tc), sum=0;
|
||||
|
|
@ -356,11 +290,9 @@ double CarbonDioxide::ldens()
|
|||
return sum;
|
||||
}
|
||||
|
||||
/*
|
||||
* the following functions allow users
|
||||
* to get the properties of CarbonDioxide
|
||||
* that are not dependent on the state
|
||||
*/
|
||||
// The following functions allow users to get the properties of CarbonDioxide
|
||||
// that are not dependent on the state
|
||||
|
||||
double CarbonDioxide::Tcrit()
|
||||
{
|
||||
return Tc;
|
||||
|
|
@ -395,6 +327,3 @@ double CarbonDioxide::MolWt()
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,19 +3,11 @@
|
|||
|
||||
#include "cantera/tpx/Sub.h"
|
||||
|
||||
|
||||
|
||||
/* FILE: CarbonDioxide.h
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
//! Pure species representation of carbon dioxide. Values and functions are
|
||||
//! from "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
class CarbonDioxide : public Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -35,21 +27,56 @@ public:
|
|||
char* name();
|
||||
char* formula();
|
||||
|
||||
//! Pressure. Equation P-3 in Reynolds. P(rho, T).
|
||||
double Pp();
|
||||
|
||||
/*!
|
||||
* 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 up();
|
||||
|
||||
//! entropy. See Reynolds eqn (16) section 2
|
||||
double sp();
|
||||
|
||||
//! Pressure at Saturation. Equation S-2 in Reynolds.
|
||||
double Psat();
|
||||
|
||||
private:
|
||||
//! Liquid density. Equation D2 in Reynolds.
|
||||
double ldens();
|
||||
|
||||
/*!
|
||||
* 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 C(int jm, double, double, double, double);
|
||||
|
||||
//! Derivative of C(i)
|
||||
double Cprime(int i, double, double, double);
|
||||
|
||||
/*!
|
||||
* I = integral from o-rho { 1/(rho^2) * H(i, rho) d rho }
|
||||
* ( see section 2 of Reynolds TPSI )
|
||||
*/
|
||||
double I(int i, double, double);
|
||||
|
||||
/*!
|
||||
* 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 H(int i, double egrho);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ! TPX_CARBONDIOXIDE_H
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ using namespace Cantera;
|
|||
namespace tpx
|
||||
{
|
||||
|
||||
/*
|
||||
* Heptane constants
|
||||
*/
|
||||
// Heptane constants
|
||||
static const double Tmn = 182.56; // [K] minimum temperature for which calculations are valid
|
||||
static const double Tmx = 1000.0; // [K] maximum temperature for which calculations are valid
|
||||
static const double Tc=537.68; // [K] critical temperature
|
||||
|
|
@ -33,9 +31,7 @@ static const double Tp=400; // [K] ??
|
|||
static const double Pc=2.6199E6; // [Pa] critical pressure
|
||||
static const double M=100.20; // [kg/kmol] molar density
|
||||
|
||||
/*
|
||||
* array Ahept is used by the function Pp
|
||||
*/
|
||||
// array Ahept is used by the function Pp
|
||||
static const double Ahept[]= {
|
||||
2.246032E-3,
|
||||
2.082990E2,
|
||||
|
|
@ -49,10 +45,7 @@ static const double Ahept[]= {
|
|||
5.291379E-9
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* array F is used by Psat
|
||||
*/
|
||||
// array F is used by Psat
|
||||
static const double F[]= {
|
||||
-7.2298764,
|
||||
3.8607475E-1,
|
||||
|
|
@ -64,10 +57,7 @@ static const double F[]= {
|
|||
3.1758992E2
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* array D is used by the function ldens
|
||||
*/
|
||||
// array D is used by the function ldens
|
||||
static const double D[]= {
|
||||
1.9760405E2,
|
||||
8.9451237E2,
|
||||
|
|
@ -77,10 +67,7 @@ static const double D[]= {
|
|||
9.7088329E2
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* array G is used by the function sp
|
||||
*/
|
||||
// array G is used by the function sp
|
||||
static const double G[]= {
|
||||
1.1925213E5,
|
||||
-7.7231363E2,
|
||||
|
|
@ -90,14 +77,6 @@ static const double G[]= {
|
|||
0.0
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* C returns a multiplier in each term of the sum
|
||||
* in P-2, 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...
|
||||
*/
|
||||
double Heptane::C(int j,double Tinverse, double T2inverse, double T3inverse, double T4inverse)
|
||||
{
|
||||
switch (j) {
|
||||
|
|
@ -120,10 +99,6 @@ double Heptane::C(int j,double Tinverse, double T2inverse, double T3inverse, dou
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* cprime
|
||||
* derivative of C(i)
|
||||
*/
|
||||
inline double Heptane::Cprime(int j, double T2inverse, double T3inverse, double T4inverse)
|
||||
{
|
||||
switch (j) {
|
||||
|
|
@ -144,11 +119,6 @@ inline double Heptane::Cprime(int j, double T2inverse, double T3inverse, double
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* I = integral from o-rho { 1/(rho^2) * H(i, rho) d rho }
|
||||
* ( see section 2 of Reynolds TPSI )
|
||||
*/
|
||||
inline double Heptane::I(int j, double ergho, double Gamma)
|
||||
{
|
||||
switch (j) {
|
||||
|
|
@ -165,14 +135,6 @@ inline double Heptane::I(int j, double ergho, double Gamma)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* H returns a multiplier in each term of the sum
|
||||
* in P-2
|
||||
* 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 Heptane::H(int i, double egrho)
|
||||
{
|
||||
if (i < 2) {
|
||||
|
|
@ -186,13 +148,6 @@ double Heptane::H(int i, double egrho)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 Heptane::up()
|
||||
{
|
||||
double Tinverse = 1.0/T;
|
||||
|
|
@ -218,11 +173,6 @@ double Heptane::up()
|
|||
return sum + m_energy_offset;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* entropy
|
||||
* see Reynolds eqn (16) section 2
|
||||
*/
|
||||
double Heptane::sp()
|
||||
{
|
||||
double T2inverse = pow(T, -2);
|
||||
|
|
@ -248,12 +198,6 @@ double Heptane::sp()
|
|||
return sum + m_entropy_offset;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Equation P-2 in Reynolds
|
||||
* P - rho - T
|
||||
* returns P (pressure)
|
||||
*/
|
||||
double Heptane::Pp()
|
||||
{
|
||||
double Tinverse = pow(T,-1);
|
||||
|
|
@ -271,11 +215,6 @@ double Heptane::Pp()
|
|||
return P;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Equation S-2 in Reynolds
|
||||
* Pressure at Saturation
|
||||
*/
|
||||
double Heptane::Psat()
|
||||
{
|
||||
double log, sum=0;
|
||||
|
|
@ -291,11 +230,6 @@ double Heptane::Psat()
|
|||
return exp(log)*Pc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Equation D2 in Reynolds
|
||||
* liquid density, of rho_f
|
||||
*/
|
||||
double Heptane::ldens()
|
||||
{
|
||||
double xx=1-(T/Tc), sum=0;
|
||||
|
|
@ -310,12 +244,9 @@ double Heptane::ldens()
|
|||
return sum;
|
||||
}
|
||||
|
||||
// The following functions allow users to get the properties of Heptane that
|
||||
// are not dependent on the state
|
||||
|
||||
/*
|
||||
* the following functions allow users
|
||||
* to get the properties of Heptane
|
||||
* that are not dependent on the state
|
||||
*/
|
||||
double Heptane::Tcrit()
|
||||
{
|
||||
return Tc;
|
||||
|
|
|
|||
|
|
@ -3,20 +3,10 @@
|
|||
|
||||
#include "cantera/tpx/Sub.h"
|
||||
|
||||
|
||||
|
||||
/* FILE: Heptane.h
|
||||
* DESCRIPTION:
|
||||
* representation of substance Heptane
|
||||
* values and functions are from
|
||||
* "Thermodynamic Properties in SI" bu W.C. Reynolds
|
||||
* AUTHOR: me@rebeccahhunt.com: GCEP, Stanford University
|
||||
* AUTHOR: jrh@stanford.edu: GCEP, Stanford University
|
||||
*
|
||||
*/
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
//! Pure species representation of heptane. Values and functions are
|
||||
//! from "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
class Heptane : public Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -35,21 +25,55 @@ public:
|
|||
char* name();
|
||||
char* formula();
|
||||
|
||||
//! Pressure. Equation P-2 in Reynolds.
|
||||
double Pp();
|
||||
|
||||
/*!
|
||||
* 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 up();
|
||||
|
||||
//! Entropy. See Reynolds eqn (16) section 2
|
||||
double sp();
|
||||
|
||||
//! Pressure at Saturation. Equation S-2 in Reynolds.
|
||||
double Psat();
|
||||
|
||||
private:
|
||||
//! liquid density. Equation D2 in Reynolds.
|
||||
double ldens();
|
||||
|
||||
/*!
|
||||
* C returns a multiplier in each term of the sum
|
||||
* in P-2, 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...
|
||||
*/
|
||||
double C(int jm, double, double, double, double);
|
||||
|
||||
//! derivative of C(i)
|
||||
double Cprime(int i, double, double, double);
|
||||
|
||||
/*!
|
||||
* I = integral from o-rho { 1/(rho^2) * H(i, rho) d rho }
|
||||
* ( see section 2 of Reynolds TPSI )
|
||||
*/
|
||||
double I(int i, double, double);
|
||||
|
||||
/*!
|
||||
* H returns a multiplier in each term of the sum in P-2.
|
||||
* 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 H(int i, double egrho);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ! TPX_HEPTANE_H
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// Hydrogen
|
||||
|
||||
#include "Hydrogen.h"
|
||||
#include <math.h>
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
|
@ -8,7 +6,6 @@ using namespace Cantera;
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
static const double
|
||||
M = 2.0159,
|
||||
Tmn = 13.8,
|
||||
|
|
@ -54,7 +51,6 @@ static const double Ghydro[]= {
|
|||
-3.9144179e2, 5.8277696e2, 6.5409163e2, -1.8728847e2
|
||||
};
|
||||
|
||||
|
||||
double hydrogen::C(int i, double rt, double rt2)
|
||||
{
|
||||
switch (i) {
|
||||
|
|
@ -220,7 +216,6 @@ double hydrogen::Pp()
|
|||
return P;
|
||||
}
|
||||
|
||||
//equation D4
|
||||
double hydrogen::ldens()
|
||||
{
|
||||
if ((T < Tmn) || (T > Tc)) {
|
||||
|
|
@ -236,8 +231,6 @@ double hydrogen::ldens()
|
|||
return sum+Roc+Dhydro[0]*pow(x,alpha1);
|
||||
}
|
||||
|
||||
|
||||
//equation s3
|
||||
double hydrogen::Psat()
|
||||
{
|
||||
double x = (1.0 - Tt/T)/(1.0 - Tt/Tc);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
namespace tpx
|
||||
{
|
||||
|
||||
//! Pure species representation of hydrogen. Values and functions are
|
||||
//! from "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
class hydrogen : public Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -27,9 +29,12 @@ public:
|
|||
double Pp();
|
||||
double up();
|
||||
double sp();
|
||||
|
||||
//! Saturation pressure. Equation s3 in Reynolds TPSI.
|
||||
double Psat();
|
||||
|
||||
private:
|
||||
//! Liquid density. Equation D4 in Reynolds TPSI.
|
||||
double ldens();
|
||||
double C(int i, double rt, double rt2);
|
||||
double Cprime(int i, double rt, double rt2, double rt3);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// Methane
|
||||
|
||||
#include "Methane.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
#include <math.h>
|
||||
|
|
@ -10,7 +8,6 @@ using namespace Cantera;
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
static const double
|
||||
M = 16.04996,
|
||||
Tmn = 90.68,
|
||||
|
|
@ -51,8 +48,6 @@ static const double Fmeth[]=
|
|||
static const double Gmeth[]=
|
||||
{ 1.34740610e3, 1.35512060e2, -2.93910458e1, 2.12774600, 2.44656600e3 };
|
||||
|
||||
// double rt, rt2, rt3, egrho;
|
||||
|
||||
double methane::C(int i, double rt, double rt2)
|
||||
{
|
||||
switch (i) {
|
||||
|
|
@ -190,7 +185,6 @@ double methane::Pp()
|
|||
return P;
|
||||
}
|
||||
|
||||
//equation s3
|
||||
double methane::Psat()
|
||||
{
|
||||
double x = (1.0 - Tt/T)/(1.0 - Tt/Tc);
|
||||
|
|
@ -204,8 +198,6 @@ double methane::Psat()
|
|||
return exp(result)*Pt;
|
||||
}
|
||||
|
||||
|
||||
//equation D3
|
||||
double methane::ldens()
|
||||
{
|
||||
double result;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
namespace tpx
|
||||
{
|
||||
|
||||
//! Pure species representation of methane. Values and functions are
|
||||
//! from "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
class methane : public Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -27,10 +29,14 @@ public:
|
|||
double Pp();
|
||||
double up();
|
||||
double sp();
|
||||
|
||||
//! Saturation pressure. Equation S3 from Reynolds TPSI.
|
||||
double Psat();
|
||||
|
||||
private:
|
||||
//! Liquid density. Equation D3 from Reynolds TPSI.
|
||||
double ldens();
|
||||
|
||||
double C(int i, double rt, double rt2);
|
||||
double Cprime(int i, double rt, double rt2, double rt3);
|
||||
double I(int i, double egrho);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// Nitrogen
|
||||
|
||||
#include "Nitrogen.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
#include <math.h>
|
||||
|
|
@ -9,8 +7,6 @@ using namespace Cantera;
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
|
||||
static const double M = 28.01348,
|
||||
Tmn = 63.15,
|
||||
Tmx = 2000.0,
|
||||
|
|
@ -25,7 +21,6 @@ static const double M = 28.01348,
|
|||
u0 = 150877.551,
|
||||
s0 = 214.9352518;
|
||||
|
||||
|
||||
static const double Ann[] = {
|
||||
1.75889959256970e-1, 1.38197604384933e1, -3.14918412133921e2,
|
||||
4.40300150239380e3, -5.45358971644916e5, 4.84413320182919e-4,
|
||||
|
|
@ -59,8 +54,6 @@ static const double Gnn[] = {
|
|||
5.18347156760489e-6, -1.05922170493616e-9, 2.98389393363817e2
|
||||
};
|
||||
|
||||
|
||||
//equation P4
|
||||
double nitrogen::C(int i, double rt, double rt2)
|
||||
{
|
||||
switch (i) {
|
||||
|
|
@ -171,7 +164,6 @@ double nitrogen::up()
|
|||
return sum;
|
||||
}
|
||||
|
||||
|
||||
double nitrogen::sp()
|
||||
{
|
||||
double rt = 1.0/T;
|
||||
|
|
@ -205,7 +197,6 @@ double nitrogen::Pp()
|
|||
return P;
|
||||
}
|
||||
|
||||
//equation s4
|
||||
double nitrogen::Psat()
|
||||
{
|
||||
double lnp;
|
||||
|
|
@ -225,7 +216,6 @@ double nitrogen::Psat()
|
|||
return exp(lnp);
|
||||
}
|
||||
|
||||
//equation D2
|
||||
double nitrogen::ldens()
|
||||
{
|
||||
double xx=1-T/Tc, sum=0;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
namespace tpx
|
||||
{
|
||||
|
||||
//! Pure species representation of nitrogen. Values and functions are
|
||||
//! from "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
class nitrogen : public Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -28,11 +30,15 @@ public:
|
|||
double Pp();
|
||||
double up();
|
||||
double sp();
|
||||
|
||||
//! Saturation pressure. Equation S4 from Reynolds TPSI.
|
||||
double Psat();
|
||||
|
||||
private:
|
||||
|
||||
//! Liquid density. Equation D2 from Reynolds TPSI.
|
||||
double ldens();
|
||||
|
||||
//! Equation P4 from Reynolds TPSI.
|
||||
double C(int i, double rt, double rt2);
|
||||
double Cprime(int i, double rt, double rt2, double rt3);
|
||||
double I(int i, double egrho);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// Oxygen
|
||||
|
||||
#include "Oxygen.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
#include <math.h>
|
||||
|
|
@ -8,7 +6,6 @@ using namespace Cantera;
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
static const double
|
||||
M = 31.9994,
|
||||
Tmn = 54.34,
|
||||
|
|
@ -53,8 +50,6 @@ static const double Goxy[] = {
|
|||
3.4981070244228e-6, 4.21065222886885e-9, 2.67997030050139e2
|
||||
};
|
||||
|
||||
//equation P4
|
||||
|
||||
double oxygen::C(int i, double rt, double rt2)
|
||||
{
|
||||
switch (i) {
|
||||
|
|
@ -195,7 +190,6 @@ double oxygen::Pp()
|
|||
return P;
|
||||
}
|
||||
|
||||
//equation s4
|
||||
double oxygen::Psat()
|
||||
{
|
||||
double lnp;
|
||||
|
|
@ -215,7 +209,6 @@ double oxygen::Psat()
|
|||
return exp(lnp);
|
||||
}
|
||||
|
||||
//equation D2
|
||||
double oxygen::ldens()
|
||||
{
|
||||
double xx=1-T/Tc, sum=0;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
//! Pure species representation of oxygen. Values and functions are
|
||||
//! from "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
class oxygen : public Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -27,10 +28,15 @@ public:
|
|||
double Pp();
|
||||
double up();
|
||||
double sp();
|
||||
|
||||
//! Saturation pressure. Equation S4 from Reynolds TPSI.
|
||||
double Psat();
|
||||
|
||||
private:
|
||||
//! Liquid density. Equation D2 from Reynolds TPSI.
|
||||
double ldens();
|
||||
|
||||
//! Equation P4 from Reynolds TPSI.
|
||||
double C(int i, double rt, double rt2);
|
||||
double Cprime(int i, double rt, double rt2, double rt3);
|
||||
double I(int i, double egrho);
|
||||
|
|
@ -40,4 +46,3 @@ private:
|
|||
|
||||
}
|
||||
#endif // ! OXYGEN_H
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
// Lee-Kesler equation of state
|
||||
|
||||
#include "RedlichKwong.h"
|
||||
#include <math.h>
|
||||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
|
||||
//--------------------------- member functions ------------------
|
||||
|
||||
double RedlichKwong::up()
|
||||
{
|
||||
return -Pp()/Rho + hresid() + m_energy_offset;
|
||||
|
|
@ -45,7 +39,6 @@ double RedlichKwong::z()
|
|||
return Pp()*m_mw/(Rho*8314.3*T);
|
||||
}
|
||||
|
||||
|
||||
double RedlichKwong::Pp()
|
||||
{
|
||||
double R = 8314.3;
|
||||
|
|
@ -77,5 +70,4 @@ double RedlichKwong::ldens()
|
|||
return m_mw/vnew;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
const double GasConstant = 8314.3;
|
||||
|
||||
class RedlichKwong : public Substance
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ using namespace Cantera;
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
//-------------- Public Member Functions --------------
|
||||
|
||||
Substance::Substance() :
|
||||
T(Undef),
|
||||
Rho(Undef),
|
||||
|
|
@ -28,9 +26,6 @@ Substance::Substance() :
|
|||
{
|
||||
}
|
||||
|
||||
/// Pressure [Pa]. If two phases are present, return the
|
||||
/// saturation pressure; otherwise return the pressure
|
||||
/// computed directly from the underlying eos.
|
||||
double Substance::P()
|
||||
{
|
||||
return TwoPhase() ? Ps() : Pp();
|
||||
|
|
@ -38,8 +33,6 @@ double Substance::P()
|
|||
|
||||
const double DeltaT = 0.000001;
|
||||
|
||||
/// The derivative of the saturation pressure
|
||||
/// with respect to temperature.
|
||||
double Substance::dPsdT()
|
||||
{
|
||||
double tsave = T;
|
||||
|
|
@ -50,7 +43,6 @@ double Substance::dPsdT()
|
|||
return dpdt;
|
||||
}
|
||||
|
||||
/// true if a liquid/vapor mixture, false otherwise
|
||||
int Substance::TwoPhase()
|
||||
{
|
||||
if (T >= Tcrit()) {
|
||||
|
|
@ -60,9 +52,6 @@ int Substance::TwoPhase()
|
|||
return ((Rho < Rhf) && (Rho > Rhv) ? 1 : 0);
|
||||
}
|
||||
|
||||
/// Vapor fraction.
|
||||
/// If T >= Tcrit, 0 is returned for v < Vcrit, and 1 is
|
||||
/// returned if v > Vcrit.
|
||||
double Substance::x()
|
||||
{
|
||||
if (T >= Tcrit()) {
|
||||
|
|
@ -81,7 +70,6 @@ double Substance::x()
|
|||
}
|
||||
}
|
||||
|
||||
/// Saturation temperature at pressure p.
|
||||
double Substance::Tsat(double p)
|
||||
{
|
||||
if (p <= 0.0 || p > Pcrit()) {
|
||||
|
|
@ -123,9 +111,7 @@ double Substance::Tsat(double p)
|
|||
return tsat;
|
||||
}
|
||||
|
||||
|
||||
// absolute tolerances
|
||||
|
||||
static const double TolAbsH = 0.0001; // J/kg
|
||||
static const double TolAbsU = 0.0001;
|
||||
static const double TolAbsS = 1.e-7;
|
||||
|
|
@ -304,7 +290,6 @@ double Substance::Ps()
|
|||
return Pst;
|
||||
}
|
||||
|
||||
// update saturated liquid and vapor densities and saturation pressure
|
||||
void Substance::update_sat()
|
||||
{
|
||||
if ((T != Tslast) && (T < Tcrit())) {
|
||||
|
|
@ -397,10 +382,6 @@ double Substance::vprop(propertyFlag::type ijob)
|
|||
|
||||
int Substance::Lever(int itp, double sat, double val, propertyFlag::type ifunc)
|
||||
{
|
||||
/*
|
||||
* uses lever rule to set state in the dome. Returns 1 if in dome,
|
||||
* 0 if not, in which case state not set.
|
||||
*/
|
||||
double psat;
|
||||
double Tsave = T;
|
||||
double Rhosave = Rho;
|
||||
|
|
@ -442,7 +423,6 @@ int Substance::Lever(int itp, double sat, double val, propertyFlag::type ifunc)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Substance::set_xy(propertyFlag::type ifx, propertyFlag::type ify,
|
||||
double X, double Y,
|
||||
double atx, double aty,
|
||||
|
|
@ -544,7 +524,6 @@ void Substance::set_xy(propertyFlag::type ifx, propertyFlag::type ify,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
double Substance::prop(propertyFlag::type ijob)
|
||||
{
|
||||
if (ijob == propertyFlag::P) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// water
|
||||
|
||||
#include "Water.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
#include <math.h>
|
||||
|
|
@ -9,7 +7,6 @@ using namespace Cantera;
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
static const double Tmn=273.16;
|
||||
static const double Tmx=1600.0;
|
||||
static const double M=18.016;
|
||||
|
|
@ -235,5 +232,3 @@ double water::MolWt()
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
namespace tpx
|
||||
{
|
||||
|
||||
//! Pure species representation of water. Values and functions are from
|
||||
//! "Thermodynamic Properties in SI" by W.C. Reynolds
|
||||
class water : public Substance
|
||||
{
|
||||
public:
|
||||
|
|
@ -40,4 +41,3 @@ private:
|
|||
|
||||
}
|
||||
#endif // ! WATER_H
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue