diff --git a/Cantera/src/thermo/HMWSoln.cpp b/Cantera/src/thermo/HMWSoln.cpp
index 5147b705d..9059b492b 100644
--- a/Cantera/src/thermo/HMWSoln.cpp
+++ b/Cantera/src/thermo/HMWSoln.cpp
@@ -738,10 +738,13 @@ namespace Cantera {
// Molar heat capacity at constant volume. Units: J/kmol/K.
doublereal HMWSoln::cv_mole() const {
- //getPartialMolarCv(m_tmpV.begin());
- //return mean_X(m_tmpV.begin());
- err("not implemented");
- return 0.0;
+ double kappa_t = isothermalCompressibility();
+ double beta = thermalExpansionCoeff();
+ double cp = cp_mole();
+ double tt = temperature();
+ double molarV = molarVolume();
+ double cv = cp - beta * beta * tt * molarV / kappa_t;
+ return cv;
}
//
diff --git a/Cantera/src/thermo/HMWSoln_input.cpp b/Cantera/src/thermo/HMWSoln_input.cpp
index f4380c784..5faecbca2 100644
--- a/Cantera/src/thermo/HMWSoln_input.cpp
+++ b/Cantera/src/thermo/HMWSoln_input.cpp
@@ -1657,15 +1657,88 @@ namespace Cantera {
MolalityVPSSTP::initThermoXML(phaseNode, id);
/*
- * Lastly set the state
+ * Lastly calculate the charge balance and then add stuff until the charges compensate
*/
+
+ vector_fp mf(m_kk, 0.0);
+ getMoleFractions(DATA_PTR(mf));
+ bool notDone = true;
+
+ do {
+ double sum = 0.0;
+ int kMaxC = -1;
+ double MaxC = 0.0;
+ for (int k = 0; k < m_kk; k++) {
+ sum += mf[k] * m_speciesCharge[k];
+ if (fabs(mf[k] * m_speciesCharge[k]) > MaxC) {
+ kMaxC = k;
+ }
+ }
+ int kHp = speciesIndex("H+");
+ int kOHm = speciesIndex("OH-");
+
+
+ if (fabs(sum) > 1.0E-30) {
+ if (kHp >= 0) {
+ if (mf[kHp] > sum * 1.1) {
+ mf[kHp] -= sum;
+ mf[0] += sum;
+ notDone = false;
+ } else {
+ if (sum > 0.0) {
+ mf[kHp] *= 0.5;
+ mf[0] += mf[kHp];
+ sum -= mf[kHp];
+ }
+ }
+ }
+ if (notDone) {
+ if (kOHm >= 0) {
+ if (mf[kOHm] > -sum * 1.1) {
+ mf[kOHm] += sum;
+ mf[0] -= sum;
+ notDone = false;
+ } else {
+ if (sum < 0.0) {
+ mf[kOHm] *= 0.5;
+ mf[0] += mf[kOHm];
+ sum += mf[kOHm];
+ }
+ }
+ }
+ if (notDone) {
+ if (kMaxC >= 0) {
+ if (mf[kMaxC] > (1.1 * sum / m_speciesCharge[kMaxC])) {
+ mf[kMaxC] -= sum / m_speciesCharge[kMaxC];
+ mf[0] += sum / m_speciesCharge[kMaxC];
+ } else {
+ mf[kMaxC] *= 0.5;
+ mf[0] += mf[kMaxC];
+ notDone = true;
+ }
+ }
+ }
+ }
+ setMoleFractions(DATA_PTR(mf));
+ } else {
+ notDone = false;
+ }
+ } while (notDone);
+
+
+
+
+
+
+
+
// if (phaseNode.hasChild("state")) {
// XML_Node& stateNode = phaseNode.child("state");
// setStateFromXML(stateNode);
//}
}
-
+ //====================================================================================================================
// Precalculate the IMS Cutoff parameters for typeCutoff = 2
void HMWSoln::calcIMSCutoffParams_() {
IMS_afCut_ = 1.0 / (std::exp(1.0) * IMS_gamma_k_min_);
diff --git a/Cantera/src/thermo/SurfPhase.cpp b/Cantera/src/thermo/SurfPhase.cpp
index acd506062..ab0ecc4c7 100644
--- a/Cantera/src/thermo/SurfPhase.cpp
+++ b/Cantera/src/thermo/SurfPhase.cpp
@@ -211,6 +211,8 @@ namespace Cantera {
}
}
+ // HKM 9/1/11 The partial molar volumes returned here are really partial molar areas.
+ // Partial molar volumes for this phase should actually be equal to zero.
void SurfPhase::getPartialMolarVolumes(doublereal* vbar) const {
getStandardVolumes(vbar);
}
diff --git a/Cantera/src/thermo/ThermoPhase.h b/Cantera/src/thermo/ThermoPhase.h
index 758919b3e..322a749f1 100644
--- a/Cantera/src/thermo/ThermoPhase.h
+++ b/Cantera/src/thermo/ThermoPhase.h
@@ -1264,7 +1264,31 @@ namespace Cantera {
virtual void getPartialMolarVolumes(doublereal* vbar) const {
err("getPartialMolarVolumes");
}
-
+
+ //! Return an array of derivatives of partial molar volumes wrt temperature for the
+ //! species in the mixture. Units: m^3/kmol.
+ /*!
+ * The derivative is at constant pressure
+ *
+ * @param d_vbar_dT Output vector of derivatives of species partial molar volumes wrt T.
+ * Length = m_kk. units are m^3/kmol/K.
+ */
+ virtual void getdPartialMolarVolumes_dT(doublereal* d_vbar_dT) const {
+ err("getdPartialMolarVolumes_dT");
+ }
+
+ //! Return an array of derivatives of partial molar volumes wrt pressure for the
+ //! species in the mixture. Units: m^3/kmol.
+ /*!
+ * The derivative is at constant temperature
+ *
+ * @param d_vbar_dP Output vector of derivatives of species partial molar volumes wrt P.
+ * Length = m_kk. units are m^3/kmol/Pa.
+ */
+ virtual void getdPartialMolarVolumes_dP(doublereal* d_vbar_dP) const {
+ err("getdPartialMolarVolumes_dP");
+ }
+
//@}
/// @name Properties of the Standard State of the Species in the Solution
//@{
@@ -1357,11 +1381,36 @@ namespace Cantera {
err("getStandardVolumes");
}
+ //! Get the derivative of the molar volumes of the species standard states wrt temperature at the current
+ //! T and P of the solution.
+ /*!
+ * The derivative is at constant pressure
+ * units = m^3 / kmol / K
+ *
+ * @param d_vol_dT Output vector containing derivatives of standard state volumes wrt T
+ * Length: m_kk.
+ */
+ virtual void getdStandardVolumes_dT(doublereal *d_vol_dT) const {
+ err("getdStandardVolumes_dT");
+ }
+
+ //! Get the derivative molar volumes of the species standard states wrt pressure at the current
+ //! T and P of the solution.
+ /*!
+ * The derivative is at constant temperature.
+ * units = m^3 / kmol / Pa
+ *
+ * @param d_vol_dP Output vector containing the derivative of standard state volumes wrt P.
+ * Length: m_kk.
+ */
+ virtual void getdStandardVolumes_dP(doublereal *d_vol_dP) const {
+ err("getdStandardVolumes_dP");
+ }
+
//@}
/// @name 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.