30 static const double xxSmall = 1.0E-150;
36 MolarityIonicVPSSTP::MolarityIonicVPSSTP() :
38 PBType_(PBTYPE_PASSTHROUGH),
40 indexSpecialSpecies_(
npos),
43 numPassThroughSpecies_(0),
44 neutralPBindexStart(0)
58 PBType_(PBTYPE_PASSTHROUGH),
60 indexSpecialSpecies_(
npos),
63 numPassThroughSpecies_(0),
64 neutralPBindexStart(0)
71 PBType_(PBTYPE_PASSTHROUGH),
73 indexSpecialSpecies_(
npos),
76 numPassThroughSpecies_(0),
77 neutralPBindexStart(0)
90 PBType_(PBTYPE_PASSTHROUGH),
92 indexSpecialSpecies_(
npos),
95 numPassThroughSpecies_(0),
96 neutralPBindexStart(0)
117 PBMoleFractions_ = b.PBMoleFractions_;
120 anionList_ = b.anionList_;
121 numAnionSpecies_ = b.numAnionSpecies_;
122 passThroughList_ = b.passThroughList_;
123 numPassThroughSpecies_ = b.numPassThroughSpecies_;
124 neutralPBindexStart = b.neutralPBindexStart;
125 moleFractionsTmp_ = b.moleFractionsTmp_;
188 if ((
int) inputFile.size() == 0) {
189 throw CanteraError(
"MolarityIonicVPSSTP:constructPhaseFile",
190 "input file is null");
193 std::ifstream fin(path.c_str());
195 throw CanteraError(
"MolarityIonicVPSSTP:constructPhaseFile",
"could not open "
196 +path+
" for reading.");
207 throw CanteraError(
"MolarityIonicVPSSTP:constructPhaseFile",
208 "ERROR: Can not find phase named " +
209 id +
" in file named " + inputFile);
211 fxml_phase->
copy(&phaseNode_XML);
246 if ((
int)
id.
size() > 0) {
247 string idp = phaseNode.
id();
249 throw CanteraError(
"MolarityIonicVPSSTP::constructPhaseXML",
250 "phasenode and Id are incompatible");
257 if (!phaseNode.
hasChild(
"thermo")) {
258 throw CanteraError(
"MolarityIonicVPSSTP::constructPhaseXML",
259 "no thermo XML node");
266 stemp = thermoNode.
attrib(
"model");
268 if (formString !=
"molarityionicvpss" && formString !=
"molarityionicvpsstp") {
269 throw CanteraError(
"MolarityIonicVPSSTP::constructPhaseXML",
270 "model name isn't MolarityIonicVPSSTP: " + formString);
280 throw CanteraError(
"MolarityIonicVPSSTP::constructPhaseXML",
"importPhase failed ");
304 for (
size_t k = 0; k <
m_kk; k++) {
327 for (
size_t k = 0; k <
m_kk; k++) {
338 for (
size_t k = 0; k <
m_kk; k++) {
369 for (
size_t k = 0; k <
m_kk; k++) {
379 for (
size_t k = 0; k <
m_kk; k++) {
412 for (
size_t k = 0; k <
m_kk; k++) {
418 for (
size_t k = 0; k <
m_kk; k++) {
452 for (
size_t k = 0; k <
m_kk; k++) {
459 for (
size_t k = 0; k <
m_kk; k++) {
479 for (
size_t iK = 0; iK <
m_kk; iK++) {
492 doublereal sum = 0.0;
495 case PBTYPE_PASSTHROUGH:
496 for (k = 0; k <
m_kk; k++) {
500 case PBTYPE_SINGLEANION:
503 for (k = 0; k <
m_kk; k++) {
520 sum = sumCat - sumAnion;
521 if (fabs(sum) > 1.0E-16) {
525 sum += moleFractionsTmp_[k];
528 moleFractionsTmp_[k]/= sum;
533 PBMoleFractions_[k] = moleFractionsTmp_[
cationList_[k]];
535 for (k = 0; k < numPassThroughSpecies_; k++) {
536 PBMoleFractions_[neutralPBindexStart + k] =
moleFractions_[passThroughList_[k]];
539 sum =
std::max(0.0, PBMoleFractions_[0]);
541 sum += PBMoleFractions_[k];
545 PBMoleFractions_[k] /= sum;
549 case PBTYPE_SINGLECATION:
554 case PBTYPE_MULTICATIONANION:
574 for (
size_t k = 0; k <
m_kk; k++) {
605 throw CanteraError(
"MolarityIonicVPSSTP",
"Base class method "
634 passThroughList_.clear();
635 for (
size_t k = 0; k <
m_kk; k++) {
640 }
else if (ch < 0.0) {
641 anionList_.push_back(k);
644 passThroughList_.push_back(k);
645 numPassThroughSpecies_++;
650 PBType_ = PBTYPE_MULTICATIONANION;
651 if (numAnionSpecies_ == 1) {
665 moleFractionsTmp_.resize(
m_kk);
685 std::string subname =
"MolarityIonicVPSSTP::initThermoXML";
693 std::string mStringa = thermoNode.
attrib(
"model");
694 std::string mString =
lowercase(mStringa);
695 if (mString !=
"molarityionicvpss" && mString !=
"molarityionicvpsstp") {
697 "Unknown thermo model: " + mStringa +
" - This object only knows \"MolarityIonicVPSSTP\" ");
708 if (thermoNode.
hasChild(
"activityCoefficients")) {
711 std::string mStringa = acNode.
attrib(
"model");
712 std::string mString =
lowercase(mStringa);
718 for (
size_t i = 0; i < n; i++) {
720 stemp = xmlACChild.
name();
725 if (nodeName ==
"binaryneutralspeciesparameters") {
746 std::string xname = xmLBinarySpecies.
name();
759 sprintf(p,
" \n %s:\n",
name().c_str());
762 sprintf(p,
" \n temperature %12.6g K\n",
temperature());
764 sprintf(p,
" pressure %12.6g Pa\n",
pressure());
766 sprintf(p,
" density %12.6g kg/m^3\n",
density());
772 sprintf(p,
" potential %12.6g V\n", phi);
792 sprintf(p,
" 1 kg 1 kmol\n");
794 sprintf(p,
" ----------- ------------\n");
796 sprintf(p,
" enthalpy %12.6g %12.4g J\n",
799 sprintf(p,
" internal energy %12.6g %12.4g J\n",
802 sprintf(p,
" entropy %12.6g %12.4g J/K\n",
805 sprintf(p,
" Gibbs function %12.6g %12.4g J\n",
808 sprintf(p,
" heat capacity c_p %12.6g %12.4g J/K\n",
812 sprintf(p,
" heat capacity c_v %12.6g %12.4g J/K\n",
817 sprintf(p,
" heat capacity c_v <not implemented> \n");