A further iteration, where I've added an interface that maintains a
current mole fraction vector.
This commit is contained in:
parent
07bcac001b
commit
201c32bea6
2 changed files with 116 additions and 1 deletions
|
|
@ -9,7 +9,7 @@
|
|||
* variable pressure standard state methods for calculating
|
||||
* thermodynamic properties that are further based upon expressions
|
||||
* for the excess gibbs free energy expressed as a function of
|
||||
* the mole fractions
|
||||
* the mole fractions.
|
||||
*/
|
||||
/*
|
||||
* Copywrite (2009) Sandia Corporation. Under the terms of
|
||||
|
|
@ -59,6 +59,7 @@ namespace Cantera {
|
|||
if (&b != this) {
|
||||
VPStandardStateTP::operator=(b);
|
||||
}
|
||||
moleFractions_ = b.moleFractions_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +87,45 @@ namespace Cantera {
|
|||
* -------------- Utilities -------------------------------
|
||||
*/
|
||||
|
||||
void GibbsExcessVPSSTP::setMassFractions(const doublereal* const y) {
|
||||
#if DEBUG_MODE
|
||||
checkMFSum(y);
|
||||
#endif
|
||||
State::setMassFractions(y);
|
||||
getMoleFractions(DATA_PTR(moleFractions_));
|
||||
}
|
||||
|
||||
void GibbsExcessVPSSTP::setMassFractions_NoNorm(const doublereal* const y) {
|
||||
#if DEBUG_MODE
|
||||
checkMFSum(y);
|
||||
#endif
|
||||
State::setMassFractions_NoNorm(y);
|
||||
getMoleFractions(DATA_PTR(moleFractions_));
|
||||
}
|
||||
|
||||
void GibbsExcessVPSSTP::setMoleFractions(const doublereal* const x) {
|
||||
#if DEBUG_MODE
|
||||
checkMFSum(x);
|
||||
#endif
|
||||
State::setMoleFractions(x);
|
||||
getMoleFractions(DATA_PTR(moleFractions_));
|
||||
}
|
||||
|
||||
void GibbsExcessVPSSTP::setMoleFractions_NoNorm(const doublereal* const x) {
|
||||
#if DEBUG_MODE
|
||||
checkMFSum(x);
|
||||
#endif
|
||||
State::setMoleFractions_NoNorm(x);
|
||||
getMoleFractions(DATA_PTR(moleFractions_));
|
||||
}
|
||||
|
||||
|
||||
void GibbsExcessVPSSTP::setConcentrations(const doublereal* const c) {
|
||||
State::setConcentrations(c);
|
||||
getMoleFractions(DATA_PTR(moleFractions_));
|
||||
}
|
||||
|
||||
|
||||
// Equation of state type flag.
|
||||
/*
|
||||
* The ThermoPhase base class returns
|
||||
|
|
@ -148,6 +188,15 @@ namespace Cantera {
|
|||
return 0;
|
||||
}
|
||||
|
||||
double GibbsExcessVPSSTP::checkMFSum(const doublereal * const x) const {
|
||||
doublereal norm = accumulate(x, x + m_kk, 0.0);
|
||||
if (fabs(norm - 1.0) > 1.0E-9) {
|
||||
throw CanteraError("GibbsExcessVPSSTP::checkMFSun",
|
||||
"MF sum exceeded tolerance of 1.0E-9:" + fp2str(norm));
|
||||
}
|
||||
return norm;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the units of the standard and general concentrations
|
||||
* Note they have the same units, as their divisor is
|
||||
|
|
|
|||
|
|
@ -312,6 +312,8 @@ namespace Cantera {
|
|||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//@}
|
||||
|
||||
/**
|
||||
|
|
@ -321,6 +323,66 @@ namespace Cantera {
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the mass fractions to the specified values, and then
|
||||
* normalize them so that they sum to 1.0.
|
||||
* @param y Array of unnormalized mass fraction values (input).
|
||||
* Must have a length greater than or equal to the number of
|
||||
* species.
|
||||
*
|
||||
* @param y Input vector of mass fractions.
|
||||
* Length is m_kk.
|
||||
*/
|
||||
virtual void setMassFractions(const doublereal* const y);
|
||||
|
||||
/**
|
||||
* Set the mass fractions to the specified values without
|
||||
* normalizing. This is useful when the normalization
|
||||
* condition is being handled by some other means, for example
|
||||
* by a constraint equation as part of a larger set of
|
||||
* equations.
|
||||
*
|
||||
* @param y Input vector of mass fractions.
|
||||
* Length is m_kk.
|
||||
*/
|
||||
virtual void setMassFractions_NoNorm(const doublereal* const y);
|
||||
|
||||
|
||||
/**
|
||||
* Set the mole fractions to the specified values, and then
|
||||
* normalize them so that they sum to 1.0.
|
||||
* @param x Array of unnormalized mole fraction values (input).
|
||||
* Must have a length greater than or equal to the number of
|
||||
* species.
|
||||
*
|
||||
* @param x Input vector of mole fractions.
|
||||
* Length is m_kk.
|
||||
*/
|
||||
virtual void setMoleFractions(const doublereal* const x);
|
||||
/**
|
||||
* Set the mole fractions to the specified values without
|
||||
* normalizing. This is useful when the normalization
|
||||
* condition is being handled by some other means, for example
|
||||
* by a constraint equation as part of a larger set of
|
||||
* equations.
|
||||
*
|
||||
* @param x Input vector of mole fractions.
|
||||
* Length is m_kk.
|
||||
*/
|
||||
virtual void setMoleFractions_NoNorm(const doublereal* const x);
|
||||
|
||||
/**
|
||||
* Set the concentrations to the specified values within the
|
||||
* phase.
|
||||
*
|
||||
* @param c The input vector to this routine is in dimensional
|
||||
* units. For volumetric phases c[k] is the
|
||||
* concentration of the kth species in kmol/m3.
|
||||
* For surface phases, c[k] is the concentration
|
||||
* in kmol/m2. The length of the vector is the number
|
||||
* of species in the phase.
|
||||
*/
|
||||
virtual void setConcentrations(const doublereal* const c);
|
||||
|
||||
//@}
|
||||
|
||||
|
|
@ -392,6 +454,10 @@ namespace Cantera {
|
|||
*/
|
||||
doublereal err(std::string msg) const;
|
||||
|
||||
protected:
|
||||
|
||||
double checkMFSum(const doublereal * const x) const;
|
||||
|
||||
private:
|
||||
|
||||
//! Storage for the current values of the mole fractions of the species
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue