From 48261703d43d4017b68b55ad96c9a0c88e6f55d3 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 20 Oct 2009 22:26:24 +0000 Subject: [PATCH] Added the object PDSS_SSVol. This has more functionality than PDSS_ConstVol in that there are a range of models for fitting the standard state volume. Removed executable flags. removed the function pdssType. --- Cantera/src/thermo/ConstDensityThermo.cpp | 0 Cantera/src/thermo/ConstDensityThermo.h | 0 Cantera/src/thermo/Constituents.cpp | 0 Cantera/src/thermo/Constituents.h | 0 Cantera/src/thermo/NasaPoly1.h | 0 Cantera/src/thermo/NasaThermo.h | 0 Cantera/src/thermo/PDSS_ConstVol.h | 1 - Cantera/src/thermo/PDSS_HKFT.h | 1 - Cantera/src/thermo/PDSS_IdealGas.h | 2 - Cantera/src/thermo/PDSS_IonsFromNeutral.h | 2 - Cantera/src/thermo/PDSS_SSVol.cpp | 427 ++++++++++++++++++ Cantera/src/thermo/PDSS_SSVol.h | 452 ++++++++++++++++++++ Cantera/src/thermo/Phase.cpp | 0 Cantera/src/thermo/Phase.h | 0 Cantera/src/thermo/ShomatePoly.h | 0 Cantera/src/thermo/ShomateThermo.h | 0 Cantera/src/thermo/SpeciesThermo.h | 0 Cantera/src/thermo/SpeciesThermoFactory.cpp | 0 Cantera/src/thermo/SpeciesThermoFactory.h | 0 Cantera/src/thermo/SpeciesThermoMgr.h | 0 Cantera/src/thermo/State.h | 0 Cantera/src/thermo/ThermoPhase.h | 0 Cantera/src/thermo/VPSSMgr_General.cpp | 10 + Cantera/src/thermo/mix_defs.h | 18 + Cantera/src/thermo/speciesThermoTypes.h | 0 25 files changed, 907 insertions(+), 6 deletions(-) mode change 100755 => 100644 Cantera/src/thermo/ConstDensityThermo.cpp mode change 100755 => 100644 Cantera/src/thermo/ConstDensityThermo.h mode change 100755 => 100644 Cantera/src/thermo/Constituents.cpp mode change 100755 => 100644 Cantera/src/thermo/Constituents.h mode change 100755 => 100644 Cantera/src/thermo/NasaPoly1.h mode change 100755 => 100644 Cantera/src/thermo/NasaThermo.h create mode 100644 Cantera/src/thermo/PDSS_SSVol.cpp create mode 100644 Cantera/src/thermo/PDSS_SSVol.h mode change 100755 => 100644 Cantera/src/thermo/Phase.cpp mode change 100755 => 100644 Cantera/src/thermo/Phase.h mode change 100755 => 100644 Cantera/src/thermo/ShomatePoly.h mode change 100755 => 100644 Cantera/src/thermo/ShomateThermo.h mode change 100755 => 100644 Cantera/src/thermo/SpeciesThermo.h mode change 100755 => 100644 Cantera/src/thermo/SpeciesThermoFactory.cpp mode change 100755 => 100644 Cantera/src/thermo/SpeciesThermoFactory.h mode change 100755 => 100644 Cantera/src/thermo/SpeciesThermoMgr.h mode change 100755 => 100644 Cantera/src/thermo/State.h mode change 100755 => 100644 Cantera/src/thermo/ThermoPhase.h mode change 100755 => 100644 Cantera/src/thermo/mix_defs.h mode change 100755 => 100644 Cantera/src/thermo/speciesThermoTypes.h diff --git a/Cantera/src/thermo/ConstDensityThermo.cpp b/Cantera/src/thermo/ConstDensityThermo.cpp old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/ConstDensityThermo.h b/Cantera/src/thermo/ConstDensityThermo.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/Constituents.cpp b/Cantera/src/thermo/Constituents.cpp old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/Constituents.h b/Cantera/src/thermo/Constituents.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/NasaPoly1.h b/Cantera/src/thermo/NasaPoly1.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/NasaThermo.h b/Cantera/src/thermo/NasaThermo.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/PDSS_ConstVol.h b/Cantera/src/thermo/PDSS_ConstVol.h index 0d668f1db..eaea66322 100644 --- a/Cantera/src/thermo/PDSS_ConstVol.h +++ b/Cantera/src/thermo/PDSS_ConstVol.h @@ -99,7 +99,6 @@ namespace Cantera { * @name Utilities * @{ */ - virtual int pdssType() const { return -1; } /** * @} diff --git a/Cantera/src/thermo/PDSS_HKFT.h b/Cantera/src/thermo/PDSS_HKFT.h index cdb95103d..987005f72 100644 --- a/Cantera/src/thermo/PDSS_HKFT.h +++ b/Cantera/src/thermo/PDSS_HKFT.h @@ -126,7 +126,6 @@ namespace Cantera { * @name Utilities * @{ */ - virtual int pdssType() const { return -1; } /** * @} diff --git a/Cantera/src/thermo/PDSS_IdealGas.h b/Cantera/src/thermo/PDSS_IdealGas.h index 9cd996f51..909581ec0 100644 --- a/Cantera/src/thermo/PDSS_IdealGas.h +++ b/Cantera/src/thermo/PDSS_IdealGas.h @@ -101,8 +101,6 @@ namespace Cantera { * @name Utilities * @{ */ - virtual int pdssType() const { return -1; } - /** * @} diff --git a/Cantera/src/thermo/PDSS_IonsFromNeutral.h b/Cantera/src/thermo/PDSS_IonsFromNeutral.h index 8c545355c..7399c6953 100644 --- a/Cantera/src/thermo/PDSS_IonsFromNeutral.h +++ b/Cantera/src/thermo/PDSS_IonsFromNeutral.h @@ -103,8 +103,6 @@ namespace Cantera { * @name Utilities * @{ */ - virtual int pdssType() const { return -1; } - /** * @} diff --git a/Cantera/src/thermo/PDSS_SSVol.cpp b/Cantera/src/thermo/PDSS_SSVol.cpp new file mode 100644 index 000000000..78a4260dd --- /dev/null +++ b/Cantera/src/thermo/PDSS_SSVol.cpp @@ -0,0 +1,427 @@ +/** + * @file PDSS_SSVol.cpp + * Implementation of a pressure dependent standard state + * virtual function. + */ +/* + * Copywrite (2006) Sandia Corporation. Under the terms of + * Contract DE-AC04-94AL85000 with Sandia Corporation, the + * U.S. Government retains certain rights in this software. + */ +/* + * $Id: PDSS_SSVol.cpp,v 1.10 2009/01/04 06:34:20 hkmoffa Exp $ + */ + +#include "ct_defs.h" +#include "xml.h" +#include "ctml.h" +#include "PDSS_SSVol.h" +#include "ThermoFactory.h" + +#include "VPStandardStateTP.h" + +using namespace std; + +namespace Cantera { + /** + * Basic list of constructors and duplicators + */ + + PDSS_SSVol::PDSS_SSVol(VPStandardStateTP *tp, int spindex) : + PDSS(tp, spindex), + volumeModel_(cSSVOLUME_CONSTANT), + m_constMolarVolume(-1.0) + { + m_pdssType = cPDSS_SSVOL; + TCoeff_[0] = 0.0; + TCoeff_[1] = 0.0; + TCoeff_[2] = 0.0; + } + + + PDSS_SSVol::PDSS_SSVol(VPStandardStateTP *tp, int spindex, std::string inputFile, std::string id) : + PDSS(tp, spindex), + volumeModel_(cSSVOLUME_CONSTANT), + m_constMolarVolume(-1.0) + { + + m_pdssType = cPDSS_SSVOL; + constructPDSSFile(tp, spindex, inputFile, id); + } + + PDSS_SSVol::PDSS_SSVol(VPStandardStateTP *tp, int spindex, + const XML_Node& speciesNode, + const XML_Node& phaseRoot, + bool spInstalled) : + PDSS(tp, spindex), + volumeModel_(cSSVOLUME_CONSTANT), + m_constMolarVolume(-1.0) + { + m_pdssType = cPDSS_SSVOL; + constructPDSSXML(tp, spindex, speciesNode, phaseRoot, spInstalled) ; + } + + + PDSS_SSVol::PDSS_SSVol(const PDSS_SSVol &b) : + PDSS(b), + volumeModel_(cSSVOLUME_CONSTANT), + m_constMolarVolume(-1.0) + { + /* + * Use the assignment operator to do the brunt + * of the work for the copy construtor. + */ + *this = b; + } + + /* + * Assignment operator + */ + PDSS_SSVol& PDSS_SSVol::operator=(const PDSS_SSVol&b) { + if (&b == this) return *this; + PDSS::operator=(b); + volumeModel_ = b.volumeModel_; + m_constMolarVolume = b.m_constMolarVolume; + TCoeff_ = b.TCoeff_; + return *this; + } + + PDSS_SSVol::~PDSS_SSVol() { + } + + //! Duplicator + PDSS* PDSS_SSVol::duplMyselfAsPDSS() const { + PDSS_SSVol * idg = new PDSS_SSVol(*this); + return (PDSS *) idg; + } + + /** + * constructPDSSXML: + * + * Initialization of a PDSS_SSVol object using an + * xml file. + * + * This routine is a precursor to initThermo(XML_Node*) + * routine, which does most of the work. + * + * @param infile XML file containing the description of the + * phase + * + * @param id Optional parameter identifying the name of the + * phase. If none is given, the first XML + * phase element will be used. + */ + void PDSS_SSVol::constructPDSSXML(VPStandardStateTP *tp, int spindex, + const XML_Node& speciesNode, + const XML_Node& phaseNode, bool spInstalled) { + PDSS::initThermo(); + SpeciesThermo &sp = m_tp->speciesThermo(); + m_p0 = sp.refPressure(m_spindex); + + if (!spInstalled) { + throw CanteraError("PDSS_SSVol::constructPDSSXML", "spInstalled false not handled"); + } + + const XML_Node *ss = speciesNode.findByName("standardState"); + if (!ss) { + throw CanteraError("PDSS_SSVol::constructPDSSXML", + "no standardState Node for species " + speciesNode.name()); + } + std::string model = (*ss)["model"]; + if (model == "constant_incompressible" || model == "constant") { + volumeModel_ = cSSVOLUME_CONSTANT; + m_constMolarVolume = getFloat(*ss, "molarVolume", "toSI"); + } else if (model == "temperature_polynomial") { + volumeModel_ = cSSVOLUME_TPOLY; + getFloatArray(*ss, TCoeff_, true, "", "floatArray"); + } else if (model == "density_temperature_polynomial") { + volumeModel_ = cSSVOLUME_DENSITY_TPOLY; + getFloatArray(*ss, TCoeff_, true, "", "floatArray"); + } else { + throw CanteraError("PDSS_SSVol::initThermoXML", + "standardState model for species isn't constant_incompressible: " + speciesNode.name()); + } + std::string id = ""; + + } + + + /** + * constructPDSSFile(): + * + * Initialization of a PDSS_SSVol object using an + * xml file. + * + * This routine is a precursor to initThermo(XML_Node*) + * routine, which does most of the work. + * + * @param infile XML file containing the description of the + * phase + * + * @param id Optional parameter identifying the name of the + * phase. If none is given, the first XML + * phase element will be used. + */ + void PDSS_SSVol::constructPDSSFile(VPStandardStateTP *tp, int spindex, + std::string inputFile, std::string id) { + + if (inputFile.size() == 0) { + throw CanteraError("PDSS_SSVol::initThermo", + "input file is null"); + } + std::string path = findInputFile(inputFile); + ifstream fin(path.c_str()); + if (!fin) { + throw CanteraError("PDSS_SSVol::initThermo","could not open " + +path+" for reading."); + } + /* + * The phase object automatically constructs an XML object. + * Use this object to store information. + */ + + XML_Node *fxml = new XML_Node(); + fxml->build(fin); + XML_Node *fxml_phase = findXMLPhase(fxml, id); + if (!fxml_phase) { + throw CanteraError("PDSS_SSVol::initThermo", + "ERROR: Can not find phase named " + + id + " in file named " + inputFile); + } + + XML_Node& speciesList = fxml_phase->child("speciesArray"); + XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"], + &(fxml_phase->root())); + const vector&sss = tp->speciesNames(); + const XML_Node* s = speciesDB->findByAttr("name", sss[spindex]); + + constructPDSSXML(tp, spindex, *s, *fxml_phase, true); + delete fxml; + } + + void PDSS_SSVol::initThermoXML(const XML_Node& phaseNode, std::string& id) { + PDSS::initThermoXML(phaseNode, id); + m_minTemp = m_spthermo->minTemp(m_spindex); + m_maxTemp = m_spthermo->maxTemp(m_spindex); + m_p0 = m_spthermo->refPressure(m_spindex); + m_mw = m_tp->molecularWeight(m_spindex); + } + + void PDSS_SSVol::initThermo() { + PDSS::initThermo(); + SpeciesThermo &sp = m_tp->speciesThermo(); + m_p0 = sp.refPressure(m_spindex); + m_V0_ptr[m_spindex] = m_constMolarVolume; + m_Vss_ptr[m_spindex] = m_constMolarVolume; + } + + doublereal + PDSS_SSVol::enthalpy_mole() const { + doublereal val = enthalpy_RT(); + doublereal RT = GasConstant * m_temp; + return (val * RT); + } + + doublereal + PDSS_SSVol::enthalpy_RT() const { + doublereal val = m_hss_RT_ptr[m_spindex]; + return (val); + } + + + doublereal + PDSS_SSVol::intEnergy_mole() const { + doublereal pVRT = (m_pres * m_Vss_ptr[m_spindex]) / (GasConstant * m_temp); + doublereal val = m_h0_RT_ptr[m_spindex] - pVRT; + doublereal RT = GasConstant * m_temp; + return (val * RT); + } + + + doublereal + PDSS_SSVol::entropy_mole() const { + doublereal val = entropy_R(); + return (val * GasConstant); + } + + doublereal + PDSS_SSVol::entropy_R() const { + doublereal val = m_sss_R_ptr[m_spindex]; + return (val); + } + + /** + * Calculate the Gibbs free energy in mks units of + * J kmol-1 K-1. + */ + doublereal + PDSS_SSVol::gibbs_mole() const { + doublereal val = gibbs_RT(); + doublereal RT = GasConstant * m_temp; + return (val * RT); + } + + doublereal + PDSS_SSVol::gibbs_RT() const { + doublereal val = m_gss_RT_ptr[m_spindex]; + return (val); + } + + doublereal + PDSS_SSVol::cp_mole() const { + doublereal val = m_cpss_R_ptr[m_spindex]; + return (val * GasConstant); + } + + doublereal + PDSS_SSVol::cp_R() const { + doublereal val = m_cpss_R_ptr[m_spindex]; + return (val); + } + + doublereal + PDSS_SSVol::cv_mole() const { + doublereal val = (cp_mole() - m_V0_ptr[m_spindex]); + return (val); + } + + doublereal + PDSS_SSVol::molarVolume() const { + doublereal val = m_Vss_ptr[m_spindex]; + return (val); + } + + doublereal + PDSS_SSVol::density() const { + doublereal val = m_Vss_ptr[m_spindex]; + return (m_mw/val); + } + + doublereal + PDSS_SSVol::gibbs_RT_ref() const { + doublereal val = m_g0_RT_ptr[m_spindex]; + return (val); + } + + doublereal PDSS_SSVol::enthalpy_RT_ref() const { + doublereal val = m_h0_RT_ptr[m_spindex]; + return (val); + } + + doublereal PDSS_SSVol::entropy_R_ref() const { + doublereal val = m_s0_R_ptr[m_spindex]; + return (val); + } + + doublereal PDSS_SSVol::cp_R_ref() const { + doublereal val = m_cp0_R_ptr[m_spindex]; + return (val); + } + + doublereal PDSS_SSVol::molarVolume_ref() const { + doublereal val = m_V0_ptr[m_spindex]; + return (val); + } + + void PDSS_SSVol::calcMolarVolume() const { + if (volumeModel_ == cSSVOLUME_CONSTANT ) { + m_Vss_ptr[m_spindex] = m_constMolarVolume; + } else if (volumeModel_ == cSSVOLUME_TPOLY) { + m_Vss_ptr[m_spindex] = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * TCoeff_[2]); + dVdT_ = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2]; + d2VdT2_ = 2.0 * TCoeff_[2]; + } else if (volumeModel_ == cSSVOLUME_DENSITY_TPOLY) { + doublereal dens = (TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * TCoeff_[2])); + m_Vss_ptr[m_spindex] = m_mw / dens; + doublereal dens2 = dens * dens; + doublereal ddensdT = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2]; + doublereal d2densdT2 = 2.0 * TCoeff_[2]; + dVdT_ = - m_mw / (dens2) * (ddensdT); + d2VdT2_ = 2.0 * m_mw / (dens2 * dens) * ddensdT * ddensdT - m_mw / dens2 * d2densdT2; + } else { + throw CanteraError("PDSS_SSVol::calcMolarVolume", "unimplemented"); + } + } + + + /// critical temperature + doublereal PDSS_SSVol::critTemperature() const { + throw CanteraError("PDSS_SSVol::critTemperature()", "unimplemented"); + return (0.0); + } + + /// critical pressure + doublereal PDSS_SSVol::critPressure() const { + throw CanteraError("PDSS_SSVol::critPressure()", "unimplemented"); + return (0.0); + } + + /// critical density + doublereal PDSS_SSVol::critDensity() const { + throw CanteraError("PDSS_SSVol::critDensity()", "unimplemented"); + return (0.0); + } + + + + void PDSS_SSVol::setPressure(doublereal p) { + m_pres = p; + doublereal deltaP = m_pres - m_p0; + if (fabs(deltaP) < 1.0E-10) { + m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex]; + m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex]; + m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; + m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex]; + } else { + doublereal del_pRT = deltaP / (GasConstant * m_temp); + doublereal sV_term = - deltaP / (GasConstant) * dVdT_; + m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] + sV_term + del_pRT * (m_Vss_ptr[m_spindex]); + m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex] + sV_term; + m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; + m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex] - m_temp * deltaP * d2VdT2_; + } + } + + void PDSS_SSVol::setTemperature(doublereal temp) { + m_temp = temp; + m_spthermo->update_one(m_spindex, temp, m_cp0_R_ptr, m_h0_RT_ptr, m_s0_R_ptr); + calcMolarVolume(); + m_g0_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] - m_s0_R_ptr[m_spindex]; + doublereal deltaP = m_pres - m_p0; + if (fabs(deltaP) < 1.0E-10) { + m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex]; + m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex]; + m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; + m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex]; + } else { + doublereal del_pRT = deltaP / (GasConstant * m_temp); + doublereal sV_term = - deltaP / (GasConstant) * dVdT_; + m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] + sV_term + del_pRT * (m_Vss_ptr[m_spindex]); + m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex] + sV_term; + m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; + m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex] - m_temp * deltaP * d2VdT2_; + } + } + + + void PDSS_SSVol::setState_TP(doublereal temp, doublereal pres) { + m_pres = pres; + setTemperature(temp); + } + + + void PDSS_SSVol::setState_TR(doublereal temp, doublereal rho) { + doublereal rhoStored = m_mw / m_constMolarVolume; + if (fabs(rhoStored - rho) / (rhoStored + rho) > 1.0E-4) { + throw CanteraError("PDSS_SSVol::setState_TR", + "Inconsistent supplied rho"); + } + setTemperature(temp); + } + + /// saturation pressure + doublereal PDSS_SSVol::satPressure(doublereal t){ + return (1.0E-200); + } + +} diff --git a/Cantera/src/thermo/PDSS_SSVol.h b/Cantera/src/thermo/PDSS_SSVol.h new file mode 100644 index 000000000..422c28ed6 --- /dev/null +++ b/Cantera/src/thermo/PDSS_SSVol.h @@ -0,0 +1,452 @@ +/** + * @file PDSS_SSVol.h + * Declarations for the class PDSS_SSVol (pressure dependent standard state) + * which handles calculations for a single species with an expression for the molar volume in a phase + * given by an enumerated data type + * (see class \ref pdssthermo and \link Cantera::PDSS_SSVol PDSS_SSVol\endlink). + */ +/* + * Copywrite (2006) Sandia Corporation. Under the terms of + * Contract DE-AC04-94AL85000 with Sandia Corporation, the + * U.S. Government retains certain rights in this software. + */ +/* + * $Id: PDSS_SSVol.h,v 1.6 2008/10/13 21:01:48 hkmoffa Exp $ + */ + +#ifndef CT_PDSS_SSVOL_H +#define CT_PDSS_SSVOL_H + +#include "PDSS.h" + +namespace Cantera { + class XML_Node; + class VPStandardStateTP; + + //! Class for pressure dependent standard states that use a constant volume model + /*! + * Class for pressure dependent standard states that use a constant volume model. + * + * + * @ingroup pdssthermo + */ + class PDSS_SSVol : public PDSS { + + public: + + /** + * @name Constructors + * @{ + */ + + //! Constructor + /*! + * @param tp Pointer to the ThermoPhase object pertaining to the phase + * @param spindex Species index of the species in the phase + */ + PDSS_SSVol(VPStandardStateTP *tp, int spindex); + + + //! Constructor that initializes the object by examining the input file + //! of the ThermoPhase object + /*! + * This function calls the constructPDSSFile member function. + * + * @param tp Pointer to the ThermoPhase object pertaining to the phase + * @param spindex Species index of the species in the phase + * @param inputFile String name of the input file + * @param id String name of the phase in the input file. The default + * is the empty string, in which case the first phase in the + * file is used. + */ + PDSS_SSVol(VPStandardStateTP *tp, int spindex, + std::string inputFile, std::string id = ""); + + //! Constructor that initializes the object by examining the input file + //! of the ThermoPhase object + /*! + * This function calls the constructPDSSXML member function. + * + * @param vptp_ptr Pointer to the ThermoPhase object pertaining to the phase + * @param spindex Species index of the species in the phase + * @param speciesNode Reference to the species XML tree. + * @param phaseRef Reference to the XML tree containing the phase information. + * @param spInstalled Boolean indicating whether the species is installed yet + * or not. + */ + PDSS_SSVol(VPStandardStateTP *vptp_ptr, int spindex, const XML_Node& speciesNode, + const XML_Node& phaseRef, bool spInstalled); + + //! Copy Constructur + /*! + * @param b Object to be copied + */ + PDSS_SSVol(const PDSS_SSVol &b); + + //! Assignment operator + /*! + * @param b Object to be copeid + */ + PDSS_SSVol& operator=(const PDSS_SSVol&b); + + //! Destructor + virtual ~PDSS_SSVol(); + + //! Duplicator + virtual PDSS *duplMyselfAsPDSS() const; + + /** + * @} + * @name Utilities + * @{ + */ + + /** + * @} + * @name Molar Thermodynamic Properties of the Species Standard State + * in the Solution + * @{ + */ + + //! Return the molar enthalpy in units of J kmol-1 + /*! + * Returns the species standard state enthalpy in J kmol-1 at the + * current temperature and pressure. + * + * @return returns the species standard state enthalpy in J kmol-1 + */ + virtual doublereal enthalpy_mole() const; + + //! Return the standard state molar enthalpy divided by RT + /*! + * Returns the species standard state enthalpy divided by RT at the + * current temperature and pressure. + * + * @return returns the species standard state enthalpy in unitless form + */ + virtual doublereal enthalpy_RT() const; + + //! Return the molar internal Energy in units of J kmol-1 + /*! + * Returns the species standard state internal Energy in J kmol-1 at the + * current temperature and pressure. + * + * @return returns the species standard state internal Energy in J kmol-1 + */ + virtual doublereal intEnergy_mole() const; + + //! Return the molar entropy in units of J kmol-1 K-1 + /*! + * Returns the species standard state entropy in J kmol-1 K-1 at the + * current temperature and pressure. + * + * @return returns the species standard state entropy in J kmol-1 K-1 + */ + virtual doublereal entropy_mole() const; + + //! Return the standard state entropy divided by RT + /*! + * Returns the species standard state entropy divided by RT at the + * current temperature and pressure. + * + * @return returns the species standard state entropy divided by RT + */ + virtual doublereal entropy_R() const; + + //! Return the molar gibbs free energy in units of J kmol-1 + /*! + * Returns the species standard state gibbs free energy in J kmol-1 at the + * current temperature and pressure. + * + * @return returns the species standard state gibbs free energy in J kmol-1 + */ + virtual doublereal gibbs_mole() const; + + //! Return the molar gibbs free energy divided by RT + /*! + * Returns the species standard state gibbs free energy divided by RT at the + * current temperature and pressure. + * + * @return returns the species standard state gibbs free energy divided by RT + */ + virtual doublereal gibbs_RT() const; + + //! Return the molar const pressure heat capacity in units of J kmol-1 K-1 + /*! + * Returns the species standard state Cp in J kmol-1 K-1 at the + * current temperature and pressure. + * + * @return returns the species standard state Cp in J kmol-1 K-1 + */ + virtual doublereal cp_mole() const; + + //! Return the molar const pressure heat capacity divided by RT + /*! + * Returns the species standard state Cp divided by RT at the + * current temperature and pressure. + * + * @return returns the species standard state Cp divided by RT + */ + virtual doublereal cp_R() const; + + //! Return the molar const volume heat capacity in units of J kmol-1 K-1 + /*! + * Returns the species standard state Cv in J kmol-1 K-1 at the + * current temperature and pressure. + * + * @return returns the species standard state Cv in J kmol-1 K-1 + */ + virtual doublereal cv_mole() const; + + //! Return the molar volume at standard state + /*! + * Returns the species standard state molar volume at the + * current temperature and pressure + * + * @return returns the standard state molar volume divided by R + * units are m**3 kmol-1. + */ + virtual doublereal molarVolume() const; + + //! Return the standard state density at standard state + /*! + * Returns the species standard state density at the + * current temperature and pressure + * + * @return returns the standard state density + * units are kg m-3 + */ + virtual doublereal density() const; + + /** + * @} + * @name Properties of the Reference State of the Species + * in the Solution + * @{ + */ + + //! Return the molar gibbs free energy divided by RT at reference pressure + /*! + * Returns the species reference state gibbs free energy divided by RT at the + * current temperature. + * + * @return returns the reference state gibbs free energy divided by RT + */ + virtual doublereal gibbs_RT_ref() const; + + //! Return the molar enthalpy divided by RT at reference pressure + /*! + * Returns the species reference state enthalpy divided by RT at the + * current temperature. + * + * @return returns the reference state enthalpy divided by RT + */ + virtual doublereal enthalpy_RT_ref() const; + + //! Return the molar entropy divided by R at reference pressure + /*! + * Returns the species reference state entropy divided by R at the + * current temperature. + * + * @return returns the reference state entropy divided by R + */ + virtual doublereal entropy_R_ref() const; + + //! Return the molar heat capacity divided by R at reference pressure + /*! + * Returns the species reference state heat capacity divided by R at the + * current temperature. + * + * @return returns the reference state heat capacity divided by R + */ + virtual doublereal cp_R_ref() const; + + //! Return the molar volume at reference pressure + /*! + * Returns the species reference state molar volume at the + * current temperature. + * + * @return returns the reference state molar volume divided by R + * units are m**3 kmol-1. + */ + virtual doublereal molarVolume_ref() const; + + private: + + //! Does the internal calculation of the volume + /*! + * + */ + void calcMolarVolume() const; + + /** + * @} + * @name Mechanical Equation of State Properties + * @{ + */ + + //! Sets the pressure in the object + /*! + * Currently, this sets the pressure in the PDSS object. + * It is indeterminant what happens to the owning VPStandardStateTP + * object and to the VPSSMgr object. + * + * @param pres Pressure to be set (Pascal) + */ + virtual void setPressure(doublereal pres); + + //! Set the internal temperature + /*! + * @param temp Temperature (Kelvin) + */ + virtual void setTemperature(doublereal temp); + + //! Set the internal temperature and pressure + /*! + * @param temp Temperature (Kelvin) + * @param pres pressure (Pascals) + */ + virtual void setState_TP(doublereal temp, doublereal pres); + + + //! Set the internal temperature and density + /*! + * @param temp Temperature (Kelvin) + * @param rho Density (kg m-3) + */ + virtual void setState_TR(doublereal temp, doublereal rho); + + /** + * @} + * @name Miscellaneous properties of the standard state + * @{ + */ + + /// critical temperature + virtual doublereal critTemperature() const; + + /// critical pressure + virtual doublereal critPressure() const; + + /// critical density + virtual doublereal critDensity() const; + + /// saturation pressure + /*! + * @param t Temperature (kelvin) + */ + virtual doublereal satPressure(doublereal t); + + /** + * @} + * @name Initialization of the Object + * @{ + */ + + //! Initialization routine for all of the shallow pointers + /*! + * This is a cascading call, where each level should call the + * the parent level. + * + * The initThermo() routines get called before the initThermoXML() routines + * from the constructPDSSXML() routine. + * + * + * Calls initPtrs(); + */ + virtual void initThermo(); + + //! Initialization of a PDSS object using an + //! input XML file. + /*! + * + * This routine is a precursor to constructPDSSXML(XML_Node*) + * routine, which does most of the work. + * + * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object + * This object must have already been malloced. + * + * @param spindex Species index within the phase + * + * @param inputFile XML file containing the description of the + * phase + * + * @param id Optional parameter identifying the name of the + * phase. If none is given, the first XML + * phase element will be used. + */ + void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex, + std::string inputFile, std::string id); + + //! Initialization of a PDSS object using an xml tree + /*! + * This routine is a driver for the initialization of the + * object. + * + * basic logic: + * initThermo() (cascade) + * getStuff from species Part of XML file + * initThermoXML(phaseNode) (cascade) + * + * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object + * This object must have already been malloced. + * + * @param spindex Species index within the phase + * + * @param speciesNode XML Node containing the species information + * + * @param phaseNode Reference to the phase Information for the phase + * that owns this species. + * + * @param spInstalled Boolean indicating whether the species is + * already installed. + */ + void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex, + const XML_Node& speciesNode, + const XML_Node& phaseNode, bool spInstalled); + + //! Initialization routine for the PDSS object based on the phaseNode + /*! + * This is a cascading call, where each level should call the + * the parent level. + * + * @param phaseNode Reference to the phase Information for the phase + * that owns this species. + * + * @param id Optional parameter identifying the name of the + * phase. If none is given, the first XML + * phase element will be used. + */ + virtual void initThermoXML(const XML_Node& phaseNode, std::string& id); + + //@} + + private: + + //! Enumerated data type describing the type of volume model + //! used to calculate the standard state volume of the species + SSVolume_Model_enumType volumeModel_; + + //! Value of the constant molar volume for the species + /*! + * m3 / kmol + */ + doublereal m_constMolarVolume; + + //! coefficients for the temperature representation + vector_fp TCoeff_; + + //! Derivative of the volume wrt temperature + mutable doublereal dVdT_; + + //! 2nd derivative of the volume wrt temperature + mutable doublereal d2VdT2_; + + }; + +} + +#endif + + + diff --git a/Cantera/src/thermo/Phase.cpp b/Cantera/src/thermo/Phase.cpp old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/Phase.h b/Cantera/src/thermo/Phase.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/ShomatePoly.h b/Cantera/src/thermo/ShomatePoly.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/ShomateThermo.h b/Cantera/src/thermo/ShomateThermo.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/SpeciesThermo.h b/Cantera/src/thermo/SpeciesThermo.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/SpeciesThermoFactory.cpp b/Cantera/src/thermo/SpeciesThermoFactory.cpp old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/SpeciesThermoFactory.h b/Cantera/src/thermo/SpeciesThermoFactory.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/SpeciesThermoMgr.h b/Cantera/src/thermo/SpeciesThermoMgr.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/State.h b/Cantera/src/thermo/State.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/ThermoPhase.h b/Cantera/src/thermo/ThermoPhase.h old mode 100755 new mode 100644 diff --git a/Cantera/src/thermo/VPSSMgr_General.cpp b/Cantera/src/thermo/VPSSMgr_General.cpp index 043310b8a..f75c9ad27 100644 --- a/Cantera/src/thermo/VPSSMgr_General.cpp +++ b/Cantera/src/thermo/VPSSMgr_General.cpp @@ -30,6 +30,7 @@ #include "PDSS_IdealGas.h" #include "PDSS_Water.h" #include "PDSS_ConstVol.h" +#include "PDSS_SSVol.h" #include "PDSS_HKFT.h" #include "PDSS_IonsFromNeutral.h" #include "GeneralSpeciesThermo.h" @@ -159,6 +160,9 @@ namespace Cantera { if (model == "constant_incompressible") { VPSSMgr::installSTSpecies(k, speciesNode, phaseNode_ptr); kPDSS = new PDSS_ConstVol(m_vptp_ptr, k, speciesNode, *phaseNode_ptr, true); + if (!kPDSS) { + throw CanteraError("VPSSMgr_General::returnPDSS_ptr", "new PDSS_ConstVol failed"); + } } else if (model == "waterIAPWS" || model == "waterPDSS") { // VPSSMgr::installSTSpecies(k, speciesNode, phaseNode_ptr); kPDSS = new PDSS_Water(m_vptp_ptr, 0); @@ -190,6 +194,12 @@ namespace Cantera { } genSpthermo->installPDSShandler(k, kPDSS, this); + } else if (model == "constant" || model == "temperature_polynomial" || model == "density_temperature_polynomial") { + VPSSMgr::installSTSpecies(k, speciesNode, phaseNode_ptr); + kPDSS = new PDSS_SSVol(m_vptp_ptr, k, speciesNode, *phaseNode_ptr, true); + if (!kPDSS) { + throw CanteraError("VPSSMgr_General::returnPDSS_ptr", "new PDSS_SSVol failed"); + } } else { throw CanteraError("VPSSMgr_General::returnPDSS_ptr", "unknown standard state formulation: " + model); diff --git a/Cantera/src/thermo/mix_defs.h b/Cantera/src/thermo/mix_defs.h old mode 100755 new mode 100644 index 05954fada..adee9aeba --- a/Cantera/src/thermo/mix_defs.h +++ b/Cantera/src/thermo/mix_defs.h @@ -83,11 +83,29 @@ namespace Cantera { const int cVPSS_DebyeHuckel = 1050; const int cVPSS_MolalSoln = 1060; + //! Types of general formulations for the specification of the standard state volume + enum SSVolume_Model_enumType { + //! This approximation is for a constant volume + cSSVOLUME_CONSTANT = 0, + //! This approximation is for a species with a quadratic polynomial in temperature + /*! + * V^ss_i = ai + bi T + ci T2 + */ + cSSVOLUME_TPOLY, + //! This approximation is for a species where the density is expressed as a + //! quadratic polynomial in temperature + /*! + * V^ss_i = M_i / (ai + bi T + ci T2) + */ + cSSVOLUME_DENSITY_TPOLY + }; + //! Types of PDSS's enum PDSS_enumType { cPDSS_UNDEF = 100, cPDSS_IDEALGAS, cPDSS_CONSTVOL, + cPDSS_SSVOL, cPDSS_MOLAL_CONSTVOL, cPDSS_WATER, cPDSS_MOLAL_HKFT, diff --git a/Cantera/src/thermo/speciesThermoTypes.h b/Cantera/src/thermo/speciesThermoTypes.h old mode 100755 new mode 100644