1 /** 2 * @file PDSS.h 3 * Declarations for the virtual base class PDSS (pressure dependent standard state) 4 * which handles calculations for a single species in a phase 5 * (see \ref pdssthermo and class \link Cantera::PDSS PDSS\endlink). 6 */ 7 8 // This file is part of Cantera. See License.txt in the top-level directory or 9 // at https://cantera.org/license.txt for license and copyright information. 10 11 #ifndef CT_PDSS_H 12 #define CT_PDSS_H 13 #include "cantera/base/ct_defs.h" 14 #include "cantera/base/AnyMap.h" 15 16 namespace Cantera 17 { 18 /** 19 * @defgroup pdssthermo Species Standard-State Thermodynamic Properties 20 * 21 * In this module we describe %Cantera's treatment of pressure dependent 22 * standard states (PDSS) objects. These are objects that calculate the standard 23 * state of a single species that depends on both temperature and pressure. 24 * 25 * To compute the thermodynamic properties of multicomponent solutions, it is 26 * necessary to know something about the thermodynamic properties of the 27 * individual species present in the solution. Exactly what sort of species 28 * properties are required depends on the thermodynamic model for the solution. 29 * For a gaseous solution (i.e., a gas mixture), the species properties required 30 * are usually ideal gas properties at the mixture temperature and at a 31 * reference pressure (almost always at 1 bar). For other types of solutions, 32 * however, it may not be possible to isolate the species in a "pure" state. For 33 * example, the thermodynamic properties of, say, Na+ and Cl- in saltwater are 34 * not easily determined from data on the properties of solid NaCl, or solid Na 35 * metal, or chlorine gas. In this case, the solvation in water is fundamental 36 * to the identity of the species, and some other reference state must be used. 37 * One common convention for liquid solutions is to use thermodynamic data for 38 * the solutes in the limit of infinite dilution within the pure solvent; 39 * another convention is to reference all properties to unit molality. 40 * 41 * In defining these standard states for species in a phase, we make the 42 * following definition. A reference state is a standard state of a species in a 43 * phase limited to one particular pressure, the reference pressure. The 44 * reference state specifies the dependence of all thermodynamic functions as a 45 * function of the temperature, in between a minimum temperature and a maximum 46 * temperature. The reference state also specifies the molar volume of the 47 * species as a function of temperature. The molar volume is a thermodynamic 48 * function. A full standard state does the same thing as a reference state, but 49 * specifies the thermodynamics functions at all pressures. 50 * 51 * Class PDSS is the base class for a family of classes that compute properties 52 * of a single species in a phase at its standard states, for a range of 53 * temperatures and pressures. PDSS objects are used by derivatives of the 54 * VPStandardState class. These classes assume that there exists a standard 55 * state for each species in the phase, where the thermodynamic functions are 56 * specified as a function of temperature and pressure. Standard state objects 57 * for each species in the phase are all derived from the PDSS virtual base 58 * class. 59 * 60 * The following classes inherit from PDSS. Each of these classes handles just 61 * one species. 62 * 63 * - PDSS_IdealGas 64 * - standardState model = "IdealGas" 65 * - This model assumes that the species in the phase obeys the ideal gas law 66 * for their pressure dependence. The manager uses a SimpleThermo object to 67 * handle the calculation of the reference state. This object adds the 68 * pressure dependencies to the thermo functions. 69 * 70 * - PDSS_ConstVol 71 * - standardState model = "ConstVol" or "constant_incompressible" 72 * - This model assumes that the species in the phase obeys the constant 73 * partial molar volume pressure dependence. The manager uses a 74 * SimpleThermo object to handle the calculation of the reference state. 75 * This object adds the pressure dependencies to these thermo functions. 76 * 77 * - PDSS_SSVol 78 * - standardState model = "temperature_polynomial" 79 * - standardState model = "density_temperature_polynomial" 80 * - This model assumes that the species in the phase obey a fairly general 81 * equation of state, but one that separates out the calculation of the 82 * standard state density and/or volume. Models include a cubic polynomial 83 * in temperature for either the standard state volume or the standard state 84 * density. The manager uses a SimpleThermo object to handle the calculation 85 * of the reference state. This object then adds the pressure dependencies 86 * and the volume terms to these thermo functions to complete the 87 * representation. 88 * 89 * - PDSS_Water 90 * - standardState model = "Water" 91 * - This model assumes that Species 0 is assumed to be water, and a real 92 * equation of state is used to model the T, P behavior. Note, the model 93 * assumes that the species is liquid water, and not steam. 94 * 95 * - PDSS_HKFT 96 * - standardState model = "HKFT" 97 * - This model assumes that the species follows the HKFT pressure dependent 98 * equation of state 99 * 100 * Normally the PDSS object is not called directly. Instead the 101 * VPStandardStateTP object manages the calls to the PDSS object for the entire 102 * set of species that comprise a phase. 103 * 104 * The PDSS objects may or may not utilize a SpeciesThermoInterpType reference 105 * state manager class to calculate the reference state thermodynamics functions 106 * in their own calculation. There are some classes, such as PDSS_IdealGas and 107 * PDSS+_ConstVol, which utilize the SpeciesThermoInterpType object because the 108 * calculation is very similar to the reference state calculation, while there 109 * are other classes, PDSS_Water and PDSS_HKFT, which don't utilize the 110 * reference state calculation at all, because it wouldn't make sense to. For 111 * example, using the PDSS_Water module, there isn't anything special about the 112 * reference pressure of 1 bar, so the reference state calculation would 113 * represent a duplication of work. Additionally, when evaluating thermodynamic 114 * properties at higher pressures and temperatures, near the critical point, 115 * evaluation of the thermodynamics at a pressure of 1 bar may lead to 116 * situations where the liquid is unstable, i.e., beyond the spinodal curve 117 * leading to potentially wrong evaluation results. 118 * 119 * @ingroup thermoprops 120 */ 121 122 class XML_Node; 123 class SpeciesThermoInterpType; 124 class VPStandardStateTP; 125 126 //! Virtual base class for a species with a pressure dependent standard state 127 /*! 128 * Virtual base class for calculation of the pressure dependent standard state 129 * for a single species 130 * 131 * Class PDSS is the base class for a family of classes that compute properties 132 * of a set of species in their standard states at a range of temperatures and 133 * pressures. The independent variables for this object are temperature and 134 * pressure. The class may have a reference to a SpeciesThermoInterpType object 135 * which handles the calculation of the reference state temperature behavior of 136 * the species. 137 * 138 * This class is analogous to the SpeciesThermoInterpType class, except that 139 * the standard state inherently incorporates the pressure dependence. 140 * 141 * The class operates on a setState temperature and pressure basis. It only 142 * recalculates the standard state when the setState functions for temperature 143 * and pressure are called. 144 * 145 * @ingroup pdssthermo 146 */ 147 class PDSS 148 { 149 public: 150 //! @name Constructors 151 //! @{ 152 153 //! Default Constructor 154 PDSS(); 155 156 // PDSS objects are not copyable or assignable 157 PDSS(const PDSS& b) = delete; 158 PDSS& operator=(const PDSS& b) = delete; ~PDSS()159 virtual ~PDSS() {} 160 161 //! @} 162 //! @name Utilities 163 //! @{ 164 165 //! @} 166 //! @name Molar Thermodynamic Properties of the Species Standard State in 167 //! the Solution 168 //! @{ 169 170 //! Return the molar enthalpy in units of J kmol-1 171 /*! 172 * @return the species standard state enthalpy in J kmol-1 at the current 173 * temperature and pressure. 174 */ 175 virtual doublereal enthalpy_mole() const; 176 177 //! Return the standard state molar enthalpy divided by RT 178 /*! 179 * @return The dimensionless species standard state enthalpy divided at 180 * the current temperature and pressure. 181 */ 182 virtual doublereal enthalpy_RT() const; 183 184 //! Return the molar internal Energy in units of J kmol-1 185 /*! 186 * @return The species standard state internal Energy in J kmol-1 at the 187 * current temperature and pressure. 188 */ 189 virtual doublereal intEnergy_mole() const; 190 191 //! Return the molar entropy in units of J kmol-1 K-1 192 /*! 193 * @return The species standard state entropy in J kmol-1 K-1 at the 194 * current temperature and pressure. 195 */ 196 virtual doublereal entropy_mole() const; 197 198 //! Return the standard state entropy divided by RT 199 /*! 200 * @return The species standard state entropy divided by RT at the current 201 * temperature and pressure. 202 */ 203 virtual doublereal entropy_R() const; 204 205 //! Return the molar Gibbs free energy in units of J kmol-1 206 /*! 207 * @return The species standard state Gibbs free energy in J kmol-1 at the 208 * current temperature and pressure. 209 */ 210 virtual doublereal gibbs_mole() const; 211 212 //! Return the molar Gibbs free energy divided by RT 213 /*! 214 * @return The species standard state Gibbs free energy divided by RT at 215 * the current temperature and pressure. 216 */ 217 virtual doublereal gibbs_RT() const; 218 219 //! Return the molar const pressure heat capacity in units of J kmol-1 K-1 220 /*! 221 * @return The species standard state Cp in J kmol-1 K-1 at the current 222 * temperature and pressure. 223 */ 224 virtual doublereal cp_mole() const; 225 226 //! Return the molar const pressure heat capacity divided by RT 227 /*! 228 * @return The species standard state Cp divided by RT at the current 229 * temperature and pressure. 230 */ 231 virtual doublereal cp_R() const; 232 233 //! Return the molar const volume heat capacity in units of J kmol-1 K-1 234 /*! 235 * @return The species standard state Cv in J kmol-1 K-1 at the 236 * current temperature and pressure. 237 */ 238 virtual doublereal cv_mole() const; 239 240 //! Return the molar volume at standard state 241 /*! 242 * @return The standard state molar volume at the current temperature and 243 * pressure. Units are m**3 kmol-1. 244 */ 245 virtual doublereal molarVolume() const; 246 247 //! Return the standard state density at standard state 248 /*! 249 * @return The standard state density at the current temperature and 250 * pressure. units are kg m-3 251 */ 252 virtual doublereal density() const; 253 254 //! Get the difference in the standard state enthalpy 255 //! between the current pressure and the reference pressure, p0. 256 virtual doublereal enthalpyDelp_mole() const; 257 258 //! Get the difference in the standard state entropy between 259 //! the current pressure and the reference pressure, p0 260 virtual doublereal entropyDelp_mole() const; 261 262 //! Get the difference in the standard state Gibbs free energy 263 //! between the current pressure and the reference pressure, p0. 264 virtual doublereal gibbsDelp_mole() const; 265 266 //! Get the difference in standard state heat capacity 267 //! between the current pressure and the reference pressure, p0. 268 virtual doublereal cpDelp_mole() const; 269 270 //! @} 271 //! @name Properties of the Reference State of the Species in the Solution 272 //! @{ 273 274 //! Return the reference pressure for this phase. refPressure()275 doublereal refPressure() const { 276 return m_p0; 277 } 278 279 //! return the minimum temperature minTemp()280 doublereal minTemp() const { 281 return m_minTemp; 282 } 283 284 //! return the minimum temperature maxTemp()285 doublereal maxTemp() const { 286 return m_maxTemp; 287 } 288 289 //! Return the molar Gibbs free energy divided by RT at reference pressure 290 /*! 291 * @return The reference state Gibbs free energy at the current 292 * temperature, divided by RT. 293 */ 294 virtual doublereal gibbs_RT_ref() const; 295 296 //! Return the molar enthalpy divided by RT at reference pressure 297 /*! 298 * @return The species reference state enthalpy at the current 299 * temperature, divided by RT. 300 */ 301 virtual doublereal enthalpy_RT_ref() const; 302 303 //! Return the molar entropy divided by R at reference pressure 304 /*! 305 * @return The species reference state entropy at the current 306 * temperature, divided by R. 307 */ 308 virtual doublereal entropy_R_ref() const; 309 310 //! Return the molar heat capacity divided by R at reference pressure 311 /*! 312 * @return The species reference state heat capacity divided by R at the 313 * current temperature. 314 */ 315 virtual doublereal cp_R_ref() const; 316 317 //! Return the molar volume at reference pressure 318 /*! 319 * @return The reference state molar volume. units are m**3 kmol-1. 320 */ 321 virtual doublereal molarVolume_ref() const; 322 323 //! @} 324 //! @name Mechanical Equation of State Properties 325 //! @{ 326 327 //! Returns the pressure (Pa) 328 virtual doublereal pressure() const; 329 330 //! Sets the pressure in the object 331 /*! 332 * Currently, this sets the pressure in the PDSS object. It is indeterminant 333 * what happens to the owning VPStandardStateTP object. 334 * 335 * @param pres Pressure to be set (Pascal) 336 */ 337 virtual void setPressure(doublereal pres); 338 339 //! Return the volumetric thermal expansion coefficient. Units: 1/K. 340 /*! 341 * The thermal expansion coefficient is defined as 342 * \f[ 343 * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P 344 * \f] 345 */ 346 virtual doublereal thermalExpansionCoeff() const; 347 348 //@} 349 /// @name Partial Molar Properties of the Solution 350 //@{ 351 352 //! Set the internal temperature 353 /*! 354 * @param temp Temperature (Kelvin) 355 */ 356 virtual void setTemperature(doublereal temp); 357 358 //! Return the current stored temperature 359 virtual doublereal temperature() const; 360 361 //! Set the internal temperature and pressure 362 /*! 363 * @param temp Temperature (Kelvin) 364 * @param pres pressure (Pascals) 365 */ 366 virtual void setState_TP(doublereal temp, doublereal pres); 367 368 //! Set the internal temperature and density 369 /*! 370 * @param temp Temperature (Kelvin) 371 * @param rho Density (kg m-3) 372 */ 373 virtual void setState_TR(doublereal temp, doublereal rho); 374 375 //! @} 376 //! @name Miscellaneous properties of the standard state 377 //! @{ 378 379 //! critical temperature 380 virtual doublereal critTemperature() const; 381 382 //! critical pressure 383 virtual doublereal critPressure() const; 384 385 //! critical density 386 virtual doublereal critDensity() const; 387 388 //! saturation pressure 389 /*! 390 * @param T Temperature (Kelvin) 391 */ 392 virtual doublereal satPressure(doublereal T); 393 394 //! Return the molecular weight of the species 395 //! in units of kg kmol-1 396 doublereal molecularWeight() const; 397 398 //! Set the molecular weight of the species 399 /*! 400 * @param mw Molecular Weight in kg kmol-1 401 */ 402 void setMolecularWeight(doublereal mw); 403 404 //! @} 405 //! @name Initialization of the Object 406 //! @{ 407 408 //! Set the SpeciesThermoInterpType object used to calculate reference 409 //! state properties setReferenceThermo(shared_ptr<SpeciesThermoInterpType> stit)410 void setReferenceThermo(shared_ptr<SpeciesThermoInterpType> stit) { 411 m_spthermo = stit; 412 } 413 414 //! Set the parent VPStandardStateTP object of this PDSS object 415 /*! 416 * This information is only used by certain PDSS subclasses 417 * @param phase Pointer to the parent phase 418 * @param k Index of this species in the phase 419 */ setParent(VPStandardStateTP * phase,size_t k)420 virtual void setParent(VPStandardStateTP* phase, size_t k) {} 421 422 //! Initialization routine 423 /*! 424 * This is a cascading call, where each level should call the the parent 425 * level. 426 */ initThermo()427 virtual void initThermo() {} 428 429 //! Set model parameters from an AnyMap phase description, e.g. from the 430 //! `equation-of-state` field of a species definition. setParameters(const AnyMap & node)431 void setParameters(const AnyMap& node) { 432 m_input = node; 433 } 434 435 //! Store the parameters needed to reconstruct a copy of this PDSS object getParameters(AnyMap & eosNode)436 virtual void getParameters(AnyMap& eosNode) const {} 437 438 //! Initialization routine for the PDSS object based on the speciesNode 439 /*! 440 * This is a cascading call, where each level should call the the parent 441 * level. This function is called before initThermo() 442 * 443 * @deprecated The XML input format is deprecated and will be removed in 444 * Cantera 3.0. 445 */ setParametersFromXML(const XML_Node & speciesNode)446 virtual void setParametersFromXML(const XML_Node& speciesNode) {} 447 448 //! This utility function reports back the type of parameterization and 449 //! all of the parameters for the species, index. 450 /*! 451 * @param kindex Species index (unused) 452 * @param type Integer type of the standard type (unused) 453 * @param c Vector of coefficients used to set the 454 * parameters for the standard state. 455 * @param minTemp output - Minimum temperature 456 * @param maxTemp output - Maximum temperature 457 * @param refPressure output - reference pressure (Pa). 458 */ 459 virtual void reportParams(size_t& kindex, int& type, doublereal* const c, 460 doublereal& minTemp, doublereal& maxTemp, 461 doublereal& refPressure) const; 462 463 //@} 464 465 protected: 466 //! Current temperature used by the PDSS object 467 mutable doublereal m_temp; 468 469 //! State of the system - pressure 470 mutable doublereal m_pres; 471 472 //! Reference state pressure of the species. 473 doublereal m_p0; 474 475 //! Minimum temperature 476 doublereal m_minTemp; 477 478 //! Maximum temperature 479 doublereal m_maxTemp; 480 481 //! Molecular Weight of the species 482 doublereal m_mw; 483 484 //! Input data supplied via setParameters. This may include parameters for 485 //! different phase models, which will be used when initThermo() is called. 486 AnyMap m_input; 487 488 //! Pointer to the species thermodynamic property manager. Not used in all 489 //! PDSS models. 490 shared_ptr<SpeciesThermoInterpType> m_spthermo; 491 }; 492 493 //! Base class for PDSS classes which compute molar properties directly 494 class PDSS_Molar : public virtual PDSS 495 { 496 public: 497 virtual doublereal enthalpy_RT() const; 498 virtual doublereal entropy_R() const; 499 virtual doublereal gibbs_RT() const; 500 virtual doublereal cp_R() const; 501 }; 502 503 //! Base class for PDSS classes which compute nondimensional properties directly 504 class PDSS_Nondimensional : public virtual PDSS 505 { 506 public: 507 PDSS_Nondimensional(); 508 509 virtual doublereal enthalpy_mole() const; 510 virtual doublereal entropy_mole() const; 511 virtual doublereal gibbs_mole() const; 512 virtual doublereal cp_mole() const; 513 514 virtual double enthalpy_RT_ref() const; 515 virtual double entropy_R_ref() const; 516 virtual double gibbs_RT_ref() const; 517 virtual double cp_R_ref() const; 518 virtual double molarVolume_ref() const; 519 virtual double enthalpy_RT() const; 520 virtual double entropy_R() const; 521 virtual double gibbs_RT() const; 522 virtual double cp_R() const; 523 virtual double molarVolume() const; 524 virtual double density() const; 525 526 protected: 527 double m_h0_RT; //!< Reference state enthalpy divided by RT 528 double m_cp0_R; //!< Reference state heat capacity divided by R 529 double m_s0_R; //!< Reference state entropy divided by R 530 double m_g0_RT; //!< Reference state Gibbs free energy divided by RT 531 double m_V0; //!< Reference state molar volume (m^3/kmol) 532 double m_hss_RT; //!< Standard state enthalpy divided by RT 533 double m_cpss_R; //!< Standard state heat capacity divided by R 534 double m_sss_R; //!< Standard state entropy divided by R 535 double m_gss_RT; //!< Standard state Gibbs free energy divided by RT 536 double m_Vss; //!< Standard State molar volume (m^3/kmol) 537 }; 538 539 } 540 541 #endif 542