moved most method definitions to PureFluidPhase.cpp
This commit is contained in:
parent
58625be0d9
commit
0d75e52c01
1 changed files with 44 additions and 113 deletions
|
|
@ -30,95 +30,21 @@ namespace Cantera {
|
|||
public:
|
||||
|
||||
PureFluid() : ThermoPhase(), m_sub(0), m_subflag(0),
|
||||
m_mw(-1.0), m_verbose(true) {}
|
||||
m_mw(-1.0), m_verbose(false) {}
|
||||
|
||||
virtual ~PureFluid() { delete m_sub; }
|
||||
|
||||
|
||||
virtual int eosType() const { return cPureFluid; }
|
||||
|
||||
/**
|
||||
* Mixture molar enthalpy. Units: J/mol.
|
||||
*/
|
||||
virtual doublereal enthalpy_mole() const {
|
||||
setTPXState();
|
||||
doublereal h = m_sub->h() * m_mw;
|
||||
check(h);
|
||||
return h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixture molar internal energy. Units: J/mol.
|
||||
*/
|
||||
virtual doublereal intEnergy_mole() const {
|
||||
setTPXState();
|
||||
doublereal u = m_sub->u() * m_mw;
|
||||
check(u);
|
||||
return u;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixture molar entropy. Units: J/mol/K.
|
||||
*/
|
||||
virtual doublereal entropy_mole() const {
|
||||
setTPXState();
|
||||
doublereal s = m_sub->s() * m_mw;
|
||||
check(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixture molar Gibbs function. Units: J/mol.
|
||||
*/
|
||||
virtual doublereal gibbs_mole() const {
|
||||
setTPXState();
|
||||
doublereal g = m_sub->g() * m_mw;
|
||||
check(g);
|
||||
return g;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixture molar heat capacity at constant pressure.
|
||||
* Units: J/mol/K.
|
||||
*/
|
||||
virtual doublereal cp_mole() const {
|
||||
setTPXState();
|
||||
doublereal cp = m_sub->cp() * m_mw;
|
||||
check(cp);
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixture molar heat capacity at constant volume.
|
||||
* Units: J/mol/K.
|
||||
*/
|
||||
virtual doublereal cv_mole() const {
|
||||
setTPXState();
|
||||
doublereal cv = m_sub->cv() * m_mw;
|
||||
check(cv);
|
||||
return cv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pressure. Units: Pa
|
||||
*/
|
||||
virtual doublereal pressure() const {
|
||||
setTPXState();
|
||||
doublereal p = m_sub->P();
|
||||
check(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pressure, holding temperature and composition
|
||||
* fixed.
|
||||
*/
|
||||
virtual void setPressure(doublereal p) {
|
||||
m_sub->Set(tpx::TP, temperature(), p);
|
||||
setDensity(1.0/m_sub->v());
|
||||
check();
|
||||
}
|
||||
virtual doublereal enthalpy_mole() const;
|
||||
virtual doublereal intEnergy_mole() const;
|
||||
virtual doublereal entropy_mole() const;
|
||||
virtual doublereal gibbs_mole() const;
|
||||
virtual doublereal cp_mole() const;
|
||||
virtual doublereal cv_mole() const;
|
||||
virtual doublereal pressure() const;
|
||||
virtual void setPressure(doublereal p);
|
||||
|
||||
virtual void getChemPotentials(doublereal* mu) const {
|
||||
mu[0] = gibbs_mole();
|
||||
|
|
@ -146,53 +72,64 @@ namespace Cantera {
|
|||
|
||||
/// saturation temperature
|
||||
virtual doublereal satTemperature(doublereal p) const {
|
||||
doublereal ts = m_sub->Tsat(p);
|
||||
check(ts);
|
||||
return ts;
|
||||
try {
|
||||
doublereal ts = m_sub->Tsat(p);
|
||||
return ts;
|
||||
}
|
||||
catch(tpx::TPX_Error) {
|
||||
reportTPXError();
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void setState_HP(doublereal h, doublereal p,
|
||||
doublereal tol = 1.e-8) {
|
||||
m_sub->Set(tpx::HP, h, p);
|
||||
Set(tpx::HP, h, p);
|
||||
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
|
||||
check();
|
||||
}
|
||||
|
||||
virtual void setState_UV(doublereal u, doublereal v,
|
||||
doublereal tol = 1.e-8) {
|
||||
m_sub->Set(tpx::UV, u, v);
|
||||
Set(tpx::UV, u, v);
|
||||
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
|
||||
check();
|
||||
}
|
||||
|
||||
virtual void setState_SV(doublereal s, doublereal v,
|
||||
doublereal tol = 1.e-8) {
|
||||
m_sub->Set(tpx::SV, s, v);
|
||||
Set(tpx::SV, s, v);
|
||||
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
|
||||
check();
|
||||
}
|
||||
|
||||
virtual void setState_SP(doublereal s, doublereal p,
|
||||
doublereal tol = 1.e-8) {
|
||||
m_sub->Set(tpx::SP, s, p);
|
||||
Set(tpx::SP, s, p);
|
||||
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
|
||||
check();
|
||||
}
|
||||
|
||||
/// saturation pressure
|
||||
virtual doublereal satPressure(doublereal t) const {
|
||||
doublereal tsv = m_sub->Temp();
|
||||
//doublereal tsv = m_sub->Temp();
|
||||
doublereal vsv = m_sub->v();
|
||||
if (t < 0.0)
|
||||
m_sub->Set(tpx::TP, temperature(), 0.5*m_sub->Pcrit());
|
||||
else
|
||||
m_sub->Set(tpx::TP, t, 0.5*m_sub->Pcrit());
|
||||
|
||||
doublereal ps = m_sub->Ps();
|
||||
m_sub->Set(tpx::TV,tsv,vsv);
|
||||
check(ps);
|
||||
return ps;
|
||||
//if (t < 0.0)
|
||||
// Set(tpx::TP, temperature(), 0.5*m_sub->Pcrit());
|
||||
//else
|
||||
// Set(tpx::TP, t, 0.5*m_sub->Pcrit());
|
||||
try {
|
||||
Set(tpx::TV,t,vsv);
|
||||
doublereal ps = m_sub->Ps();
|
||||
//Set(tpx::TV,tsv,vsv);
|
||||
//check(ps);
|
||||
return ps;
|
||||
}
|
||||
catch(tpx::TPX_Error) {
|
||||
reportTPXError();
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
virtual doublereal vaporFraction() const {
|
||||
setTPXState();
|
||||
|
|
@ -204,14 +141,14 @@ namespace Cantera {
|
|||
virtual void setState_Tsat(doublereal t, doublereal x) {
|
||||
setTemperature(t);
|
||||
setTPXState();
|
||||
m_sub->Set(tpx::TX, t, x);
|
||||
Set(tpx::TX, t, x);
|
||||
setDensity(1.0/m_sub->v());
|
||||
check();
|
||||
}
|
||||
|
||||
virtual void setState_Psat(doublereal p, doublereal x) {
|
||||
setTPXState();
|
||||
m_sub->Set(tpx::PX, p, x);
|
||||
Set(tpx::PX, p, x);
|
||||
setTemperature(m_sub->Temp());
|
||||
setDensity(1.0/m_sub->v());
|
||||
check();
|
||||
|
|
@ -222,17 +159,11 @@ namespace Cantera {
|
|||
|
||||
protected:
|
||||
|
||||
void setTPXState() const {
|
||||
m_sub->Set(tpx::TV, temperature(), 1.0/density());
|
||||
}
|
||||
|
||||
void check(doublereal v = 0.0) const {
|
||||
if (m_sub->Error() || v == tpx::Undef) {
|
||||
throw CanteraError("PureFluidPhase",string(tpx::errorMsg(
|
||||
m_sub->Error())));
|
||||
}
|
||||
}
|
||||
|
||||
void Set(int n, double x, double y) const;
|
||||
void setTPXState() const;
|
||||
void check(doublereal v = 0.0) const;
|
||||
void reportTPXError() const;
|
||||
|
||||
private:
|
||||
mutable tpx::Substance* m_sub;
|
||||
int m_subflag;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue