VPSSMgr_ConstVol.cpp

Go to the documentation of this file.
00001 /**
00002  *  @file VPSSMgr_ConstVol.cpp
00003  *  Definition file for a derived class that handles the calculation
00004  *  of standard state thermo properties for
00005  *  a set of species which have a constant molar volume pressure
00006  *  dependence (see \ref thermoprops and
00007  * class \link Cantera::VPSSMgr_ConstVol VPSSMgr_ConstVol\endlink).
00008  */
00009 /*
00010  * Copywrite (2005) Sandia Corporation. Under the terms of 
00011  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00012  * U.S. Government retains certain rights in this software.
00013  */
00014 /*
00015  *  $Author: hkmoffa $
00016  *  $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00017  *  $Revision: 279 $
00018  */
00019 
00020 // turn off warnings under Windows
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    * Get the nondimensional Entropies for the species
00071    * standard states at the current T and P of the solution.
00072    *
00073    * Note, this is equal to the reference state entropies
00074    * due to the zero volume expansivity:
00075    * i.e., (dS/dp)_T = (dV/dT)_P = 0.0
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       // m_Vss[k] constant
00087     }
00088   }
00089 
00090   /*
00091    *  Returns the vector of nondimensional
00092    *  Gibbs free energies of the reference state at the current temperature
00093    *  of the solution and the reference pressure for the species.
00094    *
00095    * @param grt Output vector contains the nondimensional Gibbs free energies
00096    *            of the reference state of the species
00097    *            length = m_kk, units = dimensionless.
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   //  Get the molar volumes of the species reference states at the current
00112   //  <I>T</I> and <I>P_ref</I> of the solution.
00113   /*
00114    * units = m^3 / kmol
00115    *
00116    * @param vol     Output vector containing the standard state volumes.
00117    *                Length: m_kk.
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   //  void
00162   // VPSSMgr_ConstVol::installSpecies(int k, const XML_Node& speciesNode,  
00163   //                               const XML_Node *phaseNode_ptr) {
00164   //}
00165 
00166   PDSS *
00167   VPSSMgr_ConstVol::createInstallPDSS(int k, const XML_Node& speciesNode,  
00168                                       const XML_Node * const phaseNode_ptr) {
00169     //VPSSMgr::installSpecies(k, speciesNode, phaseNode_ptr);
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 
Generated by  doxygen 1.6.3