18 MixedSolventElectrolyte::MixedSolventElectrolyte() :
19 numBinaryInteractions_(0),
25 MixedSolventElectrolyte::MixedSolventElectrolyte(
const std::string& inputFile,
26 const std::string& id_) :
27 numBinaryInteractions_(0),
34 MixedSolventElectrolyte::MixedSolventElectrolyte(
XML_Node& phaseRoot,
35 const std::string& id_) :
36 numBinaryInteractions_(0),
45 MixedSolventElectrolyte::operator=(b);
48 MixedSolventElectrolyte&
49 MixedSolventElectrolyte::operator=(
const MixedSolventElectrolyte& b)
55 MolarityIonicVPSSTP::operator=(b);
91 for (
size_t k = 0; k <
m_kk; k++) {
105 for (
size_t k = 0; k <
m_kk; k++) {
116 for (
size_t i = 0; i <
m_kk; i++) {
127 for (
size_t i = 0; i <
m_kk; i++) {
138 for (
size_t i = 0; i <
m_kk; i++) {
154 for (
size_t k = 0; k <
m_kk; k++) {
162 for (
size_t k = 0; k <
m_kk; k++) {
177 for (
size_t k = 0; k <
m_kk; k++) {
181 for (
size_t k = 0; k <
m_kk; k++) {
197 for (
size_t k = 0; k <
m_kk; k++) {
202 for (
size_t k = 0; k <
m_kk; k++) {
214 for (
size_t iK = 0; iK <
m_kk; iK++) {
233 vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
251 if ((
int) id_.size() > 0 && phaseNode.
id() != id_) {
252 throw CanteraError(
"MixedSolventElectrolyte::initThermoXML",
253 "phasenode and Id are incompatible");
258 if (!phaseNode.
hasChild(
"thermo")) {
259 throw CanteraError(
"MixedSolventElectrolyte::initThermoXML",
260 "no thermo XML node");
263 string mString = thermoNode[
"model"];
264 if (!ba::iequals(thermoNode[
"model"],
"mixedsolventelectrolyte")) {
265 throw CanteraError(
"MixedSolventElectrolyte::initThermoXML",
266 "Unknown thermo model: " + thermoNode[
"model"]);
271 if (thermoNode.
hasChild(
"activityCoefficients")) {
273 if (!ba::iequals(acNode[
"model"],
"margules")) {
274 throw CanteraError(
"MixedSolventElectrolyte::initThermoXML",
275 "Unknown activity coefficient model: " + acNode[
"model"]);
277 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
283 if (ba::iequals(xmlACChild.
name(),
"binaryneutralspeciesparameters")) {
297 for (
size_t iK = 0; iK <
m_kk; iK++) {
312 lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
323 for (
size_t iK = 0; iK <
m_kk; iK++) {
338 double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
348 for (
size_t k = 0; k <
m_kk; k++) {
356 for (
size_t k = 0; k <
m_kk; k++) {
362 doublereal* dlnActCoeffds)
const 367 for (
size_t iK = 0; iK <
m_kk; iK++) {
368 dlnActCoeffds[iK] = 0.0;
383 double dXA = dXds[iA];
384 double dXB = dXds[iB];
387 dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
398 for (
size_t iK = 0; iK <
m_kk; iK++) {
429 for (
size_t iK = 0; iK <
m_kk; iK++) {
430 for (
size_t iM = 0; iM <
m_kk; iM++) {
454 dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
455 dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
482 for (
size_t k = 0; k <
m_kk; k++) {
490 for (
size_t k = 0; k <
m_kk; k++) {
499 for (
size_t k = 0; k <
m_kk; k++) {
500 for (
size_t m = 0; m <
m_kk; m++) {
501 dlnActCoeffdlnN[ld * k + m] = data[
m_kk * k + m];
527 string xname = xmLBinarySpecies.
name();
528 if (xname !=
"binaryNeutralSpeciesParameters") {
529 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
530 "Incorrect name for processing this routine: " + xname);
533 string iName = xmLBinarySpecies.
attrib(
"speciesA");
535 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"no speciesA attrib");
537 string jName = xmLBinarySpecies.
attrib(
"speciesB");
539 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"no speciesB attrib");
545 if (iSpecies ==
npos) {
549 if (
charge(iSpecies) != 0) {
550 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"speciesA charge problem");
553 if (jSpecies ==
npos) {
557 if (
charge(jSpecies) != 0) {
558 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"speciesB charge problem");
566 for (
size_t iChild = 0; iChild < xmLBinarySpecies.
nChildren(); iChild++) {
568 string nodeName = ba::to_lower_copy(xmlChild.
name());
571 if (nodeName ==
"excessenthalpy") {
573 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessEnthalpy");
574 if (vParams.size() != 2) {
575 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessEnthalpy for " + ispName
577 "wrong number of params found");
583 if (nodeName ==
"excessentropy") {
585 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessEntropy");
586 if (vParams.size() != 2) {
587 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessEntropy for " + ispName
589 "wrong number of params found");
595 if (nodeName ==
"excessvolume_enthalpy") {
597 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessVolume_Enthalpy");
598 if (vParams.size() != 2) {
599 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
601 "wrong number of params found");
607 if (nodeName ==
"excessvolume_entropy") {
609 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessVolume_Entropy");
610 if (vParams.size() != 2) {
611 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
613 "wrong number of params found");
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
void s_update_lnActCoeff() const
Update the activity coefficients.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string name() const
Returns the name of the XML node.
vector_fp dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
doublereal temperature() const
Temperature (K).
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
const size_t npos
index returned by functions to indicate "no position"
vector_fp m_HE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Base class for a phase with thermodynamic properties.
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
vector_fp dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
void initLengths()
Initialize lengths of local variables after all species have been identified.
vector_fp d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
int formTempModel_
form of the temperature dependence of the Margules interaction expression
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
std::string speciesName(size_t k) const
Name of the species with index k.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual void initThermo()
MixedSolventElectrolyte is a derived class of GibbsExcessVPSSTP that employs the DH and local Margule...
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Base class for exceptions thrown by Cantera classes.
vector_fp m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
int formMargules_
form of the Margules interaction expression
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space.
virtual void initThermo()
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
vector_fp lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
vector_fp m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector_fp m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
size_t numBinaryInteractions_
number of binary interaction expressions
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
const doublereal SmallNumber
smallest number to compare to zero.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
std::string id() const
Return the id attribute, if present.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Contains declarations for string manipulation functions within Cantera.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
size_t m_kk
Number of species in the phase.
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
vector_fp m_SE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
void zero()
Set all of the entries to zero.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
Namespace for the Cantera kernel.
(see Thermodynamic Properties and class MixedSolventElectrolyte ).
size_t nChildren(bool discardComments=false) const
Return the number of children.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution...
vector_fp dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.