VPSSMgr_ConstVol.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef WIN32
00022 #pragma warning(disable:4786)
00023 #pragma warning(disable:4503)
00024 #endif
00025
00026 #include "VPSSMgr_ConstVol.h"
00027 #include "xml.h"
00028 #include "VPStandardStateTP.h"
00029 #include "SpeciesThermoFactory.h"
00030 #include "PDSS_ConstVol.h"
00031
00032 using namespace std;
00033
00034 namespace Cantera {
00035
00036 VPSSMgr_ConstVol::VPSSMgr_ConstVol(VPStandardStateTP *vp_ptr, SpeciesThermo *spth) :
00037 VPSSMgr(vp_ptr, spth)
00038 {
00039 m_useTmpRefStateStorage = true;
00040 m_useTmpStandardStateStorage = true;
00041 }
00042
00043
00044 VPSSMgr_ConstVol::~VPSSMgr_ConstVol()
00045 {
00046 }
00047
00048 VPSSMgr_ConstVol::VPSSMgr_ConstVol(const VPSSMgr_ConstVol &right) :
00049 VPSSMgr(right.m_vptp_ptr, right.m_spthermo)
00050 {
00051 m_useTmpRefStateStorage = true;
00052 m_useTmpStandardStateStorage = true;
00053 *this = right;
00054 }
00055
00056
00057 VPSSMgr_ConstVol& VPSSMgr_ConstVol::operator=(const VPSSMgr_ConstVol &b)
00058 {
00059 if (&b == this) return *this;
00060 VPSSMgr::operator=(b);
00061 return *this;
00062 }
00063
00064 VPSSMgr *VPSSMgr_ConstVol::duplMyselfAsVPSSMgr() const {
00065 VPSSMgr_ConstVol *vpm = new VPSSMgr_ConstVol(*this);
00066 return (VPSSMgr *) vpm;
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 void VPSSMgr_ConstVol::_updateStandardStateThermo() {
00078
00079 doublereal del_pRT = (m_plast - m_p0) / (GasConstant * m_tlast);
00080
00081 for (int k = 0; k < m_kk; k++) {
00082 m_hss_RT[k] = m_h0_RT[k] + del_pRT * m_Vss[k];
00083 m_cpss_R[k] = m_cp0_R[k];
00084 m_sss_R[k] = m_s0_R[k];
00085 m_gss_RT[k] = m_hss_RT[k] - m_sss_R[k];
00086
00087 }
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 void VPSSMgr_ConstVol::getGibbs_RT_ref(doublereal *grt) const {
00100 if (m_useTmpRefStateStorage) {
00101 std::copy(m_g0_RT.begin(), m_g0_RT.end(), grt);
00102 doublereal _rt = GasConstant * m_tlast;
00103 scale(grt, grt + m_kk, grt, _rt);
00104 } else {
00105 throw CanteraError("VPSSMgr_ConstVol::getGibbs_RT_ref",
00106 "unimplemented without m_useTmpRefStateStorage");
00107 }
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 void VPSSMgr_ConstVol::getStandardVolumes_ref(doublereal *vol) const {
00120 if (m_useTmpStandardStateStorage) {
00121 std::copy(m_Vss.begin(), m_Vss.end(), vol);
00122 } else {
00123 throw CanteraError("VPSSMgr_ConstVol::getStandardVolumes_ref",
00124 "unimplemented without m_useTmpRefStateStorage");
00125 }
00126 }
00127
00128 void VPSSMgr_ConstVol::initThermo() {
00129 VPSSMgr::initThermo();
00130 }
00131
00132 void
00133 VPSSMgr_ConstVol::initThermoXML(XML_Node& phaseNode, std::string id) {
00134 VPSSMgr::initThermoXML(phaseNode, id);
00135
00136 XML_Node& speciesList = phaseNode.child("speciesArray");
00137 XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
00138 &phaseNode.root());
00139 const vector<string>&sss = m_vptp_ptr->speciesNames();
00140
00141 for (int k = 0; k < m_kk; k++) {
00142 const XML_Node* s = speciesDB->findByAttr("name", sss[k]);
00143 if (!s) {
00144 throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
00145 "no species Node for species " + sss[k]);
00146 }
00147 const XML_Node *ss = s->findByName("standardState");
00148 if (!ss) {
00149 throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
00150 "no standardState Node for species " + s->name());
00151 }
00152 std::string model = (*ss)["model"];
00153 if (model != "constant_incompressible" && model != "constantVolume") {
00154 throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
00155 "standardState model for species isn't constant_incompressible: " + s->name());
00156 }
00157 m_Vss[k] = getFloat(*ss, "molarVolume", "toSI");
00158 }
00159 }
00160
00161
00162
00163
00164
00165
00166 PDSS *
00167 VPSSMgr_ConstVol::createInstallPDSS(int k, const XML_Node& speciesNode,
00168 const XML_Node * const phaseNode_ptr) {
00169
00170 const XML_Node *ss = speciesNode.findByName("standardState");
00171 if (!ss) {
00172 throw CanteraError("VPSSMgr_ConstVol::installSpecies",
00173 "no standardState Node for species " + speciesNode.name());
00174 }
00175 std::string model = (*ss)["model"];
00176 if (model != "constant_incompressible" && model != "constantVolume") {
00177 throw CanteraError("VPSSMgr_ConstVol::initThermoXML",
00178 "standardState model for species isn't "
00179 "constant_incompressible: " + speciesNode.name());
00180 }
00181 if ((int) m_Vss.size() < k+1) {
00182 m_Vss.resize(k+1, 0.0);
00183 }
00184 m_Vss[k] = getFloat(*ss, "molarVolume", "toSI");
00185
00186 installSTSpecies(k, speciesNode, phaseNode_ptr);
00187
00188
00189 PDSS *kPDSS = new PDSS_ConstVol(m_vptp_ptr, k, speciesNode,
00190 *phaseNode_ptr, true);
00191 return kPDSS;
00192 }
00193
00194 PDSS_enumType VPSSMgr_ConstVol::reportPDSSType(int k) const {
00195 return cPDSS_CONSTVOL;
00196 }
00197
00198 VPSSMgr_enumType VPSSMgr_ConstVol::reportVPSSMgrType() const {
00199 return cVPSSMGR_CONSTVOL;
00200 }
00201 }
00202