00001 /** 00002 * @file PDSS_HKFT.h 00003 * Declarations for the class PDSS_HKFT (pressure dependent standard state) 00004 * which handles calculations for a single species in a phase using the 00005 * HKFT standard state 00006 * (see \ref pdssthermo and class \link Cantera::PDSS_HKFT PDSS_HKFT\endlink). 00007 */ 00008 00009 /* 00010 * $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $ 00011 * $Revision: 279 $ 00012 */ 00013 00014 /* 00015 * Copywrite (2006) Sandia Corporation. Under the terms of 00016 * Contract DE-AC04-94AL85000 with Sandia Corporation, the 00017 * U.S. Government retains certain rights in this software. 00018 */ 00019 00020 #ifndef CT_PDSS_HKFT_H 00021 #define CT_PDSS_HKFT_H 00022 00023 class WaterPropsIAPWS; 00024 #include "PDSS.h" 00025 00026 namespace Cantera { 00027 class XML_Node; 00028 class VPStandardState; 00029 class PDSS_Water; 00030 class WaterProps; 00031 00032 //! Class for pressure dependent standard states corresponding to 00033 //! ionic solutes in electrolyte water. 00034 /*! 00035 * 00036 * Virtual base class for calculation of the 00037 * pressure dependent standard state for a single species 00038 * 00039 * Class %PDSS is the base class 00040 * for a family of classes that compute properties of a set of 00041 * species in their standard states at a range of temperatures 00042 * and pressures. The independent variables for this object 00043 * are temperature and pressure. 00044 * The class may mave a reference to a SpeciesThermo object 00045 * which handles the calculation of the reference state temperature 00046 * behavior of a subset of species. 00047 * 00048 * This class is analagous to the SpeciesThermoInterpType 00049 * class, except that the standard state inherently incorporates 00050 * the pressure dependence. 00051 * 00052 * The class operates on a setState temperature and pressure basis. 00053 * It only recalculates the standard state when the setState functions 00054 * for temperature and pressure are called 00055 * 00056 * @ingroup pdssthermo 00057 */ 00058 class PDSS_HKFT : public PDSS { 00059 00060 public: 00061 /** 00062 * @name Constructors 00063 * @{ 00064 */ 00065 00066 //! Constructor that initializes the object by examining the XML entries 00067 //! from the ThermoPhase object 00068 /*! 00069 * This function calls the constructPDSS member function. 00070 * 00071 * @param tp Pointer to the ThermoPhase object pertaining to the phase 00072 * @param spindex Species index of the species in the phase 00073 */ 00074 PDSS_HKFT(VPStandardStateTP *tp, int spindex); 00075 00076 //! Copy Constructor 00077 /*! 00078 * @param b object to be copied 00079 */ 00080 PDSS_HKFT(const PDSS_HKFT &b); 00081 00082 //! Assignment operator 00083 /*! 00084 * @param b Object to be copied 00085 */ 00086 PDSS_HKFT& operator=(const PDSS_HKFT&b); 00087 00088 //! Constructor that initializes the object by examining the input file 00089 //! of the ThermoPhase object 00090 /*! 00091 * This function calls the constructPDSSFile member function. 00092 * 00093 * @param vptp_ptr Pointer to the ThermoPhase object pertaining to the phase 00094 * @param spindex Species index of the species in the phase 00095 * @param inputFile String name of the input file 00096 * @param id String name of the phase in the input file. The default 00097 * is the empty string, in which case the first phase in the 00098 * file is used. 00099 */ 00100 PDSS_HKFT(VPStandardStateTP *vptp_ptr, int spindex, 00101 std::string inputFile, std::string id = ""); 00102 00103 //! Constructor that initializes the object by examining the input file 00104 //! of the ThermoPhase object 00105 /*! 00106 * This function calls the constructPDSSXML member function. 00107 * 00108 * @param vptp_ptr Pointer to the ThermoPhase object pertaining to the phase 00109 * @param spindex Species index of the species in the phase 00110 * @param speciesNode Reference to the species XML tree. 00111 * @param phaseRef Reference to the XML tree containing the phase information. 00112 * @param spInstalled Boolean indicating whether the species is installed yet 00113 * or not. 00114 */ 00115 PDSS_HKFT(VPStandardStateTP *vptp_ptr, int spindex, const XML_Node& speciesNode, 00116 const XML_Node& phaseRef, bool spInstalled); 00117 00118 //! Destructor for the phase 00119 virtual ~PDSS_HKFT(); 00120 00121 //! Duplicator 00122 virtual PDSS *duplMyselfAsPDSS() const; 00123 00124 /** 00125 * @} 00126 * @name Utilities 00127 * @{ 00128 */ 00129 00130 /** 00131 * @} 00132 * @name Molar Thermodynamic Properties of the Species Standard State 00133 * in the Solution 00134 * @{ 00135 */ 00136 00137 /** 00138 * @} 00139 * @name Molar Thermodynamic Properties of the Solution -------------- 00140 * @{ 00141 */ 00142 00143 //! Return the molar enthalpy in units of J kmol-1 00144 /*! 00145 * Returns the species standard state enthalpy in J kmol-1 at the 00146 * current temperature and pressure. 00147 * 00148 * @return returns the species standard state enthalpy in J kmol-1 00149 */ 00150 virtual doublereal enthalpy_mole() const; 00151 00152 #ifdef DEBUG_MODE 00153 //! Return the molar enthalpy in units of J kmol-1 00154 /*! 00155 * Returns the species standard state enthalpy in J kmol-1 at the 00156 * current temperature and pressure. 00157 * 00158 * Note this is just an extra routine to check the arithmetic 00159 * 00160 * @return returns the species standard state enthalpy in J kmol-1 00161 */ 00162 doublereal enthalpy_mole2() const; 00163 #endif 00164 00165 //! Return the standard state molar enthalpy divided by RT 00166 /*! 00167 * Returns the species standard state enthalpy divided by RT at the 00168 * current temperature and pressure. 00169 * 00170 * @return returns the species standard state enthalpy in unitless form 00171 */ 00172 virtual doublereal enthalpy_RT() const; 00173 00174 //! Return the molar internal Energy in units of J kmol-1 00175 /*! 00176 * Returns the species standard state internal Energy in J kmol-1 at the 00177 * current temperature and pressure. 00178 * 00179 * @return returns the species standard state internal Energy in J kmol-1 00180 */ 00181 virtual doublereal intEnergy_mole() const; 00182 00183 //! Return the molar entropy in units of J kmol-1 K-1 00184 /*! 00185 * Returns the species standard state entropy in J kmol-1 K-1 at the 00186 * current temperature and pressure. 00187 * 00188 * @return returns the species standard state entropy in J kmol-1 K-1 00189 */ 00190 virtual doublereal entropy_mole() const; 00191 00192 //! Return the molar gibbs free energy in units of J kmol-1 00193 /*! 00194 * Returns the species standard state gibbs free energy in J kmol-1 at the 00195 * current temperature and pressure. 00196 * 00197 * @return returns the species standard state gibbs free energy in J kmol-1 00198 */ 00199 virtual doublereal gibbs_mole() const; 00200 00201 //! Return the molar const pressure heat capacity in units of J kmol-1 K-1 00202 /*! 00203 * Returns the species standard state Cp in J kmol-1 K-1 at the 00204 * current temperature and pressure. 00205 * 00206 * @return returns the species standard state Cp in J kmol-1 K-1 00207 */ 00208 virtual doublereal cp_mole() const; 00209 00210 //! Return the molar const volume heat capacity in units of J kmol-1 K-1 00211 /*! 00212 * Returns the species standard state Cv in J kmol-1 K-1 at the 00213 * current temperature and pressure. 00214 * 00215 * @return returns the species standard state Cv in J kmol-1 K-1 00216 */ 00217 virtual doublereal cv_mole() const; 00218 00219 //! Return the molar volume at standard state 00220 /*! 00221 * Returns the species standard state molar volume at the 00222 * current temperature and pressure 00223 * 00224 * @return returns the standard state molar volume divided by R 00225 * units are m**3 kmol-1. 00226 */ 00227 virtual doublereal molarVolume() const; 00228 00229 //! Return the standard state density at standard state 00230 /*! 00231 * Returns the species standard state density at the 00232 * current temperature and pressure 00233 * 00234 * @return returns the standard state density 00235 * units are kg m-3 00236 */ 00237 virtual doublereal density() const; 00238 00239 /** 00240 * @} 00241 * @name Properties of the Reference State of the Species 00242 * in the Solution 00243 * @{ 00244 */ 00245 00246 00247 //! Return the reference pressure for this phase. 00248 doublereal refPressure() const { 00249 return m_p0; 00250 } 00251 00252 //! Return the molar gibbs free energy divided by RT at reference pressure 00253 /*! 00254 * Returns the species reference state gibbs free energy divided by RT at the 00255 * current temperature. 00256 * 00257 * @return returns the reference state gibbs free energy divided by RT 00258 */ 00259 virtual doublereal gibbs_RT_ref() const; 00260 00261 //! Return the molar enthalpy divided by RT at reference pressure 00262 /*! 00263 * Returns the species reference state enthalpy divided by RT at the 00264 * current temperature. 00265 * 00266 * @return returns the reference state enthalpy divided by RT 00267 */ 00268 virtual doublereal enthalpy_RT_ref() const; 00269 00270 //! Return the molar entropy divided by R at reference pressure 00271 /*! 00272 * Returns the species reference state entropy divided by R at the 00273 * current temperature. 00274 * 00275 * @return returns the reference state entropy divided by R 00276 */ 00277 virtual doublereal entropy_R_ref() const; 00278 00279 //! Return the molar heat capacity divided by R at reference pressure 00280 /*! 00281 * Returns the species reference state heat capacity divided by R at the 00282 * current temperature. 00283 * 00284 * @return returns the reference state heat capacity divided by R 00285 */ 00286 virtual doublereal cp_R_ref() const; 00287 00288 //! Return the molar volume at reference pressure 00289 /*! 00290 * Returns the species reference state molar volume at the 00291 * current temperature. 00292 * 00293 * @return returns the reference state molar volume divided by R 00294 * units are m**3 kmol-1. 00295 */ 00296 virtual doublereal molarVolume_ref() const; 00297 00298 /** 00299 * @} 00300 * @name Mechanical Equation of State Properties 00301 * @{ 00302 */ 00303 00304 //! Returns the pressure (Pa) 00305 virtual doublereal pressure() const; 00306 00307 //! Sets the pressure in the object 00308 /*! 00309 * Currently, this sets the pressure in the PDSS object. 00310 * It is indeterminant what happens to the owning VPStandardStateTP 00311 * object and to the VPSSMgr object. 00312 * 00313 * @param pres Pressure to be set (Pascal) 00314 */ 00315 virtual void setPressure(doublereal pres); 00316 00317 //! Set the internal temperature 00318 /*! 00319 * @param temp Temperature (Kelvin) 00320 */ 00321 virtual void setTemperature(doublereal temp); 00322 00323 //! Return the current storred temperature 00324 doublereal temperature() const; 00325 00326 //! Set the internal temperature and pressure 00327 /*! 00328 * @param temp Temperature (Kelvin) 00329 * @param pres pressure (Pascals) 00330 */ 00331 virtual void setState_TP(doublereal temp, doublereal pres); 00332 00333 /** 00334 * @} 00335 * @name Miscellaneous properties of the standard state 00336 * @{ 00337 */ 00338 00339 /// critical temperature 00340 virtual doublereal critTemperature() const; 00341 00342 /// critical pressure 00343 virtual doublereal critPressure() const; 00344 00345 /// critical density 00346 virtual doublereal critDensity() const; 00347 00348 /** 00349 * @} 00350 * @name Initialization of the Object 00351 * @{ 00352 */ 00353 00354 //! Initialization routine for all of the shallow pointers 00355 /*! 00356 * This is a cascading call, where each level should call the 00357 * the parent level. 00358 * 00359 * The initThermo() routines get called before the initThermoXML() routines 00360 * from the constructPDSSXML() routine. 00361 * 00362 * 00363 * Calls initPtrs(); 00364 */ 00365 virtual void initThermo(); 00366 00367 //! Initialization of a PDSS object using an 00368 //! input XML file. 00369 /*! 00370 * 00371 * This routine is a precursor to constructPDSSXML(XML_Node*) 00372 * routine, which does most of the work. 00373 * 00374 * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object 00375 * This object must have already been malloced. 00376 * 00377 * @param spindex Species index within the phase 00378 * 00379 * @param inputFile XML file containing the description of the 00380 * phase 00381 * 00382 * @param id Optional parameter identifying the name of the 00383 * phase. If none is given, the first XML 00384 * phase element will be used. 00385 */ 00386 void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex, 00387 std::string inputFile, std::string id); 00388 00389 //! Initialization of a PDSS object using an xml tree 00390 /*! 00391 * This routine is a driver for the initialization of the 00392 * object. 00393 * 00394 * basic logic: 00395 * initThermo() (cascade) 00396 * getStuff from species Part of XML file 00397 * initThermoXML(phaseNode) (cascade) 00398 * 00399 * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object 00400 * This object must have already been malloced. 00401 * 00402 * @param spindex Species index within the phase 00403 * 00404 * @param speciesNode XML Node containing the species information 00405 * 00406 * @param phaseNode Reference to the phase Information for the phase 00407 * that owns this species. 00408 * 00409 * @param spInstalled Boolean indicating whether the species is 00410 * already installed. 00411 */ 00412 void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex, 00413 const XML_Node& speciesNode, 00414 const XML_Node& phaseNode, bool spInstalled); 00415 00416 //! Initialization routine for the PDSS object based on the phaseNode 00417 /*! 00418 * This is a cascading call, where each level should call the 00419 * the parent level. 00420 * 00421 * @param phaseNode Reference to the phase Information for the phase 00422 * that owns this species. 00423 * 00424 * @param id Optional parameter identifying the name of the 00425 * phase. If none is given, the first XML 00426 * phase element will be used. 00427 */ 00428 virtual void initThermoXML(const XML_Node& phaseNode, std::string& id); 00429 00430 //! Initialize or Reinitialize all shallow pointers in the object 00431 /*! 00432 * This command is called to reinitialize all shallow pointers in the 00433 * object. It's needed for the duplicator capability 00434 * 00435 * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object 00436 * This object must have already been malloced. 00437 * 00438 * @param vpssmgr_ptr Pointer to the variable pressure standard state 00439 * calculator for this phase 00440 * 00441 * @param spthermo_ptr Pointer to the optional SpeciesThermo object 00442 * that will handle the calculation of the reference 00443 * state thermodynamic coefficients. 00444 */ 00445 virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, 00446 SpeciesThermo* spthermo_ptr); 00447 00448 //! This utility function reports back the type of 00449 //! parameterization and all of the parameters for the 00450 //! species, index. 00451 /*! 00452 * 00453 * The following parameters are reported 00454 * 00455 * - c[0] = m_deltaG_formation_tr_pr; 00456 * - c[1] = m_deltaH_formation_tr_pr; 00457 * - c[2] = m_Mu0_tr_pr; 00458 * - c[3] = m_Entrop_tr_pr; 00459 * - c[4] = m_a1; 00460 * - c[5] = m_a2; 00461 * - c[6] = m_a3; 00462 * - c[7] = m_a4; 00463 * - c[8] = m_c1; 00464 * - c[9] = m_c2; 00465 * - c[10] = m_omega_pr_tr; 00466 * . 00467 * 00468 * @param kindex Species index 00469 * @param type Integer type of the standard type 00470 * @param c Vector of coefficients used to set the 00471 * parameters for the standard state. 00472 * @param minTemp output - Minimum temperature 00473 * @param maxTemp output - Maximum temperature 00474 * @param refPressure output - reference pressure (Pa). 00475 * 00476 */ 00477 virtual void reportParams(int &kindex, int &type, doublereal * const c, 00478 doublereal &minTemp, doublereal &maxTemp, 00479 doublereal &refPressure) const; 00480 00481 //@} 00482 00483 00484 private: 00485 00486 //! Main routine that actually calculates the gibbs free energy difference 00487 //! between the reference state at Tr, Pr and T,P 00488 /*! 00489 * This is eEqn. 59 in Johnson et al. (1992). 00490 * 00491 */ 00492 doublereal deltaG() const; 00493 00494 //! Main routine that actually calculates the entropy difference 00495 //! between the reference state at Tr, Pr and T,P 00496 /*! 00497 * This is Eqn. 61 in Johnson et al. (1992). Actually, there appears to 00498 * be an error in the latter. This is a correction. 00499 */ 00500 doublereal deltaS() const; 00501 00502 #ifdef DEBUG_MODE 00503 //! Routine that actually calculates the enthalpy difference 00504 //! between the reference state at Tr, Pr and T,P 00505 /*! 00506 * This is an extra routine that was added to check the arithmetic 00507 */ 00508 doublereal deltaH() const; 00509 #endif 00510 00511 //! Internal formula for the calculation of a_g() 00512 /*! 00513 * The output of this is in units of Angstroms 00514 * 00515 * @param temp Temperature (K) 00516 * 00517 * @param ifunc parameters specifying the desired information 00518 * - 0 function value 00519 * - 1 derivative wrt temperature 00520 * - 2 2nd derivative wrt temperature 00521 * - 3 derivative wrt pressure 00522 */ 00523 doublereal ag(const doublereal temp, const int ifunc = 0) const; 00524 00525 //! Internal formula for the calculation of b_g() 00526 /*! 00527 * the output of this is unitless 00528 * 00529 * @param temp Temperature (K) 00530 * 00531 * @param ifunc parameters specifying the desired information 00532 * - 0 function value 00533 * - 1 derivative wrt temperature 00534 * - 2 2nd derivative wrt temperature 00535 * - 3 derivative wrt pressure 00536 */ 00537 doublereal bg(const doublereal temp, const int ifunc = 0) const; 00538 00539 //! function g appearing in the formulation 00540 /*! 00541 * Function g appearing in the Johnson et al formulation 00542 * 00543 * @param temp Temperature kelvin 00544 * @param pres Pressure (pascal) 00545 * @param ifunc parameters specifying the desired information 00546 * - 0 function value 00547 * - 1 derivative wrt temperature 00548 * - 2 2nd derivative wrt temperature 00549 * - 3 derivative wrt pressure 00550 */ 00551 doublereal g(const doublereal temp, const doublereal pres, const int ifunc = 0) const; 00552 00553 //! Difference function f appearing in the formulation 00554 /*! 00555 * Function f appearing in the Johnson et al formulation of omega_j 00556 * Eqn. 33 ref 00557 * 00558 * @param temp Temperature kelvin 00559 * @param pres Pressure (pascal) 00560 * @param ifunc parameters specifying the desired information 00561 * - 0 function value 00562 * - 1 derivative wrt temperature 00563 * - 2 2nd derivative wrt temperature 00564 * - 3 derivative wrt pressure 00565 */ 00566 doublereal f(const doublereal temp, const doublereal pres, const int ifunc = 0) const; 00567 00568 //! Evaluate the Gstar value appearing in the HKFT formulation 00569 /*! 00570 * 00571 * @param temp Temperature kelvin 00572 * @param pres Pressure (pascal) 00573 * @param ifunc parameters specifying the desired information 00574 * - 0 function value 00575 * - 1 derivative wrt temperature 00576 * - 2 2nd derivative wrt temperature 00577 * - 3 derivative wrt pressure 00578 */ 00579 doublereal gstar(const doublereal temp, const doublereal pres, 00580 const int ifunc = 0) const; 00581 00582 //! Function to look up Element Free Energies 00583 /*! 00584 * 00585 * This static function looks up the argument string in the 00586 * element database and returns the associated 298 K Gibbs Free energy 00587 * of the element in its stable state 00588 * 00589 * @param elemName String. Only the first 3 characters are significant 00590 * 00591 * @return 00592 * Return value contains the Gibbs free energy for that element 00593 * 00594 * @exception CanteraError 00595 * If a match is not found, a CanteraError is thrown as well 00596 */ 00597 doublereal LookupGe(const std::string& elemName); 00598 00599 //! Translate a Gibbs free energy of formation value to a NIST-based Chemical potential 00600 /*! 00601 * Internally, this function is used to translate the input value, 00602 * m_deltaG_formation_tr_pr, 00603 * to the internally storred value, m_Mu0_tr_pr. 00604 */ 00605 void convertDGFormation(); 00606 00607 private: 00608 //! Water standard state calculator 00609 /*! 00610 * derived from the equation of state for water. 00611 * This object doesn't own the object. Just a shallow pointer. 00612 */ 00613 PDSS_Water *m_waterSS; 00614 00615 //! density of standard-state water 00616 /*! 00617 * internal temporary variable 00618 */ 00619 mutable doublereal m_densWaterSS; 00620 00621 //! Pointer to the water property calculator 00622 WaterProps *m_waterProps; 00623 00624 //! Born coefficient for the current ion or species 00625 doublereal m_born_coeff_j; 00626 00627 //! Electrostatic radii 00628 doublereal m_r_e_j; 00629 00630 //! Input value of deltaG of Formation at Tr and Pr (cal gmol-1) 00631 /*! 00632 * Tr = 298.15 Pr = 1 atm 00633 * 00634 * This is the delta G for the formation reaction of the 00635 * ion from elements in their stable state at Tr, Pr. 00636 */ 00637 doublereal m_deltaG_formation_tr_pr; 00638 00639 //! Input value of deltaH of Formation at Tr and Pr (cal gmol-1) 00640 /*! 00641 * Tr = 298.15 Pr = 1 atm 00642 * 00643 * This is the delta H for the formation reaction of the 00644 * ion from elements in their stable state at Tr, Pr. 00645 */ 00646 doublereal m_deltaH_formation_tr_pr; 00647 00648 //! Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r 00649 /*! 00650 * This is the NIST scale value of Gibbs free energy at T_r = 298.15 00651 * and P_r = 1 atm. 00652 * 00653 * J kmol-1 00654 */ 00655 doublereal m_Mu0_tr_pr; 00656 00657 //! Input value of S_j at Tr and Pr (cal gmol-1 K-1) 00658 /*! 00659 * Tr = 298.15 Pr = 1 atm 00660 */ 00661 doublereal m_Entrop_tr_pr; 00662 00663 //! Input a1 coefficient (cal gmol-1 bar-1) 00664 doublereal m_a1; 00665 00666 //! Input a2 coefficient (cal gmol-1) 00667 doublereal m_a2; 00668 00669 //! Input a3 coefficient (cal K gmol-1 bar-1) 00670 doublereal m_a3; 00671 00672 //! Input a4 coefficient (cal K gmol-1) 00673 doublereal m_a4; 00674 00675 //! Input c1 coefficient (cal gmol-1 K-1) 00676 doublereal m_c1; 00677 00678 //! Input c2 coefficient (cal K gmol-1) 00679 doublereal m_c2; 00680 00681 //! Input omega_pr_tr coefficient(cal gmol-1) 00682 doublereal m_omega_pr_tr; 00683 00684 //! y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar 00685 doublereal m_Y_pr_tr; 00686 00687 //! Z = -1 / relEpsilon at 298.15 and 1 bar 00688 doublereal m_Z_pr_tr; 00689 00690 //! Reference pressure is 1 atm in units of bar= 1.0132 00691 doublereal m_presR_bar; 00692 00693 //! small value that is not quite zero 00694 doublereal m_domega_jdT_prtr; 00695 00696 //! Charge of the ion 00697 doublereal m_charge_j; 00698 00699 }; 00700 00701 } 00702 00703 #endif 00704 00705 00706