Cantera  2.3.0
RedlichKisterVPSSTP.cpp
Go to the documentation of this file.
1 /**
2  * @file RedlichKisterVPSSTP.cpp
3  * Definitions for ThermoPhase object for phases which
4  * employ excess Gibbs free energy formulations related to RedlichKister
5  * expansions (see \ref thermoprops
6  * and class \link Cantera::RedlichKisterVPSSTP RedlichKisterVPSSTP\endlink).
7  */
8 
9 // This file is part of Cantera. See License.txt in the top-level directory or
10 // at http://www.cantera.org/license.txt for license and copyright information.
11 
15 #include "cantera/base/ctml.h"
16 
17 using namespace std;
18 
19 namespace Cantera
20 {
21 RedlichKisterVPSSTP::RedlichKisterVPSSTP() :
22  numBinaryInteractions_(0),
23  formRedlichKister_(0),
24  formTempModel_(0)
25 {
26 }
27 
28 RedlichKisterVPSSTP::RedlichKisterVPSSTP(const std::string& inputFile,
29  const std::string& id_) :
30  numBinaryInteractions_(0),
31  formRedlichKister_(0),
32  formTempModel_(0)
33 {
34  initThermoFile(inputFile, id_);
35 }
36 
38  const std::string& id_) :
39  numBinaryInteractions_(0),
40  formRedlichKister_(0),
41  formTempModel_(0)
42 {
43  importPhase(phaseRoot, this);
44 }
45 
47  numBinaryInteractions_(0),
48  formRedlichKister_(0),
49  formTempModel_(0)
50 {
51  RedlichKisterVPSSTP::operator=(b);
52 }
53 
54 RedlichKisterVPSSTP& RedlichKisterVPSSTP::operator=(const RedlichKisterVPSSTP& b)
55 {
56  if (&b == this) {
57  return *this;
58  }
59 
60  GibbsExcessVPSSTP::operator=(b);
61 
62  numBinaryInteractions_ = b.numBinaryInteractions_;
63  m_pSpecies_A_ij = b.m_pSpecies_A_ij;
64  m_pSpecies_B_ij = b.m_pSpecies_B_ij;
65  m_N_ij = b.m_N_ij;
66  m_HE_m_ij = b.m_HE_m_ij;
67  m_SE_m_ij = b.m_SE_m_ij;
68  formRedlichKister_ = b.formRedlichKister_;
69  formTempModel_ = b.formTempModel_;
70  dlnActCoeff_dX_ = b.dlnActCoeff_dX_;
71 
72  return *this;
73 }
74 
76 {
77  return new RedlichKisterVPSSTP(*this);
78 }
79 
80 // - Activities, Standard States, Activity Concentrations -----------
81 
83 {
84  // Update the activity coefficients
86 
87  for (size_t k = 0; k < m_kk; k++) {
88  lnac[k] = lnActCoeff_Scaled_[k];
89  }
90 }
91 
92 // ------------ Partial Molar Properties of the Solution ------------
93 
94 void RedlichKisterVPSSTP::getChemPotentials(doublereal* mu) const
95 {
96  // First get the standard chemical potentials in molar form. This requires
97  // updates of standard state as a function of T and P
99  // Update the activity coefficients
101 
102  for (size_t k = 0; k < m_kk; k++) {
103  double xx = std::max(moleFractions_[k], SmallNumber);
104  mu[k] += RT() * (log(xx) + lnActCoeff_Scaled_[k]);
105  }
106 }
107 
109 {
110  double h = 0;
111  vector_fp hbar(m_kk);
112  getPartialMolarEnthalpies(&hbar[0]);
113  for (size_t i = 0; i < m_kk; i++) {
114  h += moleFractions_[i]*hbar[i];
115  }
116  return h;
117 }
118 
120 {
121  double s = 0;
122  vector_fp sbar(m_kk);
123  getPartialMolarEntropies(&sbar[0]);
124  for (size_t i = 0; i < m_kk; i++) {
125  s += moleFractions_[i]*sbar[i];
126  }
127  return s;
128 }
129 
131 {
132  double cp = 0;
133  vector_fp cpbar(m_kk);
134  getPartialMolarCp(&cpbar[0]);
135  for (size_t i = 0; i < m_kk; i++) {
136  cp += moleFractions_[i]*cpbar[i];
137  }
138  return cp;
139 }
140 
142 {
143  return cp_mole() - GasConstant;
144 }
145 
147 {
148  // Get the nondimensional standard state enthalpies
149  getEnthalpy_RT(hbar);
150  // dimensionalize it.
151  double T = temperature();
152  for (size_t k = 0; k < m_kk; k++) {
153  hbar[k] *= GasConstant * T;
154  }
155 
156  // Update the activity coefficients, This also update the internally stored
157  // molalities.
160  for (size_t k = 0; k < m_kk; k++) {
161  hbar[k] -= GasConstant * T * T * dlnActCoeffdT_Scaled_[k];
162  }
163 }
164 
165 void RedlichKisterVPSSTP::getPartialMolarCp(doublereal* cpbar) const
166 {
167  getCp_R(cpbar);
168  double T = temperature();
169 
170  // Update the activity coefficients, This also update the internally stored
171  // molalities.
174 
175  for (size_t k = 0; k < m_kk; k++) {
176  cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k];
177  }
178  // dimensionalize it.
179  for (size_t k = 0; k < m_kk; k++) {
180  cpbar[k] *= GasConstant;
181  }
182 }
183 
185 {
186  // Get the nondimensional standard state entropies
187  getEntropy_R(sbar);
188  double T = temperature();
189 
190  // Update the activity coefficients, This also update the internally stored
191  // molalities.
194 
195  for (size_t k = 0; k < m_kk; k++) {
196  double xx = std::max(moleFractions_[k], SmallNumber);
197  sbar[k] += - lnActCoeff_Scaled_[k] -log(xx) - T * dlnActCoeffdT_Scaled_[k];
198  }
199  // dimensionalize it.
200  for (size_t k = 0; k < m_kk; k++) {
201  sbar[k] *= GasConstant;
202  }
203 }
204 
206 {
207  // Get the standard state values in m^3 kmol-1
208  getStandardVolumes(vbar);
209  for (size_t iK = 0; iK < m_kk; iK++) {
210  vbar[iK] += 0.0;
211  }
212 }
213 
215 {
216  initLengths();
218 }
219 
221 {
223 }
224 
225 void RedlichKisterVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_)
226 {
227  if ((int) id_.size() > 0 && phaseNode.id() != id_) {
228  throw CanteraError("RedlichKisterVPSSTP::initThermoXML",
229  "phasenode and Id are incompatible");
230  }
231 
232  // Check on the thermo field. Must have:
233  // <thermo model="Redlich-Kister" />
234  if (!phaseNode.hasChild("thermo")) {
235  throw CanteraError("RedlichKisterVPSSTP::initThermoXML",
236  "no thermo XML node");
237  }
238  XML_Node& thermoNode = phaseNode.child("thermo");
239  if (!ba::iequals(thermoNode["model"], "redlich-kister")) {
240  throw CanteraError("RedlichKisterVPSSTP::initThermoXML",
241  "Unknown thermo model: " + thermoNode["model"]
242  + " - This object only knows \"Redlich-Kister\" ");
243  }
244 
245  // Go get all of the coefficients and factors in the activityCoefficients
246  // XML block
247  if (thermoNode.hasChild("activityCoefficients")) {
248  XML_Node& acNode = thermoNode.child("activityCoefficients");
249  if (!ba::iequals(acNode["model"], "redlich-kister")) {
250  throw CanteraError("RedlichKisterVPSSTP::initThermoXML",
251  "Unknown activity coefficient model: " + acNode["model"]);
252  }
253  for (size_t i = 0; i < acNode.nChildren(); i++) {
254  XML_Node& xmlACChild = acNode.child(i);
255 
256  // Process a binary salt field, or any of the other XML fields that
257  // make up the Pitzer Database. Entries will be ignored if any of
258  // the species in the entry isn't in the solution.
259  if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) {
260  readXMLBinarySpecies(xmlACChild);
261  }
262  }
263  }
264  // Go down the chain
265  GibbsExcessVPSSTP::initThermoXML(phaseNode, id_);
266 }
267 
269 {
270  doublereal T = temperature();
271  lnActCoeff_Scaled_.assign(m_kk, 0.0);
272 
273  // Scaling: I moved the division of RT higher so that we are always dealing
274  // with G/RT dimensionless terms within the routine. There is a severe
275  // problem with roundoff error in these calculations. The dimensionless
276  // terms help.
277  for (size_t i = 0; i < numBinaryInteractions_; i++) {
278  size_t iA = m_pSpecies_A_ij[i];
279  size_t iB = m_pSpecies_B_ij[i];
280  double XA = moleFractions_[iA];
281  double XB = moleFractions_[iB];
282  doublereal deltaX = XA - XB;
283  size_t N = m_N_ij[i];
284  vector_fp& he_vec = m_HE_m_ij[i];
285  vector_fp& se_vec = m_SE_m_ij[i];
286  doublereal poly = 1.0;
287  doublereal polyMm1 = 1.0;
288  doublereal sum = 0.0;
289  doublereal sumMm1 = 0.0;
290  doublereal sum2 = 0.0;
291  for (size_t m = 0; m < N; m++) {
292  doublereal A_ge = (he_vec[m] - T * se_vec[m]) / (GasConstant * T);
293  sum += A_ge * poly;
294  sum2 += A_ge * (m + 1) * poly;
295  poly *= deltaX;
296  if (m >= 1) {
297  sumMm1 += (A_ge * polyMm1 * m);
298  polyMm1 *= deltaX;
299  }
300  }
301  doublereal oneMXA = 1.0 - XA;
302  doublereal oneMXB = 1.0 - XB;
303  for (size_t k = 0; k < m_kk; k++) {
304  if (iA == k) {
305  lnActCoeff_Scaled_[k] += (oneMXA * XB * sum) + (XA * XB * sumMm1 * (oneMXA + XB));
306  } else if (iB == k) {
307  lnActCoeff_Scaled_[k] += (oneMXB * XA * sum) + (XA * XB * sumMm1 * (-oneMXB - XA));
308  } else {
309  lnActCoeff_Scaled_[k] += -(XA * XB * sum2);
310  }
311  }
312  // Debug against formula in literature
313  }
314 }
315 
317 {
318  dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
319  d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0);
320 
321  for (size_t i = 0; i < numBinaryInteractions_; i++) {
322  size_t iA = m_pSpecies_A_ij[i];
323  size_t iB = m_pSpecies_B_ij[i];
324  double XA = moleFractions_[iA];
325  double XB = moleFractions_[iB];
326  doublereal deltaX = XA - XB;
327  size_t N = m_N_ij[i];
328  doublereal poly = 1.0;
329  doublereal sum = 0.0;
330  vector_fp& se_vec = m_SE_m_ij[i];
331  doublereal sumMm1 = 0.0;
332  doublereal polyMm1 = 1.0;
333  doublereal sum2 = 0.0;
334  for (size_t m = 0; m < N; m++) {
335  doublereal A_ge = - se_vec[m];
336  sum += A_ge * poly;
337  sum2 += A_ge * (m + 1) * poly;
338  poly *= deltaX;
339  if (m >= 1) {
340  sumMm1 += (A_ge * polyMm1 * m);
341  polyMm1 *= deltaX;
342  }
343  }
344  doublereal oneMXA = 1.0 - XA;
345  doublereal oneMXB = 1.0 - XB;
346  for (size_t k = 0; k < m_kk; k++) {
347  if (iA == k) {
348  dlnActCoeffdT_Scaled_[k] += (oneMXA * XB * sum) + (XA * XB * sumMm1 * (oneMXA + XB));
349  } else if (iB == k) {
350  dlnActCoeffdT_Scaled_[k] += (oneMXB * XA * sum) + (XA * XB * sumMm1 * (-oneMXB - XA));
351  } else {
352  dlnActCoeffdT_Scaled_[k] += -(XA * XB * sum2);
353  }
354  }
355  }
356 }
357 
358 void RedlichKisterVPSSTP::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const
359 {
361  for (size_t k = 0; k < m_kk; k++) {
362  dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k];
363  }
364 }
365 
366 void RedlichKisterVPSSTP::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const
367 {
369  for (size_t k = 0; k < m_kk; k++) {
370  d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k];
371  }
372 }
373 
375 {
376  double T = temperature();
377  dlnActCoeffdlnX_diag_.assign(m_kk, 0.0);
378 
379  for (size_t i = 0; i < numBinaryInteractions_; i++) {
380  size_t iA = m_pSpecies_A_ij[i];
381  size_t iB = m_pSpecies_B_ij[i];
382  double XA = moleFractions_[iA];
383  double XB = moleFractions_[iB];
384  double deltaX = XA - XB;
385  size_t N = m_N_ij[i];
386  double poly = 1.0;
387  double sum = 0.0;
388  vector_fp& he_vec = m_HE_m_ij[i];
389  vector_fp& se_vec = m_SE_m_ij[i];
390  double sumMm1 = 0.0;
391  double polyMm1 = 1.0;
392  double polyMm2 = 1.0;
393  double sumMm2 = 0.0;
394  for (size_t m = 0; m < N; m++) {
395  double A_ge = (he_vec[m] - T * se_vec[m]) / (GasConstant * T);;
396  sum += A_ge * poly;
397  poly *= deltaX;
398  if (m >= 1) {
399  sumMm1 += (A_ge * polyMm1 * m);
400  polyMm1 *= deltaX;
401  }
402  if (m >= 2) {
403  sumMm2 += (A_ge * polyMm2 * m * (m - 1.0));
404  polyMm2 *= deltaX;
405  }
406  }
407 
408  for (size_t k = 0; k < m_kk; k++) {
409  if (iA == k) {
411  XA * (- (1-XA+XB) * sum + 2*(1.0 - XA) * XB * sumMm1
412  + sumMm1 * (XB * (1 - 2*XA + XB) - XA * (1 - XA + 2*XB))
413  + 2 * XA * XB * sumMm2 * (1.0 - XA + XB));
414  } else if (iB == k) {
416  XB * (- (1-XB+XA) * sum - 2*(1.0 - XB) * XA * sumMm1
417  + sumMm1 * (XA * (2*XB - XA - 1) - XB * (-2*XA + XB - 1))
418  - 2 * XA * XB * sumMm2 * (-XA - 1 + XB));
419  }
420  }
421  }
422 }
423 
425 {
426  doublereal T = temperature();
428 
429  for (size_t i = 0; i < numBinaryInteractions_; i++) {
430  size_t iA = m_pSpecies_A_ij[i];
431  size_t iB = m_pSpecies_B_ij[i];
432  double XA = moleFractions_[iA];
433  double XB = moleFractions_[iB];
434  doublereal deltaX = XA - XB;
435  size_t N = m_N_ij[i];
436  doublereal poly = 1.0;
437  doublereal sum = 0.0;
438  vector_fp& he_vec = m_HE_m_ij[i];
439  vector_fp& se_vec = m_SE_m_ij[i];
440  doublereal sumMm1 = 0.0;
441  doublereal polyMm1 = 1.0;
442  doublereal polyMm2 = 1.0;
443  doublereal sum2 = 0.0;
444  doublereal sum2Mm1 = 0.0;
445  doublereal sumMm2 = 0.0;
446  for (size_t m = 0; m < N; m++) {
447  doublereal A_ge = he_vec[m] - T * se_vec[m];
448  sum += A_ge * poly;
449  sum2 += A_ge * (m + 1) * poly;
450  poly *= deltaX;
451  if (m >= 1) {
452  sumMm1 += (A_ge * polyMm1 * m);
453  sum2Mm1 += (A_ge * polyMm1 * m * (1.0 + m));
454  polyMm1 *= deltaX;
455  }
456  if (m >= 2) {
457  sumMm2 += (A_ge * polyMm2 * m * (m - 1.0));
458  polyMm2 *= deltaX;
459  }
460  }
461 
462  for (size_t k = 0; k < m_kk; k++) {
463  if (iA == k) {
464  dlnActCoeff_dX_(k, iA) += (- XB * sum + (1.0 - XA) * XB * sumMm1
465  + XB * sumMm1 * (1.0 - 2.0 * XA + XB)
466  + XA * XB * sumMm2 * (1.0 - XA + XB));
467 
468  dlnActCoeff_dX_(k, iB) += ((1.0 - XA) * sum - (1.0 - XA) * XB * sumMm1
469  + XA * sumMm1 * (1.0 + 2.0 * XB - XA)
470  - XA * XB * sumMm2 * (1.0 - XA + XB));
471  } else if (iB == k) {
472  dlnActCoeff_dX_(k, iA) += ((1.0 - XB) * sum + (1.0 - XA) * XB * sumMm1
473  + XB * sumMm1 * (1.0 - 2.0 * XA + XB)
474  + XA * XB * sumMm2 * (1.0 - XA + XB));
475 
476  dlnActCoeff_dX_(k, iB) += (- XA * sum - (1.0 - XB) * XA * sumMm1
477  + XA * sumMm1 * (XB - XA - (1.0 - XB))
478  - XA * XB * sumMm2 * (-XA - (1.0 - XB)));
479  } else {
480  dlnActCoeff_dX_(k, iA) += (- XB * sum2 - XA * XB * sum2Mm1);
481  dlnActCoeff_dX_(k, iB) += (- XA * sum2 + XA * XB * sum2Mm1);
482  }
483  }
484  }
485 }
486 
487 void RedlichKisterVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
488  doublereal* dlnActCoeffds) const
489 {
492  for (size_t k = 0; k < m_kk; k++) {
493  dlnActCoeffds[k] = dlnActCoeffdT_Scaled_[k] * dTds;
494  for (size_t j = 0; j < m_kk; j++) {
495  dlnActCoeffds[k] += dlnActCoeff_dX_(k, j) * dXds[j];
496  }
497  }
498 }
499 
500 void RedlichKisterVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const
501 {
503  for (size_t j = 0; j < m_kk; j++) {
504  dlnActCoeffdlnN_diag[j] = dlnActCoeff_dX_(j, j);
505  for (size_t k = 0; k < m_kk; k++) {
506  dlnActCoeffdlnN_diag[k] -= dlnActCoeff_dX_(j, k) * moleFractions_[k];
507  }
508  }
509 }
510 
511 void RedlichKisterVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const
512 {
514  for (size_t k = 0; k < m_kk; k++) {
515  dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k];
516  }
517 }
518 
519 void RedlichKisterVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN)
520 {
522  double* data = & dlnActCoeffdlnN_(0,0);
523  for (size_t k = 0; k < m_kk; k++) {
524  for (size_t m = 0; m < m_kk; m++) {
525  dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
526  }
527  }
528 }
529 
531 {
533  m_pSpecies_A_ij.resize(num, npos);
534  m_pSpecies_B_ij.resize(num, npos);
535  m_N_ij.resize(num, npos);
536  m_HE_m_ij.resize(num);
537  m_SE_m_ij.resize(num);
538  dlnActCoeff_dX_.resize(num, num, 0.0);
539 }
540 
542 {
543  std::string xname = xmLBinarySpecies.name();
544  if (xname != "binaryNeutralSpeciesParameters") {
545  throw CanteraError("RedlichKisterVPSSTP::readXMLBinarySpecies",
546  "Incorrect name for processing this routine: " + xname);
547  }
548  size_t Npoly = 0;
549  vector_fp hParams, sParams;
550  std::string iName = xmLBinarySpecies.attrib("speciesA");
551  if (iName == "") {
552  throw CanteraError("RedlichKisterVPSSTP::readXMLBinarySpecies", "no speciesA attrib");
553  }
554  std::string jName = xmLBinarySpecies.attrib("speciesB");
555  if (jName == "") {
556  throw CanteraError("RedlichKisterVPSSTP::readXMLBinarySpecies", "no speciesB attrib");
557  }
558 
559  // Find the index of the species in the current phase. It's not an error to
560  // not find the species. This means that the interaction doesn't occur for
561  // the current implementation of the phase.
562  size_t iSpecies = speciesIndex(iName);
563  if (iSpecies == npos) {
564  return;
565  }
566  string ispName = speciesName(iSpecies);
567  if (charge(iSpecies) != 0) {
568  throw CanteraError("RedlichKisterVPSSTP::readXMLBinarySpecies", "speciesA charge problem");
569  }
570  size_t jSpecies = speciesIndex(jName);
571  if (jSpecies == npos) {
572  return;
573  }
574  std::string jspName = speciesName(jSpecies);
575  if (charge(jSpecies) != 0) {
576  throw CanteraError("RedlichKisterVPSSTP::readXMLBinarySpecies", "speciesB charge problem");
577  }
578 
579  // Ok we have found a valid interaction
581  size_t iSpot = numBinaryInteractions_ - 1;
584  m_pSpecies_A_ij[iSpot] = iSpecies;
585  m_pSpecies_B_ij[iSpot] = jSpecies;
586 
587  for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) {
588  XML_Node& xmlChild = xmLBinarySpecies.child(iChild);
589  string nodeName = ba::to_lower_copy(xmlChild.name());
590 
591  // Process the binary species interaction child elements
592  if (nodeName == "excessenthalpy") {
593  // Get the string containing all of the values
594  getFloatArray(xmlChild, hParams, true, "toSI", "excessEnthalpy");
595  Npoly = std::max(hParams.size(), Npoly);
596  }
597 
598  if (nodeName == "excessentropy") {
599  // Get the string containing all of the values
600  getFloatArray(xmlChild, sParams, true, "toSI", "excessEntropy");
601  Npoly = std::max(sParams.size(), Npoly);
602  }
603  }
604  hParams.resize(Npoly, 0.0);
605  sParams.resize(Npoly, 0.0);
606  m_HE_m_ij.push_back(hParams);
607  m_SE_m_ij.push_back(sParams);
608  m_N_ij.push_back(Npoly);
610 }
611 
612 void RedlichKisterVPSSTP::Vint(double& VintOut, double& voltsOut)
613 {
614  warn_deprecated("RedlichKisterVPSSTP::Vint",
615  "To be removed after Cantera 2.3.");
616  double XA = 0;
617  doublereal T = temperature();
618  double Volts = 0.0;
619  lnActCoeff_Scaled_.assign(m_kk, 0.0);
620 
621  for (size_t i = 0; i < numBinaryInteractions_; i++) {
622  size_t iA = m_pSpecies_A_ij[i];
623  XA = moleFractions_[iA];
624  if (XA <= 1.0E-14) {
625  XA = 1.0E-14;
626  }
627  if (XA >= (1.0 - 1.0E-14)) {
628  XA = 1.0 - 1.0E-14;
629  }
630 
631  size_t N = m_N_ij[i];
632  vector_fp& he_vec = m_HE_m_ij[i];
633  vector_fp& se_vec = m_SE_m_ij[i];
634  double fac = 2.0 * XA - 1.0;
635  if (fabs(fac) < 1.0E-13) {
636  fac = 1.0E-13;
637  }
638  double polykp1 = fac;
639  double poly1mk = fac;
640 
641  for (size_t m = 0; m < N; m++) {
642  doublereal A_ge = he_vec[m] - T * se_vec[m];
643  Volts += A_ge * (polykp1 - (2.0 * XA * m * (1.0-XA)) / poly1mk);
644  polykp1 *= fac;
645  poly1mk /= fac;
646  }
647  }
648  Volts /= Faraday;
649 
650  double termp = GasConstant * T * log((1.0 - XA)/XA) / Faraday;
651  VintOut = Volts;
652  voltsOut = Volts + termp;
653 }
654 
655 }
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
Definition: ctml.cpp:299
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string name() const
Returns the name of the XML node.
Definition: xml.h:370
vector_fp dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
doublereal temperature() const
Temperature (K).
Definition: Phase.h:601
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with &#39;v&#39;.
Definition: Array.h:112
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named &#39;name&#39; within the Phase object.
Definition: Phase.cpp:251
RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Redlich-Kister approxima...
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
size_t numBinaryInteractions_
number of binary interaction expressions
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
std::vector< vector_fp > m_HE_m_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
int formRedlichKister_
form of the RedlichKister interaction expression.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
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.
Definition: global.cpp:54
STL namespace.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
int formTempModel_
form of the temperature dependence of the Redlich-Kister interaction expression.
Array2D dlnActCoeff_dX_
Two dimensional array of derivatives of activity coefficients wrt mole fractions. ...
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:809
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void getLnActivityCoefficients(doublereal *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
vector_fp d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:267
void s_update_dlnActCoeff_dX_() const
Internal routine that calculates the derivative of the activity coefficients wrt the mole fractions...
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
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.
Definition: ctexceptions.h:65
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space.
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
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.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:536
XML_Node & child(const size_t n) const
Return a changeable reference to the n&#39;th child of the current node.
Definition: xml.cpp:546
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
const doublereal SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:126
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:500
void initLengths()
Initialize lengths of local variables after all species have been identified.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:428
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
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.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
size_t m_kk
Number of species in the phase.
Definition: Phase.h:784
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
void Vint(double &VintOut, double &voltsOut)
Utility routine that calculates a literature expression.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void s_update_dlnActCoeff_dlnX_diag() const
Internal routine that calculates the total derivative of the activity coefficients with respect to th...
void zero()
Set all of the entries to zero.
Definition: Array.h:220
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
void s_update_lnActCoeff() const
Update the activity coefficients.
Namespace for the Cantera kernel.
Definition: application.cpp:29
(see Thermodynamic Properties and class RedlichKisterVPSSTP).
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:556
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Redlich-Kister interac...
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 charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Definition: Phase.h:577
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution...
std::vector< size_t > m_N_ij
Vector of the length of the polynomial for the interaction.
std::vector< vector_fp > m_SE_m_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.