14 TPX_Error(
const std::string& p,
const std::string& e) :
18 namespace PropertyPair
21 TV = 12, HP = 34, SP = 54, PV = 42, TP = 14, UV = 62, ST = 51,
22 SV = 52, UP = 64, VH = 23, TH = 13, SH = 53, PX = 47, TX = 17,
23 VT = -12, PH = -34, PS = -54, VP = -42, PT = -14, VU = -62, TS = -51,
24 VS = -52, PU = -64, HV = -23, HT = -13, HS = -53, XP = -47, XT = -17
28 const int Pgiven = 0, Tgiven = 1;
30 namespace propertyFlag
32 enum type { H, S, U, V, P, T };
35 const double Undef = 999.1234;
47 void setStdState(
double h0 = 0.0,
double s0 = 0.0,
48 double t0 = 298.15,
double p0 = 1.01325e5) {
49 Set(PropertyPair::TP, t0, p0);
52 double hoff = h0 - hh;
53 double soff = s0 - ss;
54 m_entropy_offset += soff;
55 m_energy_offset += hoff;
62 virtual double MolWt()=0;
65 virtual double Tcrit()=0;
68 virtual double Pcrit()=0;
71 virtual double Vcrit()=0;
74 virtual double Tmin()=0;
77 virtual double Tmax()=0;
80 virtual char*
name() = 0;
101 return prop(propertyFlag::V);
106 return prop(propertyFlag::U);
111 return prop(propertyFlag::H);
116 return prop(propertyFlag::S);
130 virtual double cv() {
131 double Tsave = T, dt = 1.e-4*T;
132 double T1 = std::max(
Tmin(), Tsave - dt);
133 double T2 = std::min(
Tmax(), Tsave + dt);
139 return T*(s2 - s1)/(T2-T1);
143 virtual double cp() {
144 double Tsave = T, dt = 1.e-4*T;
145 double T1 = std::max(
Tmin(), Tsave - dt);
146 double T2 = std::min(
Tmax(), Tsave + dt);
148 Set(PropertyPair::TP, T1, p0);
150 Set(PropertyPair::TP, T2, p0);
152 Set(PropertyPair::TP, Tsave, p0);
153 return T*(s2 - s1)/(T2-T1);
156 virtual double thermalExpansionCoeff() {
157 double Tsave = T, dt = 1.e-4*T;
158 double T1 = std::max(
Tmin(), Tsave - dt);
159 double T2 = std::min(
Tmax(), Tsave + dt);
161 Set(PropertyPair::TP, T1, p0);
163 Set(PropertyPair::TP, T2, p0);
165 Set(PropertyPair::TP, Tsave, p0);
166 return (v2 - v1)/((v2 + v1)*(T2-T1));
169 virtual double isothermalCompressibility() {
170 double Psave =
P(), dp = 1.e-4*Psave;
171 Set(PropertyPair::TP, T, Psave - dp);
173 Set(PropertyPair::TP, T, Psave + dp);
175 Set(PropertyPair::TP, T, Psave);
176 return -(v2 - v1)/((v2 + v1)*dp);
186 virtual double dPsdT();
189 double Tsat(
double p);
199 virtual double Pp()=0;
203 return up() + Pp()/Rho;
208 return hp() - T*
sp();
211 double prop(propertyFlag::type ijob);
214 void set_TPp(
double t0,
double p0);
219 void Set(PropertyPair::type XY,
double x0,
double y0);
223 double Tslast, Rhf, Rhv;
225 double m_energy_offset;
226 double m_entropy_offset;
228 std::string m_formula;
230 virtual double ldens()=0;
233 virtual double Psat()=0;
236 virtual double up()=0;
239 virtual double sp()=0;
241 virtual int ideal() {
251 int Lever(
int itp,
double sat,
double val, propertyFlag::type ifunc);
257 void set_Rho(
double r0);
258 void set_T(
double t0);
259 void set_v(
double v0);
260 void BracketSlope(
double p);
261 double vprop(propertyFlag::type ijob);
262 void set_xy(propertyFlag::type if1, propertyFlag::type if2,
264 double atx,
double aty,
double rtx,
double rty);
270 double v_here, P_here;
virtual double MolWt()=0
Molecular weight [kg/kmol].
virtual double Vcrit()=0
Critical specific volume [m^3/kg].
virtual double dPsdT()
The derivative of the saturation pressure with respect to temperature.
virtual double sp()=0
Entropy of a single-phase state.
double x()
Vapor mass fraction.
int TwoPhase()
Returns 1 if the current state is a liquid/vapor mixture, 0 otherwise.
double Tsat(double p)
Saturation temperature at pressure p.
double gp()
Gibbs function of a single-phase state.
virtual double Tmin()=0
Minimum temperature for which the equation of state is valid.
double s()
Entropy [J/kg/K].
double v()
Specific volume [m^3/kg].
virtual double cv()
Specific heat at constant volume [J/kg/K].
double f()
Helmholtz function [J/kg].
const doublereal Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
void update_sat()
Update saturated liquid and vapor densities and saturation pressure.
void set_TPp(double t0, double p0)
set T and P
virtual double up()=0
Internal energy of a single-phase state.
virtual char * name()=0
Name of the substance.
double Temp()
Temperature [K].
CanteraError(const std::string &procedure, const std::string &msg)
Normal Constructor for the CanteraError base class.
Base class for exceptions thrown by Cantera classes.
double hp()
Enthaply of a single-phase state.
double g()
Gibbs function [J/kg].
virtual double Tmax()=0
Maximum temperature for which the equation of state is valid.
virtual char * formula()=0
Chemical formula for the substance.
virtual double Tcrit()=0
Critical temperature [K].
virtual double cp()
Specific heat at constant pressure [J/kg/K].
virtual double Psat()=0
Saturation pressure, Pa.
double h()
Enthalpy [J/kg].
double u()
Internal energy [J/kg].
void Set(PropertyPair::type XY, double x0, double y0)
Function to set or change the state for a property pair XY where x0 is the value of first property an...
virtual double Pcrit()=0
Critical pressure [Pa].
int Lever(int itp, double sat, double val, propertyFlag::type ifunc)
Uses the lever rule to set state in the dome.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...