28 GibbsExcessVPSSTP::operator=(b);
37 VPStandardStateTP::operator=(b);
51 ThermoPhase* GibbsExcessVPSSTP::duplMyselfAsThermoPhase()
const
56 void GibbsExcessVPSSTP::setMassFractions(
const doublereal*
const y)
58 Phase::setMassFractions(y);
59 getMoleFractions(
DATA_PTR(moleFractions_));
62 void GibbsExcessVPSSTP::setMassFractions_NoNorm(
const doublereal*
const y)
64 Phase::setMassFractions_NoNorm(y);
65 getMoleFractions(
DATA_PTR(moleFractions_));
68 void GibbsExcessVPSSTP::setMoleFractions(
const doublereal*
const x)
70 Phase::setMoleFractions(x);
71 getMoleFractions(
DATA_PTR(moleFractions_));
74 void GibbsExcessVPSSTP::setMoleFractions_NoNorm(
const doublereal*
const x)
76 Phase::setMoleFractions_NoNorm(x);
77 getMoleFractions(
DATA_PTR(moleFractions_));
80 void GibbsExcessVPSSTP::setConcentrations(
const doublereal*
const c)
82 Phase::setConcentrations(c);
83 getMoleFractions(
DATA_PTR(moleFractions_));
89 void GibbsExcessVPSSTP::setPressure(doublereal p)
91 setState_TP(temperature(), p);
94 void GibbsExcessVPSSTP::calcDensity()
96 vector_fp vbar = getPartialMolarVolumesVector();
97 doublereal vtotal = 0.0;
98 for (
size_t i = 0; i < m_kk; i++) {
99 vtotal += vbar[i] * moleFractions_[i];
101 doublereal dd = meanMolecularWeight() / vtotal;
102 Phase::setDensity(dd);
105 void GibbsExcessVPSSTP::setState_TP(doublereal t, doublereal p)
107 Phase::setTemperature(t);
116 updateStandardStateThermo();
127 void GibbsExcessVPSSTP::getActivityConcentrations(doublereal* c)
const
132 doublereal GibbsExcessVPSSTP::standardConcentration(
size_t k)
const
137 doublereal GibbsExcessVPSSTP::logStandardConc(
size_t k)
const
142 void GibbsExcessVPSSTP::getActivities(doublereal* ac)
const
144 getActivityCoefficients(ac);
145 getMoleFractions(
DATA_PTR(moleFractions_));
146 for (
size_t k = 0; k < m_kk; k++) {
147 ac[k] *= moleFractions_[k];
151 void GibbsExcessVPSSTP::getActivityCoefficients(doublereal*
const ac)
const
153 getLnActivityCoefficients(ac);
159 for (
size_t k = 0; k < m_kk; k++) {
161 throw CanteraError(
"GibbsExcessVPSSTP::getActivityCoefficients()",
162 "activity coefficient for " +
int2str(k) +
" is overflowing: ln(ac) = " +
fp2str(ac[k]));
163 }
else if (ac[k] < -700.) {
164 throw CanteraError(
"GibbsExcessVPSSTP::getActivityCoefficients()",
165 "activity coefficient for " +
int2str(k) +
" is underflowing: ln(ac) = " +
fp2str(ac[k]));
171 for (
size_t k = 0; k < m_kk; k++) {
174 }
else if (ac[k] < -700.) {
181 for (
size_t k = 0; k < m_kk; k++) {
187 throw CanteraError(
"GibbsExcessVPSSTP::getActivityCoefficients()",
188 "activity coefficient is over/underflowing");
191 throw CanteraError(
"GibbsExcessVPSSTP::getActivityCoefficients()",
192 "realNumberRangeBehavior_ == FENV_CHECK_CTRB not supported by compiler");
198 void GibbsExcessVPSSTP::getElectrochemPotentials(doublereal* mu)
const
200 getChemPotentials(mu);
201 double ve = Faraday * electricPotential();
202 for (
size_t k = 0; k < m_kk; k++) {
203 mu[k] += ve*charge(k);
210 void GibbsExcessVPSSTP::getPartialMolarVolumes(doublereal* vbar)
const
215 getStandardVolumes(vbar);
218 const vector_fp& GibbsExcessVPSSTP::getPartialMolarVolumesVector()
const
220 return getStandardVolumes();
223 double GibbsExcessVPSSTP::checkMFSum(
const doublereal*
const x)
const
225 doublereal norm = std::accumulate(x, x + m_kk, 0.0);
226 if (fabs(norm - 1.0) > 1.0E-9) {
228 "(MF sum - 1) exceeded tolerance of 1.0E-9:" +
fp2str(norm));
233 void GibbsExcessVPSSTP::getUnitsStandardConc(
double* uA,
int k,
int sizeUA)
const
236 "To be removed after Cantera 2.2.");
241 for (
int i = 0; i < sizeUA; i++) {
263 void GibbsExcessVPSSTP::initThermo()
266 VPStandardStateTP::initThermo();
267 getMoleFractions(
DATA_PTR(moleFractions_));
270 void GibbsExcessVPSSTP::initLengths()
272 moleFractions_.resize(m_kk);
273 lnActCoeff_Scaled_.resize(m_kk);
274 dlnActCoeffdT_Scaled_.resize(m_kk);
275 d2lnActCoeffdT2_Scaled_.resize(m_kk);
276 dlnActCoeffdlnX_diag_.resize(m_kk);
277 dlnActCoeffdlnN_diag_.resize(m_kk);
278 dlnActCoeffdlnN_.resize(m_kk, m_kk);
std::vector< doublereal > m_pp
Temporary storage space that is fair game.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
For this specification of range behavior, the overflow or underflow calculation is changed...
When an overflow or underflow occurs, Cantera will throw an error.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
std::vector< doublereal > d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
std::vector< doublereal > dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
Base class for a phase with thermodynamic properties.
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
bool check_FENV_OverUnder_Flow()
Quick check on whether there has been an underflow or overflow condition in the floating point unit...
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
Base class for exceptions thrown by Cantera classes.
std::vector< doublereal > dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
std::vector< doublereal > lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
std::vector< doublereal > moleFractions_
Storage for the current values of the mole fractions of the species.
Contains declarations for string manipulation functions within Cantera.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
Cantera will throw an error in debug mode but will not in production mode.
Cantera will use the fenv check capability introduced in C99 to check for overflow and underflow cond...
std::vector< doublereal > dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...