28 MolarityIonicVPSSTP::MolarityIonicVPSSTP() :
29 PBType_(PBTYPE_PASSTHROUGH),
31 neutralPBindexStart(0)
33 warn_deprecated(
"Class MolarityIonicVPSSTP",
"To be removed after Cantera 2.4");
36 MolarityIonicVPSSTP::MolarityIonicVPSSTP(
const std::string& inputFile,
37 const std::string& id_) :
38 PBType_(PBTYPE_PASSTHROUGH),
40 neutralPBindexStart(0)
42 warn_deprecated(
"Class MolarityIonicVPSSTP",
"To be removed after Cantera 2.4");
46 MolarityIonicVPSSTP::MolarityIonicVPSSTP(
XML_Node& phaseRoot,
47 const std::string& id_) :
48 PBType_(PBTYPE_PASSTHROUGH),
50 neutralPBindexStart(0)
52 warn_deprecated(
"Class MolarityIonicVPSSTP",
"To be removed after Cantera 2.4");
64 for (
size_t k = 0; k <
m_kk; k++) {
77 for (
size_t k = 0; k <
m_kk; k++) {
90 for (
size_t k = 0; k <
m_kk; k++) {
98 for (
size_t k = 0; k <
m_kk; k++) {
114 for (
size_t k = 0; k <
m_kk; k++) {
119 for (
size_t k = 0; k <
m_kk; k++) {
135 for (
size_t k = 0; k <
m_kk; k++) {
141 for (
size_t k = 0; k <
m_kk; k++) {
150 for (
size_t iK = 0; iK <
m_kk; iK++) {
158 case PBTYPE_PASSTHROUGH:
159 for (
size_t k = 0; k <
m_kk; k++) {
163 case PBTYPE_SINGLEANION:
166 double sumAnion = 0.0;
167 for (
size_t k = 0; k <
m_kk; k++) {
181 size_t ka = anionList_[0];
183 double sum = sumCat - sumAnion;
184 if (fabs(sum) > 1.0E-16) {
188 sum += moleFractionsTmp_[k];
191 moleFractionsTmp_[k]/= sum;
196 PBMoleFractions_[k] = moleFractionsTmp_[
cationList_[k]];
198 for (
size_t k = 0; k < passThroughList_.size(); k++) {
199 PBMoleFractions_[neutralPBindexStart + k] =
moleFractions_[passThroughList_[k]];
202 sum = std::max(0.0, PBMoleFractions_[0]);
204 sum += PBMoleFractions_[k];
207 PBMoleFractions_[k] /= sum;
211 case PBTYPE_SINGLECATION:
213 case PBTYPE_MULTICATIONANION:
222 for (
size_t k = 0; k <
m_kk; k++) {
243 passThroughList_.clear();
244 for (
size_t k = 0; k <
m_kk; k++) {
248 }
else if (ch < 0.0) {
249 anionList_.push_back(k);
251 passThroughList_.push_back(k);
256 PBType_ = PBTYPE_MULTICATIONANION;
257 if (anionList_.size() == 1) {
262 if (anionList_.size() == 0 &&
cationList_.size() == 0) {
269 moleFractionsTmp_.resize(
m_kk);
274 if ((
int)
id.
size() > 0 && phaseNode.
id() !=
id) {
275 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
276 "phasenode and Id are incompatible");
282 if (!phaseNode.
hasChild(
"thermo")) {
283 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
284 "no thermo XML node");
289 throw CanteraError(
"MolarityIonicVPSSTP::initThermoXML",
290 "Unknown thermo model: " + thermoNode[
"model"]
291 +
" - This object only knows \"MolarityIonicVPSSTP\" ");
296 if (thermoNode.
hasChild(
"activityCoefficients")) {
298 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
313 std::string xname = xmLBinarySpecies.
name();
318 fmt::memory_buffer b;
321 format_to(b,
"\n {}:\n",
name());
324 format_to(b,
" temperature {:12.6g} K\n",
temperature());
325 format_to(b,
" pressure {:12.6g} Pa\n",
pressure());
326 format_to(b,
" density {:12.6g} kg/m^3\n",
density());
330 format_to(b,
" potential {:12.6g} V\n", phi);
346 format_to(b,
" 1 kg 1 kmol\n");
347 format_to(b,
" ----------- ------------\n");
348 format_to(b,
" enthalpy {:12.6g} {:12.4g} J\n",
350 format_to(b,
" internal energy {:12.6g} {:12.4g} J\n",
352 format_to(b,
" entropy {:12.6g} {:12.4g} J/K\n",
354 format_to(b,
" Gibbs function {:12.6g} {:12.4g} J\n",
356 format_to(b,
" heat capacity c_p {:12.6g} {:12.4g} J/K\n",
359 format_to(b,
" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
362 format_to(b,
" heat capacity c_v <not implemented>\n");
366 return to_string(b) + e.
what();
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
virtual double size(size_t k) const
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...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
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.
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.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
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.
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.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
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.
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.
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...
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 ...