Changed the parameter list to a const on setParameters().

Moved remaining definitions from StoichSubstance.h to StoichSubstance.cpp
This commit is contained in:
Harry Moffat 2008-12-10 16:42:48 +00:00
parent 7524d2fdc0
commit a838d6dce2
17 changed files with 81 additions and 67 deletions

View file

@ -371,7 +371,7 @@ namespace Cantera {
* @param n number of parameters
* @param c array of \a n coefficients
*/
virtual void setParameters(int n, doublereal* c) {
virtual void setParameters(int n, doublereal* const c) {
setDensity(c[0]);
}

View file

@ -1618,7 +1618,7 @@ namespace Cantera {
* @param c array of \i n coefficients
*
*/
void DebyeHuckel::setParameters(int n, doublereal* c) {
void DebyeHuckel::setParameters(int n, doublereal* const c) {
}
void DebyeHuckel::getParameters(int &n, doublereal * const c) const {

View file

@ -1163,7 +1163,7 @@ namespace Cantera {
* @param n number of parameters
* @param c array of \a n coefficients
*/
virtual void setParameters(int n, doublereal* c);
virtual void setParameters(int n, doublereal* const c);
//! Get the equation of state parameters in a vector
/*!

View file

@ -1228,7 +1228,7 @@ namespace Cantera {
* @param c array of \i n coefficients
*
*/
void HMWSoln::setParameters(int n, doublereal* c) {
void HMWSoln::setParameters(int n, doublereal* const c) {
}
void HMWSoln::getParameters(int &n, doublereal * const c) const {

View file

@ -1857,7 +1857,7 @@ namespace Cantera {
* @param n number of parameters
* @param c array of \a n coefficients
*/
virtual void setParameters(int n, doublereal* c);
virtual void setParameters(int n, doublereal* const c);
//! Get the equation of state parameters in a vector
/*!

View file

@ -1107,7 +1107,7 @@ namespace Cantera {
* @param c array of \i n coefficients
*
*/
void IdealMolalSoln::setParameters(int n, doublereal* c) {
void IdealMolalSoln::setParameters(int n, doublereal* const c) {
}
void IdealMolalSoln::getParameters(int &n, doublereal * const c) const {

View file

@ -698,7 +698,7 @@ namespace Cantera {
* @param c array of <I>n</I> coefficients
*
*/
virtual void setParameters(int n, doublereal* c);
virtual void setParameters(int n, doublereal* const c);
/*!
* @internal

View file

@ -235,7 +235,7 @@ namespace Cantera {
}
}
void LatticePhase::setParameters(int n, doublereal* c) {
void LatticePhase::setParameters(int n, doublereal* const c) {
m_molar_density = c[0];
setMolarDensity(m_molar_density);
}

View file

@ -705,7 +705,7 @@ namespace Cantera {
* @param c array of \a n coefficients
* c[0] = The bulk lattice density (kmol m-3)
*/
virtual void setParameters(int n, doublereal* c);
virtual void setParameters(int n, doublereal* const c);
//! Get the equation of state parameters in a vector
/*!

View file

@ -624,7 +624,7 @@ namespace Cantera {
* @param c array of n coefficients
*
*/
virtual void setParameters(int n, doublereal* c) {}
virtual void setParameters(int n, doublereal* const c) {}
virtual void getParameters(int &n, doublereal * const c) const {}

View file

@ -96,6 +96,35 @@ namespace Cantera {
StoichSubstance::~StoichSubstance() {
}
doublereal StoichSubstance::enthalpy_mole() const {
double hh = intEnergy_mole() + m_press / molarDensity();
return hh;
}
doublereal StoichSubstance::intEnergy_mole() const {
_updateThermo();
return GasConstant * temperature() * m_h0_RT[0]
- m_p0 / molarDensity();
}
doublereal StoichSubstance::entropy_mole() const {
_updateThermo();
return GasConstant * m_s0_R[0];
}
doublereal StoichSubstance::gibbs_mole() const {
return enthalpy_mole() - temperature() * entropy_mole();
}
doublereal StoichSubstance::cp_mole() const {
_updateThermo();
return GasConstant * m_cp0_R[0];
}
doublereal StoichSubstance::cv_mole() const {
return cp_mole();
}
void StoichSubstance::initThermo() {
m_kk = nSpecies();
if (m_kk > 1) {
@ -123,7 +152,6 @@ namespace Cantera {
setState_TP(tnow, m_p0);
}
void StoichSubstance::_updateThermo() const {
doublereal tnow = temperature();
if (m_tlast != tnow) {
@ -153,6 +181,10 @@ namespace Cantera {
return 0.0;
}
void StoichSubstance::getStandardChemPotentials(doublereal* mu0) const {
mu0[0] = gibbs_mole();
}
void StoichSubstance::
getUnitsStandardConc(double *uA, int k, int sizeUA) const {
for (int i = 0; i < sizeUA; i++) {
@ -164,6 +196,14 @@ namespace Cantera {
*
*/
void StoichSubstance::getChemPotentials_RT(doublereal* mu) const {
mu[0] = gibbs_mole() / (GasConstant * temperature());
}
void StoichSubstance::getChemPotentials(doublereal* mu) const {
mu[0] = gibbs_mole();
}
void StoichSubstance::getElectrochemPotentials(doublereal* mu) const {
getChemPotentials(mu);
}
@ -236,7 +276,7 @@ namespace Cantera {
*
*/
void StoichSubstance::setParameters(int n, double * c) {
void StoichSubstance::setParameters(int n, double * const c) {
double rho = c[0];
setDensity(rho);
}

View file

@ -1,7 +1,5 @@
/**
*
* @file StoichSubstance.h
*
* This file contains the class declarations for the StoichSubstance
* ThermoPhase class.
*/
@ -99,10 +97,7 @@ namespace Cantera {
* is \f[ \hat h(T, P) = \hat u(T) + P \hat v \f], where the
* molar specific volume is constant.
*/
virtual doublereal enthalpy_mole() const {
double hh = intEnergy_mole() + m_press / molarDensity();
return hh;
}
virtual doublereal enthalpy_mole() const;
/**
* Molar internal energy. J/kmol. For an incompressible,
@ -112,48 +107,33 @@ namespace Cantera {
* term \f$ P_0 \hat v\f$ is subtracted from the specified molar
* enthalpy to compute the molar internal energy.
*/
virtual doublereal intEnergy_mole() const {
_updateThermo();
return GasConstant * temperature() * m_h0_RT[0]
- m_p0 / molarDensity();
}
virtual doublereal intEnergy_mole() const;
/**
* Molar entropy. Units: J/kmol/K. For an incompressible,
* stoichiometric substance, the molar entropy depends only on
* the temperature.
*/
virtual doublereal entropy_mole() const {
_updateThermo();
return GasConstant * m_s0_R[0];
}
virtual doublereal entropy_mole() const;
/**
* Molar gibbs Function. Units: J/kmol. This is determined
* from the molar enthalpy and entropy functions.
*/
virtual doublereal gibbs_mole() const {
return enthalpy_mole() - temperature() * entropy_mole();
}
virtual doublereal gibbs_mole() const;
/**
* Molar heat capacity at constant pressure. Units: J/kmol/K.
* For an incompressible substance, \f$ \hat c_p = \hat c_v\f$.
*/
virtual doublereal cp_mole() const {
_updateThermo();
return GasConstant * m_cp0_R[0];
}
virtual doublereal cp_mole() const;
/**
* Molar heat capacity at constant volume. Units: J/kmol/K.
* For an incompressible substance, \f$ \hat c_p = \hat c_v\f$.
*/
virtual doublereal cv_mole() const {
return cp_mole();
}
virtual doublereal cv_mole() const;
//@}
@ -220,9 +200,7 @@ namespace Cantera {
* standard chemical potential and the chemical potential
* are both equal to the molar Gibbs function.
*/
virtual void getStandardChemPotentials(doublereal* mu0) const {
mu0[0] = gibbs_mole();
}
virtual void getStandardChemPotentials(doublereal* mu0) const;
/**
* Returns the units of the standard and generalized
@ -246,7 +224,7 @@ namespace Cantera {
//@}
/// @name Partial Molar Properties of the Solution ----------------------------------
/// @name Partial Molar Properties of the Solution ----------------------------
//@{
@ -254,18 +232,14 @@ namespace Cantera {
* Get the array of non-dimensional chemical potentials
* \f$ \mu_k / \hat R T \f$.
*/
virtual void getChemPotentials_RT(doublereal* mu) const {
mu[0] = gibbs_mole() / (GasConstant * temperature());
}
virtual void getChemPotentials_RT(doublereal* mu) const;
/**
* For a stoichiometric substance, there is only one species.
* This method returns the molar gibbs function in the
* first element of array \c mu.
*/
virtual void getChemPotentials(doublereal* mu) const {
mu[0] = gibbs_mole();
}
virtual void getChemPotentials(doublereal* mu) const;
/**
* Get the species electrochemical potentials. Units: J/kmol.
@ -295,7 +269,7 @@ namespace Cantera {
//@}
/// @name Properties of the Standard State of the Species in the Solution -------------------------------------
/// @name Properties of the Standard State of the Species in the Solution -----
//@{
/**
* Get the nondimensional Enthalpy functions for the species
@ -394,7 +368,7 @@ namespace Cantera {
virtual void initThermo();
virtual void setParameters(int n, double *c);
virtual void setParameters(int n, double * const c);
virtual void getParameters(int &n, double * const c) const;

View file

@ -254,7 +254,7 @@ namespace Cantera {
* uA[5] = time units - default = 0
*/
void StoichSubstanceSSTP::
getUnitsStandardConc(double *uA, int k, int sizeUA) const {
getUnitsStandardConc(doublereal *uA, int k, int sizeUA) const {
for (int i = 0; i < 6; i++) {
uA[i] = 0;
}
@ -298,8 +298,8 @@ namespace Cantera {
*/
void StoichSubstanceSSTP::getEnthalpy_RT(doublereal* hrt) const {
getEnthalpy_RT_ref(hrt);
double RT = GasConstant * temperature();
double presCorrect = (m_press - m_p0) / molarDensity();
doublereal RT = GasConstant * temperature();
doublereal presCorrect = (m_press - m_p0) / molarDensity();
hrt[0] += presCorrect / RT;
}
@ -342,8 +342,8 @@ namespace Cantera {
*/
void StoichSubstanceSSTP::getIntEnergy_RT(doublereal* urt) const {
_updateThermo();
double RT = GasConstant * temperature();
double PV = m_p0 / molarDensity();
doublereal RT = GasConstant * temperature();
doublereal PV = m_p0 / molarDensity();
urt[0] = m_h0_RT[0] - PV / RT;
}
@ -365,8 +365,8 @@ namespace Cantera {
*/
void StoichSubstanceSSTP::getIntEnergy_RT_ref(doublereal* urt) const {
_updateThermo();
double RT = GasConstant * temperature();
double PV = m_p0 / molarDensity();
doublereal RT = GasConstant * temperature();
doublereal PV = m_p0 / molarDensity();
urt[0] = m_h0_RT[0] - PV / RT;
}
@ -431,8 +431,8 @@ namespace Cantera {
* by this model.
* C[0] = density of phase [ kg/m3 ]
*/
void StoichSubstanceSSTP::setParameters(int n, double * c) {
double rho = c[0];
void StoichSubstanceSSTP::setParameters(int n, doublereal * const c) {
doublereal rho = c[0];
setDensity(rho);
}
@ -444,8 +444,8 @@ namespace Cantera {
* n = 1
* C[0] = density of phase [ kg/m3 ]
*/
void StoichSubstanceSSTP::getParameters(int &n, double * const c) const {
double rho = density();
void StoichSubstanceSSTP::getParameters(int &n, doublereal * const c) const {
doublereal rho = density();
n = 1;
c[0] = rho;
}

View file

@ -369,7 +369,7 @@ namespace Cantera {
* @param sizeUA output int containing the size of the vector.
* Currently, this is equal to 6.
*/
virtual void getUnitsStandardConc(double *uA, int k = 0,
virtual void getUnitsStandardConc(doublereal *uA, int k = 0,
int sizeUA = 6) const;
//@}
@ -479,7 +479,7 @@ namespace Cantera {
* @param c array of \a n coefficients
* c[0] = density of phase [ kg/m3 ]
*/
virtual void setParameters(int n, double *c);
virtual void setParameters(int n, doublereal * const c);
//! Get the equation of state parameters in a vector
/*!
@ -492,7 +492,7 @@ namespace Cantera {
* - n = 1
* - c[0] = density of phase [ kg/m3 ]
*/
virtual void getParameters(int &n, double * const c) const;
virtual void getParameters(int &n, doublereal * const c) const;
//! Set equation of state parameter values from XML entries.
/*!

View file

@ -250,7 +250,7 @@ namespace Cantera {
/// The only parameter that can be set is the site density.
void SurfPhase::
setParameters(int n, doublereal* c) {
setParameters(int n, doublereal* const c) {
if (n != 1) {
throw CanteraError("SurfPhase::setParameters",
"Bad value for number of parameter");

View file

@ -363,7 +363,7 @@ namespace Cantera {
* @param c array of \a n coefficients
* c[0] = The site density (kmol m-2)
*/
virtual void setParameters(int n, doublereal* c);
virtual void setParameters(int n, doublereal* const c);
//! Set the Equation-of-State parameters by reading an XML Node Input
/*!

View file

@ -1924,7 +1924,7 @@ namespace Cantera {
* @param n number of parameters
* @param c array of \a n coefficients
*/
virtual void setParameters(int n, doublereal* c) {}
virtual void setParameters(int n, doublereal* const c) {}
//! Get the equation of state parameters in a vector