Added an example of SingleSpeciesTP, called StoichSubstanceSSTP, which
does the same thing as the StoichSubstance in the previous directory. Put more functionality in the SingleSpeciesTP level; it now evaluates the reference polynomials.
This commit is contained in:
parent
d0a499d70e
commit
f42594d9d9
5 changed files with 867 additions and 56 deletions
|
|
@ -18,8 +18,8 @@ do_ranlib = @DO_RANLIB@
|
|||
CXX_FLAGS = @CXXFLAGS@ $(CXX_OPT)
|
||||
|
||||
# Extended Cantera Thermodynamics Object Files
|
||||
CATHERMO_OBJ = SingleSpeciesTP.o
|
||||
CATHERMO_H = SingleSpeciesTP.h
|
||||
CATHERMO_OBJ = SingleSpeciesTP.o StoichSubstanceSSTP.o
|
||||
CATHERMO_H = SingleSpeciesTP.h StoichSubstanceSSTP.h
|
||||
|
||||
CXX_INCLUDES = -I.. @CXX_INCLUDES@
|
||||
LIB = @buildlib@/libcaThermo.a
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@ namespace Cantera {
|
|||
* class constructor
|
||||
*/
|
||||
SingleSpeciesTP::SingleSpeciesTP() :
|
||||
ThermoPhase()
|
||||
ThermoPhase(),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_p0(OneAtm),
|
||||
m_tlast(-1.0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -281,6 +286,52 @@ namespace Cantera {
|
|||
* ---- Thermodynamic Values for the Species Reference States -------
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
* enthalpies of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for the species.
|
||||
*
|
||||
*
|
||||
*/
|
||||
void SingleSpeciesTP::getEnthalpy_RT_ref(doublereal *hrt) const {
|
||||
_updateThermo();
|
||||
hrt[0] = m_h0_RT[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
* enthalpies of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for the species.
|
||||
*/
|
||||
void SingleSpeciesTP::getGibbs_RT_ref(doublereal *grt) const {
|
||||
_updateThermo();
|
||||
grt[0] = m_h0_RT[0] - m_s0_R[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vector of the
|
||||
* gibbs function of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for the species.
|
||||
* units = J/kmol
|
||||
*/
|
||||
void SingleSpeciesTP::getGibbs_ref(doublereal *g) const {
|
||||
getGibbs_RT_ref(g);
|
||||
g[0] *= GasConstant * temperature();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
* entropies of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for the species.
|
||||
*/
|
||||
void SingleSpeciesTP::getEntropy_R_ref(doublereal *er) const {
|
||||
_updateThermo();
|
||||
er[0] = m_s0_R[0];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ------------------ Setting the State ------------------------
|
||||
*/
|
||||
|
|
@ -475,6 +526,23 @@ namespace Cantera {
|
|||
ThermoPhase::initThermo();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _updateThermo():
|
||||
*
|
||||
* This crucial internal routine calls the species thermo
|
||||
* update program to calculate new species Cp0, H0, and
|
||||
* S0 whenever the temperature has changed.
|
||||
*/
|
||||
void SingleSpeciesTP::_updateThermo() const {
|
||||
doublereal tnow = temperature();
|
||||
if (m_tlast != tnow) {
|
||||
m_spthermo->update(tnow, m_cp0_R.begin(), m_h0_RT.begin(),
|
||||
m_s0_R.begin());
|
||||
m_tlast = tnow;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,14 +27,9 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup thermoprops Thermodynamic Properties
|
||||
* @ingroup thermoprops
|
||||
*
|
||||
* These classes are used to compute thermodynamic properties.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The SingleSpeciesTP class is a filter class for ThermoPhase.
|
||||
* What it does is to simplify the construction of ThermoPhase
|
||||
* objects by assuming that the phase consists of one and
|
||||
|
|
@ -43,7 +38,8 @@ namespace Cantera {
|
|||
* thermodynamic functions or the equation of state of the
|
||||
* phase. Therefore it's an incomplete description of
|
||||
* the thermodynamics. The complete description must be
|
||||
* made in a derived class.
|
||||
* made in a derived class of SingleSpeciesTP.
|
||||
* \nosubgrouping
|
||||
*/
|
||||
class SingleSpeciesTP : public ThermoPhase {
|
||||
|
||||
|
|
@ -57,28 +53,29 @@ namespace Cantera {
|
|||
|
||||
/**
|
||||
*
|
||||
* @name Utilities
|
||||
* @name Information Methods
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Equation of state type flag. The base class returns
|
||||
* zero. Subclasses should define this to return a unique
|
||||
* non-zero value. Constants defined for this purpose are
|
||||
* listed in mix_defs.h.
|
||||
* Returns the equation of state type flag.
|
||||
* This is a modified base class.
|
||||
* Therefore, if not overridden in derivied classes,
|
||||
* this call will throw an exception.
|
||||
*/
|
||||
virtual int eosType() const;
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @name Molar Thermodynamic Properties
|
||||
* @name Molar Thermodynamic Properties of the Solution
|
||||
*
|
||||
* These functions are resolved at this level, by reference
|
||||
* to the partial molar functions and standard state
|
||||
* functions for species 0. Derived classes don't need
|
||||
* to supply entries for these functions.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* These functions are resolved at this level, by reference
|
||||
* to the partial molar functions
|
||||
*/
|
||||
/// Molar enthalpy. Units: J/kmol.
|
||||
doublereal enthalpy_mole() const;
|
||||
|
||||
|
|
@ -147,6 +144,16 @@ namespace Cantera {
|
|||
err("thermalExpansionCoeff()"); return -1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @name Electric Potential
|
||||
*
|
||||
* The phase may be at some non-zero electrical
|
||||
* potential. These methods set or get the value of the
|
||||
* electric potential.
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @name Potential Energy
|
||||
|
|
@ -180,7 +187,7 @@ namespace Cantera {
|
|||
|
||||
/**
|
||||
* @}
|
||||
* @name Activities and Activity Concentrations
|
||||
* @name Activities, Standard State, and Activity Concentrations
|
||||
*
|
||||
* The activity \f$a_k\f$ of a species in solution is
|
||||
* related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
|
||||
|
|
@ -257,8 +264,10 @@ namespace Cantera {
|
|||
* Get the array of non-dimensional activities at
|
||||
* the current solution temperature, pressure, and
|
||||
* solution concentration.
|
||||
*
|
||||
* We redefine this function to just return 1.0 here.
|
||||
*/
|
||||
void getActivities(doublereal* a) {
|
||||
virtual void getActivities(doublereal* a) {
|
||||
a[0] = 1.0;
|
||||
}
|
||||
|
||||
|
|
@ -276,21 +285,19 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
//@}
|
||||
/// @name Partial Molar Properties of the Solution -----------------
|
||||
/// @name Partial Molar Properties of the Solution
|
||||
///
|
||||
/// These functions are resolved at this level, by reference
|
||||
/// to the partial molar functions and standard state
|
||||
/// functions for species 0. Derived classes don't need
|
||||
/// to supply entries for these functions.
|
||||
//@{
|
||||
|
||||
/*
|
||||
* These functions are all resolved here, to point to the
|
||||
* standard state functions.
|
||||
* These functions are all resolved here to point to the
|
||||
* standard state functions for species 0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the species chemical potentials in the solution
|
||||
* These are partial molar Gibbs free energies.
|
||||
* Units: J/kmol.
|
||||
*/
|
||||
void getChemPotentials(doublereal* mu) const;
|
||||
|
||||
/**
|
||||
* Get the array of non-dimensional species chemical potentials
|
||||
* These are partial molar Gibbs free energies.
|
||||
|
|
@ -299,6 +306,13 @@ namespace Cantera {
|
|||
*/
|
||||
void getChemPotentials_RT(doublereal* mu) const;
|
||||
|
||||
/**
|
||||
* Get the species chemical potentials in the solution
|
||||
* These are partial molar Gibbs free energies.
|
||||
* Units: J/kmol.
|
||||
*/
|
||||
void getChemPotentials(doublereal* mu) const;
|
||||
|
||||
/**
|
||||
* Get the species electrochemical potentials. Units: J/kmol.
|
||||
* This method adds a term \f$ Fz_k \phi_k \f$ to
|
||||
|
|
@ -331,13 +345,18 @@ namespace Cantera {
|
|||
void getPartialMolarVolumes(doublereal* vbar) const;
|
||||
|
||||
//@}
|
||||
/// @name Properties of the Standard State of the Species in the Solution -------------------------------------
|
||||
/// @name Properties of the Standard State of the Species in the Solution
|
||||
/// These functions are the primary way real properties are
|
||||
/// supplied to derived thermodynamics classes of SingleSpeciesTP.
|
||||
/// These functions must be supplied in derived classes. They
|
||||
/// are not resolved at the SingleSpeciesTP level.
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Get the array of chemical potentials at unit activity
|
||||
/**
|
||||
* Get the array of chemical potentials at unit activity.
|
||||
* These are the standard state chemical potentials.
|
||||
* \f$ \mu^0_k \f$.
|
||||
* \f$ \mu^0_k(T,P) \f$. The values are evaluated at the current
|
||||
* temperature and pressure.
|
||||
*/
|
||||
virtual void getStandardChemPotentials(doublereal* mu) const {
|
||||
err("getStandardChemPotentials");
|
||||
|
|
@ -406,7 +425,14 @@ namespace Cantera {
|
|||
|
||||
|
||||
//@}
|
||||
/// @name Thermodynamic Values for the Species Reference States --------------------
|
||||
/// @name Thermodynamic Values for the Species Reference State
|
||||
///
|
||||
/// Almost all functions in this group are resolved by this
|
||||
/// class. It is assumed that the m_spthermo species thermo
|
||||
/// pointer is populated and yields the reference state.
|
||||
/// The internal energy function is not given by this
|
||||
/// class, since it would involve a specification of the
|
||||
/// equation of state.
|
||||
//@{
|
||||
|
||||
/**
|
||||
|
|
@ -414,18 +440,14 @@ namespace Cantera {
|
|||
* enthalpies of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for the species.
|
||||
*/
|
||||
virtual void getEnthalpy_RT_ref(doublereal *hrt) const {
|
||||
err("enthalpy_RT_ref");
|
||||
}
|
||||
virtual void getEnthalpy_RT_ref(doublereal *hrt) const;
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
* enthalpies of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for the species.
|
||||
*/
|
||||
virtual void getGibbs_RT_ref(doublereal *grt) const {
|
||||
err("gibbs_RT_ref");
|
||||
}
|
||||
virtual void getGibbs_RT_ref(doublereal *grt) const;
|
||||
|
||||
/**
|
||||
* Returns the vector of the
|
||||
|
|
@ -433,18 +455,14 @@ namespace Cantera {
|
|||
* of the solution and the reference pressure for the species.
|
||||
* units = J/kmol
|
||||
*/
|
||||
virtual void getGibbs_ref(doublereal *g) const {
|
||||
err("gibbs_ref");
|
||||
}
|
||||
virtual void getGibbs_ref(doublereal *g) const;
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
* entropies of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for the species.
|
||||
*/
|
||||
virtual void getEntropy_R_ref(doublereal *er) const {
|
||||
err("entropy_R_ref");
|
||||
}
|
||||
virtual void getEntropy_R_ref(doublereal *er) const;
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
|
|
@ -452,9 +470,7 @@ namespace Cantera {
|
|||
* at the current temperature of the solution
|
||||
* and reference pressure for the species.
|
||||
*/
|
||||
virtual void getCp_R_ref(doublereal *cprt) const {
|
||||
err("cp_R_ref()");
|
||||
}
|
||||
virtual void getCp_R_ref(doublereal *cprt) const;
|
||||
|
||||
/**
|
||||
* @name Setting the State
|
||||
|
|
@ -619,12 +635,25 @@ namespace Cantera {
|
|||
virtual void initThermo();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
doublereal m_tmin, m_tmax, m_press, m_p0;
|
||||
|
||||
/**
|
||||
* Last temperature used to evaluate the thermodynamic
|
||||
* polynomial.
|
||||
*/
|
||||
mutable doublereal m_tlast;
|
||||
mutable array_fp m_h0_RT;
|
||||
mutable array_fp m_cp0_R;
|
||||
mutable array_fp m_s0_R;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
void _updateThermo() const;
|
||||
|
||||
private:
|
||||
doublereal err(string msg) const;
|
||||
|
||||
};
|
||||
|
|
@ -635,5 +664,3 @@ namespace Cantera {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
411
Cantera/src/thermo/StoichSubstanceSSTP.cpp
Normal file
411
Cantera/src/thermo/StoichSubstanceSSTP.cpp
Normal file
|
|
@ -0,0 +1,411 @@
|
|||
/**
|
||||
*
|
||||
* @file StoichSubstanceSSTP.cpp
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copywrite (2005) Sandia Corporation. Under the terms of
|
||||
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
|
||||
* U.S. Government retains certain rights in this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "ct_defs.h"
|
||||
#include "mix_defs.h"
|
||||
#include "StoichSubstanceSSTP.h"
|
||||
#include "SpeciesThermo.h"
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
/*
|
||||
* ---- Constructors -------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Constructor for the StoichSubstanceSSTP class
|
||||
*/
|
||||
StoichSubstanceSSTP::StoichSubstanceSSTP():
|
||||
SingleSpeciesTP()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for the routine (virtual)
|
||||
*
|
||||
*/
|
||||
StoichSubstanceSSTP::~StoichSubstanceSSTP()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Utilities -----
|
||||
*/
|
||||
|
||||
/**
|
||||
* Equation of state flag. Returns the value cStoichSubstance,
|
||||
* defined in mix_defs.h.
|
||||
*/
|
||||
int StoichSubstanceSSTP::eosType() const {
|
||||
return cStoichSubstance;
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Molar Thermodynamic properties of the solution ----
|
||||
*/
|
||||
|
||||
/**
|
||||
* ----- Mechanical Equation of State ------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pressure. Units: Pa.
|
||||
* For an incompressible substance, the density is independent
|
||||
* of pressure. This method simply returns the stored
|
||||
* pressure value.
|
||||
*/
|
||||
doublereal StoichSubstanceSSTP::pressure() const {
|
||||
return m_press;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pressure at constant temperature. Units: Pa.
|
||||
* For an incompressible substance, the density is
|
||||
* independent of pressure. Therefore, this method only
|
||||
* stores the specified pressure value. It does not
|
||||
* modify the density.
|
||||
*/
|
||||
void StoichSubstanceSSTP::setPressure(doublereal p) {
|
||||
m_press = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* The isothermal compressibility. Units: 1/Pa.
|
||||
* The isothermal compressibility is defined as
|
||||
* \f[
|
||||
* \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
|
||||
* \f]
|
||||
*
|
||||
* It's equal to zero for this model, since the molar volume
|
||||
* doesn't change with pressure or temperature.
|
||||
*/
|
||||
doublereal StoichSubstanceSSTP::isothermalCompressibility() const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The thermal expansion coefficient. Units: 1/K.
|
||||
* The thermal expansion coefficient is defined as
|
||||
*
|
||||
* \f[
|
||||
* \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
|
||||
* \f]
|
||||
*
|
||||
* It's equal to zero for this model, since the molar volume
|
||||
* doesn't change with pressure or temperature.
|
||||
*/
|
||||
doublereal StoichSubstanceSSTP::thermalExpansionCoeff() const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Chemical Potentials and Activities ----
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method returns the array of generalized
|
||||
* concentrations. For a stoichiomeetric substance, there is
|
||||
* only one species, and the generalized concentration is 1.0.
|
||||
*/
|
||||
void StoichSubstanceSSTP::
|
||||
getActivityConcentrations(doublereal* c) const {
|
||||
c[0] = 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The standard concentration. This is defined as the concentration
|
||||
* by which the generalized concentration is normalized to produce
|
||||
* the activity.
|
||||
*/
|
||||
doublereal StoichSubstanceSSTP::standardConcentration(int k) const {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the natural logarithm of the standard
|
||||
* concentration of the kth species
|
||||
*/
|
||||
doublereal StoichSubstanceSSTP::logStandardConc(int k) const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the units of the standard and generalized
|
||||
* concentrations Note they have the same units, as their
|
||||
* ratio is defined to be equal to the activity of the kth
|
||||
* species in the solution, which is unitless.
|
||||
*
|
||||
* This routine is used in print out applications where the
|
||||
* units are needed. Usually, MKS units are assumed throughout
|
||||
* the program and in the XML input files.
|
||||
*
|
||||
* uA[0] = kmol units - default = 1
|
||||
* uA[1] = m units - default = -nDim(), the number of spatial
|
||||
* dimensions in the Phase class.
|
||||
* uA[2] = kg units - default = 0;
|
||||
* uA[3] = Pa(pressure) units - default = 0;
|
||||
* uA[4] = Temperature units - default = 0;
|
||||
* uA[5] = time units - default = 0
|
||||
*/
|
||||
void StoichSubstanceSSTP::
|
||||
getUnitsStandardConc(double *uA, int k, int sizeUA) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
uA[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Partial Molar Properties of the Solution ----
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ---- Properties of the Standard State of the Species in the Solution
|
||||
* ----
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the array of chemical potentials at unit activity
|
||||
* \f$ \mu^0_k \f$.
|
||||
*
|
||||
* For a stoichiometric substance, there is no activity term in
|
||||
* the chemical potential expression, and therefore the
|
||||
* standard chemical potential and the chemical potential
|
||||
* are both equal to the molar Gibbs function.
|
||||
*/
|
||||
void StoichSubstanceSSTP::
|
||||
getStandardChemPotentials(doublereal* mu0) const {
|
||||
getGibbs_RT(mu0);
|
||||
mu0[0] *= GasConstant * temperature();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nondimensional Enthalpy functions for the species
|
||||
* at their standard states at the current
|
||||
* <I>T</I> and <I>P</I> of the solution.
|
||||
* Molar enthalpy. Units: J/kmol. For an incompressible,
|
||||
* stoichiometric substance, the internal energy is
|
||||
* independent of pressure, and therefore the molar enthalpy
|
||||
* is \f[ \hat h(T, P) = \hat u(T) + P \hat v \f], where the
|
||||
* molar specific volume is constant.
|
||||
*/
|
||||
void StoichSubstanceSSTP::getEnthalpy_RT(doublereal* hrt) const {
|
||||
getEnthalpy_RT_ref(hrt);
|
||||
double RT = GasConstant * temperature();
|
||||
double presCorrect = (m_press - m_p0) / molarDensity();
|
||||
hrt[0] += presCorrect / RT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of nondimensional Entropy functions for the
|
||||
* standard state species
|
||||
* at the current <I>T</I> and <I>P</I> of the solution.
|
||||
*/
|
||||
void StoichSubstanceSSTP::getEntropy_R(doublereal* sr) const {
|
||||
getEntropy_R_ref(sr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nondimensional Gibbs functions for the species
|
||||
* at their standard states of solution at the current T and P
|
||||
* of the solution
|
||||
*/
|
||||
void StoichSubstanceSSTP::getGibbs_RT(doublereal* grt) const {
|
||||
getEnthalpy_RT(grt);
|
||||
grt[0] -= m_s0_R[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nondimensional Gibbs functions for the standard
|
||||
* state of the species at the current T and P.
|
||||
*/
|
||||
void StoichSubstanceSSTP::getCp_R(doublereal* cpr) const {
|
||||
_updateThermo();
|
||||
cpr[0] = m_cp0_R[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Molar internal energy (J/kmol).
|
||||
* For an incompressible,
|
||||
* stoichiometric substance, the molar internal energy is
|
||||
* independent of pressure. Since the thermodynamic properties
|
||||
* are specified by giving the standard-state enthalpy, the
|
||||
* term \f$ P_0 \hat v\f$ is subtracted from the specified molar
|
||||
* enthalpy to compute the molar internal energy.
|
||||
*/
|
||||
void StoichSubstanceSSTP::getIntEnergy_RT(doublereal* urt) const {
|
||||
_updateThermo();
|
||||
double RT = GasConstant * temperature();
|
||||
double PV = m_press / molarDensity();
|
||||
urt[0] = m_h0_RT[0] - PV / RT;
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Thermodynamic Values for the Species Reference States ----
|
||||
*/
|
||||
/**
|
||||
* Molar internal energy or the reference state at the current
|
||||
* temperature, T (J/kmol).
|
||||
* For an incompressible,
|
||||
* stoichiometric substance, the molar internal energy is
|
||||
* independent of pressure. Since the thermodynamic properties
|
||||
* are specified by giving the standard-state enthalpy, the
|
||||
* term \f$ P_0 \hat v\f$ is subtracted from the specified molar
|
||||
* enthalpy to compute the molar internal energy.
|
||||
*
|
||||
* Note, this is equal to the standard state internal energy
|
||||
* evaluated at the reference pressure.
|
||||
*/
|
||||
void StoichSubstanceSSTP::getIntEnergy_RT_ref(doublereal* urt) const {
|
||||
_updateThermo();
|
||||
double RT = GasConstant * temperature();
|
||||
double PV = m_p0 / molarDensity();
|
||||
urt[0] = m_h0_RT[0] - PV / RT;
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Critical State Properties
|
||||
*/
|
||||
/// Critical temperature (K).
|
||||
doublereal StoichSubstanceSSTP::critTemperature() const {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
/// Critical pressure (Pa).
|
||||
doublereal StoichSubstanceSSTP::critPressure() const {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
/// Critical density (kg/m3).
|
||||
doublereal StoichSubstanceSSTP::critDensity() const {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Saturation Properties
|
||||
*/
|
||||
|
||||
doublereal StoichSubstanceSSTP::satTemperature(doublereal p) const {
|
||||
return (-1.0);
|
||||
}
|
||||
doublereal StoichSubstanceSSTP::satPressure(doublereal t) const {
|
||||
return 0.0;
|
||||
}
|
||||
doublereal StoichSubstanceSSTP::vaporFraction() const {
|
||||
return 0.0;
|
||||
}
|
||||
void StoichSubstanceSSTP::setState_Tsat(doublereal t, doublereal x) {
|
||||
setTemperature(t);
|
||||
}
|
||||
void StoichSubstanceSSTP::setState_Psat(doublereal p, doublereal x) {
|
||||
setPressure(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* ---- Initialization and Internal functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @internal Initialize. This method is provided to allow
|
||||
* subclasses to perform any initialization required after all
|
||||
* species have been added. For example, it might be used to
|
||||
* resize internal work arrays that must have an entry for
|
||||
* each species. The base class implementation does nothing,
|
||||
* and subclasses that do not require initialization do not
|
||||
* need to overload this method. When importing a CTML phase
|
||||
* description, this method is called just prior to returning
|
||||
* from function importPhase.
|
||||
*
|
||||
* @see importCTML.cpp
|
||||
*/
|
||||
void StoichSubstanceSSTP::initThermo() {
|
||||
/*
|
||||
* Make sure there is one and only one species in this phase.
|
||||
*/
|
||||
m_kk = nSpecies();
|
||||
if (m_kk != 1) {
|
||||
throw CanteraError("initThermo",
|
||||
"stoichiometric substances may only contain one species.");
|
||||
}
|
||||
doublereal tmin = m_spthermo->minTemp();
|
||||
doublereal tmax = m_spthermo->maxTemp();
|
||||
if (tmin > 0.0) m_tmin = tmin;
|
||||
if (tmax > 0.0) m_tmax = tmax;
|
||||
/*
|
||||
* Store the reference pressure in the variables for the class.
|
||||
*/
|
||||
m_p0 = refPressure();
|
||||
|
||||
/*
|
||||
* Resize temporary arrays.
|
||||
*/
|
||||
int leng = 1;
|
||||
m_h0_RT.resize(leng);
|
||||
m_cp0_R.resize(leng);
|
||||
m_s0_R.resize(leng);
|
||||
/*
|
||||
* Call the base class thermo initializer
|
||||
*/
|
||||
SingleSpeciesTP::initThermo();
|
||||
}
|
||||
|
||||
/**
|
||||
* setParameters:
|
||||
*
|
||||
* Generic routine that is used to set the parameters used
|
||||
* by this model.
|
||||
* C[0] = density of phase [ kg/m3 ]
|
||||
*/
|
||||
void StoichSubstanceSSTP::setParameters(int n, double * c) {
|
||||
double rho = c[0];
|
||||
setDensity(rho);
|
||||
}
|
||||
|
||||
/**
|
||||
* getParameters:
|
||||
*
|
||||
* Generic routine that is used to get the parameters used
|
||||
* by this model.
|
||||
* n = 1
|
||||
* C[0] = density of phase [ kg/m3 ]
|
||||
*/
|
||||
void StoichSubstanceSSTP::getParameters(int &n, double * const c) {
|
||||
double rho = density();
|
||||
n = 1;
|
||||
c[0] = rho;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an xml data block for the parameters needed by this
|
||||
* routine. eosdata is a reference to the xml thermo block, and looks
|
||||
* like this:
|
||||
*
|
||||
* <phase id="stoichsolid" >
|
||||
* <thermo model="StoichSubstance">
|
||||
* <density units="g/cm3">3.52</density>
|
||||
* </thermo>
|
||||
* </phase>
|
||||
*/
|
||||
void StoichSubstanceSSTP::setParametersFromXML(const XML_Node& eosdata) {
|
||||
eosdata._require("model","StoichSubstanceSSTP");
|
||||
doublereal rho = getFloat(eosdata, "density", "-");
|
||||
setDensity(rho);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
305
Cantera/src/thermo/StoichSubstanceSSTP.h
Normal file
305
Cantera/src/thermo/StoichSubstanceSSTP.h
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
/**
|
||||
*
|
||||
* @file StoichSubstanceSSTP.h
|
||||
*
|
||||
* Header file for the StoichSubstanceSSTP class
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copywrite (2005) Sandia Corporation. Under the terms of
|
||||
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
|
||||
* U.S. Government retains certain rights in this software.
|
||||
*/
|
||||
|
||||
/* $Author$
|
||||
* $Date$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CT_STOICHSUBSTANCESSTP_H
|
||||
#define CT_STOICHSUBSTANCESSTP_H
|
||||
|
||||
#include "mix_defs.h"
|
||||
#include "SingleSpeciesTP.h"
|
||||
#include "SpeciesThermo.h"
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
/**
|
||||
* @ingroup thermoprops
|
||||
*
|
||||
* Class StoichSubstance represents a stoichiometric (fixed composition)
|
||||
* incompressible substance.
|
||||
*
|
||||
*/
|
||||
class StoichSubstanceSSTP : public SingleSpeciesTP {
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default Constructor for the StoichSubstanceSSTP class
|
||||
*/
|
||||
StoichSubstanceSSTP();
|
||||
|
||||
/**
|
||||
* Destructor for the routine (virtual)
|
||||
*
|
||||
*/
|
||||
virtual ~StoichSubstanceSSTP();
|
||||
|
||||
/**
|
||||
*
|
||||
* @name Utilities
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Equation of state flag.
|
||||
*
|
||||
* Returns the value cStoichSubstance, defined in mix_defs.h.
|
||||
*/
|
||||
virtual int eosType() const;
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @name Molar Thermodynamic Properties of the Solution
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @name Mechanical Equation of State
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pressure. Units: Pa.
|
||||
* For an incompressible substance, the density is independent
|
||||
* of pressure. This method simply returns the stored
|
||||
* pressure value.
|
||||
*/
|
||||
virtual doublereal pressure() const;
|
||||
|
||||
/**
|
||||
* Set the pressure at constant temperature. Units: Pa.
|
||||
* For an incompressible substance, the density is
|
||||
* independent of pressure. Therefore, this method only
|
||||
* stores the specified pressure value. It does not
|
||||
* modify the density.
|
||||
*/
|
||||
virtual void setPressure(doublereal p);
|
||||
|
||||
/**
|
||||
* The isothermal compressibility. Units: 1/Pa.
|
||||
* The isothermal compressibility is defined as
|
||||
* \f[
|
||||
* \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
|
||||
* \f]
|
||||
*/
|
||||
virtual doublereal isothermalCompressibility() const;
|
||||
|
||||
/**
|
||||
* The thermal expansion coefficient. Units: 1/K.
|
||||
* The thermal expansion coefficient is defined as
|
||||
*
|
||||
* \f[
|
||||
* \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
|
||||
* \f]
|
||||
*/
|
||||
virtual doublereal thermalExpansionCoeff() const ;
|
||||
|
||||
//@}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @name Activities, Standard States, and Activity Concentrations
|
||||
*
|
||||
* This section is largely handled by parent classes, since there
|
||||
* is only one species. Therefore, the activity is equal to one.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method returns the array of generalized
|
||||
* concentrations. For a stoichiomeetric substance, there is
|
||||
* only one species, and the generalized concentration is 1.0.
|
||||
*/
|
||||
virtual void getActivityConcentrations(doublereal* c) const;
|
||||
|
||||
/**
|
||||
* The standard concentration. This is defined as the concentration
|
||||
* by which the generalized concentration is normalized to produce
|
||||
* the activity.
|
||||
*/
|
||||
virtual doublereal standardConcentration(int k=0) const;
|
||||
|
||||
/**
|
||||
* Returns the natural logarithm of the standard
|
||||
* concentration of the kth species
|
||||
*/
|
||||
virtual doublereal logStandardConc(int k=0) const;
|
||||
|
||||
/**
|
||||
* Get the array of chemical potentials at unit activity
|
||||
* \f$ \mu^0_k \f$.
|
||||
*
|
||||
* For a stoichiometric substance, there is no activity term in
|
||||
* the chemical potential expression, and therefore the
|
||||
* standard chemical potential and the chemical potential
|
||||
* are both equal to the molar Gibbs function.
|
||||
*/
|
||||
virtual void getStandardChemPotentials(doublereal* mu0) const;
|
||||
|
||||
/**
|
||||
* Returns the units of the standard and generalized
|
||||
* concentrations Note they have the same units, as their
|
||||
* ratio is defined to be equal to the activity of the kth
|
||||
* species in the solution, which is unitless.
|
||||
*
|
||||
* This routine is used in print out applications where the
|
||||
* units are needed. Usually, MKS units are assumed throughout
|
||||
* the program and in the XML input files.
|
||||
*
|
||||
* uA[0] = kmol units - default = 0
|
||||
* uA[1] = m units - default = 0
|
||||
* uA[2] = kg units - default = 0;
|
||||
* uA[3] = Pa(pressure) units - default = 0;
|
||||
* uA[4] = Temperature units - default = 0;
|
||||
* uA[5] = time units - default = 0
|
||||
*/
|
||||
virtual void getUnitsStandardConc(double *uA, int k = 0,
|
||||
int sizeUA = 6);
|
||||
|
||||
//@}
|
||||
/// @name Partial Molar Properties of the Solution
|
||||
///
|
||||
/// These properties are handled by the parent class,
|
||||
/// SingleSpeciesTP
|
||||
//@{
|
||||
|
||||
|
||||
//@}
|
||||
/// @name Properties of the Standard State of the Species in the Solution
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Get the nondimensional Enthalpy functions for the species
|
||||
* at their standard states at the current
|
||||
* <I>T</I> and <I>P</I> of the solution.
|
||||
*/
|
||||
virtual void getEnthalpy_RT(doublereal* hrt) const;
|
||||
|
||||
/**
|
||||
* Get the array of nondimensional Entropy functions for the
|
||||
* standard state species
|
||||
* at the current <I>T</I> and <I>P</I> of the solution.
|
||||
*/
|
||||
virtual void getEntropy_R(doublereal* sr) const;
|
||||
|
||||
/**
|
||||
* Get the nondimensional Gibbs functions for the species
|
||||
* at their standard states of solution at the current T and P
|
||||
* of the solution
|
||||
*/
|
||||
virtual void getGibbs_RT(doublereal* grt) const;
|
||||
|
||||
/**
|
||||
* Get the nondimensional Gibbs functions for the standard
|
||||
* state of the species at the current T and P.
|
||||
*/
|
||||
virtual void getCp_R(doublereal* cpr) const;
|
||||
|
||||
|
||||
/**
|
||||
* Molar internal energy. J/kmol. For an incompressible,
|
||||
* stoichiometric substance, the molar internal energy is
|
||||
* independent of pressure. Since the thermodynamic properties
|
||||
* are specified by giving the standard-state enthalpy, the
|
||||
* term \f$ P_0 \hat v\f$ is subtracted from the specified molar
|
||||
* enthalpy to compute the molar internal energy.
|
||||
*/
|
||||
virtual void getIntEnergy_RT(doublereal* urt) const;
|
||||
|
||||
//@}
|
||||
/// @name Thermodynamic Values for the Species Reference States
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Returns the vector of nondimensional
|
||||
* internal Energies of the reference state at the current temperature
|
||||
* of the solution and the reference pressure for each species.
|
||||
*/
|
||||
virtual void getIntEnergy_RT_ref(doublereal *urt) const;
|
||||
|
||||
/*
|
||||
* ---- Critical State Properties
|
||||
*/
|
||||
/// Critical temperature (K).
|
||||
virtual doublereal critTemperature() const;
|
||||
/// Critical pressure (Pa).
|
||||
virtual doublereal critPressure() const;
|
||||
/// Critical density (kg/m3).
|
||||
virtual doublereal critDensity() const;
|
||||
|
||||
/*
|
||||
* ---- Saturation Properties
|
||||
*/
|
||||
virtual doublereal satTemperature(doublereal p) const;
|
||||
virtual doublereal satPressure(doublereal t) const;
|
||||
virtual doublereal vaporFraction() const;
|
||||
virtual void setState_Tsat(doublereal t, doublereal x);
|
||||
virtual void setState_Psat(doublereal p, doublereal x);
|
||||
|
||||
/*
|
||||
* @internal Initialize. This method is provided to allow
|
||||
* subclasses to perform any initialization required after all
|
||||
* species have been added. For example, it might be used to
|
||||
* resize internal work arrays that must have an entry for
|
||||
* each species. The base class implementation does nothing,
|
||||
* and subclasses that do not require initialization do not
|
||||
* need to overload this method. When importing a CTML phase
|
||||
* description, this method is called just prior to returning
|
||||
* from function importPhase.
|
||||
*
|
||||
* @see importCTML.cpp
|
||||
*/
|
||||
virtual void initThermo();
|
||||
|
||||
/*
|
||||
* setParameters:
|
||||
*
|
||||
* Generic routine that is used to set the parameters used
|
||||
* by this model.
|
||||
* C[0] = density of phase [ kg/m3 ]
|
||||
*/
|
||||
virtual void setParameters(int n, double *c);
|
||||
/*
|
||||
* getParameters:
|
||||
*
|
||||
* Generic routine that is used to get the parameters used
|
||||
* by this model.
|
||||
* n = 1
|
||||
* C[0] = density of phase [ kg/m3 ]
|
||||
*/
|
||||
virtual void getParameters(int &n, double * const c);
|
||||
|
||||
/*
|
||||
* Reads an xml data block for the parameters needed by this
|
||||
* routine. eosdata points to the thermo block, and looks
|
||||
* like this:
|
||||
*
|
||||
* <phase id="stoichsolid" >
|
||||
* <thermo model="StoichSubstance">
|
||||
* <density units="g/cm3">3.52</density>
|
||||
* </thermo>
|
||||
* </phase>
|
||||
*/
|
||||
virtual void setParametersFromXML(const XML_Node& eosdata);
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue