00001 /** 00002 * @file StoichSubstanceSSTP.h 00003 * Header file for the StoichSubstanceSSTP class, which represents a fixed-composition 00004 * incompressible substance (see \ref thermoprops and 00005 * class \link Cantera::StoichSubstanceSSTP StoichSubstanceSSTP\endlink) 00006 */ 00007 00008 /* 00009 * Copywrite (2005) Sandia Corporation. Under the terms of 00010 * Contract DE-AC04-94AL85000 with Sandia Corporation, the 00011 * U.S. Government retains certain rights in this software. 00012 */ 00013 00014 /* 00015 * $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $ 00016 * $Revision: 279 $ 00017 */ 00018 00019 #ifndef CT_STOICHSUBSTANCESSTP_H 00020 #define CT_STOICHSUBSTANCESSTP_H 00021 00022 #include "mix_defs.h" 00023 #include "SingleSpeciesTP.h" 00024 #include "SpeciesThermo.h" 00025 00026 namespace Cantera { 00027 00028 //! Class %StoichSubstanceSSTP represents a stoichiometric (fixed 00029 //! composition) incompressible substance. 00030 /*! 00031 * This class internally changes the independent degree of freedom from 00032 * density to pressure. This is necessary because the phase is 00033 * incompressible. It uses a constant volume approximation. 00034 * 00035 * 00036 * <b> Specification of Species Standard %State Properties </b> 00037 * 00038 * This class inherits from SingleSpeciesTP. 00039 * It is assumed that the reference state thermodynamics may be 00040 * obtained by a pointer to a populated species thermodynamic property 00041 * manager class (see ThermoPhase::m_spthermo). How to relate pressure 00042 * changes to the reference state thermodynamics is resolved at this level. 00043 * 00044 * For an incompressible, 00045 * stoichiometric substance, the molar internal energy is 00046 * independent of pressure. Since the thermodynamic properties 00047 * are specified by giving the standard-state enthalpy, the 00048 * term \f$ P_0 \hat v\f$ is subtracted from the specified molar 00049 * enthalpy to compute the molar internal energy. The entropy is 00050 * assumed to be independent of the pressure. 00051 * 00052 * The enthalpy function is given by the following relation. 00053 * 00054 * \f[ 00055 * \raggedright h^o_k(T,P) = 00056 * h^{ref}_k(T) + \tilde v \left( P - P_{ref} \right) 00057 * \f] 00058 * 00059 * For an incompressible, 00060 * stoichiometric substance, the molar internal energy is 00061 * independent of pressure. Since the thermodynamic properties 00062 * are specified by giving the standard-state enthalpy, the 00063 * term \f$ P_{ref} \tilde v\f$ is subtracted from the specified reference molar 00064 * enthalpy to compute the molar internal energy. 00065 * 00066 * \f[ 00067 * u^o_k(T,P) = h^{ref}_k(T) - P_{ref} \tilde v 00068 * \f] 00069 * 00070 * The standard state heat capacity and entropy are independent 00071 * of pressure. The standard state gibbs free energy is obtained 00072 * from the enthalpy and entropy functions. 00073 * 00074 * 00075 * <b> Specification of Solution Thermodynamic Properties </b> 00076 * 00077 * All solution properties are obtained from the standard state 00078 * species functions, since there is only one species in the phase. 00079 * 00080 * <b> Application within %Kinetics Managers </b> 00081 * 00082 * The standard concentration is equal to 1.0. This means that the 00083 * kinetics operator works on an (activities basis). Since this 00084 * is a stoichiometric substance, this means that the concentration 00085 * of this phase drops out of kinetics expressions. 00086 * 00087 * An example of a reaction using this is a sticking coefficient 00088 * reaction of a substance in an ideal gas phase on a surface with a bulk phase 00089 * species in this phase. In this case, the rate of progress for this 00090 * reaction, \f$ R_s \f$, may be expressed via the following equation: 00091 * \f[ 00092 * R_s = k_s C_{gas} 00093 * \f] 00094 * where the units for \f$ R_s \f$ are kmol m-2 s-1. \f$ C_{gas} \f$ has units 00095 * of kmol m-3. Therefore, the kinetic rate constant, \f$ k_s \f$, has 00096 * units of m s-1. Nowhere does the concentration of the bulk phase 00097 * appear in the rate constant expression, since it's a stoichiometric 00098 * phase and the activity is always equal to 1.0. 00099 * 00100 * <b> Instanteation of the Class </b> 00101 * 00102 * The constructor for this phase is NOT located in the default ThermoFactory 00103 * for %Cantera. However, a new %StoichSubstanceSSTP may be created by 00104 * the following code snippets: 00105 * 00106 * @code 00107 * sprintf(file_ID,"%s#NaCl(S)", iFile); 00108 * XML_Node *xm = get_XML_NameID("phase", file_ID, 0); 00109 * StoichSubstanceSSTP *solid = new StoichSubstanceSSTP(*xm); 00110 * @endcode 00111 * 00112 * or by the following call to importPhase(): 00113 * 00114 * @code 00115 * sprintf(file_ID,"%s#NaCl(S)", iFile); 00116 * XML_Node *xm = get_XML_NameID("phase", file_ID, 0); 00117 * StoichSubstanceSSTP solid; 00118 * importPhase(*xm, &solid); 00119 * @endcode 00120 * 00121 * <b> XML Example </b> 00122 * 00123 * The phase model name for this is called StoichSubstance. It must be supplied 00124 * as the model attribute of the thermo XML element entry. 00125 * Within the phase XML block, 00126 * the density of the phase must be specified. An example of an XML file 00127 * this phase is given below. 00128 * 00129 * @verbatim 00130 <!-- phase NaCl(S) --> 00131 <phase dim="3" id="NaCl(S)"> 00132 <elementArray datasrc="elements.xml"> 00133 Na Cl 00134 </elementArray> 00135 <speciesArray datasrc="#species_NaCl(S)"> NaCl(S) </speciesArray> 00136 <thermo model="StoichSubstanceSSTP"> 00137 <density units="g/cm3">2.165</density> 00138 </thermo> 00139 <transport model="None"/> 00140 <kinetics model="none"/> 00141 </phase> 00142 00143 <!-- species definitions --> 00144 <speciesData id="species_NaCl(S)"> 00145 <!-- species NaCl(S) --> 00146 <species name="NaCl(S)"> 00147 <atomArray> Na:1 Cl:1 </atomArray> 00148 <thermo> 00149 <Shomate Pref="1 bar" Tmax="1075.0" Tmin="250.0"> 00150 <floatArray size="7"> 00151 50.72389, 6.672267, -2.517167, 00152 10.15934, -0.200675, -427.2115, 00153 130.3973 00154 </floatArray> 00155 </Shomate> 00156 </thermo> 00157 <density units="g/cm3">2.165</density> 00158 </species> 00159 </speciesData> @endverbatim 00160 * 00161 * The model attribute, "StoichSubstanceSSTP", on the thermo element 00162 * identifies the phase as being a StoichSubstanceSSTP object. 00163 * 00164 * @ingroup thermoprops 00165 */ 00166 class StoichSubstanceSSTP : public SingleSpeciesTP { 00167 00168 public: 00169 00170 //! Default constructor for the StoichSubstanceSSTP class 00171 StoichSubstanceSSTP(); 00172 00173 //! Construct and initialize a StoichSubstanceSSTP ThermoPhase object 00174 //! directly from an asci input file 00175 /*! 00176 * @param infile name of the input file 00177 * @param id name of the phase id in the file. 00178 * If this is blank, the first phase in the file is used. 00179 */ 00180 StoichSubstanceSSTP(std::string infile, std::string id = ""); 00181 00182 //! Construct and initialize a StoichSubstanceSSTP ThermoPhase object 00183 //! directly from an XML database 00184 /*! 00185 * @param phaseRef XML node pointing to a StoichSubstanceSSTP description 00186 * @param id Id of the phase. 00187 */ 00188 StoichSubstanceSSTP(XML_Node& phaseRef, std::string id = ""); 00189 00190 //! Copy constructor 00191 /*! 00192 * @param right Object to be copied 00193 */ 00194 StoichSubstanceSSTP(const StoichSubstanceSSTP &right); 00195 00196 //! Assignment operator 00197 /*! 00198 * @param right Object to be copied 00199 */ 00200 StoichSubstanceSSTP & operator=(const StoichSubstanceSSTP & right); 00201 00202 //! Destructor for the routine (virtual) 00203 virtual ~StoichSubstanceSSTP(); 00204 00205 //! Duplication function 00206 /*! 00207 * This virtual function is used to create a duplicate of the 00208 * current phase. It's used to duplicate the phase when given 00209 * a ThermoPhase pointer to the phase. 00210 * 00211 * @return It returns a ThermoPhase pointer. 00212 */ 00213 ThermoPhase *duplMyselfAsThermoPhase() const; 00214 00215 /** 00216 * 00217 * @name Utilities 00218 * @{ 00219 */ 00220 00221 /** 00222 * Equation of state flag. 00223 * 00224 * Returns the value cStoichSubstance, defined in mix_defs.h. 00225 */ 00226 virtual int eosType() const; 00227 00228 /** 00229 * @} 00230 * @name Molar Thermodynamic Properties of the Solution 00231 * @{ 00232 */ 00233 00234 /** 00235 * @} 00236 * @name Mechanical Equation of State 00237 * @{ 00238 */ 00239 00240 00241 //! Report the Pressure. Units: Pa. 00242 /*! 00243 * For an incompressible substance, the density is independent 00244 * of pressure. This method simply returns the storred 00245 * pressure value. 00246 */ 00247 virtual doublereal pressure() const; 00248 00249 //! Set the pressure at constant temperature. Units: Pa. 00250 /*! 00251 * For an incompressible substance, the density is 00252 * independent of pressure. Therefore, this method only 00253 * stores the specified pressure value. It does not 00254 * modify the density. 00255 * 00256 * @param p Pressure (units - Pa) 00257 */ 00258 virtual void setPressure(doublereal p); 00259 00260 //! Returns the isothermal compressibility. Units: 1/Pa. 00261 /*! 00262 * The isothermal compressibility is defined as 00263 * \f[ 00264 * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T 00265 * \f] 00266 */ 00267 virtual doublereal isothermalCompressibility() const; 00268 00269 //! Return the volumetric thermal expansion coefficient. Units: 1/K. 00270 /*! 00271 * The thermal expansion coefficient is defined as 00272 * \f[ 00273 * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P 00274 * \f] 00275 */ 00276 virtual doublereal thermalExpansionCoeff() const ; 00277 00278 /** 00279 * @} 00280 * @name Activities, Standard States, and Activity Concentrations 00281 * 00282 * This section is largely handled by parent classes, since there 00283 * is only one species. Therefore, the activity is equal to one. 00284 * @{ 00285 */ 00286 00287 //! This method returns an array of generalized concentrations 00288 /*! 00289 * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k / 00290 * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration 00291 * defined below and \f$ a_k \f$ are activities used in the 00292 * thermodynamic functions. These activity (or generalized) 00293 * concentrations are used 00294 * by kinetics manager classes to compute the forward and 00295 * reverse rates of elementary reactions. 00296 * 00297 * For a stoichiomeetric substance, there is 00298 * only one species, and the generalized concentration is 1.0. 00299 * 00300 * @param c Output array of generalized concentrations. The 00301 * units depend upon the implementation of the 00302 * reaction rate expressions within the phase. 00303 */ 00304 virtual void getActivityConcentrations(doublereal* c) const; 00305 00306 //! Return the standard concentration for the kth species 00307 /*! 00308 * The standard concentration \f$ C^0_k \f$ used to normalize 00309 * the activity (i.e., generalized) concentration. 00310 * This phase assumes that the kinetics operator works on an 00311 * dimensionless basis. Thus, the standard concentration is 00312 * equal to 1.0. 00313 * 00314 * @param k Optional parameter indicating the species. The default 00315 * is to assume this refers to species 0. 00316 * @return 00317 * Returns The standard Concentration as 1.0 00318 */ 00319 virtual doublereal standardConcentration(int k=0) const; 00320 00321 //! Natural logarithm of the standard concentration of the kth species. 00322 /*! 00323 * @param k index of the species (defaults to zero) 00324 */ 00325 virtual doublereal logStandardConc(int k=0) const; 00326 00327 //! Get the array of chemical potentials at unit activity for the species 00328 //! at their standard states at the current <I>T</I> and <I>P</I> of the solution. 00329 /*! 00330 * For a stoichiometric substance, there is no activity term in 00331 * the chemical potential expression, and therefore the 00332 * standard chemical potential and the chemical potential 00333 * are both equal to the molar Gibbs function. 00334 * 00335 * These are the standard state chemical potentials \f$ \mu^0_k(T,P) 00336 * \f$. The values are evaluated at the current 00337 * temperature and pressure of the solution 00338 * 00339 * @param mu0 Output vector of chemical potentials. 00340 * Length: m_kk. 00341 */ 00342 virtual void getStandardChemPotentials(doublereal* mu0) const; 00343 00344 //! Returns the units of the standard and generalized concentrations. 00345 /*! 00346 * Note they have the same units, as their 00347 * ratio is defined to be equal to the activity of the kth 00348 * species in the solution, which is unitless. 00349 * 00350 * This routine is used in print out applications where the 00351 * units are needed. Usually, MKS units are assumed throughout 00352 * the program and in the XML input files. 00353 * 00354 * The base %ThermoPhase class assigns thedefault quantities 00355 * of (kmol/m3) for all species. 00356 * Inherited classes are responsible for overriding the default 00357 * values if necessary. 00358 * 00359 * @param uA Output vector containing the units 00360 * uA[0] = kmol units - default = 1 00361 * uA[1] = m units - default = -nDim(), the number of spatial 00362 * dimensions in the Phase class. 00363 * uA[2] = kg units - default = 0; 00364 * uA[3] = Pa(pressure) units - default = 0; 00365 * uA[4] = Temperature units - default = 0; 00366 * uA[5] = time units - default = 0 00367 * @param k species index. Defaults to 0. 00368 * @param sizeUA output int containing the size of the vector. 00369 * Currently, this is equal to 6. 00370 */ 00371 virtual void getUnitsStandardConc(doublereal *uA, int k = 0, 00372 int sizeUA = 6) const; 00373 00374 //@} 00375 /// @name Partial Molar Properties of the Solution 00376 /// 00377 /// These properties are handled by the parent class, 00378 /// SingleSpeciesTP 00379 //@{ 00380 00381 00382 //@} 00383 /// @name Properties of the Standard State of the Species in the Solution 00384 //@{ 00385 00386 //! Get the nondimensional Enthalpy functions for the species 00387 //! at their standard states at the current <I>T</I> and <I>P</I> of the solution. 00388 /*! 00389 * @param hrt Output vector of nondimensional standard state enthalpies. 00390 * Length: m_kk. 00391 */ 00392 virtual void getEnthalpy_RT(doublereal* hrt) const; 00393 00394 //! Get the array of nondimensional Entropy functions for the 00395 //! standard state species at the current <I>T</I> and <I>P</I> of the solution. 00396 /*! 00397 * @param sr Output vector of nondimensional standard state entropies. 00398 * Length: m_kk. 00399 */ 00400 virtual void getEntropy_R(doublereal* sr) const; 00401 00402 //! Get the nondimensional Gibbs functions for the species 00403 //! in their standard states at the current <I>T</I> and <I>P</I> of the solution. 00404 /*! 00405 * @param grt Output vector of nondimensional standard state gibbs free energies 00406 * Length: m_kk. 00407 */ 00408 virtual void getGibbs_RT(doublereal* grt) const; 00409 00410 //! Get the nondimensional Heat Capacities at constant 00411 //! pressure for the species standard states 00412 //! at the current <I>T</I> and <I>P</I> of the solution 00413 /*! 00414 * @param cpr Output vector of nondimensional standard state heat capacities 00415 * Length: m_kk. 00416 */ 00417 virtual void getCp_R(doublereal* cpr) const; 00418 00419 //! Returns the vector of nondimensional Internal Energies of the standard 00420 //! state species at the current <I>T</I> and <I>P</I> of the solution 00421 /*! 00422 * For an incompressible, 00423 * stoichiometric substance, the molar internal energy is 00424 * independent of pressure. Since the thermodynamic properties 00425 * are specified by giving the standard-state enthalpy, the 00426 * term \f$ P_{ref} \hat v\f$ is subtracted from the specified reference molar 00427 * enthalpy to compute the standard state molar internal energy. 00428 * 00429 * @param urt output vector of nondimensional standard state 00430 * internal energies of the species. Length: m_kk. 00431 */ 00432 virtual void getIntEnergy_RT(doublereal* urt) const; 00433 00434 //@} 00435 /// @name Thermodynamic Values for the Species Reference States 00436 //@{ 00437 00438 //! Returns the vector of nondimensional 00439 //! internal Energies of the reference state at the current temperature 00440 //! of the solution and the reference pressure for each species. 00441 /*! 00442 * @param urt Output vector of nondimensional reference state 00443 * internal energies of the species. 00444 * Length: m_kk 00445 */ 00446 virtual void getIntEnergy_RT_ref(doublereal *urt) const; 00447 00448 /* 00449 * ---- Critical State Properties 00450 */ 00451 00452 00453 /* 00454 * ---- Saturation Properties 00455 */ 00456 00457 /* 00458 * @internal Initialize. This method is provided to allow 00459 * subclasses to perform any initialization required after all 00460 * species have been added. For example, it might be used to 00461 * resize internal work arrays that must have an entry for 00462 * each species. The base class implementation does nothing, 00463 * and subclasses that do not require initialization do not 00464 * need to overload this method. When importing a CTML phase 00465 * description, this method is called just prior to returning 00466 * from function importPhase. 00467 * 00468 * @see importCTML.cpp 00469 */ 00470 virtual void initThermo(); 00471 00472 00473 virtual void initThermoXML(XML_Node& phaseNode, std::string id); 00474 00475 //! Set the equation of state parameters 00476 /*! 00477 * @internal 00478 * The number and meaning of these depends on the subclass. 00479 * 00480 * @param n number of parameters 00481 * @param c array of \a n coefficients 00482 * c[0] = density of phase [ kg/m3 ] 00483 */ 00484 virtual void setParameters(int n, doublereal * const c); 00485 00486 //! Get the equation of state parameters in a vector 00487 /*! 00488 * @internal 00489 * 00490 * @param n number of parameters 00491 * @param c array of \a n coefficients 00492 * 00493 * For this phase: 00494 * - n = 1 00495 * - c[0] = density of phase [ kg/m3 ] 00496 */ 00497 virtual void getParameters(int &n, doublereal * const c) const; 00498 00499 //! Set equation of state parameter values from XML entries. 00500 /*! 00501 * This method is called by function importPhase() in 00502 * file importCTML.cpp when processing a phase definition in 00503 * an input file. It should be overloaded in subclasses to set 00504 * any parameters that are specific to that particular phase 00505 * model. Note, this method is called before the phase is 00506 * initialzed with elements and/or species. 00507 * 00508 * For this phase, the density of the phase is specified in this block. 00509 * 00510 * @param eosdata An XML_Node object corresponding to 00511 * the "thermo" entry for this phase in the input file. 00512 * 00513 * eosdata points to the thermo block, and looks like this: 00514 * 00515 * @verbatim 00516 <phase id="stoichsolid" > 00517 <thermo model="StoichSubstance"> 00518 <density units="g/cm3">3.52</density> 00519 </thermo> 00520 </phase> @endverbatim 00521 * 00522 */ 00523 virtual void setParametersFromXML(const XML_Node& eosdata); 00524 00525 protected: 00526 00527 }; 00528 00529 //! Class %electrodeElectron represents an electron in a 00530 //! metal using the Standard hydrogen reference electrode 00531 /*! 00532 * 00533 * The class is based on the electron have a chemical potential 00534 * equal to one-half of the entropy of the H2 gas at 1 bar. 00535 * 00536 */ 00537 class electrodeElectron : public StoichSubstanceSSTP { 00538 public: 00539 00540 //! Default constructor for the electrodeElectron class 00541 electrodeElectron(); 00542 00543 //! Construct and initialize a electrodeElectron ThermoPhase object 00544 //! directly from an asci input file 00545 /*! 00546 * @param infile name of the input file 00547 * @param id name of the phase id in the file. 00548 * If this is blank, the first phase in the file is used. 00549 */ 00550 electrodeElectron(std::string infile, std::string id = ""); 00551 00552 //! Construct and initialize a electrodeElectron ThermoPhase object 00553 //! directly from an XML database 00554 /*! 00555 * @param phaseRef XML node pointing to a electrodeElectron description 00556 * @param id Id of the phase. 00557 */ 00558 electrodeElectron(XML_Node& phaseRef, std::string id = ""); 00559 00560 //! Copy constructor 00561 /*! 00562 * @param right Object to be copied 00563 */ 00564 electrodeElectron(const electrodeElectron &right); 00565 00566 //! Assignment operator 00567 /*! 00568 * @param right Object to be copied 00569 */ 00570 electrodeElectron & operator=(const electrodeElectron & right); 00571 00572 //! Destructor for the routine (virtual) 00573 virtual ~electrodeElectron(); 00574 00575 void setParametersFromXML(const XML_Node& eosdata); 00576 00577 virtual void initThermoXML(XML_Node& phaseNode, std::string id); 00578 00579 void setParameters(int n, doublereal * const c); 00580 }; 00581 00582 } 00583 00584 #endif