31double A_Debye_default = 1.172576;
32double B_Debye_default = 3.28640E9;
33double maxIionicStrength_default = 30.0;
37 const std::string& id_) :
38 m_formDH(DHFORM_DILUTE_LIMIT),
39 m_Aionic_default(NAN),
40 m_IionicMolality(0.0),
41 m_maxIionicStrength(maxIionicStrength_default),
42 m_useHelgesonFixedForm(false),
43 m_IionicMolalityStoich(0.0),
44 m_form_A_Debye(A_DEBYE_CONST),
45 m_A_Debye(A_Debye_default),
46 m_B_Debye(B_Debye_default),
54 m_formDH(DHFORM_DILUTE_LIMIT),
55 m_Aionic_default(NAN),
56 m_IionicMolality(0.0),
57 m_maxIionicStrength(maxIionicStrength_default),
58 m_useHelgesonFixedForm(false),
59 m_IionicMolalityStoich(0.0),
60 m_form_A_Debye(A_DEBYE_CONST),
61 m_A_Debye(A_Debye_default),
62 m_B_Debye(B_Debye_default),
69DebyeHuckel::~DebyeHuckel()
119 for (
size_t k = 0; k <
m_kk; k++) {
127 return 1.0 / mvSolvent;
137 for (
size_t k = 1; k <
m_kk; k++) {
150 for (
size_t k = 0; k <
m_kk; k++) {
151 acMolality[k] = exp(acMolality[k]);
169 for (
size_t k = 1; k <
m_kk; k++) {
183 for (
size_t k = 0; k <
m_kk; k++) {
196 for (
size_t k = 0; k <
m_kk; k++) {
209 for (
size_t k = 0; k <
m_kk; k++) {
220 for (
size_t k = 1; k <
m_kk; k++) {
234 for (
size_t k = 0; k <
m_kk; k++) {
247 for (
size_t k = 0; k <
m_kk; k++) {
255 for (
size_t k = 0; k <
m_kk; k++) {
269 for (
size_t k = 0; k <
m_kk; k++) {
287 }
else if (estString ==
"charged-species"
289 return cEST_chargedSpecies;
290 }
else if (estString ==
"weak-acid-associated"
292 return cEST_weakAcidAssociated;
293 }
else if (estString ==
"strong-acid-associated"
295 return cEST_strongAcidAssociated;
296 }
else if (estString ==
"polar-neutral"
298 return cEST_polarNeutral;
299 }
else if (estString ==
"nonpolar-neutral"
301 return cEST_nonpolarNeutral;
304 "Invalid electrolyte species type '{}'", estString);
310 || model ==
"dilute-limit"
313 }
else if (model ==
"B-dot-with-variable-a"
316 }
else if (model ==
"B-dot-with-common-a"
322 }
else if (model ==
"Pitzer-with-beta_ij"
328 "Unknown model '{}'", model);
342void DebyeHuckel::setB_dot(
double bdot)
347 "B_dot entry in the wrong DH form");
350 for (
size_t k = 0; k <
nSpecies(); k++) {
351 if (fabs(
charge(k)) > 0.0001) {
362 for (
size_t k = 0; k <
m_kk; k++) {
374 throw CanteraError(
"DebyeHuckel::setBeta",
"Species '{}' not found", sp1);
378 throw CanteraError(
"DebyeHuckel::setBeta",
"Species '{}' not found", sp2);
386 if (id_.size() > 0) {
387 std::string idp = phaseNode.
id();
390 "phasenode and Id are incompatible");
395 if (!phaseNode.
hasChild(
"thermo")) {
397 "no thermo XML node");
405 if (thermoNode.
hasChild(
"activityCoefficients")) {
414 if (thermoNode.
hasChild(
"activityCoefficients")) {
421 string modelString = ss->
attrib(
"model");
422 if (modelString !=
"") {
427 "A_Debye Model \"" + modelString +
437 setB_Debye(
getFloat(acNode,
"B_Debye"));
442 setB_dot(
getFloat(acNode,
"B_dot"));
446 if (acNode.
hasChild(
"maxIonicStrength")) {
447 setMaxIonicStrength(
getFloat(acNode,
"maxIonicStrength"));
451 useHelgesonFixedForm(acNode.
hasChild(
"UseHelgesonFixedForm"));
454 if (acNode.
hasChild(
"ionicRadius")) {
457 double Afactor = 1.0;
459 std::string Aunits = irNode.
attrib(
"units");
460 Afactor =
toSI(Aunits);
479 map<string, string> m;
486 for (
const auto& b : m) {
498 if (acNode.
hasChild(
"DHBetaMatrix")) {
506 "DHBetaMatrix found for wrong type");
511 if (acNodePtr && acNodePtr->
hasChild(
"stoichIsMods")) {
513 map<std::string, std::string> msIs;
515 for (
const auto& b : msIs) {
517 double val =
fpValue(b.second);
524 if (acNodePtr && acNodePtr->
hasChild(
"electrolyteSpeciesType")) {
525 XML_Node& ESTNode = acNodePtr->
child(
"electrolyteSpeciesType");
526 map<std::string, std::string> msEST;
528 for (
const auto& b : msEST) {
530 std::string est = b.second;
533 "Bad electrolyte type: " + est);
551 if (node.hasKey(
"A_Debye")) {
552 if (node[
"A_Debye"] ==
"variable") {
555 setA_Debye(node.convert(
"A_Debye",
"kg^0.5/gmol^0.5"));
558 if (node.hasKey(
"B_Debye")) {
559 setB_Debye(node.convert(
"B_Debye",
"kg^0.5/gmol^0.5/m"));
561 if (node.hasKey(
"max-ionic-strength")) {
562 setMaxIonicStrength(node[
"max-ionic-strength"].asDouble());
564 if (node.hasKey(
"use-Helgeson-fixed-form")) {
565 useHelgesonFixedForm(node[
"use-Helgeson-fixed-form"].asBool());
567 if (node.hasKey(
"default-ionic-radius")) {
570 if (node.hasKey(
"B-dot")) {
571 setB_dot(node[
"B-dot"].asDouble());
573 if (node.hasKey(
"beta")) {
574 for (
auto& item : node[
"beta"].asVector<AnyMap>()) {
575 auto&
species = item[
"species"].asVector<
string>(2);
589 }
else if (
dynamic_cast<PDSS_ConstVol*
>(providePDSS(0)) == 0) {
590 throw CanteraError(
"DebyeHuckel::initThermo",
"Solvent standard state"
591 " model must be WaterIAPWS or constant_incompressible.");
595 for (
size_t k = 1; k <
nSpecies(); k++) {
597 throw CanteraError(
"DebyeHuckel::initThermo",
"Solute standard"
598 " state model must be constant_incompressible.");
609 case DHFORM_DILUTE_LIMIT:
610 activityNode[
"model"] =
"dilute-limit";
613 activityNode[
"model"] =
"B-dot-with-variable-a";
615 case DHFORM_BDOT_ACOMMON:
616 activityNode[
"model"] =
"B-dot-with-common-a";
619 activityNode[
"model"] =
"beta_ij";
621 case DHFORM_PITZER_BETAIJ:
622 activityNode[
"model"] =
"Pitzer-with-beta_ij";
627 activityNode[
"A_Debye"] =
"variable";
628 }
else if (
m_A_Debye != A_Debye_default) {
629 activityNode[
"A_Debye"].setQuantity(
m_A_Debye,
"kg^0.5/gmol^0.5");
633 activityNode[
"B_Debye"].setQuantity(
m_B_Debye,
"kg^0.5/gmol^0.5/m");
639 activityNode[
"use-Helgeson-fixed-form"] =
true;
646 activityNode[
"B-dot"] = B_dot;
651 std::vector<AnyMap> beta;
652 for (
size_t i = 0; i <
m_kk; i++) {
653 for (
size_t j = i; j <
m_kk; j++) {
656 entry[
"species"] = vector<std::string>{
659 beta.push_back(std::move(entry));
663 activityNode[
"beta"] = std::move(beta);
665 phaseNode[
"activity-data"] = std::move(activityNode);
669 AnyMap& speciesNode)
const
676 dhNode[
"ionic-radius"].setQuantity(
m_Aionic[k],
"m");
679 int estDefault = cEST_nonpolarNeutral;
686 estDefault = cEST_weakAcidAssociated;
687 }
else if (fabs(
charge(k)) > 0.0001) {
688 estDefault = cEST_chargedSpecies;
697 case cEST_chargedSpecies:
698 estType =
"charged-species";
700 case cEST_weakAcidAssociated:
701 estType =
"weak-acid-associated";
703 case cEST_strongAcidAssociated:
704 estType =
"strong-acid-associated";
706 case cEST_polarNeutral:
707 estType =
"polar-neutral";
709 case cEST_nonpolarNeutral:
710 estType =
"nonpolar-neutral";
714 "Unknown electrolyte species type ({}) for species '{}'",
717 dhNode[
"electrolyte-species-type"] = estType;
721 speciesNode[
"Debye-Huckel"] = std::move(dhNode);
730 if (tempArg != -1.0) {
734 if (presArg != -1.0) {
747 throw CanteraError(
"DebyeHuckel::A_Debye_TP",
"shouldn't be here");
755 if (tempArg != -1.0) {
759 if (presArg != -1.0) {
771 throw CanteraError(
"DebyeHuckel::dA_DebyedT_TP",
"shouldn't be here");
779 if (tempArg != -1.0) {
783 if (presArg != -1.0) {
795 throw CanteraError(
"DebyeHuckel::d2A_DebyedT2_TP",
"shouldn't be here");
803 if (tempArg != -1.0) {
807 if (presArg != -1.0) {
819 throw CanteraError(
"DebyeHuckel::dA_DebyedP_TP",
"shouldn't be here");
848 int est = cEST_nonpolarNeutral;
849 double stoichCharge = spec->charge;
850 if (fabs(spec->charge) > 0.0001) {
851 est = cEST_chargedSpecies;
854 if (spec->input.hasKey(
"Debye-Huckel")) {
855 auto& dhNode = spec->input[
"Debye-Huckel"].as<
AnyMap>();
856 Aionic = dhNode.
convert(
"ionic-radius",
"m", NAN);
857 if (dhNode.hasKey(
"weak-acid-charge")) {
858 stoichCharge = dhNode[
"weak-acid-charge"].asDouble();
859 if (fabs(stoichCharge - spec->charge) > 0.0001) {
860 est = cEST_weakAcidAssociated;
864 if (dhNode.hasKey(
"electrolyte-species-type")) {
865 est =
interp_est(dhNode[
"electrolyte-species-type"].asString());
885 const static double npActCoeff[] = {0.1127, -0.01049, 1.545E-3};
886 double I2 = IionicMolality * IionicMolality;
888 npActCoeff[0] * IionicMolality +
890 npActCoeff[2] * I2 * IionicMolality;
891 return pow(10.0 , l10actCoeff);
896 const double a0 = 1.454;
897 const double b0 = 0.02236;
898 const double c0 = 9.380E-3;
899 const double d0 = -5.362E-4;
904 double Is2 = Is * Is;
905 double bhat = 1.0 + a0 * sqrt(Is);
906 double func = bhat - 2.0 * log(bhat) - 1.0/bhat;
907 double v1 =
m_A_Debye / (a0 * a0 * a0 * Is) * func;
908 double oc = 1.0 - v1 + b0 * Is / 2.0 + 2.0 * c0 * Is2 / 3.0
909 + 3.0 * d0 * Is2 * Is / 4.0;
919 for (
size_t k = 1; k <
m_kk; k++) {
930 double z_k, zs_k1, zs_k2;
941 for (
size_t k = 0; k <
m_kk; k++) {
950 for (
size_t k = 0; k <
m_kk; k++) {
972 xmolSolvent = std::max(8.689E-3, xmolSolvent);
975 double ac_nonPolar = 1.0;
979 double lnActivitySolvent = 0.0;
982 double y, yp1, sigma;
984 case DHFORM_DILUTE_LIMIT:
985 for (
size_t k = 0; k <
m_kk; k++) {
990 (xmolSolvent - 1.0)/xmolSolvent +
997 for (
size_t k = 0; k <
m_kk; k++) {
999 if (est == cEST_nonpolarNeutral) {
1004 - z_k * z_k * numTmp / (1.0 + denomTmp *
m_Aionic[k])
1009 lnActivitySolvent = (xmolSolvent - 1.0)/xmolSolvent;
1013 if (denomTmp > 0.0) {
1014 for (
size_t k = 0; k <
m_kk; k++) {
1015 if (k != 0 ||
m_Aionic[k] != 0.0) {
1018 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1024 lnActivitySolvent += coeff * tmp;
1026 for (
size_t k = 1; k <
m_kk; k++) {
1032 lnActivitySolvent -=
1042 case DHFORM_BDOT_ACOMMON:
1044 for (
size_t k = 0; k <
m_kk; k++) {
1047 - z_k * z_k * numTmp / (1.0 + denomTmp)
1050 if (denomTmp > 0.0) {
1053 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1058 (xmolSolvent - 1.0)/xmolSolvent +
1062 for (
size_t k = 1; k <
m_kk; k++) {
1068 lnActivitySolvent -=
1076 (xmolSolvent - 1.0)/xmolSolvent;
1078 for (
size_t k = 1; k <
m_kk; k++) {
1081 - z_k * z_k * numTmp / (1.0 + denomTmp);
1082 for (
size_t j = 0; j <
m_kk; j++) {
1087 if (denomTmp > 0.0) {
1090 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 -2.0*log(yp1));
1095 (xmolSolvent - 1.0)/xmolSolvent +
1099 for (
size_t k = 0; k <
m_kk; k++) {
1100 for (
size_t j = 0; j <
m_kk; j++) {
1108 case DHFORM_PITZER_BETAIJ:
1112 tmpLn = log(1.0 + denomTmp);
1113 for (
size_t k = 1; k <
m_kk; k++) {
1116 - z_k * z_k * numTmp / 3.0 / (1.0 + denomTmp);
1120 for (
size_t j = 0; j <
m_kk; j++) {
1125 sigma = 1.0 / (1.0 + denomTmp);
1127 (xmolSolvent - 1.0)/xmolSolvent +
1131 for (
size_t k = 0; k <
m_kk; k++) {
1132 for (
size_t j = 0; j <
m_kk; j++) {
1141 throw CanteraError(
"DebyeHuckel::s_update_lnMolalityActCoeff",
"ERROR");
1153 double z_k, coeff, tmp, y, yp1, sigma, tmpLn;
1157 for (
size_t k = 0; k <
m_kk; k++) {
1165 xmolSolvent = std::max(8.689E-3, xmolSolvent);
1167 double numdAdTTmp = dAdT * sqrtI;
1169 double d_lnActivitySolvent_dT = 0;
1172 case DHFORM_DILUTE_LIMIT:
1173 for (
size_t k = 1; k <
m_kk; k++) {
1177 d_lnActivitySolvent_dT = 2.0 / 3.0 * dAdT *
m_Mnaught *
1182 case DHFORM_BDOT_AK:
1183 for (
size_t k = 0; k <
m_kk; k++) {
1186 - z_k * z_k * numdAdTTmp / (1.0 + denomTmp *
m_Aionic[k]);
1190 coeff = 2.0 / 3.0 * dAdT *
m_Mnaught * sqrtI;
1192 if (denomTmp > 0.0) {
1193 for (
size_t k = 0; k <
m_kk; k++) {
1196 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1204 case DHFORM_BDOT_ACOMMON:
1206 for (
size_t k = 0; k <
m_kk; k++) {
1209 - z_k * z_k * numdAdTTmp / (1.0 + denomTmp);
1211 if (denomTmp > 0.0) {
1214 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1224 for (
size_t k = 1; k <
m_kk; k++) {
1228 if (denomTmp > 0.0) {
1231 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1239 case DHFORM_PITZER_BETAIJ:
1241 tmpLn = log(1.0 + denomTmp);
1242 for (
size_t k = 1; k <
m_kk; k++) {
1245 - z_k * z_k * numdAdTTmp / (1.0 + denomTmp)
1250 sigma = 1.0 / (1.0 + denomTmp);
1256 throw CanteraError(
"DebyeHuckel::s_update_dlnMolalityActCoeff_dT",
1263 double z_k, coeff, tmp, y, yp1, sigma, tmpLn;
1266 if (d2AdT2 == 0.0 && dAdT == 0.0) {
1267 for (
size_t k = 0; k <
m_kk; k++) {
1275 xmolSolvent = std::max(8.689E-3, xmolSolvent);
1277 double numd2AdT2Tmp = d2AdT2 * sqrtI;
1281 case DHFORM_DILUTE_LIMIT:
1282 for (
size_t k = 0; k <
m_kk; k++) {
1288 case DHFORM_BDOT_AK:
1289 for (
size_t k = 0; k <
m_kk; k++) {
1292 - z_k * z_k * numd2AdT2Tmp / (1.0 + denomTmp *
m_Aionic[k]);
1296 coeff = 2.0 / 3.0 * d2AdT2 *
m_Mnaught * sqrtI;
1298 if (denomTmp > 0.0) {
1299 for (
size_t k = 0; k <
m_kk; k++) {
1302 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1310 case DHFORM_BDOT_ACOMMON:
1312 for (
size_t k = 0; k <
m_kk; k++) {
1315 - z_k * z_k * numd2AdT2Tmp / (1.0 + denomTmp);
1317 if (denomTmp > 0.0) {
1320 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1330 for (
size_t k = 1; k <
m_kk; k++) {
1334 if (denomTmp > 0.0) {
1337 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 -2.0*log(yp1));
1345 case DHFORM_PITZER_BETAIJ:
1347 tmpLn = log(1.0 + denomTmp);
1348 for (
size_t k = 1; k <
m_kk; k++) {
1351 - z_k * z_k * numd2AdT2Tmp / (1.0 + denomTmp)
1356 sigma = 1.0 / (1.0 + denomTmp);
1362 throw CanteraError(
"DebyeHuckel::s_update_d2lnMolalityActCoeff_dT2",
1369 double z_k, coeff, tmp, y, yp1, sigma, tmpLn;
1373 for (
size_t k = 0; k <
m_kk; k++) {
1381 xmolSolvent = std::max(8.689E-3, xmolSolvent);
1383 double numdAdPTmp = dAdP * sqrtI;
1387 case DHFORM_DILUTE_LIMIT:
1388 for (
size_t k = 0; k <
m_kk; k++) {
1394 case DHFORM_BDOT_AK:
1395 for (
size_t k = 0; k <
m_kk; k++) {
1397 if (est == cEST_nonpolarNeutral) {
1402 - z_k * z_k * numdAdPTmp / (1.0 + denomTmp *
m_Aionic[k]);
1407 coeff = 2.0 / 3.0 * dAdP *
m_Mnaught * sqrtI;
1409 if (denomTmp > 0.0) {
1410 for (
size_t k = 0; k <
m_kk; k++) {
1413 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1421 case DHFORM_BDOT_ACOMMON:
1423 for (
size_t k = 0; k <
m_kk; k++) {
1426 - z_k * z_k * numdAdPTmp / (1.0 + denomTmp);
1428 if (denomTmp > 0.0) {
1431 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1442 for (
size_t k = 1; k <
m_kk; k++) {
1446 if (denomTmp > 0.0) {
1449 sigma = 3.0 / (y * y * y) * (yp1 - 1.0/yp1 - 2.0*log(yp1));
1457 case DHFORM_PITZER_BETAIJ:
1459 tmpLn = log(1.0 + denomTmp);
1460 for (
size_t k = 1; k <
m_kk; k++) {
1463 - z_k * z_k * numdAdPTmp / (1.0 + denomTmp)
1464 - 2.0 * z_k * z_k * dAdP * tmpLn
1469 sigma = 1.0 / (1.0 + denomTmp);
1475 throw CanteraError(
"DebyeHuckel::s_update_dlnMolalityActCoeff_dP",
Headers for the DebyeHuckel ThermoPhase object, which models dilute electrolyte solutions (see Thermo...
Declarations for the class PDSS_ConstVol (pressure dependent standard state) which handles calculatio...
Implementation of a pressure dependent standard state virtual function for a Pure Water Phase (see Sp...
Declaration for class Cantera::Species.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
A map of string keys to values whose type can vary at runtime.
size_t size() const
Returns the number of elements in this map.
double convert(const std::string &key, const std::string &units) const
Convert the item stored by the given key to the units specified in units.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
size_t nRows() const
Number of rows.
size_t nColumns() const
Number of columns.
doublereal & value(size_t i, size_t j)
Returns a changeable reference to position in the matrix.
void resize(size_t n, size_t m, double v=0.0)
Resize the array, and fill the new entries with 'v'.
Base class for exceptions thrown by Cantera classes.
Array2D m_Beta_ij
Array of 2D data used in the DHFORM_BETAIJ formulation Beta_ij.value(i,j) is the coefficient of the j...
int m_formDH
form of the Debye-Huckel parameterization used in the model.
virtual bool addSpecies(shared_ptr< Species > spec)
double m_A_Debye
Current value of the Debye Constant, A_Debye.
virtual double d2A_DebyedT2_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the 2nd derivative of the Debye Huckel constant with respect to temperature as a function of...
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
vector_fp m_d2lnActCoeffMolaldT2
2nd Derivative of log act coeff wrt T
double m_IionicMolality
Current value of the ionic strength on the molality scale.
double _osmoticCoeffHelgesonFixedForm() const
Formula for the osmotic coefficient that occurs in the GWB.
double m_densWaterSS
Storage for the density of water's standard state.
void s_update_d2lnMolalityActCoeff_dT2() const
Calculate the temperature 2nd derivative of the activity coefficient.
vector_fp m_speciesCharge_Stoich
Stoichiometric species charge -> This is for calculations of the ionic strength which ignore ion-ion ...
int m_form_A_Debye
Form of the constant outside the Debye-Huckel term called A.
bool m_useHelgesonFixedForm
If true, then the fixed for of Helgeson's activity for water is used instead of the rigorous form obt...
static double _nonpolarActCoeff(double IionicMolality)
Static function that implements the non-polar species salt-out modifications.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of non-dimensional molality-based activity coefficients at the current solution tempera...
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
double m_B_Debye
Current value of the constant that appears in the denominator.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
double AionicRadius(int k=0) const
Reports the ionic radius of the kth species.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
void s_update_dlnMolalityActCoeff_dT() const
Calculation of temperature derivative of activity coefficient.
void s_update_lnMolalityActCoeff() const
Calculate the log activity coefficients.
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
void setBeta(const std::string &sp1, const std::string &sp2, double value)
Set the value for the beta interaction between species sp1 and sp2.
vector_fp m_dlnActCoeffMolaldP
Derivative of log act coeff wrt P.
void setDebyeHuckelModel(const std::string &form)
Set the DebyeHuckel parameterization form.
void setA_Debye(double A)
Set the A_Debye parameter.
vector_fp m_dlnActCoeffMolaldT
Derivative of log act coeff wrt T.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
vector_int m_electrolyteSpeciesType
Vector containing the electrolyte species type.
virtual void initThermo()
double m_Aionic_default
Default ionic radius for species where it is not specified.
vector_fp m_B_Dot
Array of B_Dot values.
double m_maxIionicStrength
Maximum value of the ionic strength allowed in the calculation of the activity coefficients.
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
DebyeHuckel(const std::string &inputFile="", const std::string &id="")
Full constructor for creating the phase.
double _lnactivityWaterHelgesonFixedForm() const
Formula for the log of the water activity that occurs in the GWB.
vector_fp m_Aionic
a_k = Size of the ionic species in the DH formulation. units = meters
virtual double dA_DebyedT_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the derivative of the Debye Huckel constant with respect to temperature.
virtual void getSpeciesParameters(const std::string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
void setDefaultIonicRadius(double value)
Set the default ionic radius [m] for each species.
void s_update_dlnMolalityActCoeff_dP() const
Calculate the pressure derivative of the activity coefficient.
PDSS_Water * m_waterSS
Pointer to the Water standard state object.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
double m_IionicMolalityStoich
Stoichiometric ionic strength on the molality scale.
std::unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities at the current solution temperature, pressure,...
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
vector_fp m_lnActCoeffMolal
Logarithm of the activity coefficients on the molality scale.
virtual double A_Debye_TP(double temperature=-1.0, double pressure=-1.0) const
Return the Debye Huckel constant as a function of temperature and pressure (Units = sqrt(kg/gmol))
virtual double dA_DebyedP_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the derivative of the Debye Huckel constant with respect to pressure, as a function of tempe...
virtual void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void initThermo()
doublereal m_Mnaught
This is the multiplication factor that goes inside log expressions involving the molalities of specie...
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
vector_fp m_molalities
Current value of the molalities of the species in the phase.
Class for pressure dependent standard states that use a constant volume model.
Class for the liquid water pressure dependent standard state.
virtual doublereal density() const
Return the standard state density at standard state.
virtual doublereal molarVolume() const
Return the molar volume at standard state.
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of the phase.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
vector_fp m_speciesCharge
Vector of species charges. length m_kk.
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
std::string name() const
Return the name of the phase.
size_t nSpecies() const
Returns the number of species in the phase.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
size_t m_kk
Number of species in the phase.
std::string speciesName(size_t k) const
Name of the species with index k.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
double moleFraction(size_t k) const
Return the mole fraction of a single species.
doublereal temperature() const
Temperature (K).
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
shared_ptr< Species > species(const std::string &name) const
Return the Species object for the named species.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
void initThermoFile(const std::string &inputFile, const std::string &id)
AnyMap m_input
Data supplied via setParameters.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
virtual void _updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
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 doublereal pressure() const
Returns the current pressure of the phase.
virtual void getSpeciesParameters(const std::string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
The WaterProps class is used to house several approximation routines for properties of water.
Class XML_Node is a tree-based representation of the contents of an XML file.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
std::string id() const
Return the id attribute, if present.
const XML_Node * findByName(const std::string &nm, int depth=100000) const
This routine carries out a recursive search for an XML node based on the name of the node.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
Header file for a common definitions used in electrolytes thermodynamics.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type="")
Get a floating-point value from a child element.
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
const double SmallNumber
smallest number to compare to zero.
const double GasConstant
Universal Gas Constant [J/kmol/K].
void getMatrixValues(const XML_Node &node, const std::vector< std::string > &keyStringRow, const std::vector< std::string > &keyStringCol, Array2D &returnValues, const bool convert=true, const bool matrixSymmetric=false)
This function interprets the value portion of an XML element as a series of "Matrix ids and entries" ...
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
static int interp_est(const std::string &estString)
Utility function to assign an integer value from a string for the ElectrolyteSpeciesType field.
const int cEST_solvent
Electrolyte species type.
void getMap(const XML_Node &node, std::map< std::string, std::string > &m)
This routine is used to interpret the value portions of XML elements that contain colon separated pai...
Contains declarations for string manipulation functions within Cantera.