From 72a6de13a48709b53ab8bbf43bcbf2775074ac93 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 28 Nov 2006 18:44:23 +0000 Subject: [PATCH] Uupdaetd the structure of the namespaces so that it would compile. --- Cantera/src/thermo/DebyeHuckel.cpp | 64 +- Cantera/src/thermo/DebyeHuckel.h | 12 +- Cantera/src/thermo/HMWSoln.cpp | 27 +- Cantera/src/thermo/HMWSoln.h | 12 +- Cantera/src/thermo/HMWSoln_input.cpp | 11 +- Cantera/src/thermo/IdealMolalSoln.cpp | 36 +- Cantera/src/thermo/IdealMolalSoln.h | 12 +- Cantera/src/thermo/IdealSolidSolnPhase.h | 10 +- Cantera/src/thermo/MolalityVPSSTP.cpp | 2 +- Cantera/src/thermo/MolalityVPSSTP.h | 8 +- Cantera/src/thermo/PDSS.cpp | 71 +- Cantera/src/thermo/PDSS.h | 37 +- Cantera/src/thermo/SingleSpeciesTP.cpp | 948 +++++++++---------- Cantera/src/thermo/SingleSpeciesTP.h | 1070 +++++++++++----------- Cantera/src/thermo/VPStandardStateTP.cpp | 27 +- Cantera/src/thermo/VPStandardStateTP.h | 767 ++++++++-------- Cantera/src/thermo/WaterPDSS.cpp | 23 +- Cantera/src/thermo/WaterPDSS.h | 10 +- Cantera/src/thermo/WaterTP.cpp | 14 +- Cantera/src/thermo/WaterTP.h | 10 +- 20 files changed, 1651 insertions(+), 1520 deletions(-) diff --git a/Cantera/src/thermo/DebyeHuckel.cpp b/Cantera/src/thermo/DebyeHuckel.cpp index 10fce49b7..5a114a25c 100644 --- a/Cantera/src/thermo/DebyeHuckel.cpp +++ b/Cantera/src/thermo/DebyeHuckel.cpp @@ -19,6 +19,8 @@ #include "WaterProps.h" #include "WaterPDSS.h" +using namespace std; + namespace Cantera { /** @@ -53,7 +55,7 @@ namespace Cantera { * the routine initThermo(), with a reference to the * XML database to get the info for the phase. */ - DebyeHuckel::DebyeHuckel(string inputFile, string id) : + DebyeHuckel::DebyeHuckel(std::string inputFile, std::string id) : MolalityVPSSTP(), m_formDH(DHFORM_DILUTE_LIMIT), m_formGC(2), @@ -76,7 +78,7 @@ namespace Cantera { constructPhaseFile(inputFile, id); } - DebyeHuckel::DebyeHuckel(XML_Node& phaseRoot, string id) : + DebyeHuckel::DebyeHuckel(XML_Node& phaseRoot, std::string id) : MolalityVPSSTP(), m_formDH(DHFORM_DILUTE_LIMIT), m_formGC(2), @@ -1036,13 +1038,13 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void DebyeHuckel::constructPhaseFile(string inputFile, string id) { + void DebyeHuckel::constructPhaseFile(std::string inputFile, std::string id) { if (inputFile.size() == 0) { throw CanteraError("DebyeHuckel::initThermo", "input file is null"); } - string path = findInputFile(inputFile); + std::string path = findInputFile(inputFile); ifstream fin(path.c_str()); if (!fin) { throw CanteraError("DebyeHuckel::initThermo","could not open " @@ -1072,7 +1074,7 @@ namespace Cantera { * utility function to assign an integer value from a string * for the ElectrolyteSpeciesType field. */ - static int interp_est(string estString) { + static int interp_est(std::string estString) { const char *cc = estString.c_str(); if (!strcasecmp(cc, "solvent")) { return cEST_solvent; @@ -1118,10 +1120,10 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - void DebyeHuckel::constructPhaseXML(XML_Node& phaseNode, string id) { + void DebyeHuckel::constructPhaseXML(XML_Node& phaseNode, std::string id) { if (id.size() > 0) { - string idp = phaseNode.id(); + std::string idp = phaseNode.id(); if (idp != id) { throw CanteraError("DebyeHuckel::constructPhaseXML", "phasenode and Id are incompatible"); @@ -1143,7 +1145,7 @@ namespace Cantera { if (thermoNode.hasChild("standardConc")) { XML_Node& scNode = thermoNode.child("standardConc"); m_formGC = 2; - string formString = scNode.attrib("model"); + std::string formString = scNode.attrib("model"); if (formString != "") { if (formString == "unity") { m_formGC = 0; @@ -1165,10 +1167,10 @@ namespace Cantera { * Get the Name of the Solvent: * solventName */ - string solventName = ""; + std::string solventName = ""; if (thermoNode.hasChild("solvent")) { XML_Node& scNode = thermoNode.child("solvent"); - vector nameSolventa; + vector nameSolventa; getStringArray(scNode, nameSolventa); int nsp = static_cast(nameSolventa.size()); if (nsp != 1) { @@ -1185,7 +1187,7 @@ namespace Cantera { if (thermoNode.hasChild("activityCoefficients")) { XML_Node& scNode = thermoNode.child("activityCoefficients"); m_formDH = DHFORM_DILUTE_LIMIT; - string formString = scNode.attrib("model"); + std::string formString = scNode.attrib("model"); if (formString != "") { if (formString == "Dilute_limit") { m_formDH = DHFORM_DILUTE_LIMIT; @@ -1242,9 +1244,9 @@ namespace Cantera { * with the correct id. */ void DebyeHuckel:: - initThermoXML(XML_Node& phaseNode, string id) { + initThermoXML(XML_Node& phaseNode, std::string id) { int k; - string stemp; + std::string stemp; /* * Find the Thermo XML node */ @@ -1267,10 +1269,10 @@ namespace Cantera { * Get the Name of the Solvent: * solventName */ - string solventName = ""; + std::string solventName = ""; if (thermoNode.hasChild("solvent")) { XML_Node& scNode = thermoNode.child("solvent"); - vector nameSolventa; + vector nameSolventa; getStringArray(scNode, nameSolventa); int nsp = static_cast(nameSolventa.size()); if (nsp != 1) { @@ -1280,7 +1282,7 @@ namespace Cantera { solventName = nameSolventa[0]; } for (k = 0; k < m_kk; k++) { - string sname = speciesName(k); + std::string sname = speciesName(k); if (solventName == sname) { m_indexSolvent = k; break; @@ -1321,13 +1323,13 @@ namespace Cantera { "Species " + sss[k] + " standardState XML block not found"); } - string modelStringa = ss->attrib("model"); + std::string modelStringa = ss->attrib("model"); if (modelStringa == "") { throw CanteraError("DebyeHuckel::initThermoXML", "Species " + sss[k] + " standardState XML block model attribute not found"); } - string modelString = lowercase(modelStringa); + std::string modelString = lowercase(modelStringa); if (k == 0) { if (modelString == "wateriapws" || modelString == "real_water" || @@ -1479,15 +1481,15 @@ namespace Cantera { if (acNode.hasChild("ionicRadius")) { XML_Node& irNode = acNode.child("ionicRadius"); - string Aunits = ""; + std::string Aunits = ""; double Afactor = 1.0; if (irNode.hasAttrib("units")) { - string Aunits = irNode.attrib("units"); + std::string Aunits = irNode.attrib("units"); Afactor = toSI(Aunits); } if (irNode.hasAttrib("default")) { - string ads = irNode.attrib("default"); + std::string ads = irNode.attrib("default"); double ad = fpValue(ads); for (int k = 0; k < m_kk; k++) { m_Aionic[k] = ad * Afactor; @@ -1521,7 +1523,7 @@ namespace Cantera { * lack of agreement (HKM -> may be changed in the * future). */ - map::const_iterator _b = m.begin(); + map::const_iterator _b = m.begin(); for (; _b != m.end(); ++_b) { int kk = speciesIndex(_b->first); if (kk < 0) { @@ -1571,7 +1573,7 @@ namespace Cantera { */ const XML_Node *phaseSpecies = speciesData(); if (phaseSpecies) { - string kname, jname; + std::string kname, jname; vector xspecies; phaseSpecies->getChildren("species",xspecies); int jj = xspecies.size(); @@ -1602,9 +1604,9 @@ namespace Cantera { if (acNodePtr->hasChild("stoichIsMods")) { XML_Node& sIsNode = acNodePtr->child("stoichIsMods"); - map msIs; + map msIs; getMap(sIsNode, msIs); - map::const_iterator _b = msIs.begin(); + map::const_iterator _b = msIs.begin(); for (; _b != msIs.end(); ++_b) { int kk = speciesIndex(_b->first); if (kk < 0) { @@ -1650,13 +1652,13 @@ namespace Cantera { const XML_Node *phaseSpecies = speciesData(); const XML_Node *spPtr = 0; if (phaseSpecies) { - string kname; + std::string kname; for (k = 0; k < m_kk; k++) { kname = speciesName(k); spPtr = speciesXML_Node(kname, phaseSpecies); if (!spPtr) { if (spPtr->hasChild("electrolyteSpeciesType")) { - string est = getString(*spPtr, "electrolyteSpeciesType"); + std::string est = getString(*spPtr, "electrolyteSpeciesType"); if ((m_electrolyteSpeciesType[k] = interp_est(est)) == -1) { throw CanteraError("DebyeHuckel:initThermoXML", "Bad electrolyte type: " + est); @@ -1671,14 +1673,14 @@ namespace Cantera { if (acNodePtr) { if (acNodePtr->hasChild("electrolyteSpeciesType")) { XML_Node& ESTNode = acNodePtr->child("electrolyteSpeciesType"); - map msEST; + map msEST; getMap(ESTNode, msEST); - map::const_iterator _b = msEST.begin(); + map::const_iterator _b = msEST.begin(); for (; _b != msEST.end(); ++_b) { int kk = speciesIndex(_b->first); if (kk < 0) { } else { - string est = _b->second; + std::string est = _b->second; if ((m_electrolyteSpeciesType[kk] = interp_est(est)) == -1) { throw CanteraError("DebyeHuckel:initThermoXML", "Bad electrolyte type: " + est); @@ -1895,7 +1897,7 @@ namespace Cantera { * Bail out of functions with an error exit if they are not * implemented. */ - doublereal DebyeHuckel::err(string msg) const { + doublereal DebyeHuckel::err(std::string msg) const { throw CanteraError("DebyeHuckel", "Unfinished func called: " + msg ); return 0.0; diff --git a/Cantera/src/thermo/DebyeHuckel.h b/Cantera/src/thermo/DebyeHuckel.h index ba0aa31b0..5f3ed7b9b 100644 --- a/Cantera/src/thermo/DebyeHuckel.h +++ b/Cantera/src/thermo/DebyeHuckel.h @@ -111,8 +111,8 @@ namespace Cantera { DebyeHuckel(const DebyeHuckel &); DebyeHuckel& operator=(const DebyeHuckel&); - DebyeHuckel(string inputFile, string id = ""); - DebyeHuckel(XML_Node& phaseRef, string id = ""); + DebyeHuckel(std::string inputFile, std::string id = ""); + DebyeHuckel(XML_Node& phaseRef, std::string id = ""); /// Destructor. virtual ~DebyeHuckel(); @@ -816,7 +816,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - virtual void constructPhaseFile(string infile, string id=""); + virtual void constructPhaseFile(std::string infile, std::string id=""); /* * Import and initialize a DebyeHuckel phase @@ -842,10 +842,10 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - virtual void constructPhaseXML(XML_Node& phaseNode, string id=""); + virtual void constructPhaseXML(XML_Node& phaseNode, std::string id=""); - virtual void initThermoXML(XML_Node& phaseNode, string id); + virtual void initThermoXML(XML_Node& phaseNode, std::string id); /** * Report the molar volume of species k @@ -1187,7 +1187,7 @@ namespace Cantera { mutable array_fp m_dlnActCoeffMolaldP; private: - doublereal err(string msg) const; + doublereal err(std::string msg) const; void initLengths(); diff --git a/Cantera/src/thermo/HMWSoln.cpp b/Cantera/src/thermo/HMWSoln.cpp index a0c4ce3c9..6b9a2ed0c 100644 --- a/Cantera/src/thermo/HMWSoln.cpp +++ b/Cantera/src/thermo/HMWSoln.cpp @@ -56,7 +56,7 @@ namespace Cantera { * the routine initThermo(), with a reference to the * XML database to get the info for the phase. */ - HMWSoln::HMWSoln(string inputFile, string id) : + HMWSoln::HMWSoln(std::string inputFile, std::string id) : MolalityVPSSTP(), m_formPitzer(PITZERFORM_BASE), m_formPitzerTemp(PITZER_TEMP_CONSTANT), @@ -80,7 +80,7 @@ namespace Cantera { constructPhaseFile(inputFile, id); } - HMWSoln::HMWSoln(XML_Node& phaseRoot, string id) : + HMWSoln::HMWSoln(XML_Node& phaseRoot, std::string id) : MolalityVPSSTP(), m_formPitzer(PITZERFORM_BASE), m_formPitzerTemp(PITZER_TEMP_CONSTANT), @@ -423,15 +423,6 @@ namespace Cantera { getPartialMolarEnthalpies(DATA_PTR(m_tmpV)); getMoleFractions(DATA_PTR(m_pp)); double val = mean_X(DATA_PTR(m_tmpV)); -#ifdef DEBUG_HKM - double val0 = 0.0; - for (int k = 0; k < m_kk; k++) { - val0 += m_tmpV[k] * m_pp[k]; - } - //if (val != val0) { - // printf("ERROR\n"); - //} -#endif return val; } @@ -1542,7 +1533,7 @@ namespace Cantera { * Bail out of functions with an error exit if they are not * implemented. */ - doublereal HMWSoln::err(string msg) const { + doublereal HMWSoln::err(std::string msg) const { throw CanteraError("HMWSoln", "Unfinished func called: " + msg ); return 0.0; @@ -1905,7 +1896,7 @@ namespace Cantera { } #endif double wateract; - string sni, snj, snk; + std::string sni, snj, snk; /* * This is the molality of the species in solution. @@ -2730,7 +2721,7 @@ namespace Cantera { } double d_wateract_dT; - string sni, snj, snk; + std::string sni, snj, snk; const double *molality = DATA_PTR(m_molalities); const double *charge = DATA_PTR(m_speciesCharge); @@ -3510,7 +3501,7 @@ namespace Cantera { } double d2_wateract_dT2; - string sni, snj, snk; + std::string sni, snj, snk; const double *molality = DATA_PTR(m_molalities); const double *charge = DATA_PTR(m_speciesCharge); @@ -4317,7 +4308,7 @@ namespace Cantera { } double d_wateract_dP; - string sni, snj, snk; + std::string sni, snj, snk; const double *molality = DATA_PTR(m_molalities); const double *charge = DATA_PTR(m_speciesCharge); @@ -5205,7 +5196,7 @@ namespace Cantera { */ void HMWSoln::printCoeffs() const { int i, j, k; - string sni, snj; + std::string sni, snj; calcMolalities(); const double *charge = DATA_PTR(m_speciesCharge); double *molality = DATA_PTR(m_molalities); @@ -5249,7 +5240,7 @@ namespace Cantera { for (j = 1; j < m_kk; j++) { snj = speciesName(j); for (k = 1; k < m_kk; k++) { - string snk = speciesName(k); + std::string snk = speciesName(k); int n = k + j * m_kk + i * m_kk * m_kk; if (m_Psi_ijk[n] != 0.0) { printf(" %-16s %-16s %-16s %9.5f \n", diff --git a/Cantera/src/thermo/HMWSoln.h b/Cantera/src/thermo/HMWSoln.h index 139fb1100..31b78fd00 100644 --- a/Cantera/src/thermo/HMWSoln.h +++ b/Cantera/src/thermo/HMWSoln.h @@ -95,8 +95,8 @@ namespace Cantera { HMWSoln(const HMWSoln &); HMWSoln& operator=(const HMWSoln&); - HMWSoln(string inputFile, string id = ""); - HMWSoln(XML_Node& phaseRef, string id = ""); + HMWSoln(std::string inputFile, std::string id = ""); + HMWSoln(XML_Node& phaseRef, std::string id = ""); /** * This is a special constructor, used to replicate test problems @@ -800,7 +800,7 @@ namespace Cantera { * This routine is a precursor to constructPhaseXML(XML_Node*) * routine, which does most of the work. */ - virtual void constructPhaseFile(string inputFile, string id); + virtual void constructPhaseFile(std::string inputFile, std::string id); /* * constructPhaseXML (virtual from HMWSoln) @@ -816,7 +816,7 @@ namespace Cantera { * particular to the specification of the activity * coefficient model for the Pitzer parameterization. */ - virtual void constructPhaseXML(XML_Node& phaseNode, string id); + virtual void constructPhaseXML(XML_Node& phaseNode, std::string id); /** * @internal Initialize. This method is provided to allow @@ -851,7 +851,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - virtual void initThermoXML(XML_Node& phaseNode, string id); + virtual void initThermoXML(XML_Node& phaseNode, std::string id); /** * Report the molar volume of species k @@ -1371,7 +1371,7 @@ namespace Cantera { mutable vector_fp m_gamma; private: - doublereal err(string msg) const; + doublereal err(std::string msg) const; void initLengths(); diff --git a/Cantera/src/thermo/HMWSoln_input.cpp b/Cantera/src/thermo/HMWSoln_input.cpp index 1c8aea639..1789bde94 100644 --- a/Cantera/src/thermo/HMWSoln_input.cpp +++ b/Cantera/src/thermo/HMWSoln_input.cpp @@ -15,6 +15,9 @@ #include "WaterProps.h" #include "WaterPDSS.h" +using namespace std; + + namespace Cantera { /** @@ -23,7 +26,7 @@ namespace Cantera { * utility function to assign an integer value from a string * for the ElectrolyteSpeciesType field. */ - static int interp_est(string estString) { + static int interp_est(std::string estString) { const char *cc = estString.c_str(); if (!strcasecmp(cc, "solvent")) { return cEST_solvent; @@ -581,7 +584,7 @@ namespace Cantera { "input file is null"); } string path = findInputFile(inputFile); - ifstream fin(path.c_str()); + std::ifstream fin(path.c_str()); if (!fin) { throw CanteraError("HMWSoln:constructPhaseFile","could not open " +path+" for reading."); @@ -830,8 +833,8 @@ namespace Cantera { } } if (m_indexSolvent == -1) { - cout << "HMWSoln::initThermo: Solvent Name not found" - << endl; + std::cout << "HMWSoln::initThermo: Solvent Name not found" + << std::endl; throw CanteraError("HMWSoln::initThermoXML", "Solvent name not found"); } diff --git a/Cantera/src/thermo/IdealMolalSoln.cpp b/Cantera/src/thermo/IdealMolalSoln.cpp index 9ba363902..30bafe837 100644 --- a/Cantera/src/thermo/IdealMolalSoln.cpp +++ b/Cantera/src/thermo/IdealMolalSoln.cpp @@ -70,13 +70,13 @@ namespace Cantera { return *this; } - IdealMolalSoln::IdealMolalSoln(string inputFile, string id) : + IdealMolalSoln::IdealMolalSoln(std::string inputFile, std::string id) : MolalityVPSSTP() { constructPhaseFile(inputFile, id); } - IdealMolalSoln::IdealMolalSoln(XML_Node& root, string id) : + IdealMolalSoln::IdealMolalSoln(XML_Node& root, std::string id) : MolalityVPSSTP() { constructPhaseXML(root, id); @@ -802,14 +802,15 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void IdealMolalSoln::constructPhaseFile(string inputFile, string id) { + void IdealMolalSoln::constructPhaseFile(std::string inputFile, + std::string id) { if (inputFile.size() == 0) { throw CanteraError("IdealMolalSoln::constructPhaseFile", "input file is null"); } - string path = findInputFile(inputFile); - ifstream fin(path.c_str()); + std::string path = findInputFile(inputFile); + std::ifstream fin(path.c_str()); if (!fin) { throw CanteraError("IdealMolalSoln::constructPhaseFile", "could not open " @@ -857,9 +858,10 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - void IdealMolalSoln::constructPhaseXML(XML_Node& phaseNode, string id) { + void IdealMolalSoln::constructPhaseXML(XML_Node& phaseNode, + std::string id) { if (id.size() > 0) { - string idp = phaseNode.id(); + std::string idp = phaseNode.id(); if (idp != id) { throw CanteraError("IdealMolalSoln::constructPhaseXML", "phasenode and Id are incompatible"); @@ -904,7 +906,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - void IdealMolalSoln::initThermoXML(XML_Node& phaseNode, string id) { + void IdealMolalSoln::initThermoXML(XML_Node& phaseNode, std::string id) { /* * Initialize the whole thermo object, using a virtual function. @@ -912,7 +914,7 @@ namespace Cantera { initThermo(); if (id.size() > 0) { - string idp = phaseNode.id(); + std::string idp = phaseNode.id(); if (idp != id) { throw CanteraError("IdealMolalSoln::initThermo", "phasenode and Id are incompatible"); @@ -934,7 +936,7 @@ namespace Cantera { if (thermoNode.hasChild("standardConc")) { XML_Node& scNode = thermoNode.child("standardConc"); m_formGC = 2; - string formString = scNode.attrib("model"); + std::string formString = scNode.attrib("model"); if (formString != "") { if (formString == "unity") { m_formGC = 0; @@ -953,10 +955,10 @@ namespace Cantera { * Get the Name of the Solvent: * solventName */ - string solventName = ""; + std::string solventName = ""; if (thermoNode.hasChild("solvent")) { XML_Node& scNode = thermoNode.child("solvent"); - vector nameSolventa; + std::vector nameSolventa; getStringArray(scNode, nameSolventa); int nsp = static_cast(nameSolventa.size()); if (nsp != 1) { @@ -971,15 +973,15 @@ namespace Cantera { * Reconcile the solvent name and index. */ for (int k = 0; k < m_kk; k++) { - string sname = speciesName(k); + std::string sname = speciesName(k); if (solventName == sname) { m_indexSolvent = k; break; } } if (m_indexSolvent == -1) { - cout << "IdealMolalSoln::initThermo: Solvent Name not found" - << endl; + std::cout << "IdealMolalSoln::initThermo: Solvent Name not found" + << std::endl; throw CanteraError("IdealMolalSoln::initThermo", "Solvent name not found"); } @@ -996,7 +998,7 @@ namespace Cantera { XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"], &phaseNode.root()); - const vector&sss = speciesNames(); + const std::vector &sss = speciesNames(); for (int k = 0; k < m_kk; k++) { XML_Node* s = speciesDB->findByAttr("name", sss[k]); @@ -1055,7 +1057,7 @@ namespace Cantera { * Bail out of functions with an error exit if they are not * implemented. */ - doublereal IdealMolalSoln::err(string msg) const { + doublereal IdealMolalSoln::err(std::string msg) const { throw CanteraError("IdealMolalSoln", "Unfinished func called: " + msg ); return 0.0; diff --git a/Cantera/src/thermo/IdealMolalSoln.h b/Cantera/src/thermo/IdealMolalSoln.h index 44f5ae2eb..b0e1a27f8 100644 --- a/Cantera/src/thermo/IdealMolalSoln.h +++ b/Cantera/src/thermo/IdealMolalSoln.h @@ -88,8 +88,8 @@ namespace Cantera { IdealMolalSoln(const IdealMolalSoln &); IdealMolalSoln& operator=(const IdealMolalSoln&); - IdealMolalSoln(string inputFile, string id = ""); - IdealMolalSoln(XML_Node& phaseRef, string id = ""); + IdealMolalSoln(std::string inputFile, std::string id = ""); + IdealMolalSoln(XML_Node& phaseRef, std::string id = ""); /// Destructor. virtual ~IdealMolalSoln(); @@ -725,7 +725,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - virtual void constructPhaseFile(string infile, string id=""); + virtual void constructPhaseFile(std::string infile, std::string id=""); /* * constructPhaseXML (virtual from here) @@ -745,7 +745,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - virtual void constructPhaseXML(XML_Node& phaseNode, string id); + virtual void constructPhaseXML(XML_Node& phaseNode, std::string id); /* * initThermoXML (virtual from ThermoPhase) @@ -766,7 +766,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - virtual void initThermoXML(XML_Node& phaseNode, string id=""); + virtual void initThermoXML(XML_Node& phaseNode, std::string id=""); /* * Report the molar volume of species k @@ -831,7 +831,7 @@ namespace Cantera { mutable vector_fp m_tmpV; private: - doublereal err(string msg) const; + doublereal err(std::string msg) const; void initLengths(); diff --git a/Cantera/src/thermo/IdealSolidSolnPhase.h b/Cantera/src/thermo/IdealSolidSolnPhase.h index 68485a2e5..e370c9ef9 100644 --- a/Cantera/src/thermo/IdealSolidSolnPhase.h +++ b/Cantera/src/thermo/IdealSolidSolnPhase.h @@ -107,7 +107,7 @@ namespace Cantera { * @param formCG This parameter initializes the m_formGC variable. The default * is a value of 0. */ - IdealSolidSolnPhase(string infile, string id="", int formCG=0); + IdealSolidSolnPhase(std::string infile, std::string id="", int formCG=0); /** @@ -133,7 +133,7 @@ namespace Cantera { * @param formCG This parameter initializes the m_formGC variable. The default * is a value of 0. */ - IdealSolidSolnPhase(XML_Node& root, string id="", int formCG=0); + IdealSolidSolnPhase(XML_Node& root, std::string id="", int formCG=0); /* * Copy Constructor @@ -827,7 +827,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - virtual void constructPhaseFile(string infile, string id=""); + virtual void constructPhaseFile(std::string infile, std::string id=""); /** * Import and initialize an IdealSolidSolnPhase phase @@ -854,7 +854,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - virtual void constructPhaseXML(XML_Node& phaseNode, string id=""); + virtual void constructPhaseXML(XML_Node& phaseNode, std::string id=""); /** * Initialization of an IdealSolidSolnPhase phase: @@ -889,7 +889,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - virtual void initThermoXML(XML_Node& phaseNode, string id); + virtual void initThermoXML(XML_Node& phaseNode, std::string id); /** diff --git a/Cantera/src/thermo/MolalityVPSSTP.cpp b/Cantera/src/thermo/MolalityVPSSTP.cpp index 5d428dd3e..9833e4cdc 100644 --- a/Cantera/src/thermo/MolalityVPSSTP.cpp +++ b/Cantera/src/thermo/MolalityVPSSTP.cpp @@ -18,7 +18,7 @@ #include "MolalityVPSSTP.h" - +using namespace std; namespace Cantera { diff --git a/Cantera/src/thermo/MolalityVPSSTP.h b/Cantera/src/thermo/MolalityVPSSTP.h index 9a8b08e89..64c14bdff 100644 --- a/Cantera/src/thermo/MolalityVPSSTP.h +++ b/Cantera/src/thermo/MolalityVPSSTP.h @@ -135,7 +135,7 @@ namespace Cantera { void setMolalities(const doublereal * const molal); void setMolalitiesByName(compositionMap& xMap); - void setMolalitiesByName(const string &); + void setMolalitiesByName(const std::string &); /** * @} @@ -436,7 +436,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - void initThermoXML(XML_Node& phaseNode, string id); + void initThermoXML(XML_Node& phaseNode, std::string id); /** * Set the temperature (K), pressure (Pa), and molalities @@ -449,7 +449,7 @@ namespace Cantera { void setState_TPM(doublereal t, doublereal p, compositionMap& m); /** Set the temperature (K), pressure (Pa), and molalities. */ - void setState_TPM(doublereal t, doublereal p, const string& m); + void setState_TPM(doublereal t, doublereal p, const std::string& m); private: void initLengths(); @@ -477,7 +477,7 @@ namespace Cantera { mutable vector_fp m_molalities; private: - doublereal err(string msg) const; + doublereal err(std::string msg) const; }; diff --git a/Cantera/src/thermo/PDSS.cpp b/Cantera/src/thermo/PDSS.cpp index a504f42b6..9544d5d19 100644 --- a/Cantera/src/thermo/PDSS.cpp +++ b/Cantera/src/thermo/PDSS.cpp @@ -18,7 +18,7 @@ #include "ctml.h" #include "PDSS.h" #include "importCTML.h" - +#include "SpeciesThermo.h" #include "ThermoPhase.h" @@ -31,31 +31,55 @@ namespace Cantera { m_temp(-1.0), m_dens(-1.0), m_tp(tp), + m_mw(0.0), m_spindex(spindex), - m_mw(0.0) + m_spthermo(0), + m_cp0_R_ptr(0), + m_h0_RT_ptr(0), + m_s0_R_ptr(0), + m_g0_RT_ptr(0) { constructPDSS(tp, spindex); + if (tp) { + m_spthermo = &(tp->speciesThermo()); + } } - PDSS::PDSS(ThermoPhase *tp, int spindex, string inputFile, string id) : + PDSS::PDSS(ThermoPhase *tp, int spindex, std::string inputFile, std::string id) : m_temp(-1.0), m_dens(-1.0), m_tp(tp), - m_spindex(spindex), - m_mw(0.0) + m_mw(0.0), + m_spindex(spindex), + m_spthermo(0), + m_cp0_R_ptr(0), + m_h0_RT_ptr(0), + m_s0_R_ptr(0), + m_g0_RT_ptr(0) { constructPDSSFile(tp, spindex, inputFile, id); + if (tp) { + m_spthermo = &(tp->speciesThermo()); + } } - PDSS::PDSS(ThermoPhase *tp, int spindex, XML_Node& phaseRoot, string id) : + PDSS::PDSS(ThermoPhase *tp, int spindex, XML_Node& phaseRoot, std::string id) : m_temp(-1.0), m_dens(-1.0), m_tp(0), + m_mw(0.0), m_spindex(0), - m_mw(0.0) + m_spthermo(0), + m_cp0_R_ptr(0), + m_h0_RT_ptr(0), + m_s0_R_ptr(0), + m_g0_RT_ptr(0) { + if (tp) { + m_spthermo = &(tp->speciesThermo()); + } constructPDSSXML(tp, spindex, phaseRoot, id) ; } @@ -64,8 +88,13 @@ namespace Cantera { m_temp(-1.0), m_dens(-1.0), m_tp(0), - m_spindex(0), - m_mw(b.m_mw) + m_mw(b.m_mw), + m_spindex(b.m_spindex), + m_spthermo(b.m_spthermo), + m_cp0_R_ptr(b.m_cp0_R_ptr), + m_h0_RT_ptr(b.m_h0_RT_ptr), + m_s0_R_ptr(b.m_s0_R_ptr), + m_g0_RT_ptr(b.m_g0_RT_ptr) { /* * Use the assignment operator to do the brunt @@ -81,9 +110,15 @@ namespace Cantera { if (&b == this) return *this; m_tp = b.m_tp; m_spindex = b.m_spindex; + m_spthermo = b.m_spthermo; m_temp = b.m_temp; m_dens = b.m_dens; m_mw = b.m_mw; + m_spthermo = b.m_spthermo; + m_cp0_R_ptr = b.m_cp0_R_ptr; + m_h0_RT_ptr = b.m_h0_RT_ptr; + m_s0_R_ptr = b.m_s0_R_ptr; + m_g0_RT_ptr = b.m_g0_RT_ptr; return *this; } @@ -112,7 +147,7 @@ namespace Cantera { * phase element will be used. */ void PDSS::constructPDSSXML(ThermoPhase *tp, int spindex, - XML_Node& phaseNode, string id) { + XML_Node& phaseNode, std::string id) { initThermo(); } @@ -134,14 +169,14 @@ namespace Cantera { * phase element will be used. */ void PDSS::constructPDSSFile(ThermoPhase *tp, int spindex, - string inputFile, string id) { + std::string inputFile, std::string id) { if (inputFile.size() == 0) { throw CanteraError("PDSS::initThermo", "input file is null"); } - string path = findInputFile(inputFile); - ifstream fin(path.c_str()); + std::string path = findInputFile(inputFile); + std::ifstream fin(path.c_str()); if (!fin) { throw CanteraError("PDSS::initThermo","could not open " +path+" for reading."); @@ -164,7 +199,7 @@ namespace Cantera { } void PDSS:: - initThermoXML(XML_Node& phaseNode, string id) { + initThermoXML(XML_Node& phaseNode, std::string id) { initThermo(); } @@ -177,11 +212,15 @@ namespace Cantera { /** * Return the molar enthalpy in units of J kmol-1 + * + * (NOTE: assumes that ThermoPhase Ref Polynomials are up-to-date) */ doublereal PDSS:: enthalpy_mole() const { - throw CanteraError("PDSS::enthalpy_mole()", "unimplemented"); - return (0.0); + //m_tp->_updateThermo(); + double m_temp = m_tp->temperature(); + double RT = GasConstant * m_temp; + return m_h0_RT_ptr[m_spindex] * RT; } /** diff --git a/Cantera/src/thermo/PDSS.h b/Cantera/src/thermo/PDSS.h index 097f42b40..820c84886 100644 --- a/Cantera/src/thermo/PDSS.h +++ b/Cantera/src/thermo/PDSS.h @@ -20,11 +20,13 @@ class XML_Node; class ThermoPhase; -class WaterPropsIAPWS; + class WaterPropsIAPWS; + namespace Cantera { - + class SpeciesThermo; + /** * Class for pressure dependent standard states. * @@ -40,8 +42,8 @@ namespace Cantera { PDSS(ThermoPhase *tp, int spindex); PDSS(const PDSS &b); PDSS& operator=(const PDSS&b); - PDSS(ThermoPhase *tp, int spindex, string inputFile, string id = ""); - PDSS(ThermoPhase *tp, int spindex, XML_Node& phaseRef, string id = ""); + PDSS(ThermoPhase *tp, int spindex, std::string inputFile, std::string id = ""); + PDSS(ThermoPhase *tp, int spindex, XML_Node& phaseRef, std::string id = ""); virtual ~PDSS(); /** @@ -123,10 +125,10 @@ namespace Cantera { virtual void constructPDSS(ThermoPhase *tp, int spindex); virtual void constructPDSSFile(ThermoPhase *tp, int spindex, - string inputFile, string id); + std::string inputFile, std::string id); virtual void constructPDSSXML(ThermoPhase *tp, int spindex, - XML_Node& phaseNode, string id); - virtual void initThermoXML(XML_Node& eosdata, string id); + XML_Node& phaseNode, std::string id); + virtual void initThermoXML(XML_Node& eosdata, std::string id); virtual void initThermo(); virtual void setParametersFromXML(const XML_Node& eosdata); @@ -153,15 +155,32 @@ namespace Cantera { */ ThermoPhase *m_tp; + + /** + * Molecular Weight of the species + */ + doublereal m_mw; + /** * Species index in the thermophase corresponding to this species. */ int m_spindex; /** - * Molecular Weight of the species + * Pointer to the species thermodynamic property manager. + * This is a copy of the pointer in the ThermoPhase object. + * Note, this object doesn't own the pointer. + * If the SpeciesThermo ThermoPhase object doesn't know + * or doesn't control the calculation, this will be + * set to zero. */ - doublereal m_mw; + SpeciesThermo* m_spthermo; + + doublereal *m_cp0_R_ptr; + doublereal *m_h0_RT_ptr; + doublereal *m_s0_R_ptr; + doublereal *m_g0_RT_ptr; + }; diff --git a/Cantera/src/thermo/SingleSpeciesTP.cpp b/Cantera/src/thermo/SingleSpeciesTP.cpp index 297e26070..0a80d9028 100644 --- a/Cantera/src/thermo/SingleSpeciesTP.cpp +++ b/Cantera/src/thermo/SingleSpeciesTP.cpp @@ -16,541 +16,543 @@ #include "SingleSpeciesTP.h" +using namespace std; + namespace Cantera { - /* - * -------------- Constructors ------------------------------------ - * - */ + /* + * -------------- Constructors ------------------------------------ + * + */ - /** - * SingleSpeciesTP(): - * - * Base constructor -> does nothing but called the inherited - * class constructor - */ - SingleSpeciesTP::SingleSpeciesTP() : - ThermoPhase(), - m_tmin(0.0), - m_tmax(0.0), - m_press(OneAtm), - m_p0(OneAtm), - m_tlast(-1.0) - { - } + /** + * SingleSpeciesTP(): + * + * Base constructor -> does nothing but called the inherited + * class constructor + */ + SingleSpeciesTP::SingleSpeciesTP() : + ThermoPhase(), + m_tmin(0.0), + m_tmax(0.0), + m_press(OneAtm), + m_p0(OneAtm), + m_tlast(-1.0) + { + } - /** - * ~SingleSpeciesTP(): - * - * destructor -> does nothing but implicitly calls the inherited - * class destructors. - */ - SingleSpeciesTP::~SingleSpeciesTP() - { - } - /** - * - * ------------------- Utilities ---------------------------------- - * - */ + /** + * ~SingleSpeciesTP(): + * + * destructor -> does nothing but implicitly calls the inherited + * class destructors. + */ + SingleSpeciesTP::~SingleSpeciesTP() + { + } + /** + * + * ------------------- Utilities ---------------------------------- + * + */ - /** - * eosType(): - * Creates an error because this is not a fully formed - * class - */ - int SingleSpeciesTP::eosType() const { - err("eosType"); - return -1; - } + /** + * eosType(): + * Creates an error because this is not a fully formed + * class + */ + int SingleSpeciesTP::eosType() const { + err("eosType"); + return -1; + } - /** - * ------------ Molar Thermodynamic Properties -------------------- - * - * - * For this single species template, the molar properties of - * the mixture are identified with the partial molar properties - * of species number 0. The partial molar property routines - * are called to evaluate these functions. - */ + /** + * ------------ Molar Thermodynamic Properties -------------------- + * + * + * For this single species template, the molar properties of + * the mixture are identified with the partial molar properties + * of species number 0. The partial molar property routines + * are called to evaluate these functions. + */ - /** - * enthalpy_mole(): - * - * Molar enthalpy. Units: J/kmol. - */ - doublereal SingleSpeciesTP::enthalpy_mole() const { - double hbar; - getPartialMolarEnthalpies(&hbar); - return hbar; - } + /** + * enthalpy_mole(): + * + * Molar enthalpy. Units: J/kmol. + */ + doublereal SingleSpeciesTP::enthalpy_mole() const { + double hbar; + getPartialMolarEnthalpies(&hbar); + return hbar; + } - /** - * enthalpy_mole(): - * - * Molar internal energy. Units: J/kmol. - */ - doublereal SingleSpeciesTP::intEnergy_mole() const { - double ubar; - getPartialMolarIntEnergies(&ubar); - return ubar; - } + /** + * enthalpy_mole(): + * + * Molar internal energy. Units: J/kmol. + */ + doublereal SingleSpeciesTP::intEnergy_mole() const { + double ubar; + getPartialMolarIntEnergies(&ubar); + return ubar; + } - /** - * entropy_mole(): - * - * Molar entropy of the mixture. Units: J/kmol/K. - */ - doublereal SingleSpeciesTP::entropy_mole() const { - double sbar; - getPartialMolarEntropies(&sbar); - return sbar; - } - - /** - * gibbs_mole(): - * - * Molar Gibbs free energy of the mixture. Units: J/kmol/K. - */ - doublereal SingleSpeciesTP::gibbs_mole() const { - double gbar; - /* - * Get the chemical potential of the first species. - * This is the same as the partial molar Gibbs - * free energy. - */ - getChemPotentials(&gbar); - return gbar; - } - - /** - * cp_mole(): - * - * Molar heat capacity at constant pressure of the mixture. - * Units: J/kmol/K. - */ - doublereal SingleSpeciesTP::cp_mole() const { - double cpbar; - /* - * Really should have a partial molar heat capacity - * function in ThermoPhase. However, the standard - * state heat capacity will do fine here for now. - */ - //getPartialMolarCp(&cpbar); - getCp_R(&cpbar); - cpbar *= GasConstant; - return cpbar; - } - - /** - * cv_mole(): - * - * Molar heat capacity at constant volume of the mixture. - * Units: J/kmol/K. - * - * For single species, we go directory to the - * general Cp - Cv relation - * - * Cp = Cv + alpha**2 * V * T / beta - * - * where - * alpha = volume thermal expansion coefficient - * beta = isothermal compressibility - */ - doublereal SingleSpeciesTP::cv_mole() const { - doublereal cvbar = cp_mole(); - doublereal alpha = thermalExpansionCoeff(); - doublereal beta = isothermalCompressibility(); - doublereal molecW = molecularWeight(0); - doublereal V = molecW/density(); - doublereal T = temperature(); - if (beta != 0.0) { - cvbar -= alpha * alpha * V * T / beta; - } - return cvbar; - } + /** + * entropy_mole(): + * + * Molar entropy of the mixture. Units: J/kmol/K. + */ + doublereal SingleSpeciesTP::entropy_mole() const { + double sbar; + getPartialMolarEntropies(&sbar); + return sbar; + } + /** + * gibbs_mole(): + * + * Molar Gibbs free energy of the mixture. Units: J/kmol/K. + */ + doublereal SingleSpeciesTP::gibbs_mole() const { + double gbar; /* - * ----------- Chemical Potentials and Activities ---------------------- + * Get the chemical potential of the first species. + * This is the same as the partial molar Gibbs + * free energy. */ + getChemPotentials(&gbar); + return gbar; + } + /** + * cp_mole(): + * + * Molar heat capacity at constant pressure of the mixture. + * Units: J/kmol/K. + */ + doublereal SingleSpeciesTP::cp_mole() const { + double cpbar; /* - * ----------- Partial Molar Properties of the Solution ----------------- - * - * These are calculated by reference to the standard state properties - * of the zeroeth species. + * Really should have a partial molar heat capacity + * function in ThermoPhase. However, the standard + * state heat capacity will do fine here for now. */ + //getPartialMolarCp(&cpbar); + getCp_R(&cpbar); + cpbar *= GasConstant; + return cpbar; + } - /** - * Get the array of chemical potentials at unit activity - * These are the standard state chemical potentials. - * \f$ \mu^0_k \f$. - */ - void SingleSpeciesTP::getChemPotentials(doublereal* mu) const { - getStandardChemPotentials(mu); + /** + * cv_mole(): + * + * Molar heat capacity at constant volume of the mixture. + * Units: J/kmol/K. + * + * For single species, we go directory to the + * general Cp - Cv relation + * + * Cp = Cv + alpha**2 * V * T / beta + * + * where + * alpha = volume thermal expansion coefficient + * beta = isothermal compressibility + */ + doublereal SingleSpeciesTP::cv_mole() const { + doublereal cvbar = cp_mole(); + doublereal alpha = thermalExpansionCoeff(); + doublereal beta = isothermalCompressibility(); + doublereal molecW = molecularWeight(0); + doublereal V = molecW/density(); + doublereal T = temperature(); + if (beta != 0.0) { + cvbar -= alpha * alpha * V * T / beta; } + return cvbar; + } - /** - * Get the array of non-dimensional species chemical potentials - * These are partial molar Gibbs free energies. - * \f$ \mu_k / \hat R T \f$. - * Units: unitless - */ - void SingleSpeciesTP::getChemPotentials_RT(doublereal* murt) const { - getStandardChemPotentials(murt); - double rt = GasConstant * temperature(); - murt[0] /= rt; - } + /* + * ----------- Chemical Potentials and Activities ---------------------- + */ - /** - * Get the species electrochemical potentials. Units: J/kmol. - * This method adds a term \f$ Fz_k \phi_k \f$ to - * each chemical potential. - * - * This is resolved here. A single single species phase - * is not allowed to have anything other than a zero - * charge. - */ - void SingleSpeciesTP::getElectrochemPotentials(doublereal* mu) const { - getChemPotentials(mu); - } + /* + * ----------- Partial Molar Properties of the Solution ----------------- + * + * These are calculated by reference to the standard state properties + * of the zeroeth species. + */ - /** - * Get the species partial molar enthalpies. Units: J/kmol. - */ - void SingleSpeciesTP:: - getPartialMolarEnthalpies(doublereal* hbar) const { - double _rt = GasConstant * temperature(); - getEnthalpy_RT(hbar); - hbar[0] *= _rt; - } + /** + * Get the array of chemical potentials at unit activity + * These are the standard state chemical potentials. + * \f$ \mu^0_k \f$. + */ + void SingleSpeciesTP::getChemPotentials(doublereal* mu) const { + getStandardChemPotentials(mu); + } - /** - * Get the species partial molar internal energies. Units: J/kmol. - */ - void SingleSpeciesTP:: - getPartialMolarIntEnergies(doublereal* ubar) const { - double _rt = GasConstant * temperature(); - getIntEnergy_RT(ubar); - ubar[0] *= _rt; - } + /** + * Get the array of non-dimensional species chemical potentials + * These are partial molar Gibbs free energies. + * \f$ \mu_k / \hat R T \f$. + * Units: unitless + */ + void SingleSpeciesTP::getChemPotentials_RT(doublereal* murt) const { + getStandardChemPotentials(murt); + double rt = GasConstant * temperature(); + murt[0] /= rt; + } - /** - * Get the species partial molar entropy. Units: J/kmol K. - */ - void SingleSpeciesTP:: - getPartialMolarEntropies(doublereal* sbar) const { - getEntropy_R(sbar); - sbar[0] *= GasConstant; - } + /** + * Get the species electrochemical potentials. Units: J/kmol. + * This method adds a term \f$ Fz_k \phi_k \f$ to + * each chemical potential. + * + * This is resolved here. A single single species phase + * is not allowed to have anything other than a zero + * charge. + */ + void SingleSpeciesTP::getElectrochemPotentials(doublereal* mu) const { + getChemPotentials(mu); + } - /** - * Get the species partial molar volumes. Units: m^3/kmol. - */ - void SingleSpeciesTP::getPartialMolarVolumes(doublereal* vbar) const { - double mw = molecularWeight(0); - double dens = density(); - vbar[0] = mw / dens; - } + /** + * Get the species partial molar enthalpies. Units: J/kmol. + */ + void SingleSpeciesTP:: + getPartialMolarEnthalpies(doublereal* hbar) const { + double _rt = GasConstant * temperature(); + getEnthalpy_RT(hbar); + hbar[0] *= _rt; + } - /* - * ----- Properties of the Standard State of the Species in the Solution - * ----- - */ + /** + * Get the species partial molar internal energies. Units: J/kmol. + */ + void SingleSpeciesTP:: + getPartialMolarIntEnergies(doublereal* ubar) const { + double _rt = GasConstant * temperature(); + getIntEnergy_RT(ubar); + ubar[0] *= _rt; + } - /** - * Get the dimensional Gibbs functions for the standard - * state of the species at the current T and P. - */ - void SingleSpeciesTP::getPureGibbs(doublereal* gpure) const { - getGibbs_RT(gpure); - gpure[0] *= GasConstant * temperature(); - } + /** + * Get the species partial molar entropy. Units: J/kmol K. + */ + void SingleSpeciesTP:: + getPartialMolarEntropies(doublereal* sbar) const { + getEntropy_R(sbar); + sbar[0] *= GasConstant; + } - /** - * Get the molar volumes of each species in their standard - * states at the current - * T and P of the solution. - * units = m^3 / kmol - * - * We resolve this function at this level, by assigning - * the molec weight divided by the phase density - */ - void SingleSpeciesTP::getStandardVolumes(doublereal* vbar) const { - double mw = molecularWeight(0); - double dens = density(); - vbar[0] = mw / dens; - } + /** + * Get the species partial molar volumes. Units: m^3/kmol. + */ + void SingleSpeciesTP::getPartialMolarVolumes(doublereal* vbar) const { + double mw = molecularWeight(0); + double dens = density(); + vbar[0] = mw / dens; + } - /* - * ---- Thermodynamic Values for the Species Reference States ------- - */ + /* + * ----- Properties of the Standard State of the Species in the Solution + * ----- + */ + + /** + * Get the dimensional Gibbs functions for the standard + * state of the species at the current T and P. + */ + void SingleSpeciesTP::getPureGibbs(doublereal* gpure) const { + getGibbs_RT(gpure); + gpure[0] *= GasConstant * temperature(); + } + + /** + * Get the molar volumes of each species in their standard + * states at the current + * T and P of the solution. + * units = m^3 / kmol + * + * We resolve this function at this level, by assigning + * the molec weight divided by the phase density + */ + void SingleSpeciesTP::getStandardVolumes(doublereal* vbar) const { + double mw = molecularWeight(0); + double dens = density(); + vbar[0] = mw / dens; + } + + /* + * ---- 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. - * - * - */ - void SingleSpeciesTP::getEnthalpy_RT_ref(doublereal *hrt) const { - _updateThermo(); - hrt[0] = m_h0_RT[0]; - } + /** + * Returns the vector of nondimensional + * enthalpies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + * + * + */ + void SingleSpeciesTP::getEnthalpy_RT_ref(doublereal *hrt) const { + _updateThermo(); + hrt[0] = m_h0_RT[0]; + } - /** - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - */ - void SingleSpeciesTP::getGibbs_RT_ref(doublereal *grt) const { - _updateThermo(); - grt[0] = m_h0_RT[0] - m_s0_R[0]; - } + /** + * Returns the vector of nondimensional + * enthalpies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + void SingleSpeciesTP::getGibbs_RT_ref(doublereal *grt) const { + _updateThermo(); + grt[0] = m_h0_RT[0] - m_s0_R[0]; + } - /** - * Returns the vector of the - * gibbs function of the reference state at the current temperature - * of the solution and the reference pressure for the species. - * units = J/kmol - */ - void SingleSpeciesTP::getGibbs_ref(doublereal *g) const { - getGibbs_RT_ref(g); - g[0] *= GasConstant * temperature(); - } + /** + * Returns the vector of the + * gibbs function of the reference state at the current temperature + * of the solution and the reference pressure for the species. + * units = J/kmol + */ + void SingleSpeciesTP::getGibbs_ref(doublereal *g) const { + getGibbs_RT_ref(g); + g[0] *= GasConstant * temperature(); + } - /** - * Returns the vector of nondimensional - * entropies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - */ - void SingleSpeciesTP::getEntropy_R_ref(doublereal *er) const { - _updateThermo(); - er[0] = m_s0_R[0]; - } + /** + * Returns the vector of nondimensional + * entropies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + void SingleSpeciesTP::getEntropy_R_ref(doublereal *er) const { + _updateThermo(); + er[0] = m_s0_R[0]; + } - /** - * Get the nondimensional Gibbs functions for the standard - * state of the species at the current T and reference pressure - * for the species. - */ - void SingleSpeciesTP::getCp_R_ref(doublereal* cpr) const { - _updateThermo(); - cpr[0] = m_cp0_R[0]; - } + /** + * Get the nondimensional Gibbs functions for the standard + * state of the species at the current T and reference pressure + * for the species. + */ + void SingleSpeciesTP::getCp_R_ref(doublereal* cpr) const { + _updateThermo(); + cpr[0] = m_cp0_R[0]; + } - /* - * ------------------ Setting the State ------------------------ - */ + /* + * ------------------ Setting the State ------------------------ + */ - void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p, - const doublereal* x) { - setTemperature(t); setPressure(p); - } + void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p, + const doublereal* x) { + setTemperature(t); setPressure(p); + } - void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p, - compositionMap& x) { - setTemperature(t); setPressure(p); - } + void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p, + compositionMap& x) { + setTemperature(t); setPressure(p); + } - void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p, - const string& x) { - setTemperature(t); setPressure(p); - } + void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p, + const string& x) { + setTemperature(t); setPressure(p); + } - void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p, - const doublereal* y) { - setTemperature(t); setPressure(p); - } + void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p, + const doublereal* y) { + setTemperature(t); setPressure(p); + } - void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p, - compositionMap& y) { - setTemperature(t); setPressure(p); - } + void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p, + compositionMap& y) { + setTemperature(t); setPressure(p); + } - void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p, - const string& y) { - setTemperature(t); setPressure(p); - } + void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p, + const string& y) { + setTemperature(t); setPressure(p); + } - void SingleSpeciesTP::setState_PX(doublereal p, doublereal* x) { - if (x[0] != 1.0) { - err("setStatePX -> x[0] not 1.0"); - } - setPressure(p); + void SingleSpeciesTP::setState_PX(doublereal p, doublereal* x) { + if (x[0] != 1.0) { + err("setStatePX -> x[0] not 1.0"); } + setPressure(p); + } - void SingleSpeciesTP::setState_PY(doublereal p, doublereal* y) { - if (y[0] != 1.0) { - err("setStatePY -> x[0] not 1.0"); - } - setMassFractions(y); setPressure(p); + void SingleSpeciesTP::setState_PY(doublereal p, doublereal* y) { + if (y[0] != 1.0) { + err("setStatePY -> x[0] not 1.0"); } + setMassFractions(y); setPressure(p); + } - void SingleSpeciesTP::setState_HP(doublereal h, doublereal p, - doublereal tol) { - doublereal dt; - setPressure(p); - for (int n = 0; n < 50; n++) { - dt = (h - enthalpy_mass())/cp_mass(); - if (dt > 100.0) dt = 100.0; - else if (dt < -100.0) dt = -100.0; - setState_TP(temperature() + dt, p); - if (fabs(dt) < tol) { - return; - } - } - throw CanteraError("setState_HP","no convergence. dt = " + fp2str(dt)); + void SingleSpeciesTP::setState_HP(doublereal h, doublereal p, + doublereal tol) { + doublereal dt; + setPressure(p); + for (int n = 0; n < 50; n++) { + dt = (h - enthalpy_mass())/cp_mass(); + if (dt > 100.0) dt = 100.0; + else if (dt < -100.0) dt = -100.0; + setState_TP(temperature() + dt, p); + if (fabs(dt) < tol) { + return; + } } + throw CanteraError("setState_HP","no convergence. dt = " + fp2str(dt)); + } - void SingleSpeciesTP::setState_UV(doublereal u, doublereal v, - doublereal tol) { - doublereal dt; - setDensity(1.0/v); - for (int n = 0; n < 50; n++) { - dt = (u - intEnergy_mass())/cv_mass(); - if (dt > 100.0) dt = 100.0; - else if (dt < -100.0) dt = -100.0; - setTemperature(temperature() + dt); - if (fabs(dt) < tol) { - return; - } - } - throw CanteraError("setState_UV", - "no convergence. dt = " + fp2str(dt)+"\n" - +"u = "+fp2str(u)+" v = "+fp2str(v)+"\n"); + void SingleSpeciesTP::setState_UV(doublereal u, doublereal v, + doublereal tol) { + doublereal dt; + setDensity(1.0/v); + for (int n = 0; n < 50; n++) { + dt = (u - intEnergy_mass())/cv_mass(); + if (dt > 100.0) dt = 100.0; + else if (dt < -100.0) dt = -100.0; + setTemperature(temperature() + dt); + if (fabs(dt) < tol) { + return; + } } + throw CanteraError("setState_UV", + "no convergence. dt = " + fp2str(dt)+"\n" + +"u = "+fp2str(u)+" v = "+fp2str(v)+"\n"); + } - void SingleSpeciesTP::setState_SP(doublereal s, doublereal p, - doublereal tol) { - doublereal dt; - setPressure(p); - for (int n = 0; n < 50; n++) { - dt = (s - entropy_mass())*temperature()/cp_mass(); - if (dt > 100.0) dt = 100.0; - else if (dt < -100.0) dt = -100.0; - setState_TP(temperature() + dt, p); - if (fabs(dt) < tol) { - return; - } - } - throw CanteraError("setState_SP","no convergence. dt = " + fp2str(dt)); + void SingleSpeciesTP::setState_SP(doublereal s, doublereal p, + doublereal tol) { + doublereal dt; + setPressure(p); + for (int n = 0; n < 50; n++) { + dt = (s - entropy_mass())*temperature()/cp_mass(); + if (dt > 100.0) dt = 100.0; + else if (dt < -100.0) dt = -100.0; + setState_TP(temperature() + dt, p); + if (fabs(dt) < tol) { + return; + } } + throw CanteraError("setState_SP","no convergence. dt = " + fp2str(dt)); + } - void SingleSpeciesTP::setState_SV(doublereal s, doublereal v, - doublereal tol) { - doublereal dt; - setDensity(1.0/v); - for (int n = 0; n < 50; n++) { - dt = (s - entropy_mass())*temperature()/cv_mass(); - if (dt > 100.0) dt = 100.0; - else if (dt < -100.0) dt = -100.0; - setTemperature(temperature() + dt); - if (fabs(dt) < tol) { - return; - } - } - throw CanteraError("setState_SV","no convergence. dt = " + fp2str(dt)); + void SingleSpeciesTP::setState_SV(doublereal s, doublereal v, + doublereal tol) { + doublereal dt; + setDensity(1.0/v); + for (int n = 0; n < 50; n++) { + dt = (s - entropy_mass())*temperature()/cv_mass(); + if (dt > 100.0) dt = 100.0; + else if (dt < -100.0) dt = -100.0; + setTemperature(temperature() + dt); + if (fabs(dt) < tol) { + return; + } } + throw CanteraError("setState_SV","no convergence. dt = " + fp2str(dt)); + } - /** - * This private function throws a cantera exception. It's used when - * this class doesn't have an answer for the question given to it, - * because the derived class isn't overriding a function. + /** + * This private function throws a cantera exception. It's used when + * this class doesn't have an answer for the question given to it, + * because the derived class isn't overriding a function. + */ + doublereal SingleSpeciesTP::err(string msg) const { + throw CanteraError("SingleSpeciesTP","Base class method " + +msg+" called. Equation of state type: " + +int2str(eosType())); + return 0; + } + + /** + * Returns the units of the standard and general concentrations + * Note they have the same units, as their divisor is + * defined to be equal to the activity of the kth species + * in the solution, which is unitless. + * + * This routine is used in print out applications where the + * units are needed. Usually, MKS units are assumed throughout + * the program and in the XML input files. + * + * On return uA contains the powers of the units (MKS assumed) + * of the standard concentrations and generalized concentrations + * for the kth species. + * + * uA[0] = kmol units - default = 1 + * uA[1] = m units - default = -nDim(), the number of spatial + * dimensions in the Phase class. + * uA[2] = kg units - default = 0; + * uA[3] = Pa(pressure) units - default = 0; + * uA[4] = Temperature units - default = 0; + * uA[5] = time units - default = 0 + */ + void SingleSpeciesTP::getUnitsStandardConc(double *uA, int k, int sizeUA) { + for (int i = 0; i < sizeUA; i++) { + if (i == 0) uA[0] = 1.0; + if (i == 1) uA[1] = -nDim(); + if (i == 2) uA[2] = 0.0; + if (i == 3) uA[3] = 0.0; + if (i == 4) uA[4] = 0.0; + if (i == 5) uA[5] = 0.0; + } + } + + /** + * @internal Initialize. This method is provided to allow + * subclasses to perform any initialization required after all + * species have been added. For example, it might be used to + * resize internal work arrays that must have an entry for + * each species. The base class implementation does nothing, + * and subclasses that do not require initialization do not + * need to overload this method. When importing a CTML phase + * description, this method is called just prior to returning + * from function importPhase. + * + * Inheriting objects should call this function + * + * @see importCTML.cpp + */ + void SingleSpeciesTP::initThermo() { + /* + * Check to make sure that there is one and only one species + * in this phase. */ - doublereal SingleSpeciesTP::err(string msg) const { - throw CanteraError("SingleSpeciesTP","Base class method " - +msg+" called. Equation of state type: " - +int2str(eosType())); - return 0; + if (m_kk != 1) { + err("singleSpeciesTP ERROR m_kk != 1"); } - - /** - * Returns the units of the standard and general concentrations - * Note they have the same units, as their divisor is - * defined to be equal to the activity of the kth species - * in the solution, which is unitless. - * - * This routine is used in print out applications where the - * units are needed. Usually, MKS units are assumed throughout - * the program and in the XML input files. - * - * On return uA contains the powers of the units (MKS assumed) - * of the standard concentrations and generalized concentrations - * for the kth species. - * - * uA[0] = kmol units - default = 1 - * uA[1] = m units - default = -nDim(), the number of spatial - * dimensions in the Phase class. - * uA[2] = kg units - default = 0; - * uA[3] = Pa(pressure) units - default = 0; - * uA[4] = Temperature units - default = 0; - * uA[5] = time units - default = 0 + /* + * Make sure the species mole fraction is equal to 1.0; */ - void SingleSpeciesTP::getUnitsStandardConc(double *uA, int k, int sizeUA) { - for (int i = 0; i < sizeUA; i++) { - if (i == 0) uA[0] = 1.0; - if (i == 1) uA[1] = -nDim(); - if (i == 2) uA[2] = 0.0; - if (i == 3) uA[3] = 0.0; - if (i == 4) uA[4] = 0.0; - if (i == 5) uA[5] = 0.0; - } - } - - /** - * @internal Initialize. This method is provided to allow - * subclasses to perform any initialization required after all - * species have been added. For example, it might be used to - * resize internal work arrays that must have an entry for - * each species. The base class implementation does nothing, - * and subclasses that do not require initialization do not - * need to overload this method. When importing a CTML phase - * description, this method is called just prior to returning - * from function importPhase. - * - * Inheriting objects should call this function - * - * @see importCTML.cpp + double x = 1.0; + setMoleFractions(&x); + /* + * Call the base class initThermo object. */ - void SingleSpeciesTP::initThermo() { - /* - * Check to make sure that there is one and only one species - * in this phase. - */ - if (m_kk != 1) { - err("singleSpeciesTP ERROR m_kk != 1"); - } - /* - * Make sure the species mole fraction is equal to 1.0; - */ - double x = 1.0; - setMoleFractions(&x); - /* - * Call the base class initThermo object. - */ - ThermoPhase::initThermo(); - } + ThermoPhase::initThermo(); + } - /** - * _updateThermo(): - * - * This crucial internal routine calls the species thermo - * update program to calculate new species Cp0, H0, and - * S0 whenever the temperature has changed. - */ - void SingleSpeciesTP::_updateThermo() const { - doublereal tnow = temperature(); - if (m_tlast != tnow) { - m_spthermo->update(tnow, DATA_PTR(m_cp0_R), DATA_PTR(m_h0_RT), - DATA_PTR(m_s0_R)); - m_tlast = tnow; - } + /** + * _updateThermo(): + * + * This crucial internal routine calls the species thermo + * update program to calculate new species Cp0, H0, and + * S0 whenever the temperature has changed. + */ + void SingleSpeciesTP::_updateThermo() const { + doublereal tnow = temperature(); + if (m_tlast != tnow) { + m_spthermo->update(tnow, DATA_PTR(m_cp0_R), DATA_PTR(m_h0_RT), + DATA_PTR(m_s0_R)); + m_tlast = tnow; } + } } diff --git a/Cantera/src/thermo/SingleSpeciesTP.h b/Cantera/src/thermo/SingleSpeciesTP.h index 9029fea6e..b81a4d2db 100644 --- a/Cantera/src/thermo/SingleSpeciesTP.h +++ b/Cantera/src/thermo/SingleSpeciesTP.h @@ -27,636 +27,636 @@ namespace Cantera { + /** + * @ingroup thermoprops + * + * The SingleSpeciesTP class is a filter class for ThermoPhase. + * What it does is to simplify the construction of ThermoPhase + * objects by assuming that the phase consists of one and + * only one type of species. In other words, it's a stoichiometric + * phase. However, no assumptions are made concerning the + * thermodynamic functions or the equation of state of the + * phase. Therefore it's an incomplete description of + * the thermodynamics. The complete description must be + * made in a derived class of SingleSpeciesTP. + * \nosubgrouping + */ + class SingleSpeciesTP : public ThermoPhase { + + public: + + /// Constructor. + SingleSpeciesTP(); + + /// Destructor + virtual ~SingleSpeciesTP(); + /** - * @ingroup thermoprops - * - * The SingleSpeciesTP class is a filter class for ThermoPhase. - * What it does is to simplify the construction of ThermoPhase - * objects by assuming that the phase consists of one and - * only one type of species. In other words, it's a stoichiometric - * phase. However, no assumptions are made concerning the - * thermodynamic functions or the equation of state of the - * phase. Therefore it's an incomplete description of - * the thermodynamics. The complete description must be - * made in a derived class of SingleSpeciesTP. - * \nosubgrouping + * + * @name Information Methods + * @{ */ - class SingleSpeciesTP : public ThermoPhase { - public: - - /// Constructor. - SingleSpeciesTP(); + /** + * Returns the equation of state type flag. + * This is a modified base class. + * Therefore, if not overridden in derivied classes, + * this call will throw an exception. + */ + virtual int eosType() const; - /// Destructor - virtual ~SingleSpeciesTP(); + /** + * @} + * @name Molar Thermodynamic Properties of the Solution + * + * These functions are resolved at this level, by reference + * to the partial molar functions and standard state + * functions for species 0. Derived classes don't need + * to supply entries for these functions. + * @{ + */ - /** - * - * @name Information Methods - * @{ - */ + /// Molar enthalpy. Units: J/kmol. + doublereal enthalpy_mole() const; - /** - * Returns the equation of state type flag. - * This is a modified base class. - * Therefore, if not overridden in derivied classes, - * this call will throw an exception. - */ - virtual int eosType() const; + /// Molar internal energy. Units: J/kmol. + doublereal intEnergy_mole() const; - /** - * @} - * @name Molar Thermodynamic Properties of the Solution - * - * These functions are resolved at this level, by reference - * to the partial molar functions and standard state - * functions for species 0. Derived classes don't need - * to supply entries for these functions. - * @{ - */ + /// Molar entropy. Units: J/kmol/K. + doublereal entropy_mole() const; - /// Molar enthalpy. Units: J/kmol. - doublereal enthalpy_mole() const; + /// Molar Gibbs function. Units: J/kmol. + doublereal gibbs_mole() const; - /// Molar internal energy. Units: J/kmol. - doublereal intEnergy_mole() const; + /// Molar heat capacity at constant pressure. Units: J/kmol/K. + doublereal cp_mole() const; - /// Molar entropy. Units: J/kmol/K. - doublereal entropy_mole() const; + /// Molar heat capacity at constant volume. Units: J/kmol/K. + doublereal cv_mole() const; - /// Molar Gibbs function. Units: J/kmol. - doublereal gibbs_mole() const; + /** + * @} + * @name Mechanical Properties + * @{ + */ - /// Molar heat capacity at constant pressure. Units: J/kmol/K. - doublereal cp_mole() const; + /** + * Pressure. Return the thermodynamic pressure (Pa). This + * method must be reimplemented in derived classes. + * Since the mass density, temperature, and mass fractions + * are stored, this method should use these + * values to implement the mechanical equation of state + * \f$ P(T, \rho, Y_1, \dots, Y_K) \f$. + */ + virtual doublereal pressure() const { + return err("pressure"); + } - /// Molar heat capacity at constant volume. Units: J/kmol/K. - doublereal cv_mole() const; + /** + * Set the pressure. + * Sets the thermodynamic pressure -> must be reimplemented + * in derived classes. Units: Pa. + */ + virtual void setPressure(doublereal p) { + err("setPressure"); + } - /** - * @} - * @name Mechanical Properties - * @{ - */ + /** + * The isothermal compressibility. Units: 1/Pa. + * The isothermal compressibility is defined as + * \f[ + * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T + * \f] + */ + virtual doublereal isothermalCompressibility() const { + err("isothermalCompressibility"); return -1.0; + } - /** - * Pressure. Return the thermodynamic pressure (Pa). This - * method must be reimplemented in derived classes. - * Since the mass density, temperature, and mass fractions - * are stored, this method should use these - * values to implement the mechanical equation of state - * \f$ P(T, \rho, Y_1, \dots, Y_K) \f$. - */ - virtual doublereal pressure() const { - return err("pressure"); - } + /** + * The thermal expansion coefficient. Units: 1/K. + * The thermal expansion coefficient is defined as + * + * \f[ + * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P + * \f] + */ + virtual doublereal thermalExpansionCoeff() const { + err("thermalExpansionCoeff()"); return -1.0; + } - /** - * Set the pressure. - * Sets the thermodynamic pressure -> must be reimplemented - * in derived classes. Units: Pa. - */ - virtual void setPressure(doublereal p) { - err("setPressure"); - } + /** + * @} + * @name Electric Potential + * + * The phase may be at some non-zero electrical + * potential. These methods set or get the value of the + * electric potential. + */ + //@{ - /** - * The isothermal compressibility. Units: 1/Pa. - * The isothermal compressibility is defined as - * \f[ - * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T - * \f] - */ - virtual doublereal isothermalCompressibility() const { - err("isothermalCompressibility"); return -1.0; - } + /** + * @} + * @name Potential Energy + * + * Species may have an additional potential energy due to the + * presence of external gravitation or electric fields. These + * methods allow specifying a potential energy for individual + * species. + * @{ + */ - /** - * The thermal expansion coefficient. Units: 1/K. - * The thermal expansion coefficient is defined as - * - * \f[ - * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P - * \f] - */ - virtual doublereal thermalExpansionCoeff() const { - err("thermalExpansionCoeff()"); return -1.0; - } + /** + * Set the potential energy of species k to pe. + * Units: J/kmol. + * This function must be reimplemented in inherited classes + * of ThermoPhase. + */ + virtual void setPotentialEnergy(int k, doublereal pe) { + err("setPotentialEnergy"); + } - /** - * @} - * @name Electric Potential - * - * The phase may be at some non-zero electrical - * potential. These methods set or get the value of the - * electric potential. - */ - //@{ + /** + * Get the potential energy of species k. + * Units: J/kmol. + * This function must be reimplemented in inherited classes + * of ThermoPhase. + */ + virtual doublereal potentialEnergy(int k) const { + return err("potentialEnergy"); + } - /** - * @} - * @name Potential Energy - * - * Species may have an additional potential energy due to the - * presence of external gravitation or electric fields. These - * methods allow specifying a potential energy for individual - * species. - * @{ - */ + /** + * @} + * @name Activities, Standard State, and Activity Concentrations + * + * The activity \f$a_k\f$ of a species in solution is + * related to the chemical potential by \f[ \mu_k = \mu_k^0(T) + * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T)\f$ is + * the chemical potential at unit activity, which depends only + * on temperature. + * @{ + */ - /** - * Set the potential energy of species k to pe. - * Units: J/kmol. - * This function must be reimplemented in inherited classes - * of ThermoPhase. - */ - virtual void setPotentialEnergy(int k, doublereal pe) { - err("setPotentialEnergy"); - } + /** + * This method returns an array of generalized concentrations + * \f$ C_k\f$ that are defined such that + * \f$ a_k = C_k / C^0_k, \f$ where \f$ C^0_k \f$ + * is a standard concentration + * defined below. These generalized concentrations are used + * by kinetics manager classes to compute the forward and + * reverse rates of elementary reactions. + * + * @param c Array of generalized concentrations. The + * units depend upon the implementation of the + * reaction rate expressions within the phase. + */ + virtual void getActivityConcentrations(doublereal* c) const { + err("getActivityConcentrations"); + } - /** - * Get the potential energy of species k. - * Units: J/kmol. - * This function must be reimplemented in inherited classes - * of ThermoPhase. - */ - virtual doublereal potentialEnergy(int k) const { - return err("potentialEnergy"); - } + /** + * The standard concentration \f$ C^0_k \f$ used to normalize + * the generalized concentration. In many cases, this quantity + * will be the same for all species in a phase - for example, + * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this + * reason, this method returns a single value, instead of an + * array. However, for phases in which the standard + * concentration is species-specific (e.g. surface species of + * different sizes), this method may be called with an + * optional parameter indicating the species. + */ + virtual doublereal standardConcentration(int k=0) const { + err("standardConcentration"); + return -1.0; + } - /** - * @} - * @name Activities, Standard State, and Activity Concentrations - * - * The activity \f$a_k\f$ of a species in solution is - * related to the chemical potential by \f[ \mu_k = \mu_k^0(T) - * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T)\f$ is - * the chemical potential at unit activity, which depends only - * on temperature. - * @{ - */ + /** + * Returns the natural logarithm of the standard + * concentration of the kth species + */ + virtual doublereal logStandardConc(int k=0) const { + err("logStandardConc"); + return -1.0; + } - /** - * This method returns an array of generalized concentrations - * \f$ C_k\f$ that are defined such that - * \f$ a_k = C_k / C^0_k, \f$ where \f$ C^0_k \f$ - * is a standard concentration - * defined below. These generalized concentrations are used - * by kinetics manager classes to compute the forward and - * reverse rates of elementary reactions. - * - * @param c Array of generalized concentrations. The - * units depend upon the implementation of the - * reaction rate expressions within the phase. - */ - virtual void getActivityConcentrations(doublereal* c) const { - err("getActivityConcentrations"); - } + /** + * Returns the units of the standard and generalized + * concentrations Note they have the same units, as their + * ratio is defined to be equal to the activity of the kth + * species in the solution, which is unitless. + * + * This routine is used in print out applications where the + * units are needed. Usually, MKS units are assumed throughout + * the program and in the XML input files. + * + * uA[0] = kmol units - default = 1 + * uA[1] = m units - default = -nDim(), the number of spatial + * dimensions in the Phase class. + * uA[2] = kg units - default = 0; + * uA[3] = Pa(pressure) units - default = 0; + * uA[4] = Temperature units - default = 0; + * uA[5] = time units - default = 0 + */ + virtual void getUnitsStandardConc(double *uA, int k = 0, + int sizeUA = 6); - /** - * The standard concentration \f$ C^0_k \f$ used to normalize - * the generalized concentration. In many cases, this quantity - * will be the same for all species in a phase - for example, - * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this - * reason, this method returns a single value, instead of an - * array. However, for phases in which the standard - * concentration is species-specific (e.g. surface species of - * different sizes), this method may be called with an - * optional parameter indicating the species. - */ - virtual doublereal standardConcentration(int k=0) const { - err("standardConcentration"); - return -1.0; - } + /** + * Get the array of non-dimensional activities at + * the current solution temperature, pressure, and + * solution concentration. + * + * We redefine this function to just return 1.0 here. + */ + virtual void getActivities(doublereal* a) { + a[0] = 1.0; + } - /** - * Returns the natural logarithm of the standard - * concentration of the kth species - */ - virtual doublereal logStandardConc(int k=0) const { - err("logStandardConc"); - return -1.0; - } + /** + * Get the array of non-dimensional activity coefficients at + * the current solution temperature, pressure, and + * solution concentration. + */ + virtual void getActivityCoefficients(doublereal* ac) const { + if (m_kk == 1) { + ac[0] = 1.0; + } else { + err("getActivityCoefficients"); + } + } - /** - * Returns the units of the standard and generalized - * concentrations Note they have the same units, as their - * ratio is defined to be equal to the activity of the kth - * species in the solution, which is unitless. - * - * This routine is used in print out applications where the - * units are needed. Usually, MKS units are assumed throughout - * the program and in the XML input files. - * - * uA[0] = kmol units - default = 1 - * uA[1] = m units - default = -nDim(), the number of spatial - * dimensions in the Phase class. - * uA[2] = kg units - default = 0; - * uA[3] = Pa(pressure) units - default = 0; - * uA[4] = Temperature units - default = 0; - * uA[5] = time units - default = 0 - */ - virtual void getUnitsStandardConc(double *uA, int k = 0, - int sizeUA = 6); + //@} + /// @name Partial Molar Properties of the Solution + /// + /// These functions are resolved at this level, by reference + /// to the partial molar functions and standard state + /// functions for species 0. Derived classes don't need + /// to supply entries for these functions. + //@{ - /** - * Get the array of non-dimensional activities at - * the current solution temperature, pressure, and - * solution concentration. - * - * We redefine this function to just return 1.0 here. - */ - virtual void getActivities(doublereal* a) { - a[0] = 1.0; - } + /* + * These functions are all resolved here to point to the + * standard state functions for species 0 + */ - /** - * Get the array of non-dimensional activity coefficients at - * the current solution temperature, pressure, and - * solution concentration. - */ - virtual void getActivityCoefficients(doublereal* ac) const { - if (m_kk == 1) { - ac[0] = 1.0; - } else { - err("getActivityCoefficients"); - } - } + /** + * Get the array of non-dimensional species chemical potentials + * These are partial molar Gibbs free energies. + * \f$ \mu_k / \hat R T \f$. + * Units: unitless + */ + void getChemPotentials_RT(doublereal* mu) const; - //@} - /// @name Partial Molar Properties of the Solution - /// - /// These functions are resolved at this level, by reference - /// to the partial molar functions and standard state - /// functions for species 0. Derived classes don't need - /// to supply entries for these functions. - //@{ + /** + * Get the species chemical potentials in the solution + * These are partial molar Gibbs free energies. + * Units: J/kmol. + */ + void getChemPotentials(doublereal* mu) const; - /* - * These functions are all resolved here to point to the - * standard state functions for species 0 - */ + /** + * Get the species electrochemical potentials. Units: J/kmol. + * This method adds a term \f$ Fz_k \phi_k \f$ to + * each chemical potential. + * + * This is resolved here. A single single species phase + * is not allowed to have anything other than a zero + * charge. + */ + void getElectrochemPotentials(doublereal* mu) const; - /** - * Get the array of non-dimensional species chemical potentials - * These are partial molar Gibbs free energies. - * \f$ \mu_k / \hat R T \f$. - * Units: unitless - */ - void getChemPotentials_RT(doublereal* mu) const; + /** + * Get the species partial molar enthalpies. Units: J/kmol. + */ + void getPartialMolarEnthalpies(doublereal* hbar) const; - /** - * Get the species chemical potentials in the solution - * These are partial molar Gibbs free energies. - * Units: J/kmol. - */ - void getChemPotentials(doublereal* mu) const; + /** + * Get the species partial molar internal energies. Units: J/kmol. + */ + virtual void getPartialMolarIntEnergies(doublereal* ubar) const; - /** - * Get the species electrochemical potentials. Units: J/kmol. - * This method adds a term \f$ Fz_k \phi_k \f$ to - * each chemical potential. - * - * This is resolved here. A single single species phase - * is not allowed to have anything other than a zero - * charge. - */ - void getElectrochemPotentials(doublereal* mu) const; + /** + * Get the species partial molar entropies. Units: J/kmol. + */ + void getPartialMolarEntropies(doublereal* sbar) const; - /** - * Get the species partial molar enthalpies. Units: J/kmol. - */ - void getPartialMolarEnthalpies(doublereal* hbar) const; + /** + * Get the species partial molar volumes. Units: m^3/kmol. + */ + void getPartialMolarVolumes(doublereal* vbar) const; - /** - * Get the species partial molar internal energies. Units: J/kmol. - */ - virtual void getPartialMolarIntEnergies(doublereal* ubar) const; + //@} + /// @name Properties of the Standard State of the Species in the Solution + /// These functions are the primary way real properties are + /// supplied to derived thermodynamics classes of SingleSpeciesTP. + /// These functions must be supplied in derived classes. They + /// are not resolved at the SingleSpeciesTP level. + //@{ - /** - * Get the species partial molar entropies. Units: J/kmol. - */ - void getPartialMolarEntropies(doublereal* sbar) const; + /** + * Get the array of chemical potentials at unit activity. + * These are the standard state chemical potentials. + * \f$ \mu^0_k(T,P) \f$. The values are evaluated at the current + * temperature and pressure. + */ + virtual void getStandardChemPotentials(doublereal* mu) const { + err("getStandardChemPotentials"); + } - /** - * Get the species partial molar volumes. Units: m^3/kmol. - */ - void getPartialMolarVolumes(doublereal* vbar) const; + /** + * Get the nondimensional Enthalpy functions for the species + * at their standard states at the current + * T and P of the solution. + */ + virtual void getEnthalpy_RT(doublereal* hrt) const { + err("getEnthalpy_RT"); + } - //@} - /// @name Properties of the Standard State of the Species in the Solution - /// These functions are the primary way real properties are - /// supplied to derived thermodynamics classes of SingleSpeciesTP. - /// These functions must be supplied in derived classes. They - /// are not resolved at the SingleSpeciesTP level. - //@{ + /** + * Get the nondimensional Enthalpy functions for the species + * at their standard states at the current + * T and P of the solution. + */ + virtual void getIntEnergy_RT(doublereal* urt) const { + err("getIntEnergy_RT"); + } - /** - * Get the array of chemical potentials at unit activity. - * These are the standard state chemical potentials. - * \f$ \mu^0_k(T,P) \f$. The values are evaluated at the current - * temperature and pressure. - */ - virtual void getStandardChemPotentials(doublereal* mu) const { - err("getStandardChemPotentials"); - } + /** + * Get the array of nondimensional Enthalpy functions for the + * standard state species + * at the current T and P of the solution. + */ + virtual void getEntropy_R(doublereal* sr) const { + err("getEntropy_R"); + } - /** - * Get the nondimensional Enthalpy functions for the species - * at their standard states at the current - * T and P of the solution. - */ - virtual void getEnthalpy_RT(doublereal* hrt) const { - err("getEnthalpy_RT"); - } + /** + * Get the nondimensional Gibbs functions for the species + * at their standard states of solution at the current T and P + * of the solution + */ + virtual void getGibbs_RT(doublereal* grt) const { + err("getGibbs_RT"); + } - /** - * Get the nondimensional Enthalpy functions for the species - * at their standard states at the current - * T and P of the solution. - */ - virtual void getIntEnergy_RT(doublereal* urt) const { - err("getIntEnergy_RT"); - } + /** + * Get the dimensional Gibbs functions for the standard + * state of the species at the current T and P. + */ + void getPureGibbs(doublereal* gpure) const; - /** - * Get the array of nondimensional Enthalpy functions for the - * standard state species - * at the current T and P of the solution. - */ - virtual void getEntropy_R(doublereal* sr) const { - err("getEntropy_R"); - } + /** + * Get the nondimensional Gibbs functions for the standard + * state of the species at the current T and P. + */ + virtual void getCp_R(doublereal* cpr) const { + err("getCp_RT"); + } - /** - * Get the nondimensional Gibbs functions for the species - * at their standard states of solution at the current T and P - * of the solution - */ - virtual void getGibbs_RT(doublereal* grt) const { - err("getGibbs_RT"); - } - - /** - * Get the dimensional Gibbs functions for the standard - * state of the species at the current T and P. - */ - void getPureGibbs(doublereal* gpure) const; - - /** - * Get the nondimensional Gibbs functions for the standard - * state of the species at the current T and P. - */ - virtual void getCp_R(doublereal* cpr) const { - err("getCp_RT"); - } - - /** - * Get the molar volumes of each species in their standard - * states at the current - * T and P of the solution. - * units = m^3 / kmol - * - * We resolve this function at this level, by assigning - * the molec weight divided by the phase density - */ - void getStandardVolumes(doublereal *vol) const; + /** + * Get the molar volumes of each species in their standard + * states at the current + * T and P of the solution. + * units = m^3 / kmol + * + * We resolve this function at this level, by assigning + * the molec weight divided by the phase density + */ + void getStandardVolumes(doublereal *vol) const; - //@} - /// @name Thermodynamic Values for the Species Reference State - /// - /// Almost all functions in this group are resolved by this - /// class. It is assumed that the m_spthermo species thermo - /// pointer is populated and yields the reference state. - /// The internal energy function is not given by this - /// class, since it would involve a specification of the - /// equation of state. - //@{ + //@} + /// @name Thermodynamic Values for the Species Reference State + /// + /// Almost all functions in this group are resolved by this + /// class. It is assumed that the m_spthermo species thermo + /// pointer is populated and yields the reference state. + /// The internal energy function is not given by this + /// class, since it would involve a specification of the + /// equation of state. + //@{ - /** - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - */ - virtual void getEnthalpy_RT_ref(doublereal *hrt) const; + /** + * Returns the vector of nondimensional + * enthalpies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + virtual void getEnthalpy_RT_ref(doublereal *hrt) const; - /** - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - */ - virtual void getGibbs_RT_ref(doublereal *grt) const; + /** + * Returns the vector of nondimensional + * enthalpies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + virtual void getGibbs_RT_ref(doublereal *grt) const; - /** - * Returns the vector of the - * gibbs function of the reference state at the current temperature - * of the solution and the reference pressure for the species. - * units = J/kmol - */ - virtual void getGibbs_ref(doublereal *g) const; + /** + * Returns the vector of the + * gibbs function of the reference state at the current temperature + * of the solution and the reference pressure for the species. + * units = J/kmol + */ + virtual void getGibbs_ref(doublereal *g) const; - /** - * Returns the vector of nondimensional - * entropies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - */ - virtual void getEntropy_R_ref(doublereal *er) const; + /** + * Returns the vector of nondimensional + * entropies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + virtual void getEntropy_R_ref(doublereal *er) const; - /** - * Returns the vector of nondimensional - * constant pressure heat capacities of the reference state - * at the current temperature of the solution - * and reference pressure for the species. - */ - virtual void getCp_R_ref(doublereal *cprt) const; + /** + * Returns the vector of nondimensional + * constant pressure heat capacities of the reference state + * at the current temperature of the solution + * and reference pressure for the species. + */ + virtual void getCp_R_ref(doublereal *cprt) const; - /** - * @name Setting the State - * - * These methods set all or part of the thermodynamic - * state. - * @{ - */ - /** Set the temperature (K), pressure (Pa), and mole fractions. */ - void setState_TPX(doublereal t, doublereal p, const doublereal* x); + /** + * @name Setting the State + * + * These methods set all or part of the thermodynamic + * state. + * @{ + */ + /** Set the temperature (K), pressure (Pa), and mole fractions. */ + void setState_TPX(doublereal t, doublereal p, const doublereal* x); - /** Set the temperature (K), pressure (Pa), and mole fractions. */ - void setState_TPX(doublereal t, doublereal p, compositionMap& x); + /** Set the temperature (K), pressure (Pa), and mole fractions. */ + void setState_TPX(doublereal t, doublereal p, compositionMap& x); - /** Set the temperature (K), pressure (Pa), and mole fractions. */ - void setState_TPX(doublereal t, doublereal p, const string& x); + /** Set the temperature (K), pressure (Pa), and mole fractions. */ + void setState_TPX(doublereal t, doublereal p, const std::string& x); - /** Set the temperature (K), pressure (Pa), and mass fractions. */ - void setState_TPY(doublereal t, doublereal p, const doublereal* y); + /** Set the temperature (K), pressure (Pa), and mass fractions. */ + void setState_TPY(doublereal t, doublereal p, const doublereal* y); - /** Set the temperature (K), pressure (Pa), and mass fractions. */ - void setState_TPY(doublereal t, doublereal p, compositionMap& y); + /** Set the temperature (K), pressure (Pa), and mass fractions. */ + void setState_TPY(doublereal t, doublereal p, compositionMap& y); - /** Set the temperature (K), pressure (Pa), and mass fractions. */ - void setState_TPY(doublereal t, doublereal p, const string& y); + /** Set the temperature (K), pressure (Pa), and mass fractions. */ + void setState_TPY(doublereal t, doublereal p, const std::string& y); - /** Set the pressure (Pa) and mole fractions. */ - void setState_PX(doublereal p, doublereal* x); + /** Set the pressure (Pa) and mole fractions. */ + void setState_PX(doublereal p, doublereal* x); - /** Set the pressure (Pa) and mass fractions. */ - void setState_PY(doublereal p, doublereal* y); + /** Set the pressure (Pa) and mass fractions. */ + void setState_PY(doublereal p, doublereal* y); - /** Set the specific enthalpy (J/kg) and pressure (Pa). */ - virtual void setState_HP(doublereal h, doublereal p, - doublereal tol = 1.e-8); + /** Set the specific enthalpy (J/kg) and pressure (Pa). */ + virtual void setState_HP(doublereal h, doublereal p, + doublereal tol = 1.e-8); - /** Set the specific enthalpy (J/kg) and specific volume (m^3/kg). */ - virtual void setState_UV(doublereal u, doublereal v, - doublereal tol = 1.e-8); + /** Set the specific enthalpy (J/kg) and specific volume (m^3/kg). */ + virtual void setState_UV(doublereal u, doublereal v, + doublereal tol = 1.e-8); - /** Set the specific entropy (J/kg/K) and pressure (Pa). */ - virtual void setState_SP(doublereal s, doublereal p, - doublereal tol = 1.e-8); + /** Set the specific entropy (J/kg/K) and pressure (Pa). */ + virtual void setState_SP(doublereal s, doublereal p, + doublereal tol = 1.e-8); - /** Set the specific entropy (J/kg/K) and specific volume (m^3/kg). */ - virtual void setState_SV(doublereal s, doublereal v, - doublereal tol = 1.e-8); + /** Set the specific entropy (J/kg/K) and specific volume (m^3/kg). */ + virtual void setState_SV(doublereal s, doublereal v, + doublereal tol = 1.e-8); - //@} + //@} - /** - * @name Chemical Equilibrium - * Chemical equilibrium. - * @{ - */ + /** + * @name Chemical Equilibrium + * Chemical equilibrium. + * @{ + */ - /** - * This method is used by the ChemEquil equilibrium solver. - * It sets the state such that the chemical potentials satisfy - * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m} - * \left(\frac{\lambda_m} {\hat R T}\right) \f] where - * \f$ \lambda_m \f$ is the element potential of element m. The - * temperature is unchanged. Any phase (ideal or not) that - * implements this method can be equilibrated by ChemEquil. - */ - virtual void setToEquilState(const doublereal* lambda_RT) { - err("setToEquilState"); - } + /** + * This method is used by the ChemEquil equilibrium solver. + * It sets the state such that the chemical potentials satisfy + * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m} + * \left(\frac{\lambda_m} {\hat R T}\right) \f] where + * \f$ \lambda_m \f$ is the element potential of element m. The + * temperature is unchanged. Any phase (ideal or not) that + * implements this method can be equilibrated by ChemEquil. + */ + virtual void setToEquilState(const doublereal* lambda_RT) { + err("setToEquilState"); + } - //@} + //@} - /** - * @internal - * Set equation of state parameters. The number and meaning of - * these depends on the subclass. - * @param n number of parameters - * @param c array of \i n coefficients - * - */ - virtual void setParameters(int n, doublereal* c) {} - virtual void getParameters(int &n, doublereal * const c) {} + /** + * @internal + * Set equation of state parameters. The number and meaning of + * these depends on the subclass. + * @param n number of parameters + * @param c array of \i n coefficients + * + */ + virtual void setParameters(int n, doublereal* c) {} + virtual void getParameters(int &n, doublereal * const c) {} - /** - * Set equation of state parameter values from XML - * entries. This method is called by function importPhase in - * file importCTML.cpp when processing a phase definition in - * an input file. It should be overloaded in subclasses to set - * any parameters that are specific to that particular phase - * model. - * - * @param eosdata An XML_Node object corresponding to - * the "thermo" entry for this phase in the input file. - */ - virtual void setParametersFromXML(const XML_Node& eosdata) {} + /** + * Set equation of state parameter values from XML + * entries. This method is called by function importPhase in + * file importCTML.cpp when processing a phase definition in + * an input file. It should be overloaded in subclasses to set + * any parameters that are specific to that particular phase + * model. + * + * @param eosdata An XML_Node object corresponding to + * the "thermo" entry for this phase in the input file. + */ + virtual void setParametersFromXML(const XML_Node& eosdata) {} - //--------------------------------------------------------- - /// @name Critical state properties. - /// These methods are only implemented by some subclasses. + //--------------------------------------------------------- + /// @name Critical state properties. + /// These methods are only implemented by some subclasses. - //@{ + //@{ - /// Critical temperature (K). - virtual doublereal critTemperature() const { - err("critTemperature"); return -1.0; - } + /// Critical temperature (K). + virtual doublereal critTemperature() const { + err("critTemperature"); return -1.0; + } - /// Critical pressure (Pa). - virtual doublereal critPressure() const { - err("critPressure"); return -1.0; - } + /// Critical pressure (Pa). + virtual doublereal critPressure() const { + err("critPressure"); return -1.0; + } - /// Critical density (kg/m3). - virtual doublereal critDensity() const { - err("critDensity"); return -1.0; - } + /// Critical density (kg/m3). + virtual doublereal critDensity() const { + err("critDensity"); return -1.0; + } - //@} + //@} - /// @name Saturation properties. - /// These methods are only implemented by subclasses that - /// implement full liquid-vapor equations of state. - /// - virtual doublereal satTemperature(doublereal p) const { - err("satTemperature"); return -1.0; - } + /// @name Saturation properties. + /// These methods are only implemented by subclasses that + /// implement full liquid-vapor equations of state. + /// + virtual doublereal satTemperature(doublereal p) const { + err("satTemperature"); return -1.0; + } - virtual doublereal satPressure(doublereal t) const { - err("satPressure"); return -1.0; - } + virtual doublereal satPressure(doublereal t) const { + err("satPressure"); return -1.0; + } - virtual doublereal vaporFraction() const { - err("vaprFraction"); return -1.0; - } + virtual doublereal vaporFraction() const { + err("vaprFraction"); return -1.0; + } - virtual void setState_Tsat(doublereal t, doublereal x) { - err("setState_sat"); - } + virtual void setState_Tsat(doublereal t, doublereal x) { + err("setState_sat"); + } - virtual void setState_Psat(doublereal p, doublereal x) { - err("setState_sat"); - } + virtual void setState_Psat(doublereal p, doublereal x) { + err("setState_sat"); + } - //@} + //@} - /** - * @internal Initialize. This method is provided to allow - * subclasses to perform any initialization required after all - * species have been added. For example, it might be used to - * resize internal work arrays that must have an entry for - * each species. The base class implementation does nothing, - * and subclasses that do not require initialization do not - * need to overload this method. When importing a CTML phase - * description, this method is called just prior to returning - * from function importPhase. - * - * @see importCTML.cpp - */ - virtual void initThermo(); + /** + * @internal Initialize. This method is provided to allow + * subclasses to perform any initialization required after all + * species have been added. For example, it might be used to + * resize internal work arrays that must have an entry for + * each species. The base class implementation does nothing, + * and subclasses that do not require initialization do not + * need to overload this method. When importing a CTML phase + * description, this method is called just prior to returning + * from function importPhase. + * + * @see importCTML.cpp + */ + virtual void initThermo(); - protected: + protected: - doublereal m_tmin, m_tmax, m_press, m_p0; + doublereal m_tmin, m_tmax, m_press, m_p0; - /** - * Last temperature used to evaluate the thermodynamic - * polynomial. - */ - mutable doublereal m_tlast; - mutable array_fp m_h0_RT; - mutable array_fp m_cp0_R; - mutable array_fp m_s0_R; + /** + * Last temperature used to evaluate the thermodynamic + * polynomial. + */ + mutable doublereal m_tlast; + mutable array_fp m_h0_RT; + mutable array_fp m_cp0_R; + mutable array_fp m_s0_R; - protected: + protected: - void _updateThermo() const; + void _updateThermo() const; - private: - doublereal err(string msg) const; + private: + doublereal err(std::string msg) const; - }; + }; } diff --git a/Cantera/src/thermo/VPStandardStateTP.cpp b/Cantera/src/thermo/VPStandardStateTP.cpp index 490771cfa..33f198de9 100644 --- a/Cantera/src/thermo/VPStandardStateTP.cpp +++ b/Cantera/src/thermo/VPStandardStateTP.cpp @@ -21,6 +21,7 @@ #include "VPStandardStateTP.h" +using namespace std; namespace Cantera { @@ -29,7 +30,8 @@ namespace Cantera { */ VPStandardStateTP::VPStandardStateTP() : ThermoPhase(), - m_tlast(-1.0) + m_tlast(-1.0), + m_plast(-1.0) { } @@ -44,7 +46,8 @@ namespace Cantera { */ VPStandardStateTP::VPStandardStateTP(const VPStandardStateTP &b) : ThermoPhase(), - m_tlast(-1.0) + m_tlast(-1.0), + m_plast(-1.0) { *this = b; } @@ -67,10 +70,15 @@ namespace Cantera { * However, we have to handle data that we own. */ m_tlast = b.m_tlast; + m_plast = b.m_plast; m_h0_RT = b.m_h0_RT; m_cp0_R = b.m_cp0_R; m_g0_RT = b.m_g0_RT; m_s0_R = b.m_s0_R; + m_hss_RT = b.m_hss_RT; + m_cpss_R = b.m_cpss_R; + m_gss_RT = b.m_gss_RT; + m_sss_R = b.m_sss_R; } return *this; } @@ -323,6 +331,21 @@ namespace Cantera { } } } + + /** + * void _updateStandardStateThermo() (private, const) + * + * This function gets called for every call to functions in this + * class. It checks to see whether the temperature has changed and + * thus the ss thermodynamics functions for all of the species + * must be recalculated. + */ + void VPStandardStateTP::_updateStandardStateThermo() const { + doublereal tnow = temperature(); + if (m_tlast != tnow) { + _updateRefStateThermo(); + } + } } diff --git a/Cantera/src/thermo/VPStandardStateTP.h b/Cantera/src/thermo/VPStandardStateTP.h index 19c5b26bf..d6be98fbb 100644 --- a/Cantera/src/thermo/VPStandardStateTP.h +++ b/Cantera/src/thermo/VPStandardStateTP.h @@ -24,431 +24,473 @@ namespace Cantera { - class XML_Node; + class XML_Node; + + /** + * @ingroup thermoprops + * + * This is a filter class for ThermoPhase that implements + * a variable pressure standard state for ThermoPhase objects. + * + * In addition support for the molality unit scale is provided. + * + * Currently, it really is just a shell. The ThermoPhase object + * itself is based around the general concepts of + * VPStandardStateTP. Therefore, there really isn't much going + * on here. However, this may change. The ThermoPhase object + * itself could change. Additionally, this object may revolve + * around the molality unit scale in the near future. We will + * have to see how things fare. + */ + + class VPStandardStateTP : public ThermoPhase { + + public: + + /// Constructor. + VPStandardStateTP(); + + /// Copy Constructor. + VPStandardStateTP(const VPStandardStateTP &); + + /// Assignment operator + VPStandardStateTP& operator=(const VPStandardStateTP &); + + /// Destructor. + virtual ~VPStandardStateTP(); + + /* + * Duplication routine + */ + virtual ThermoPhase *duplMyselfAsThermoPhase(); /** - * @ingroup thermoprops - * - * This is a filter class for ThermoPhase that implements - * a variable pressure standard state for ThermoPhase objects. - * - * In addition support for the molality unit scale is provided. - * - * Currently, it really is just a shell. The ThermoPhase object - * itself is based around the general concepts of - * VPStandardStateTP. Therefore, there really isn't much going - * on here. However, this may change. The ThermoPhase object - * itself could change. Additionally, this object may revolve - * around the molality unit scale in the near future. We will - * have to see how things fare. + * + * @name Utilities + * @{ */ - class VPStandardStateTP : public ThermoPhase { - - public: - - /// Constructor. - VPStandardStateTP(); - - /// Copy Constructor. - VPStandardStateTP(const VPStandardStateTP &); - - /// Assignment operator - VPStandardStateTP& operator=(const VPStandardStateTP &); - - /// Destructor. - virtual ~VPStandardStateTP(); - - /* - * Duplication routine - */ - virtual ThermoPhase *duplMyselfAsThermoPhase(); - - /** - * - * @name Utilities - * @{ - */ - - /** - * Equation of state type flag. The base class returns - * zero. Subclasses should define this to return a unique - * non-zero value. Constants defined for this purpose are - * listed in mix_defs.h. - */ - virtual int eosType() const { return 0; } + /** + * Equation of state type flag. The base class returns + * zero. Subclasses should define this to return a unique + * non-zero value. Constants defined for this purpose are + * listed in mix_defs.h. + */ + virtual int eosType() const { return 0; } - /** - * @} - * @name Molar Thermodynamic Properties of the Solution - * @{ - */ + /** + * @} + * @name Molar Thermodynamic Properties of the Solution + * @{ + */ - /* - * These are handled by inherited objects. At this level, - * this pass-through routine doesn't add anything to the - * ThermoPhase description. - */ + /* + * These are handled by inherited objects. At this level, + * this pass-through routine doesn't add anything to the + * ThermoPhase description. + */ - /** - * @} - * @name Mechanical Properties - * @{ - */ + /** + * @} + * @name Mechanical Properties + * @{ + */ - /* - * These are handled by inherited objects. At this level, - * this pass-through routine doesn't add anything to the - * ThermoPhase description. - */ + /* + * These are handled by inherited objects. At this level, + * this pass-through routine doesn't add anything to the + * ThermoPhase description. + */ - /** - * @} - * @name Electric Potential - * - * The phase may be at some non-zero electrical - * potential. These methods set or get the value of the - * electric potential. - * @{ - */ + /** + * @} + * @name Electric Potential + * + * The phase may be at some non-zero electrical + * potential. These methods set or get the value of the + * electric potential. + * @{ + */ - /* - * These are handled by inherited objects. At this level, - * this pass-through routine doesn't add anything to the - * ThermoPhase description. - */ + /* + * These are handled by inherited objects. At this level, + * this pass-through routine doesn't add anything to the + * ThermoPhase description. + */ - /** - * @} - * @name Activities and Activity Concentrations - * - * The activity \f$a_k\f$ of a species in solution is - * related to the chemical potential by \f[ \mu_k = \mu_k^0(T) - * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T)\f$ is - * the chemical potential at unit activity, which depends only - * on temperature. - * @{ - */ + /** + * @} + * @name Activities and Activity Concentrations + * + * The activity \f$a_k\f$ of a species in solution is + * related to the chemical potential by \f[ \mu_k = \mu_k^0(T) + * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T)\f$ is + * the chemical potential at unit activity, which depends only + * on temperature. + * @{ + */ - /** - * Returns the units of the standard and generalized - * concentrations Note they have the same units, as their - * ratio is defined to be equal to the activity of the kth - * species in the solution, which is unitless. - * - * This routine is used in print out applications where the - * units are needed. Usually, MKS units are assumed throughout - * the program and in the XML input files. - * - * uA[0] = kmol units - default = 1 - * uA[1] = m units - default = -nDim(), the number of spatial - * dimensions in the Phase class. - * uA[2] = kg units - default = 0; - * uA[3] = Pa(pressure) units - default = 0; - * uA[4] = Temperature units - default = 0; - * uA[5] = time units - default = 0 - */ - virtual void getUnitsStandardConc(double *uA, int k = 0, - int sizeUA = 6); + /** + * Returns the units of the standard and generalized + * concentrations Note they have the same units, as their + * ratio is defined to be equal to the activity of the kth + * species in the solution, which is unitless. + * + * This routine is used in print out applications where the + * units are needed. Usually, MKS units are assumed throughout + * the program and in the XML input files. + * + * uA[0] = kmol units - default = 1 + * uA[1] = m units - default = -nDim(), the number of spatial + * dimensions in the Phase class. + * uA[2] = kg units - default = 0; + * uA[3] = Pa(pressure) units - default = 0; + * uA[4] = Temperature units - default = 0; + * uA[5] = time units - default = 0 + */ + virtual void getUnitsStandardConc(double *uA, int k = 0, + int sizeUA = 6); - //@} - /// @name Partial Molar Properties of the Solution - //@{ + //@} + /// @name Partial Molar Properties of the Solution + //@{ - /** - * Get the array of non-dimensional species chemical potentials - * These are partial molar Gibbs free energies. - * \f$ \mu_k / \hat R T \f$. - * Units: unitless - * - * We close the loop on this function, here, calling - * getChemPotentials() and then dividing by RT. - */ - virtual void getChemPotentials_RT(doublereal* mu) const; + /** + * Get the array of non-dimensional species chemical potentials + * These are partial molar Gibbs free energies. + * \f$ \mu_k / \hat R T \f$. + * Units: unitless + * + * We close the loop on this function, here, calling + * getChemPotentials() and then dividing by RT. + */ + virtual void getChemPotentials_RT(doublereal* mu) const; - //@} - /// @name Properties of the Standard State of the Species in the Solution - //@{ + //@} + /// @name Properties of the Standard State of the Species in the Solution + //@{ - /* - * These are handled by inherited objects. At this level, - * this pass-through routine doesn't add anything to the - * ThermoPhase description. - * - * However, we assume these methods exist for inherited objects. - * Therefore, we will bring the error routines up to this object - */ + /* + * These are handled by inherited objects. At this level, + * this pass-through routine doesn't add anything to the + * ThermoPhase description. + * + * However, we assume these methods exist for inherited objects. + * Therefore, we will bring the error routines up to this object + */ - /** - * Get the array of chemical potentials at unit activity. - * These - * are the standard state chemical potentials \f$ \mu^0_k(T,P) - * \f$.. The values are evaluated at the current - * temperature and pressure. - */ - virtual void getStandardChemPotentials(doublereal* mu) const { - err("getStandardChemPotentials"); - } + /** + * Get the array of chemical potentials at unit activity. + * These + * are the standard state chemical potentials \f$ \mu^0_k(T,P) + * \f$.. The values are evaluated at the current + * temperature and pressure. + */ + virtual void getStandardChemPotentials(doublereal* mu) const { + err("getStandardChemPotentials"); + } - /** - * Get the nondimensional Enthalpy functions for the species - * at their standard states at the current - * T and P of the solution. - */ - virtual void getEnthalpy_RT(doublereal* hrt) const { - err("getEnthalpy_RT"); - } + /** + * Get the nondimensional Enthalpy functions for the species + * at their standard states at the current + * T and P of the solution. + */ + virtual void getEnthalpy_RT(doublereal* hrt) const { + err("getEnthalpy_RT"); + } - /** - * Get the array of nondimensional Enthalpy functions for the - * standard state species - * at the current T and P of the solution. - */ - virtual void getEntropy_R(doublereal* sr) const { - err("getEntropy_R"); - } + /** + * Get the array of nondimensional Enthalpy functions for the + * standard state species + * at the current T and P of the solution. + */ + virtual void getEntropy_R(doublereal* sr) const { + err("getEntropy_R"); + } - /** - * Get the nondimensional Gibbs functions for the species - * at their standard states of solution at the current T and P - * of the solution. - */ - virtual void getGibbs_RT(doublereal* grt) const { - err("getGibbs_RT"); - } + /** + * Get the nondimensional Gibbs functions for the species + * at their standard states of solution at the current T and P + * of the solution. + */ + virtual void getGibbs_RT(doublereal* grt) const { + err("getGibbs_RT"); + } - /** - * Get the nondimensional Gibbs functions for the standard - * state of the species at the current T and P. - */ - virtual void getPureGibbs(doublereal* gpure) const { - err("getPureGibbs"); - } + /** + * Get the nondimensional Gibbs functions for the standard + * state of the species at the current T and P. + */ + virtual void getPureGibbs(doublereal* gpure) const { + err("getPureGibbs"); + } - /** - * Returns the vector of nondimensional - * internal Energies of the standard state at the current temperature - * and pressure of the solution for each species. - */ - virtual void getIntEnergy_RT(doublereal *urt) const { - err("getIntEnergy_RT"); - } + /** + * Returns the vector of nondimensional + * internal Energies of the standard state at the current temperature + * and pressure of the solution for each species. + */ + virtual void getIntEnergy_RT(doublereal *urt) const { + err("getIntEnergy_RT"); + } - /** - * Get the nondimensional Heat Capacities at constant - * pressure for the standard state of the species - * at the current T and P. - */ - virtual void getCp_R(doublereal* cpr) const { - err("getCp_R"); - } + /** + * Get the nondimensional Heat Capacities at constant + * pressure for the standard state of the species + * at the current T and P. + */ + virtual void getCp_R(doublereal* cpr) const { + err("getCp_R"); + } - /** - * Get the molar volumes of each species in their standard - * states at the current - * T and P of the solution. - * units = m^3 / kmol - */ - virtual void getStandardVolumes(doublereal *vol) const { - err("getStandardVolumes"); - } + /** + * Get the molar volumes of each species in their standard + * states at the current + * T and P of the solution. + * units = m^3 / kmol + */ + virtual void getStandardVolumes(doublereal *vol) const { + err("getStandardVolumes"); + } - //@} - /// @name Thermodynamic Values for the Species Reference States -------------------- - //@{ + //@} + /// @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. - */ - virtual void getEnthalpy_RT_ref(doublereal *hrt) const; + /** + * Returns the vector of nondimensional + * enthalpies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + virtual void getEnthalpy_RT_ref(doublereal *hrt) const; - /** - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - */ - virtual void getGibbs_RT_ref(doublereal *grt) const; + /** + * Returns the vector of nondimensional + * enthalpies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + virtual void getGibbs_RT_ref(doublereal *grt) const; - /** - * Returns the vector of the - * gibbs function of the reference state at the current temperature - * of the solution and the reference pressure for the species. - * units = J/kmol - */ - virtual void getGibbs_ref(doublereal *g) const; + /** + * Returns the vector of the + * gibbs function of the reference state at the current temperature + * of the solution and the reference pressure for the species. + * units = J/kmol + */ + virtual void getGibbs_ref(doublereal *g) const; - /** - * Returns the vector of nondimensional - * entropies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - */ - virtual void getEntropy_R_ref(doublereal *er) const; + /** + * Returns the vector of nondimensional + * entropies of the reference state at the current temperature + * of the solution and the reference pressure for the species. + */ + virtual void getEntropy_R_ref(doublereal *er) const; - /** - * Returns the vector of nondimensional - * constant pressure heat capacities of the reference state - * at the current temperature of the solution - * and reference pressure for the species. - */ - virtual void getCp_R_ref(doublereal *cprt) const; + /** + * Returns the vector of nondimensional + * constant pressure heat capacities of the reference state + * at the current temperature of the solution + * and reference pressure for the species. + */ + virtual void getCp_R_ref(doublereal *cprt) const; - /////////////////////////////////////////////////////// - // - // The methods below are not virtual, and should not - // be overloaded. - // - ////////////////////////////////////////////////////// + /////////////////////////////////////////////////////// + // + // The methods below are not virtual, and should not + // be overloaded. + // + ////////////////////////////////////////////////////// - /** - * @name Specific Properties - * @{ - */ + /** + * @name Specific Properties + * @{ + */ - /** - * @name Setting the State - * - * These methods set all or part of the thermodynamic - * state. - * @{ - */ + /** + * @name Setting the State + * + * These methods set all or part of the thermodynamic + * state. + * @{ + */ - //@} + //@} - /** - * @name Chemical Equilibrium - * Chemical equilibrium. - * @{ - */ + /** + * @name Chemical Equilibrium + * Chemical equilibrium. + * @{ + */ - //@} + //@} - /** - * Set equation of state parameter values from XML - * entries. This method is called by function importPhase in - * file importCTML.cpp when processing a phase definition in - * an input file. It should be overloaded in subclasses to set - * any parameters that are specific to that particular phase - * model. - * - * @param eosdata An XML_Node object corresponding to - * the "thermo" entry for this phase in the input file. - */ - virtual void setParametersFromXML(const XML_Node& eosdata) {} + /** + * Set equation of state parameter values from XML + * entries. This method is called by function importPhase in + * file importCTML.cpp when processing a phase definition in + * an input file. It should be overloaded in subclasses to set + * any parameters that are specific to that particular phase + * model. + * + * @param eosdata An XML_Node object corresponding to + * the "thermo" entry for this phase in the input file. + */ + virtual void setParametersFromXML(const XML_Node& eosdata) {} - //--------------------------------------------------------- - /// @name Critical state properties. - /// These methods are only implemented by some subclasses. + //--------------------------------------------------------- + /// @name Critical state properties. + /// These methods are only implemented by some subclasses. - //@{ + //@{ - //@} + //@} - /// @name Saturation properties. - /// These methods are only implemented by subclasses that - /// implement full liquid-vapor equations of state. - /// + /// @name Saturation properties. + /// These methods are only implemented by subclasses that + /// implement full liquid-vapor equations of state. + /// - //@} + //@} - /// The following methods are used in the process of constructing - /// the phase and setting its parameters from a specification in an - /// input file. They are not normally used in application programs. - /// To see how they are used, see files importCTML.cpp and - /// ThermoFactory.cpp. + /// The following methods are used in the process of constructing + /// the phase and setting its parameters from a specification in an + /// input file. They are not normally used in application programs. + /// To see how they are used, see files importCTML.cpp and + /// ThermoFactory.cpp. - /** - * @internal Initialize. This method is provided to allow - * subclasses to perform any initialization required after all - * species have been added. For example, it might be used to - * resize internal work arrays that must have an entry for - * each species. The base class implementation does nothing, - * and subclasses that do not require initialization do not - * need to overload this method. When importing a CTML phase - * description, this method is called just prior to returning - * from function importPhase. - * - * @see importCTML.cpp - */ - virtual void initThermo(); + /** + * @internal Initialize. This method is provided to allow + * subclasses to perform any initialization required after all + * species have been added. For example, it might be used to + * resize internal work arrays that must have an entry for + * each species. The base class implementation does nothing, + * and subclasses that do not require initialization do not + * need to overload this method. When importing a CTML phase + * description, this method is called just prior to returning + * from function importPhase. + * + * @see importCTML.cpp + */ + virtual void initThermo(); - /** - * Import and initialize a ThermoPhase object - * - * @param phaseNode This object must be the phase node of a - * complete XML tree - * description of the phase, including all of the - * species data. In other words while "phase" must - * point to an XML phase object, it must have - * sibling nodes "speciesData" that describe - * the species in the phase. - * @param id ID of the phase. If nonnull, a check is done - * to see if phaseNode is pointing to the phase - * with the correct id. - */ - void initThermoXML(XML_Node& phaseNode, string id); + /** + * Import and initialize a ThermoPhase object + * + * @param phaseNode This object must be the phase node of a + * complete XML tree + * description of the phase, including all of the + * species data. In other words while "phase" must + * point to an XML phase object, it must have + * sibling nodes "speciesData" that describe + * the species in the phase. + * @param id ID of the phase. If nonnull, a check is done + * to see if phaseNode is pointing to the phase + * with the correct id. + */ + void initThermoXML(XML_Node& phaseNode, std::string id); - private: - void initLengths(); + private: + void initLengths(); - protected: - /* - * The last temperature at which the reference thermodynamic - * properties were calculated at. - */ - mutable doublereal m_tlast; - /** - * Vector containing the species reference enthalpies at T = m_tlast - */ - mutable vector_fp m_h0_RT; + protected: + /* + * The last temperature at which the reference thermodynamic + * properties were calculated at. + */ + mutable doublereal m_tlast; + /* + * The last pressure at which the Standard State thermodynamic + * properties were calculated at. + */ + mutable doublereal m_plast; + /** + * Vector containing the species reference enthalpies at T = m_tlast + * and P = p_ref. + */ + mutable vector_fp m_h0_RT; - /** - * Vector containing the species reference constant pressure - * heat capacities at T = m_tlast - */ - mutable vector_fp m_cp0_R; + /** + * Vector containing the species reference constant pressure + * heat capacities at T = m_tlast and P = p_ref. + */ + mutable vector_fp m_cp0_R; - /** - * Vector containing the species reference Gibbs functions - * at T = m_tlast - */ - mutable vector_fp m_g0_RT; + /** + * Vector containing the species reference Gibbs functions + * at T = m_tlast and P = p_ref. + */ + mutable vector_fp m_g0_RT; + + /** + * Vector containing the species reference entropies + * at T = m_tlast and P = p_ref. + */ + mutable vector_fp m_s0_R; + + /** + * Vector containing the species Standard State enthalpies at T = m_tlast + * and P = m_plast. + */ + mutable vector_fp m_hss_RT; + + /** + * Vector containing the species Standard State constant pressure + * heat capacities at T = m_tlast and P = m_plast. + */ + mutable vector_fp m_cpss_R; + + /** + * Vector containing the species Standard State Gibbs functions + * at T = m_tlast and P = m_plast. + */ + mutable vector_fp m_gss_RT; + + /** + * Vector containing the species Standard State entropies + * at T = m_tlast and P = m_plast. + */ + mutable vector_fp m_sss_R; - /** - * Vector containing the species reference entropies - * at T = m_tlast - */ - mutable vector_fp m_s0_R; - private: + private: - /** - * VPStandardStateTP has its own err routine - * - */ - doublereal err(string msg) const; + /** + * VPStandardStateTP has its own err routine + * + */ + doublereal err(std::string msg) const; + + /** + * This function gets called for every call to functions in this + * class. It checks to see whether the temperature has changed and + * thus the reference thermodynamics functions for all of the species + * must be recalculated. + * If the temperature has changed, the species thermo manager is called + * to recalculate G, Cp, H, and S at the current temperature. + */ + void _updateRefStateThermo() const; + + /** + * void _updateStandardStateThermo() (private, const) + * + * This function gets called for every call to functions in this + * class. It checks to see whether the temperature has changed and + * thus the ss thermodynamics functions for all of the species + * must be recalculated. + */ + void _updateStandardStateThermo() const; - /** - * This function gets called for every call to functions in this - * class. It checks to see whether the temperature has changed and - * thus the reference thermodynamics functions for all of the species - * must be recalculated. - * If the temperature has changed, the species thermo manager is called - * to recalculate G, Cp, H, and S at the current temperature. - */ - void _updateRefStateThermo() const; }; -} + } #endif @@ -456,3 +498,4 @@ namespace Cantera { + diff --git a/Cantera/src/thermo/WaterPDSS.cpp b/Cantera/src/thermo/WaterPDSS.cpp index 09fe2badb..ad00adb1a 100644 --- a/Cantera/src/thermo/WaterPDSS.cpp +++ b/Cantera/src/thermo/WaterPDSS.cpp @@ -35,11 +35,12 @@ namespace Cantera { m_allowGasPhase(false) { constructPDSS(tp, spindex); + m_spthermo = 0; } WaterPDSS::WaterPDSS(ThermoPhase *tp, int spindex, - string inputFile, string id) : + std::string inputFile, std::string id) : PDSS(tp, spindex), m_sub(0), m_iState(-1), @@ -50,10 +51,11 @@ namespace Cantera { m_allowGasPhase(false) { constructPDSSFile(tp, spindex, inputFile, id); + m_spthermo = 0; } WaterPDSS::WaterPDSS(ThermoPhase *tp, int spindex, - XML_Node& phaseRoot, string id) : + XML_Node& phaseRoot, std::string id) : PDSS(tp, spindex), m_sub(0), m_iState(-1), @@ -64,6 +66,7 @@ namespace Cantera { m_allowGasPhase(false) { constructPDSSXML(tp, spindex, phaseRoot, id) ; + m_spthermo = 0; } @@ -91,8 +94,12 @@ namespace Cantera { */ WaterPDSS& WaterPDSS::operator=(const WaterPDSS&b) { if (&b == this) return *this; - m_sub->operator=(*(b.m_sub)); + /* + * Call the base class operator + */ PDSS::operator=(b); + + m_sub->operator=(*(b.m_sub)); m_verbose = b.m_verbose; m_allowGasPhase = b.m_allowGasPhase; return *this; @@ -123,7 +130,7 @@ namespace Cantera { * phase element will be used. */ void WaterPDSS::constructPDSSXML(ThermoPhase *tp, int spindex, - XML_Node& phaseNode, string id) { + XML_Node& phaseNode, std::string id) { initThermo(); } @@ -144,14 +151,14 @@ namespace Cantera { * phase element will be used. */ void WaterPDSS::constructPDSSFile(ThermoPhase *tp, int spindex, - string inputFile, string id) { + std::string inputFile, std::string id) { if (inputFile.size() == 0) { throw CanteraError("WaterTp::initThermo", "input file is null"); } - string path = findInputFile(inputFile); - ifstream fin(path.c_str()); + std::string path = findInputFile(inputFile); + std::ifstream fin(path.c_str()); if (!fin) { throw CanteraError("WaterPDSS::initThermo","could not open " +path+" for reading."); @@ -174,7 +181,7 @@ namespace Cantera { } void WaterPDSS:: - initThermoXML(XML_Node& phaseNode, string id) { + initThermoXML(XML_Node& phaseNode, std::string id) { initThermo(); } diff --git a/Cantera/src/thermo/WaterPDSS.h b/Cantera/src/thermo/WaterPDSS.h index 34bc695ae..3680712b7 100644 --- a/Cantera/src/thermo/WaterPDSS.h +++ b/Cantera/src/thermo/WaterPDSS.h @@ -68,9 +68,9 @@ namespace Cantera { WaterPDSS(const WaterPDSS &b); WaterPDSS& operator=(const WaterPDSS&b); WaterPDSS(ThermoPhase *tp, int spindex, - string inputFile, string id = ""); + std::string inputFile, std::string id = ""); WaterPDSS(ThermoPhase *tp, int spindex, - XML_Node& phaseRef, string id = ""); + XML_Node& phaseRef, std::string id = ""); virtual ~WaterPDSS(); /** @@ -142,10 +142,10 @@ namespace Cantera { virtual void constructPDSS(ThermoPhase *tp, int spindex); virtual void constructPDSSFile(ThermoPhase *tp, int spindex, - string inputFile, string id); + std::string inputFile, std::string id); virtual void constructPDSSXML(ThermoPhase *tp, int spindex, - XML_Node& phaseNode, string id); - virtual void initThermoXML(XML_Node& eosdata, string id); + XML_Node& phaseNode, std::string id); + virtual void initThermoXML(XML_Node& eosdata, std::string id); virtual void initThermo(); virtual void setParametersFromXML(const XML_Node& eosdata); WaterPropsIAPWS *getWater() const { diff --git a/Cantera/src/thermo/WaterTP.cpp b/Cantera/src/thermo/WaterTP.cpp index 18ae092f1..ab964a24f 100644 --- a/Cantera/src/thermo/WaterTP.cpp +++ b/Cantera/src/thermo/WaterTP.cpp @@ -35,7 +35,7 @@ namespace Cantera { } - WaterTP::WaterTP(string inputFile, string id) : + WaterTP::WaterTP(std::string inputFile, std::string id) : ThermoPhase(), m_sub(0), m_subflag(0), @@ -49,7 +49,7 @@ namespace Cantera { } - WaterTP::WaterTP(XML_Node& phaseRoot, string id) : + WaterTP::WaterTP(XML_Node& phaseRoot, std::string id) : ThermoPhase(), m_sub(0), m_subflag(0), @@ -129,7 +129,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void WaterTP::constructPhaseXML(XML_Node& phaseNode, string id) { + void WaterTP::constructPhaseXML(XML_Node& phaseNode, std::string id) { /* * Call the Cantera importPhase() function. This will import @@ -162,14 +162,14 @@ namespace Cantera { * phase. If none is given, the first XML * phase element will be used. */ - void WaterTP::constructPhaseFile(string inputFile, string id) { + void WaterTP::constructPhaseFile(std::string inputFile, std::string id) { if (inputFile.size() == 0) { throw CanteraError("WaterTp::initThermo", "input file is null"); } - string path = findInputFile(inputFile); - ifstream fin(path.c_str()); + std::string path = findInputFile(inputFile); + std::ifstream fin(path.c_str()); if (!fin) { throw CanteraError("WaterTP::initThermo","could not open " +path+" for reading."); @@ -202,7 +202,7 @@ namespace Cantera { } void WaterTP:: - initThermoXML(XML_Node& phaseNode, string id) { + initThermoXML(XML_Node& phaseNode, std::string id) { if (m_sub) delete m_sub; m_sub = new WaterPropsIAPWS(); if (m_sub == 0) { diff --git a/Cantera/src/thermo/WaterTP.h b/Cantera/src/thermo/WaterTP.h index 8d643e84d..685d0899f 100644 --- a/Cantera/src/thermo/WaterTP.h +++ b/Cantera/src/thermo/WaterTP.h @@ -65,8 +65,8 @@ namespace Cantera { WaterTP(); WaterTP(const WaterTP &b); WaterTP& operator=(const WaterTP&b); - WaterTP(string inputFile, string id = ""); - WaterTP(XML_Node& phaseRef, string id = ""); + WaterTP(std::string inputFile, std::string id = ""); + WaterTP(XML_Node& phaseRef, std::string id = ""); virtual ~WaterTP(); ThermoPhase *duplMyselfAsThermoPhase(); @@ -143,11 +143,11 @@ namespace Cantera { virtual void setTemperature(double temp); virtual void constructPhase(); - virtual void constructPhaseFile(string inputFile, string id); - virtual void constructPhaseXML(XML_Node& phaseNode, string id); + virtual void constructPhaseFile(std::string inputFile, std::string id); + virtual void constructPhaseXML(XML_Node& phaseNode, std::string id); - virtual void initThermoXML(XML_Node& eosdata, string id); + virtual void initThermoXML(XML_Node& eosdata, std::string id); virtual void initThermo(); virtual void setParametersFromXML(const XML_Node& eosdata);