30 MolarityIonicVPSSTP::MolarityIonicVPSSTP() :
31 PBType_(PBTYPE_PASSTHROUGH),
33 indexSpecialSpecies_(
npos),
34 neutralPBindexStart(0)
39 const std::string& id_) :
40 PBType_(PBTYPE_PASSTHROUGH),
42 indexSpecialSpecies_(
npos),
43 neutralPBindexStart(0)
49 const std::string& id_) :
50 PBType_(PBTYPE_PASSTHROUGH),
52 indexSpecialSpecies_(
npos),
53 neutralPBindexStart(0)
59 PBType_(PBTYPE_PASSTHROUGH),
61 indexSpecialSpecies_(
npos),
62 neutralPBindexStart(0)
76 PBMoleFractions_ = b.PBMoleFractions_;
78 anionList_ = b.anionList_;
79 passThroughList_ = b.passThroughList_;
80 neutralPBindexStart = b.neutralPBindexStart;
81 moleFractionsTmp_ = b.moleFractionsTmp_;
106 for (
size_t k = 0; k <
m_kk; k++) {
125 for (
size_t k = 0; k <
m_kk; k++) {
135 for (
size_t k = 0; k <
m_kk; k++) {
150 for (
size_t k = 0; k <
m_kk; k++) {
159 for (
size_t k = 0; k <
m_kk; k++) {
178 for (
size_t k = 0; k <
m_kk; k++) {
184 for (
size_t k = 0; k <
m_kk; k++) {
203 for (
size_t k = 0; k <
m_kk; k++) {
210 for (
size_t k = 0; k <
m_kk; k++) {
221 for (
size_t iK = 0; iK <
m_kk; iK++) {
229 case PBTYPE_PASSTHROUGH:
230 for (
size_t k = 0; k <
m_kk; k++) {
234 case PBTYPE_SINGLEANION:
237 double sumAnion = 0.0;
238 for (
size_t k = 0; k <
m_kk; k++) {
252 size_t ka = anionList_[0];
254 double sum = sumCat - sumAnion;
255 if (fabs(sum) > 1.0E-16) {
256 moleFractionsTmp_[
cationList_[kMax]] -= sum / m_speciesCharge[kMax];
258 for (
size_t k = 0; k < cationList_.size(); k++) {
259 sum += moleFractionsTmp_[k];
261 for (
size_t k = 0; k < cationList_.size(); k++) {
262 moleFractionsTmp_[k]/= sum;
267 PBMoleFractions_[k] = moleFractionsTmp_[
cationList_[k]];
269 for (
size_t k = 0; k < passThroughList_.size(); k++) {
270 PBMoleFractions_[neutralPBindexStart + k] =
moleFractions_[passThroughList_[k]];
273 sum = std::max(0.0, PBMoleFractions_[0]);
275 sum += PBMoleFractions_[k];
279 PBMoleFractions_[k] /= sum;
284 case PBTYPE_SINGLECATION:
289 case PBTYPE_MULTICATIONANION:
302 for (
size_t k = 0; k <
m_kk; k++) {
324 passThroughList_.clear();
325 for (
size_t k = 0; k <
m_kk; k++) {
329 }
else if (ch < 0.0) {
330 anionList_.push_back(k);
332 passThroughList_.push_back(k);
337 PBType_ = PBTYPE_MULTICATIONANION;
338 if (anionList_.size() == 1) {
343 if (anionList_.size() == 0 &&
cationList_.size() == 0) {
350 moleFractionsTmp_.resize(
m_kk);
355 if ((
int)
id.
size() > 0 && phaseNode.
id() !=
id) {
356 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
357 "phasenode and Id are incompatible");
365 if (!phaseNode.
hasChild(
"thermo")) {
366 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
367 "no thermo XML node");
370 std::string mStringa = thermoNode.
attrib(
"model");
371 std::string mString =
lowercase(mStringa);
372 if (mString !=
"molarityionicvpss" && mString !=
"molarityionicvpsstp") {
373 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
374 "Unknown thermo model: " + mStringa +
" - This object only knows \"MolarityIonicVPSSTP\" ");
381 if (thermoNode.
hasChild(
"activityCoefficients")) {
383 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
388 if (
lowercase(xmlACChild.
name()) ==
"binaryneutralspeciesparameters") {
403 std::string xname = xmLBinarySpecies.
name();
412 sprintf(p,
" \n %s:\n",
name().c_str());
415 sprintf(p,
" \n temperature %12.6g K\n",
temperature());
417 sprintf(p,
" pressure %12.6g Pa\n",
pressure());
419 sprintf(p,
" density %12.6g kg/m^3\n",
density());
425 sprintf(p,
" potential %12.6g V\n", phi);
444 sprintf(p,
" 1 kg 1 kmol\n");
446 sprintf(p,
" ----------- ------------\n");
448 sprintf(p,
" enthalpy %12.6g %12.4g J\n",
451 sprintf(p,
" internal energy %12.6g %12.4g J\n",
454 sprintf(p,
" entropy %12.6g %12.4g J/K\n",
457 sprintf(p,
" Gibbs function %12.6g %12.4g J\n",
460 sprintf(p,
" heat capacity c_p %12.6g %12.4g J/K\n",
464 sprintf(p,
" heat capacity c_v %12.6g %12.4g J/K\n",
469 sprintf(p,
" heat capacity c_v <not implemented> \n");
virtual doublereal density() const
Density (kg/m^3).
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.
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 std::string report(bool show_thermo=true, doublereal threshold=1e-14) const
returns a summary of the state of the phase as a string
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.
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.
std::string id() const
Return the string id for the phase.
Base class for exceptions thrown by Cantera classes.
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.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
void initLengths()
Initialize lengths of local variables after all species have been identified.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
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.