31 TPX_Error(std::string p, std::string e) {
35 virtual ~TPX_Error() {}
36 static std::string ErrorMessage;
37 static std::string ErrorProcedure;
41 const double OneAtm = 1.01325e5;
42 const double Liquid = 0.0;
43 const double Vapor = 1.0;
45 const int TV = 12, HP = 34, SP = 54, PV = 42, TP = 14, UV = 62,
46 ST = 51, SV = 52, UP = 64, VH = 23, TH = 13, SH = 53,
49 const int VT = -12, PH = -34, PS = -54, VP = -42, PT = -14, VU = -62,
50 TS = -51, VS = -52, PU = -64, HV = -23, HT = -13, HS = -53,
53 const int NoConverge = -900;
54 const int GenError = -901;
55 const int InvalidInput = -902;
56 const int TempError = -800;
57 const int PresError = -801;
58 const int CKError = -802;
61 const int Pgiven = 0, Tgiven = 1;
75 const int EvalMW = 13;
76 const int EvalEA = 14;
77 const int EvalCdot = 15;
78 const int EvalDdot = 16;
79 const int EvalWdot = 17;
80 const int EvalTchem = 18;
81 const int EvalRgas = 19;
83 const double Undef = 999.1234;
85 std::string errorMsg(
int flag);
92 virtual ~Substance() {}
94 void setStdState(
double h0 = 0.0,
double s0 = 0.0,
95 double t0 = 298.15,
double p0 = 1.01325e5) {
99 double hoff = h0 - hh;
100 double soff = s0 - ss;
101 m_entropy_offset += soff;
102 m_energy_offset += hoff;
107 virtual double MolWt()=0;
108 virtual double Tcrit()=0;
109 virtual double Pcrit()=0;
110 virtual double Vcrit()=0;
111 virtual double Tmin()=0;
112 virtual double Tmax()=0;
113 virtual char* name() = 0;
114 virtual char* formula() = 0;
141 virtual double cv() {
142 double Tsave = T, dt = 1.e-4*T;
148 return T*(s2 - s1)/(2.0*dt);
151 virtual double cp() {
152 double Tsave = T, dt = 1.e-4*T;
154 Set(TP, Tsave - dt, p0);
156 Set(TP, Tsave + dt, p0);
159 return T*(s2 - s1)/(2.0*dt);
162 virtual double thermalExpansionCoeff() {
163 double Tsave = T, dt = 1.e-4*T;
165 Set(TP, Tsave - dt, p0);
167 Set(TP, Tsave + dt, p0);
170 return (v2 - v1)/((v2 + v1)*dt);
173 virtual double isothermalCompressibility() {
174 double Psave = P(), dp = 1.e-4*Psave;
175 Set(TP, T, Psave - dp);
177 Set(TP, T, Psave + dp);
180 return -(v2 - v1)/((v2 + v1)*dp);
187 virtual double dPsdT();
188 double Tsat(
double p);
191 virtual double Pp()=0;
193 return up() + Pp()/Rho;
196 return hp() - T*sp();
199 double prop(
int ijob);
200 void set_TPp(
double t0,
double p0);
205 void Set(
int XY,
double x0,
double y0);
206 void Set_meta(
double phase,
double pp);
216 double Tslast, Rhf, Rhv;
219 double m_energy_offset;
220 double m_entropy_offset;
222 std::string m_formula;
227 virtual double ldens()=0;
228 virtual double Psat()=0;
229 virtual double up()=0;
230 virtual double sp()=0;
231 virtual int ideal() {
237 int Lever(
int itp,
double sat,
double val,
int ifunc);
240 void set_Err(
int ErrFlag) {
252 void set_Rho(
double r0);
253 void set_T(
double t0);
254 void set_v(
double v0);
255 void BracketSlope(
double p);
256 double lprop(
int ijob);
257 double vprop(
int ijob);
258 void set_xy(
int if1,
int if2,
double X,
double Y,
259 double atx,
double aty,
double rtx,
double rty);
265 double v_here, P_here;
268 void Error(
char* message,
int flag,
double val=
Undef);
269 void Mess(
char* message);