28 MolarityIonicVPSSTP::MolarityIonicVPSSTP() :
29 PBType_(PBTYPE_PASSTHROUGH),
31 indexSpecialSpecies_(
npos),
32 neutralPBindexStart(0)
36 MolarityIonicVPSSTP::MolarityIonicVPSSTP(
const std::string& inputFile,
37 const std::string& id_) :
38 PBType_(PBTYPE_PASSTHROUGH),
40 indexSpecialSpecies_(
npos),
41 neutralPBindexStart(0)
46 MolarityIonicVPSSTP::MolarityIonicVPSSTP(
XML_Node& phaseRoot,
47 const std::string& id_) :
48 PBType_(PBTYPE_PASSTHROUGH),
50 indexSpecialSpecies_(
npos),
51 neutralPBindexStart(0)
57 PBType_(PBTYPE_PASSTHROUGH),
59 indexSpecialSpecies_(
npos),
60 neutralPBindexStart(0)
65 MolarityIonicVPSSTP& MolarityIonicVPSSTP::operator=(
const MolarityIonicVPSSTP& b)
68 GibbsExcessVPSSTP::operator=(b);
74 PBMoleFractions_ = b.PBMoleFractions_;
76 anionList_ = b.anionList_;
77 passThroughList_ = b.passThroughList_;
78 neutralPBindexStart = b.neutralPBindexStart;
79 moleFractionsTmp_ = b.moleFractionsTmp_;
97 for (
size_t k = 0; k <
m_kk; k++) {
110 for (
size_t k = 0; k <
m_kk; k++) {
123 for (
size_t k = 0; k <
m_kk; k++) {
131 for (
size_t k = 0; k <
m_kk; k++) {
147 for (
size_t k = 0; k <
m_kk; k++) {
152 for (
size_t k = 0; k <
m_kk; k++) {
168 for (
size_t k = 0; k <
m_kk; k++) {
174 for (
size_t k = 0; k <
m_kk; k++) {
183 for (
size_t iK = 0; iK <
m_kk; iK++) {
191 case PBTYPE_PASSTHROUGH:
192 for (
size_t k = 0; k <
m_kk; k++) {
196 case PBTYPE_SINGLEANION:
199 double sumAnion = 0.0;
200 for (
size_t k = 0; k <
m_kk; k++) {
214 size_t ka = anionList_[0];
216 double sum = sumCat - sumAnion;
217 if (fabs(sum) > 1.0E-16) {
221 sum += moleFractionsTmp_[k];
224 moleFractionsTmp_[k]/= sum;
229 PBMoleFractions_[k] = moleFractionsTmp_[
cationList_[k]];
231 for (
size_t k = 0; k < passThroughList_.size(); k++) {
232 PBMoleFractions_[neutralPBindexStart + k] =
moleFractions_[passThroughList_[k]];
235 sum = std::max(0.0, PBMoleFractions_[0]);
237 sum += PBMoleFractions_[k];
240 PBMoleFractions_[k] /= sum;
244 case PBTYPE_SINGLECATION:
246 case PBTYPE_MULTICATIONANION:
255 for (
size_t k = 0; k <
m_kk; k++) {
276 passThroughList_.clear();
277 for (
size_t k = 0; k <
m_kk; k++) {
281 }
else if (ch < 0.0) {
282 anionList_.push_back(k);
284 passThroughList_.push_back(k);
289 PBType_ = PBTYPE_MULTICATIONANION;
290 if (anionList_.size() == 1) {
295 if (anionList_.size() == 0 &&
cationList_.size() == 0) {
302 moleFractionsTmp_.resize(
m_kk);
307 if ((
int)
id.
size() > 0 && phaseNode.
id() !=
id) {
308 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
309 "phasenode and Id are incompatible");
315 if (!phaseNode.
hasChild(
"thermo")) {
316 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
317 "no thermo XML node");
320 if (!ba::iequals(thermoNode[
"model"],
"molarityionicvpss")
321 && !ba::iequals(thermoNode[
"model"],
"molarityionicvpsstp")) {
322 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
323 "Unknown thermo model: " + thermoNode[
"model"]
324 +
" - This object only knows \"MolarityIonicVPSSTP\" ");
329 if (thermoNode.
hasChild(
"activityCoefficients")) {
331 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
334 if (ba::iequals(xmlACChild.
name(),
"binaryneutralspeciesparameters")) {
346 std::string xname = xmLBinarySpecies.
name();
354 b.write(
"\n {}:\n",
name());
357 b.write(
" temperature {:12.6g} K\n",
temperature());
358 b.write(
" pressure {:12.6g} Pa\n",
pressure());
359 b.write(
" density {:12.6g} kg/m^3\n",
density());
363 b.write(
" potential {:12.6g} V\n", phi);
379 b.write(
" 1 kg 1 kmol\n");
380 b.write(
" ----------- ------------\n");
381 b.write(
" enthalpy {:12.6g} {:12.4g} J\n",
383 b.write(
" internal energy {:12.6g} {:12.4g} J\n",
385 b.write(
" entropy {:12.6g} {:12.4g} J/K\n",
387 b.write(
" Gibbs function {:12.6g} {:12.4g} J\n",
389 b.write(
" heat capacity c_p {:12.6g} {:12.4g} J/K\n",
392 b.write(
" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
395 b.write(
" heat capacity c_v <not implemented>\n");
399 return b.str() + e.
what();
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
std::string name() const
Returns the name of the XML node.
virtual void calcPseudoBinaryMoleFractions() const
Calculate pseudo binary mole fractions.
doublereal temperature() const
Temperature (K).
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
An error indicating that an unimplemented function has been called.
doublereal cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
const size_t npos
index returned by functions to indicate "no position"
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
vector_fp m_speciesCharge
Vector of species charges. length m_kk.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
const char * what() const
Get a description of the error.
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...
virtual doublereal density() const
Density (kg/m^3).
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
std::vector< size_t > cationList_
Vector of cation indices in the mixture.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
(see Thermodynamic Properties and class MolarityIonicVPSSTP).
void s_update_lnActCoeff() const
Update the activity coefficients.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
Base class for a phase with thermodynamic properties.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
virtual void initThermo()
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
vector_fp d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
virtual void initThermo()
doublereal electricPotential() const
Returns the electric potential of this phase (V).
doublereal entropy_mass() const
Specific entropy. Units: J/kg/K.
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.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
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.
virtual doublereal pressure() const
Returns the current pressure of the phase.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
void initLengths()
Initialize lengths of local variables after all species have been identified.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
void s_update_dlnActCoeff_dX_() const
Internal routine that calculates the derivative of the activity coefficients wrt the mole fractions...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
virtual void getLnActivityCoefficients(doublereal *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
doublereal cv_mass() const
Specific heat at constant volume. Units: J/kg/K.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
std::string id() const
Return the string id for the phase.
const doublereal SmallNumber
smallest number to compare to zero.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
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
doublereal gibbs_mass() const
Specific Gibbs function. Units: J/kg.
std::string id() const
Return the id attribute, if present.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
std::string name() const
Return the name of the phase.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
Contains declarations for string manipulation functions within Cantera.
doublereal size(size_t k) const
This routine returns the size of species k.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
size_t numPBSpecies_
Number of pseudo binary species.
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.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
Namespace for the Cantera kernel.
doublereal intEnergy_mass() const
Specific internal energy. Units: J/kg.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
size_t nChildren(bool discardComments=false) const
Return the number of children.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
size_t indexSpecialSpecies_
index of special species
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 ...