diff --git a/include/cantera/thermo/IdealGasPhase.h b/include/cantera/thermo/IdealGasPhase.h
index df206e21a..629c3669e 100644
--- a/include/cantera/thermo/IdealGasPhase.h
+++ b/include/cantera/thermo/IdealGasPhase.h
@@ -6,7 +6,6 @@
*/
// Copyright 2001 California Institute of Technology
-
#ifndef CT_IDEALGASPHASE_H
#define CT_IDEALGASPHASE_H
@@ -18,7 +17,6 @@
namespace Cantera
{
-
//! Class %IdealGasPhase represents low-density gases that obey the
//! ideal gas equation of state.
/*!
@@ -284,19 +282,19 @@ namespace Cantera
* object named silane is given below.
*
* @verbatim
-
-
- Si H He
-
- H2 H HE SIH4 SI SIH SIH2 SIH3 H3SISIH SI2H6
- H2SISIH2 SI3H8 SI2 SI3
-
-
-
-
-
-
- @endverbatim
+
+
+ Si H He
+
+ H2 H HE SIH4 SI SIH SIH2 SIH3 H3SISIH SI2H6
+ H2SISIH2 SI3H8 SI2 SI3
+
+
+
+
+
+
+ @endverbatim
*
* The model attribute "IdealGas" of the thermo XML element identifies the phase as
* being of the type handled by the IdealGasPhase object.
@@ -304,7 +302,7 @@ namespace Cantera
* @ingroup thermoprops
*
*/
-class IdealGasPhase : public ThermoPhase
+class IdealGasPhase: public ThermoPhase
{
public:
@@ -312,6 +310,32 @@ public:
//! Default empty Constructor
IdealGasPhase();
+ //! Construct and initialize an IdealGasPhase ThermoPhase object
+ //! directly from an ASCII input file
+ /*!
+ * Working constructors
+ *
+ * The two constructors below are a direct way that
+ * the phase can initialize itself. They are shells that call
+ * the routine initThermo(), with a reference to the
+ * XML database to get the info for the phase.
+ *
+ * @param inputFile Name of the input file containing the phase XML data
+ * to set up the object
+ * @param id ID of the phase in the input file. Defaults to the
+ * empty string.
+ */
+ IdealGasPhase(const std::string& inputFile, const std::string& id = "");
+
+ //! Construct and initialize an IdealGasPhase ThermoPhase object
+ //! directly from an XML database
+ /*!
+ * @param phaseRef XML phase node containing the description of the phase
+ * @param id id attribute containing the name of the phase.
+ * (default is the empty string)
+ */
+ IdealGasPhase(XML_Node& phaseRef, const std::string& id = "");
+
//! Copy Constructor
/*!
* Copy constructor for the object. Constructed
@@ -323,7 +347,6 @@ public:
*/
IdealGasPhase(const IdealGasPhase& right);
-
//! Assignment operator
/*!
* Assignment operator for the object. Constructed
@@ -332,10 +355,10 @@ public:
*
* @param right Object to be copied.
*/
- IdealGasPhase& operator=(const IdealGasPhase& right);
+ IdealGasPhase& operator=(const IdealGasPhase& right);
//! Destructor
- virtual ~IdealGasPhase() {}
+ virtual ~IdealGasPhase();
//! Duplicator from the %ThermoPhase parent class
/*!
@@ -361,7 +384,6 @@ public:
* @{
*/
-
//! Return the Molar enthalpy. Units: J/kmol.
/*!
* For an ideal gas mixture,
@@ -376,8 +398,7 @@ public:
* \see SpeciesThermo
*/
virtual doublereal enthalpy_mole() const {
- return GasConstant * temperature() *
- mean_X(&enthalpy_RT_ref()[0]);
+ return GasConstant * temperature() * mean_X(&enthalpy_RT_ref()[0]);
}
/**
@@ -498,7 +519,6 @@ public:
return GasConstant * molarDensity() * temperature();
}
-
//! Set the pressure at constant temperature and composition.
/*!
* Units: Pa.
@@ -510,8 +530,7 @@ public:
* @param p Pressure (Pa)
*/
virtual void setPressure(doublereal p) {
- setDensity(p * meanMolecularWeight()
- /(GasConstant * temperature()));
+ setDensity(p * meanMolecularWeight() / (GasConstant * temperature()));
}
//! Returns the isothermal compressibility. Units: 1/Pa.
@@ -523,7 +542,7 @@ public:
* For ideal gases it's equal to the inverse of the pressure
*/
virtual doublereal isothermalCompressibility() const {
- return 1.0/pressure();
+ return 1.0 / pressure();
}
//! Return the volumetric thermal expansion coefficient. Units: 1/K.
@@ -535,7 +554,7 @@ public:
* For ideal gases, it's equal to the inverse of the temperature.
*/
virtual doublereal thermalExpansionCoeff() const {
- return 1.0/temperature();
+ return 1.0 / temperature();
}
//@}
@@ -601,14 +620,14 @@ public:
* @return
* Returns the standard Concentration in units of m3 kmol-1.
*/
- virtual doublereal standardConcentration(size_t k=0) const;
+ virtual doublereal standardConcentration(size_t k = 0) const;
//! Returns the natural logarithm of the standard
//! concentration of the kth species
/*!
* @param k index of the species. (defaults to zero)
*/
- virtual doublereal logStandardConc(size_t k=0) const;
+ virtual doublereal logStandardConc(size_t k = 0) const;
//! Get the array of non-dimensional activity coefficients at
//! the current solution temperature, pressure, and solution concentration.
@@ -619,12 +638,10 @@ public:
*/
virtual void getActivityCoefficients(doublereal* ac) const;
-
//@}
/// @name Partial Molar Properties of the Solution ----------------------------------
//@{
-
//! Get the species chemical potentials. Units: J/kmol.
/*!
* This function returns a vector of chemical potentials of the
@@ -751,7 +768,6 @@ public:
/// @name Thermodynamic Values for the Species Reference States ---------------------
//@{
-
//! Returns the vector of nondimensional
//! enthalpies of the reference state at the current temperature
//! of the solution and the reference pressure for the species.
@@ -816,7 +832,7 @@ public:
* heat capacities at constant pressure for the species.
* Length: m_kk
*/
- virtual void getCp_R_ref(doublereal* cprt) const;
+ virtual void getCp_R_ref(doublereal* cprt) const;
//! Get the molar volumes of the species standard states at the current
//! T and P_ref of the solution.
@@ -921,27 +937,27 @@ protected:
doublereal m_p0;
//! last value of the temperature processed by reference state
- mutable doublereal m_tlast;
+ mutable doublereal m_tlast;
- //! Temporary storage for log of p/rt
- mutable doublereal m_logc0;
+ //! Temporary storage for log of p/RT
+ mutable doublereal m_logc0;
//! Temporary storage for dimensionless reference state enthalpies
- mutable vector_fp m_h0_RT;
+ mutable vector_fp m_h0_RT;
//! Temporary storage for dimensionless reference state heat capacities
- mutable vector_fp m_cp0_R;
+ mutable vector_fp m_cp0_R;
//! Temporary storage for dimensionless reference state gibbs energies
- mutable vector_fp m_g0_RT;
+ mutable vector_fp m_g0_RT;
//! Temporary storage for dimensionless reference state entropies
- mutable vector_fp m_s0_R;
+ mutable vector_fp m_s0_R;
- mutable vector_fp m_expg0_RT;
+ mutable vector_fp m_expg0_RT;
//! Temporary array containing internally calculated partial pressures
- mutable vector_fp m_pp;
+ mutable vector_fp m_pp;
private:
diff --git a/src/thermo/IdealGasPhase.cpp b/src/thermo/IdealGasPhase.cpp
index 624b6b767..6ac1b45b7 100644
--- a/src/thermo/IdealGasPhase.cpp
+++ b/src/thermo/IdealGasPhase.cpp
@@ -15,15 +15,35 @@ using namespace std;
namespace Cantera
{
// Default empty Constructor
-IdealGasPhase::IdealGasPhase():
+IdealGasPhase::IdealGasPhase() :
m_p0(-1.0),
m_tlast(0.0),
m_logc0(0.0)
{
}
+IdealGasPhase::IdealGasPhase(const std::string& inputFile, const std::string& id) :
+ m_p0(-1.0),
+ m_tlast(0.0),
+ m_logc0(0.0)
+{
+ initThermoFile(inputFile, id);
+}
+
+IdealGasPhase::IdealGasPhase(XML_Node& phaseRef, const std::string& id) :
+ m_p0(-1.0),
+ m_tlast(0.0),
+ m_logc0(0.0)
+{
+ initThermoXML(phaseRef, id);
+}
+
+IdealGasPhase::~IdealGasPhase()
+{
+}
+
// Copy Constructor
-IdealGasPhase::IdealGasPhase(const IdealGasPhase& right):
+IdealGasPhase::IdealGasPhase(const IdealGasPhase& right) :
m_p0(right.m_p0),
m_tlast(right.m_tlast),
m_logc0(right.m_logc0)
@@ -43,20 +63,19 @@ IdealGasPhase::IdealGasPhase(const IdealGasPhase& right):
*
* @param right Object to be copied.
*/
-IdealGasPhase& IdealGasPhase::
-operator=(const IdealGasPhase& right)
+IdealGasPhase& IdealGasPhase::operator=(const IdealGasPhase& right)
{
if (&right != this) {
ThermoPhase::operator=(right);
- m_p0 = right.m_p0;
- m_tlast = right.m_tlast;
- m_logc0 = right.m_logc0;
- m_h0_RT = right.m_h0_RT;
- m_cp0_R = right.m_cp0_R;
- m_g0_RT = right.m_g0_RT;
- m_s0_R = right.m_s0_R;
- m_expg0_RT= right.m_expg0_RT;
- m_pp = right.m_pp;
+ m_p0 = right.m_p0;
+ m_tlast = right.m_tlast;
+ m_logc0 = right.m_logc0;
+ m_h0_RT = right.m_h0_RT;
+ m_cp0_R = right.m_cp0_R;
+ m_g0_RT = right.m_g0_RT;
+ m_s0_R = right.m_s0_R;
+ m_expg0_RT = right.m_expg0_RT;
+ m_pp = right.m_pp;
}
return *this;
}
@@ -89,8 +108,7 @@ ThermoPhase* IdealGasPhase::duplMyselfAsThermoPhase() const
*/
doublereal IdealGasPhase::intEnergy_mole() const
{
- return GasConstant * temperature()
- * (mean_X(&enthalpy_RT_ref()[0]) - 1.0);
+ return GasConstant * temperature() * (mean_X(&enthalpy_RT_ref()[0]) - 1.0);
}
/*
@@ -106,8 +124,7 @@ doublereal IdealGasPhase::intEnergy_mole() const
*/
doublereal IdealGasPhase::entropy_mole() const
{
- return GasConstant * (mean_X(&entropy_R_ref()[0]) -
- sum_xlogx() - std::log(pressure()/m_spthermo->refPressure()));
+ return GasConstant * (mean_X(&entropy_R_ref()[0]) - sum_xlogx() - std::log(pressure() / m_spthermo->refPressure()));
}
/*
@@ -155,19 +172,17 @@ doublereal IdealGasPhase::cv_mole() const
doublereal IdealGasPhase::cv_tr(doublereal atomicity) const
{
// k is the species number
- int dum = 0;
+ int dum = 0;
int type = 0;
doublereal c[12];
doublereal minTemp;
doublereal maxTemp;
doublereal refPressure;
- m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure);
+ m_spthermo->reportParams(dum, type, c, minTemp, maxTemp, refPressure);
if (type != 111) {
- throw CanteraError("Error in IdealGasPhase.cpp",
- "cv_tr only supported for StatMech!. \n\n");
-
+ throw CanteraError("Error in IdealGasPhase.cpp", "cv_tr only supported for StatMech!. \n\n");
}
// see reportParameters for specific details
@@ -179,7 +194,7 @@ doublereal IdealGasPhase::cv_tr(doublereal atomicity) const
*/
doublereal IdealGasPhase::cv_trans() const
{
- return 1.5*GasConstant;
+ return 1.5 * GasConstant;
}
/**
@@ -216,7 +231,7 @@ doublereal IdealGasPhase::cv_vib(const int k, const doublereal T) const
{
// k is the species number
- int dum = 0;
+ int dum = 0;
int type = 0;
doublereal c[12];
doublereal minTemp;
@@ -225,12 +240,11 @@ doublereal IdealGasPhase::cv_vib(const int k, const doublereal T) const
c[0] = temperature();
- m_spthermo->reportParams(dum,type,c,minTemp,maxTemp,refPressure);
+ m_spthermo->reportParams(dum, type, c, minTemp, maxTemp, refPressure);
// basic sanity check
if (type != 111) {
- throw CanteraError("Error in IdealGasPhase.cpp",
- "cv_vib only supported for StatMech!. \n\n");
+ throw CanteraError("Error in IdealGasPhase.cpp", "cv_vib only supported for StatMech!. \n\n");
}
@@ -249,7 +263,7 @@ doublereal IdealGasPhase::cv_vib(const int k, const doublereal T) const
doublereal IdealGasPhase::standardConcentration(size_t k) const
{
double p = pressure();
- return p/(GasConstant * temperature());
+ return p / (GasConstant * temperature());
}
/*
@@ -282,10 +296,10 @@ void IdealGasPhase::getStandardChemPotentials(doublereal* muStar) const
{
const vector_fp& gibbsrt = gibbs_RT_ref();
scale(gibbsrt.begin(), gibbsrt.end(), muStar, _RT());
- double tmp = log(pressure() /m_spthermo->refPressure());
- tmp *= GasConstant * temperature();
+ double tmp = log(pressure() / m_spthermo->refPressure());
+ tmp *= GasConstant * temperature();
for (size_t k = 0; k < m_kk; k++) {
- muStar[k] += tmp; // add RT*ln(P/P_0)
+ muStar[k] += tmp; // add RT*ln(P/P_0)
}
}
@@ -300,7 +314,7 @@ void IdealGasPhase::getChemPotentials(doublereal* mu) const
//const vector_fp& g_RT = gibbs_RT_ref();
for (size_t k = 0; k < m_kk; k++) {
xx = std::max(SmallNumber, moleFraction(k));
- mu[k] += rt*(log(xx));
+ mu[k] += rt * (log(xx));
}
}
@@ -324,10 +338,10 @@ void IdealGasPhase::getPartialMolarEntropies(doublereal* sbar) const
const vector_fp& _s = entropy_R_ref();
doublereal r = GasConstant;
scale(_s.begin(), _s.end(), sbar, r);
- doublereal logp = log(pressure()/m_spthermo->refPressure());
+ doublereal logp = log(pressure() / m_spthermo->refPressure());
for (size_t k = 0; k < m_kk; k++) {
doublereal xx = std::max(SmallNumber, moleFraction(k));
- sbar[k] += r * (- logp - log(xx));
+ sbar[k] += r * (-logp - log(xx));
}
}
@@ -340,7 +354,7 @@ void IdealGasPhase::getPartialMolarIntEnergies(doublereal* ubar) const
const vector_fp& _h = enthalpy_RT_ref();
doublereal rt = GasConstant * temperature();
for (size_t k = 0; k < m_kk; k++) {
- ubar[k] = rt * (_h[k] - 1.0);
+ ubar[k] = rt * (_h[k] - 1.0);
}
}
@@ -387,7 +401,7 @@ void IdealGasPhase::getEntropy_R(doublereal* sr) const
{
const vector_fp& _s = entropy_R_ref();
copy(_s.begin(), _s.end(), sr);
- double tmp = log(pressure() /m_spthermo->refPressure());
+ double tmp = log(pressure() / m_spthermo->refPressure());
for (size_t k = 0; k < m_kk; k++) {
sr[k] -= tmp;
}
@@ -401,7 +415,7 @@ void IdealGasPhase::getGibbs_RT(doublereal* grt) const
{
const vector_fp& gibbsrt = gibbs_RT_ref();
copy(gibbsrt.begin(), gibbsrt.end(), grt);
- double tmp = log(pressure() /m_spthermo->refPressure());
+ double tmp = log(pressure() / m_spthermo->refPressure());
for (size_t k = 0; k < m_kk; k++) {
grt[k] += tmp;
}
@@ -416,7 +430,7 @@ void IdealGasPhase::getPureGibbs(doublereal* gpure) const
{
const vector_fp& gibbsrt = gibbs_RT_ref();
scale(gibbsrt.begin(), gibbsrt.end(), gpure, _RT());
- double tmp = log(pressure() /m_spthermo->refPressure());
+ double tmp = log(pressure() / m_spthermo->refPressure());
tmp *= _RT();
for (size_t k = 0; k < m_kk; k++) {
gpure[k] += tmp;
@@ -542,10 +556,8 @@ void IdealGasPhase::getStandardVolumes_ref(doublereal* vol) const
}
}
-
// new methods defined here -------------------------------
-
void IdealGasPhase::initThermo()
{
m_p0 = refPressure();
@@ -593,7 +605,6 @@ void IdealGasPhase::setToEquilState(const doublereal* mu_RT)
setState_PX(pres, &m_pp[0]);
}
-
/// This method is called each time a thermodynamic property is
/// requested, to check whether the internal species properties
/// within the object need to be updated.
@@ -612,15 +623,14 @@ void IdealGasPhase::_updateThermo() const
// If the temperature has changed since the last time these
// properties were computed, recompute them.
if (m_tlast != tnow) {
- m_spthermo->update(tnow, &m_cp0_R[0], &m_h0_RT[0],
- &m_s0_R[0]);
+ m_spthermo->update(tnow, &m_cp0_R[0], &m_h0_RT[0], &m_s0_R[0]);
m_tlast = tnow;
// update the species Gibbs functions
for (size_t k = 0; k < m_kk; k++) {
m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
}
- m_logc0 = log(m_p0/(GasConstant * tnow));
+ m_logc0 = log(m_p0 / (GasConstant * tnow));
m_tlast = tnow;
}
}
diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp
index bfee214ee..0c2cdaecb 100644
--- a/src/thermo/ThermoPhase.cpp
+++ b/src/thermo/ThermoPhase.cpp
@@ -909,7 +909,7 @@ void ThermoPhase::saveSpeciesData(const size_t k, const XML_Node* const data)
//====================================================================================================================
// Return a pointer to the XML tree containing the species
// data for this phase.
-const std::vector & ThermoPhase::speciesData() const
+const std::vector& ThermoPhase::speciesData() const
{
if (m_speciesData.size() != m_kk) {
throw CanteraError("ThermoPhase::speciesData",