Cantera  2.4.0
MargulesVPSSTP.cpp
Go to the documentation of this file.
1 /**
2  * @file MargulesVPSSTP.cpp
3  * Definitions for ThermoPhase object for phases which
4  * employ excess Gibbs free energy formulations related to Margules
5  * expansions (see \ref thermoprops
6  * and class \link Cantera::MargulesVPSSTP MargulesVPSSTP\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 MargulesVPSSTP::MargulesVPSSTP() :
22  numBinaryInteractions_(0),
23  formMargules_(0),
24  formTempModel_(0)
25 {
26 }
27 
28 MargulesVPSSTP::MargulesVPSSTP(const std::string& inputFile, const std::string& id_) :
29  numBinaryInteractions_(0),
30  formMargules_(0),
31  formTempModel_(0)
32 {
33  initThermoFile(inputFile, id_);
34 }
35 
36 MargulesVPSSTP::MargulesVPSSTP(XML_Node& phaseRoot, const std::string& id_) :
37  numBinaryInteractions_(0),
38  formMargules_(0),
39  formTempModel_(0)
40 {
41  importPhase(phaseRoot, this);
42 }
43 
44 // -- Activities, Standard States, Activity Concentrations -----------
45 
46 void MargulesVPSSTP::getLnActivityCoefficients(doublereal* lnac) const
47 {
48  // Update the activity coefficients
50 
51  // take the exp of the internally stored coefficients.
52  for (size_t k = 0; k < m_kk; k++) {
53  lnac[k] = lnActCoeff_Scaled_[k];
54  }
55 }
56 
57 // ------------ Partial Molar Properties of the Solution ------------
58 
59 void MargulesVPSSTP::getChemPotentials(doublereal* mu) const
60 {
61  // First get the standard chemical potentials in molar form. This requires
62  // updates of standard state as a function of T and P
64 
65  // Update the activity coefficients
67  for (size_t k = 0; k < m_kk; k++) {
68  double xx = std::max(moleFractions_[k], SmallNumber);
69  mu[k] += RT() * (log(xx) + lnActCoeff_Scaled_[k]);
70  }
71 }
72 
74 {
75  size_t kk = nSpecies();
76  double h = 0;
77  vector_fp hbar(kk);
78  getPartialMolarEnthalpies(&hbar[0]);
79  for (size_t i = 0; i < kk; i++) {
80  h += moleFractions_[i]*hbar[i];
81  }
82  return h;
83 }
84 
85 doublereal MargulesVPSSTP::entropy_mole() const
86 {
87  size_t kk = nSpecies();
88  double s = 0;
89  vector_fp sbar(kk);
90  getPartialMolarEntropies(&sbar[0]);
91  for (size_t i = 0; i < kk; i++) {
92  s += moleFractions_[i]*sbar[i];
93  }
94  return s;
95 }
96 
97 doublereal MargulesVPSSTP::cp_mole() const
98 {
99  size_t kk = nSpecies();
100  double cp = 0;
101  vector_fp cpbar(kk);
102  getPartialMolarCp(&cpbar[0]);
103  for (size_t i = 0; i < kk; i++) {
104  cp += moleFractions_[i]*cpbar[i];
105  }
106  return cp;
107 }
108 
109 doublereal MargulesVPSSTP::cv_mole() const
110 {
111  return cp_mole() - GasConstant;
112 }
113 
114 void MargulesVPSSTP::getPartialMolarEnthalpies(doublereal* hbar) const
115 {
116  // Get the nondimensional standard state enthalpies
117  getEnthalpy_RT(hbar);
118 
119  // dimensionalize it.
120  for (size_t k = 0; k < m_kk; k++) {
121  hbar[k] *= RT();
122  }
123 
124  // Update the activity coefficients, This also update the internally stored
125  // molalities.
128  for (size_t k = 0; k < m_kk; k++) {
129  hbar[k] -= RT() * temperature() * dlnActCoeffdT_Scaled_[k];
130  }
131 }
132 
133 void MargulesVPSSTP::getPartialMolarCp(doublereal* cpbar) const
134 {
135  // Get the nondimensional standard state entropies
136  getCp_R(cpbar);
137  double T = temperature();
138 
139  // Update the activity coefficients, This also update the internally stored
140  // molalities.
143 
144  for (size_t k = 0; k < m_kk; k++) {
145  cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k];
146  }
147  // dimensionalize it.
148  for (size_t k = 0; k < m_kk; k++) {
149  cpbar[k] *= GasConstant;
150  }
151 }
152 
153 void MargulesVPSSTP::getPartialMolarEntropies(doublereal* sbar) const
154 {
155  // Get the nondimensional standard state entropies
156  getEntropy_R(sbar);
157  double T = temperature();
158 
159  // Update the activity coefficients, This also update the internally stored
160  // molalities.
163 
164  for (size_t k = 0; k < m_kk; k++) {
165  double xx = std::max(moleFractions_[k], SmallNumber);
166  sbar[k] += - lnActCoeff_Scaled_[k] -log(xx) - T * dlnActCoeffdT_Scaled_[k];
167  }
168 
169  // dimensionalize it.
170  for (size_t k = 0; k < m_kk; k++) {
171  sbar[k] *= GasConstant;
172  }
173 }
174 
175 void MargulesVPSSTP::getPartialMolarVolumes(doublereal* vbar) const
176 {
177  double T = temperature();
178 
179  // Get the standard state values in m^3 kmol-1
180  getStandardVolumes(vbar);
181 
182  for (size_t i = 0; i < numBinaryInteractions_; i++) {
183  size_t iA = m_pSpecies_A_ij[i];
184  size_t iB = m_pSpecies_B_ij[i];
185  double XA = moleFractions_[iA];
186  double XB = moleFractions_[iB];
187  double g0 = (m_VHE_b_ij[i] - T * m_VSE_b_ij[i]);
188  double g1 = (m_VHE_c_ij[i] - T * m_VSE_c_ij[i]);
189  const doublereal temp1 = g0 + g1 * XB;
190  const doublereal all = -1.0*XA*XB*temp1 - XA*XB*XB*g1;
191 
192  for (size_t iK = 0; iK < m_kk; iK++) {
193  vbar[iK] += all;
194  }
195  vbar[iA] += XB * temp1;
196  vbar[iB] += XA * temp1 + XA*XB*g1;
197  }
198 }
199 
201 {
202  initLengths();
204 }
205 
207 {
209 }
210 
211 void MargulesVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_)
212 {
213  if ((int) id_.size() > 0) {
214  string idp = phaseNode.id();
215  if (idp != id_) {
216  throw CanteraError("MargulesVPSSTP::initThermoXML", "phasenode and Id are incompatible");
217  }
218  }
219 
220  // Find the Thermo XML node
221  if (!phaseNode.hasChild("thermo")) {
222  throw CanteraError("MargulesVPSSTP::initThermoXML",
223  "no thermo XML node");
224  }
225  XML_Node& thermoNode = phaseNode.child("thermo");
226 
227  // Make sure that the thermo model is Margules
228  if (!caseInsensitiveEquals(thermoNode["model"], "margules")) {
229  throw CanteraError("MargulesVPSSTP::initThermoXML",
230  "model name isn't Margules: " + thermoNode["model"]);
231  }
232 
233  // Go get all of the coefficients and factors in the activityCoefficients
234  // XML block
235  if (thermoNode.hasChild("activityCoefficients")) {
236  XML_Node& acNode = thermoNode.child("activityCoefficients");
237  if (!caseInsensitiveEquals(acNode["model"], "margules")) {
238  throw CanteraError("MargulesVPSSTP::initThermoXML",
239  "Unknown activity coefficient model: " + acNode["model"]);
240  }
241  for (size_t i = 0; i < acNode.nChildren(); i++) {
242  XML_Node& xmlACChild = acNode.child(i);
243 
244  // Process a binary salt field, or any of the other XML fields that
245  // make up the Pitzer Database. Entries will be ignored if any of
246  // the species in the entry isn't in the solution.
247  if (caseInsensitiveEquals(xmlACChild.name(), "binaryneutralspeciesparameters")) {
248  readXMLBinarySpecies(xmlACChild);
249  }
250  }
251  }
252 
253  // Go down the chain
254  GibbsExcessVPSSTP::initThermoXML(phaseNode, id_);
255 }
256 
257 void MargulesVPSSTP::addBinaryInteraction(const std::string& speciesA,
258  const std::string& speciesB, double h0, double h1, double s0, double s1,
259  double vh0, double vh1, double vs0, double vs1)
260 {
261  size_t kA = speciesIndex(speciesA);
262  size_t kB = speciesIndex(speciesB);
263  // The interaction is silently ignored if either species is not defined in
264  // the current phase.
265  if (kA == npos || kB == npos) {
266  return;
267  }
268  m_pSpecies_A_ij.push_back(kA);
269  m_pSpecies_B_ij.push_back(kB);
270 
271  m_HE_b_ij.push_back(h0);
272  m_HE_c_ij.push_back(h1);
273  m_SE_b_ij.push_back(s0);
274  m_SE_c_ij.push_back(s1);
275  m_VHE_b_ij.push_back(vh0);
276  m_VHE_c_ij.push_back(vh1);
277  m_VSE_b_ij.push_back(vs0);
278  m_VSE_c_ij.push_back(vs1);
280 }
281 
282 
284 {
285  double T = temperature();
286  lnActCoeff_Scaled_.assign(m_kk, 0.0);
287  for (size_t i = 0; i < numBinaryInteractions_; i++) {
288  size_t iA = m_pSpecies_A_ij[i];
289  size_t iB = m_pSpecies_B_ij[i];
290  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
291  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
292  double XA = moleFractions_[iA];
293  double XB = moleFractions_[iB];
294  const doublereal XAXB = XA * XB;
295  const doublereal g0g1XB = (g0 + g1 * XB);
296  const doublereal all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
297  for (size_t iK = 0; iK < m_kk; iK++) {
298  lnActCoeff_Scaled_[iK] += all;
299  }
300  lnActCoeff_Scaled_[iA] += XB * g0g1XB;
301  lnActCoeff_Scaled_[iB] += XA * g0g1XB + XAXB * g1;
302  }
303 }
304 
306 {
307  doublereal invT = 1.0 / temperature();
308  doublereal invRTT = 1.0 / GasConstant*invT*invT;
309  dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
310  d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0);
311  for (size_t i = 0; i < numBinaryInteractions_; i++) {
312  size_t iA = m_pSpecies_A_ij[i];
313  size_t iB = m_pSpecies_B_ij[i];
314  double XA = moleFractions_[iA];
315  double XB = moleFractions_[iB];
316  double g0 = -m_HE_b_ij[i] * invRTT;
317  double g1 = -m_HE_c_ij[i] * invRTT;
318  const doublereal XAXB = XA * XB;
319  const doublereal g0g1XB = (g0 + g1 * XB);
320  const doublereal all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
321  const doublereal mult = 2.0 * invT;
322  const doublereal dT2all = mult * all;
323  for (size_t iK = 0; iK < m_kk; iK++) {
324  dlnActCoeffdT_Scaled_[iK] += all;
325  d2lnActCoeffdT2_Scaled_[iK] -= dT2all;
326  }
327  dlnActCoeffdT_Scaled_[iA] += XB * g0g1XB;
328  dlnActCoeffdT_Scaled_[iB] += XA * g0g1XB + XAXB * g1;
329  d2lnActCoeffdT2_Scaled_[iA] -= mult * XB * g0g1XB;
330  d2lnActCoeffdT2_Scaled_[iB] -= mult * (XA * g0g1XB + XAXB * g1);
331  }
332 }
333 
334 void MargulesVPSSTP::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const
335 {
337  for (size_t k = 0; k < m_kk; k++) {
338  dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k];
339  }
340 }
341 
342 void MargulesVPSSTP::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const
343 {
345  for (size_t k = 0; k < m_kk; k++) {
346  d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k];
347  }
348 }
349 
350 void MargulesVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
351  doublereal* dlnActCoeffds) const
352 {
353  double T = temperature();
355  for (size_t iK = 0; iK < m_kk; iK++) {
356  dlnActCoeffds[iK] = 0.0;
357  }
358 
359  for (size_t i = 0; i < numBinaryInteractions_; i++) {
360  size_t iA = m_pSpecies_A_ij[i];
361  size_t iB = m_pSpecies_B_ij[i];
362  double XA = moleFractions_[iA];
363  double XB = moleFractions_[iB];
364  double dXA = dXds[iA];
365  double dXB = dXds[iB];
366  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
367  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
368  const doublereal g02g1XB = g0 + 2*g1*XB;
369  const doublereal g2XAdXB = 2*g1*XA*dXB;
370  const doublereal all = (-XB * dXA - XA *dXB) * g02g1XB - XB *g2XAdXB;
371  for (size_t iK = 0; iK < m_kk; iK++) {
372  dlnActCoeffds[iK] += all + dlnActCoeffdT_Scaled_[iK]*dTds;
373  }
374  dlnActCoeffds[iA] += dXB * g02g1XB;
375  dlnActCoeffds[iB] += dXA * g02g1XB + g2XAdXB;
376  }
377 }
378 
380 {
381  double T = temperature();
382  dlnActCoeffdlnN_diag_.assign(m_kk, 0.0);
383 
384  for (size_t iK = 0; iK < m_kk; iK++) {
385  double XK = moleFractions_[iK];
386 
387  for (size_t i = 0; i < numBinaryInteractions_; i++) {
388  size_t iA = m_pSpecies_A_ij[i];
389  size_t iB = m_pSpecies_B_ij[i];
390  size_t delAK = 0;
391  size_t delBK = 0;
392 
393  if (iA==iK) {
394  delAK = 1;
395  } else if (iB==iK) {
396  delBK = 1;
397  }
398 
399  double XA = moleFractions_[iA];
400  double XB = moleFractions_[iB];
401 
402  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
403  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
404 
405  dlnActCoeffdlnN_diag_[iK] += 2*(delBK-XB)*(g0*(delAK-XA)+g1*(2*(delAK-XA)*XB+XA*(delBK-XB)));
406  }
408  }
409 }
410 
412 {
413  double T = temperature();
415 
416  // Loop over the activity coefficient gamma_k
417  for (size_t iK = 0; iK < m_kk; iK++) {
418  for (size_t iM = 0; iM < m_kk; iM++) {
419  double XM = moleFractions_[iM];
420  for (size_t i = 0; i < numBinaryInteractions_; i++) {
421  size_t iA = m_pSpecies_A_ij[i];
422  size_t iB = m_pSpecies_B_ij[i];
423  double delAK = 0.0;
424  double delBK = 0.0;
425  double delAM = 0.0;
426  double delBM = 0.0;
427  if (iA==iK) {
428  delAK = 1.0;
429  } else if (iB==iK) {
430  delBK = 1.0;
431  }
432  if (iA==iM) {
433  delAM = 1.0;
434  } else if (iB==iM) {
435  delBM = 1.0;
436  }
437 
438  double XA = moleFractions_[iA];
439  double XB = moleFractions_[iB];
440  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
441  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
442  dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
443  dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
444  }
445  dlnActCoeffdlnN_(iK,iM) = XM*dlnActCoeffdlnN_(iK,iM);
446  }
447  }
448 }
449 
451 {
452  doublereal T = temperature();
453  dlnActCoeffdlnX_diag_.assign(m_kk, 0.0);
454 
455  for (size_t i = 0; i < numBinaryInteractions_; i++) {
456  size_t iA = m_pSpecies_A_ij[i];
457  size_t iB = m_pSpecies_B_ij[i];
458 
459  doublereal XA = moleFractions_[iA];
460  doublereal XB = moleFractions_[iB];
461 
462  doublereal g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
463  doublereal g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
464 
465  dlnActCoeffdlnX_diag_[iA] += XA*XB*(2*g1*-2*g0-6*g1*XB);
466  dlnActCoeffdlnX_diag_[iB] += XA*XB*(2*g1*-2*g0-6*g1*XB);
467  }
468 }
469 
470 void MargulesVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const
471 {
473  for (size_t k = 0; k < m_kk; k++) {
474  dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k];
475  }
476 }
477 
478 void MargulesVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const
479 {
481  for (size_t k = 0; k < m_kk; k++) {
482  dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k];
483  }
484 }
485 
486 void MargulesVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN)
487 {
489  double* data = & dlnActCoeffdlnN_(0,0);
490  for (size_t k = 0; k < m_kk; k++) {
491  for (size_t m = 0; m < m_kk; m++) {
492  dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
493  }
494  }
495 }
496 
498 {
499  string xname = xmLBinarySpecies.name();
500  if (xname != "binaryNeutralSpeciesParameters") {
501  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies",
502  "Incorrect name for processing this routine: " + xname);
503  }
504  string aName = xmLBinarySpecies.attrib("speciesA");
505  if (aName == "") {
506  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies", "no speciesA attrib");
507  }
508  string bName = xmLBinarySpecies.attrib("speciesB");
509  if (bName == "") {
510  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies", "no speciesB attrib");
511  }
512 
513  vector_fp vParams;
514  double h0 = 0.0;
515  double h1 = 0.0;
516  double s0 = 0.0;
517  double s1 = 0.0;
518  double vh0 = 0.0;
519  double vh1 = 0.0;
520  double vs0 = 0.0;
521  double vs1 = 0.0;
522 
523  for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) {
524  XML_Node& xmlChild = xmLBinarySpecies.child(iChild);
525  string nodeName = toLowerCopy(xmlChild.name());
526 
527  // Process the binary species interaction parameters.
528  // They are in subblocks labeled:
529  // excessEnthalpy
530  // excessEntropy
531  // excessVolume_Enthalpy
532  // excessVolume_Entropy
533  // Other blocks are currently ignored.
534  // @TODO determine a policy about ignoring blocks that should or shouldn't be there.
535  if (nodeName == "excessenthalpy") {
536  // Get the string containing all of the values
537  getFloatArray(xmlChild, vParams, true, "toSI", "excessEnthalpy");
538  if (vParams.size() != 2) {
539  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
540  "excessEnthalpy for {} : {}: wrong number of params found."
541  " Need 2", aName, bName);
542  }
543  h0 = vParams[0];
544  h1 = vParams[1];
545  } else if (nodeName == "excessentropy") {
546  // Get the string containing all of the values
547  getFloatArray(xmlChild, vParams, true, "toSI", "excessEntropy");
548  if (vParams.size() != 2) {
549  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
550  "excessEntropy for {} : {}: wrong number of params found."
551  " Need 2", aName, bName);
552  }
553  s0 = vParams[0];
554  s1 = vParams[1];
555  } else if (nodeName == "excessvolume_enthalpy") {
556  // Get the string containing all of the values
557  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Enthalpy");
558  if (vParams.size() != 2) {
559  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
560  "excessVolume_Enthalpy for {} : {}: wrong number of params"
561  " found. Need 2", aName, bName);
562  }
563  vh0 = vParams[0];
564  vh1 = vParams[1];
565  } else if (nodeName == "excessvolume_entropy") {
566  // Get the string containing all of the values
567  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Entropy");
568  if (vParams.size() != 2) {
569  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
570  "excessVolume_Entropy for {} : {}: wrong number of params"
571  " found. Need 2", aName, bName);
572  }
573  vs0 = vParams[0];
574  vs1 = vParams[1];
575  }
576  }
577  addBinaryInteraction(aName, bName, h0, h1, s0, s1, vh0, vh1, vs0, vs1);
578 }
579 
580 }
vector_fp m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getLnActivityCoefficients(doublereal *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
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 m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
(see Thermodynamic Properties and class MargulesVPSSTP).
vector_fp dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
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
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:256
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:175
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
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...
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:266
STL namespace.
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
size_t numBinaryInteractions_
number of binary interaction expressions
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
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 ...
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
void initLengths()
Initialize lengths of local variables after all species have been identified.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:748
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
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 getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
vector_fp dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
void addBinaryInteraction(const std::string &speciesA, const std::string &speciesB, double h0, double h1, double s0, double s1, double vh0, double vh1, double vs0, double vs1)
Add a binary species interaction with the specified parameters.
vector_fp d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
void s_update_lnActCoeff() const
Update the activity coefficients.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
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
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
vector_fp m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
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.
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
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
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
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.
Definition: ct_defs.h:126
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:500
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
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
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
Contains declarations for string manipulation functions within Cantera.
vector_fp m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
vector_fp m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
size_t m_kk
Number of species in the phase.
Definition: Phase.h:788
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
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 zero()
Set all of the entries to zero.
Definition: Array.h:198
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
std::string toLowerCopy(const std::string &input)
Convert to lower case.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:556
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 ...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.