30 MolarityIonicVPSSTP::MolarityIonicVPSSTP() :
32 PBType_(PBTYPE_PASSTHROUGH),
34 indexSpecialSpecies_(
npos),
37 numPassThroughSpecies_(0),
38 neutralPBindexStart(0)
43 const std::string& id_) :
45 PBType_(PBTYPE_PASSTHROUGH),
47 indexSpecialSpecies_(
npos),
50 numPassThroughSpecies_(0),
51 neutralPBindexStart(0)
57 const std::string& id_) :
59 PBType_(PBTYPE_PASSTHROUGH),
61 indexSpecialSpecies_(
npos),
64 numPassThroughSpecies_(0),
65 neutralPBindexStart(0)
72 PBType_(PBTYPE_PASSTHROUGH),
74 indexSpecialSpecies_(
npos),
77 numPassThroughSpecies_(0),
78 neutralPBindexStart(0)
93 PBMoleFractions_ = b.PBMoleFractions_;
96 anionList_ = b.anionList_;
97 numAnionSpecies_ = b.numAnionSpecies_;
98 passThroughList_ = b.passThroughList_;
99 numPassThroughSpecies_ = b.numPassThroughSpecies_;
100 neutralPBindexStart = b.neutralPBindexStart;
101 moleFractionsTmp_ = b.moleFractionsTmp_;
135 for (
size_t k = 0; k <
m_kk; k++) {
158 for (
size_t k = 0; k <
m_kk; k++) {
168 for (
size_t k = 0; k <
m_kk; k++) {
184 for (
size_t k = 0; k <
m_kk; k++) {
194 for (
size_t k = 0; k <
m_kk; k++) {
213 for (
size_t k = 0; k <
m_kk; k++) {
219 for (
size_t k = 0; k <
m_kk; k++) {
239 for (
size_t k = 0; k <
m_kk; k++) {
246 for (
size_t k = 0; k <
m_kk; k++) {
251 void MolarityIonicVPSSTP::getPartialMolarVolumes(doublereal* vbar)
const
257 for (
size_t iK = 0; iK <
m_kk; iK++) {
270 doublereal sum = 0.0;
273 case PBTYPE_PASSTHROUGH:
274 for (k = 0; k <
m_kk; k++) {
278 case PBTYPE_SINGLEANION:
281 for (k = 0; k <
m_kk; k++) {
298 sum = sumCat - sumAnion;
299 if (fabs(sum) > 1.0E-16) {
303 sum += moleFractionsTmp_[k];
306 moleFractionsTmp_[k]/= sum;
311 PBMoleFractions_[k] = moleFractionsTmp_[
cationList_[k]];
313 for (k = 0; k < numPassThroughSpecies_; k++) {
314 PBMoleFractions_[neutralPBindexStart + k] =
moleFractions_[passThroughList_[k]];
317 sum = std::max(0.0, PBMoleFractions_[0]);
319 sum += PBMoleFractions_[k];
323 PBMoleFractions_[k] /= sum;
327 case PBTYPE_SINGLECATION:
332 case PBTYPE_MULTICATIONANION:
345 for (
size_t k = 0; k <
m_kk; k++) {
367 throw CanteraError(
"MolarityIonicVPSSTP",
"Base class method "
383 passThroughList_.clear();
384 for (
size_t k = 0; k <
m_kk; k++) {
389 }
else if (ch < 0.0) {
390 anionList_.push_back(k);
393 passThroughList_.push_back(k);
394 numPassThroughSpecies_++;
399 PBType_ = PBTYPE_MULTICATIONANION;
400 if (numAnionSpecies_ == 1) {
413 moleFractionsTmp_.resize(
m_kk);
418 std::string subname =
"MolarityIonicVPSSTP::initThermoXML";
421 if ((
int)
id.
size() > 0) {
422 string idp = phaseNode.
id();
424 throw CanteraError(subname,
"phasenode and Id are incompatible");
433 if (!phaseNode.
hasChild(
"thermo")) {
437 std::string mStringa = thermoNode.
attrib(
"model");
438 std::string mString =
lowercase(mStringa);
439 if (mString !=
"molarityionicvpss" && mString !=
"molarityionicvpsstp") {
441 "Unknown thermo model: " + mStringa +
" - This object only knows \"MolarityIonicVPSSTP\" ");
449 if (thermoNode.
hasChild(
"activityCoefficients")) {
452 mStringa = acNode.
attrib(
"model");
459 for (
size_t i = 0; i < n; i++) {
461 stemp = xmlACChild.
name();
466 if (nodeName ==
"binaryneutralspeciesparameters") {
481 std::string xname = xmLBinarySpecies.
name();
491 sprintf(p,
" \n %s:\n",
name().c_str());
494 sprintf(p,
" \n temperature %12.6g K\n",
temperature());
496 sprintf(p,
" pressure %12.6g Pa\n",
pressure());
498 sprintf(p,
" density %12.6g kg/m^3\n",
density());
504 sprintf(p,
" potential %12.6g V\n", phi);
524 sprintf(p,
" 1 kg 1 kmol\n");
526 sprintf(p,
" ----------- ------------\n");
528 sprintf(p,
" enthalpy %12.6g %12.4g J\n",
531 sprintf(p,
" internal energy %12.6g %12.4g J\n",
534 sprintf(p,
" entropy %12.6g %12.4g J/K\n",
537 sprintf(p,
" Gibbs function %12.6g %12.4g J\n",
540 sprintf(p,
" heat capacity c_p %12.6g %12.4g J/K\n",
544 sprintf(p,
" heat capacity c_v %12.6g %12.4g J/K\n",
549 sprintf(p,
" heat capacity c_v <not implemented> \n");
virtual doublereal density() const
Density (kg/m^3).
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
GibbsExcessVPSSTP & operator=(const GibbsExcessVPSSTP &b)
Assignment operator.
size_t numCationSpecies_
Number of cations in the mixture.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of each species in their standard states at the current T and P of the solution...
virtual void calcPseudoBinaryMoleFractions() const
Calculate pseudo binary mole fractions.
const size_t npos
index returned by functions to indicate "no position"
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
vector_fp m_speciesCharge
Vector of species charges. length m_kk.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the standard state of the species at ...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
virtual void getLnActivityCoefficients(doublereal *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
Class XML_Node is a tree-based representation of the contents of an XML file.
doublereal size(size_t k) const
This routine returns the size of species k.
std::vector< size_t > cationList_
Vector of cation indices in the mixture.
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
std::vector< doublereal > d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
std::string name() const
Return the name of the phase.
Header for intermediate ThermoPhase object for phases which employ gibbs excess free energy based for...
MolarityIonicVPSSTP & operator=(const MolarityIonicVPSSTP &b)
Assignment operator.
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.
doublereal intEnergy_mass() const
Specific internal energy.
Base class for a phase with thermodynamic properties.
virtual std::string report(bool show_thermo=true) const
returns a summary of the state of the phase as a string
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty thermophase object.
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
doublereal gibbs_mass() const
Specific Gibbs function.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
doublereal entropy_mass() const
Specific entropy.
doublereal pressure() const
Returns the current pressure of the phase.
virtual void initThermo()
std::string name() const
Returns the name of the XML node.
doublereal cp_mass() const
Specific heat at constant pressure.
Base class for exceptions thrown by Cantera classes.
doublereal err(const std::string &msg) const
Error function.
doublereal cv_mass() const
Specific heat at constant volume.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
MolarityIonicVPSSTP()
Constructor.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
void initLengths()
Initialize lengths of local variables after all species have been identified.
virtual int eosType() const
Equation of state type flag.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
size_t nSpecies() const
Returns the number of species in the phase.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Enthalpy functions for the standard state species at the current T an...
doublereal temperature() const
Temperature (K).
std::string id() const
Return the id attribute, if present.
const doublereal SmallNumber
smallest number to compare to zero.
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.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
doublereal enthalpy_mass() const
Specific enthalpy.
std::vector< doublereal > moleFractions_
Storage for the current values of the mole fractions of the species.
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 meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Initialize a ThermoPhase object, potentially reading activity coefficient information from an XML dat...
Contains declarations for string manipulation functions within Cantera.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void initThermo()
size_t numPBSpecies_
Number of pseudo binary species.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
size_t m_kk
Number of species in the phase.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity.
size_t nChildren(bool discardComments=false) const
Return the number of children.
void s_update_dlnActCoeff_dX_() const
Internal routine that calculates the derivative of the activity coefficients wrt the mole fractions...
size_t indexSpecialSpecies_
index of special species
std::vector< doublereal > dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
void s_update_lnActCoeff() const
Update the activity coefficients.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
void save()
Function to put this error onto Cantera's error stack.