Cantera  2.4.0
PhaseCombo_Interaction.cpp
Go to the documentation of this file.
1 /**
2  * @file PhaseCombo_Interaction.cpp
3  */
4 
5 // This file is part of Cantera. See License.txt in the top-level directory or
6 // at http://www.cantera.org/license.txt for license and copyright information.
7 
11 #include "cantera/base/ctml.h"
12 
13 using namespace std;
14 
15 namespace Cantera
16 {
17 PhaseCombo_Interaction::PhaseCombo_Interaction() :
18  numBinaryInteractions_(0),
19  formMargules_(0),
20  formTempModel_(0)
21 {
22  warn_deprecated("Class PhaseCombo_Interaction", "To be removed after Cantera 2.4");
23 }
24 
26  const std::string& id_) :
27  numBinaryInteractions_(0),
28  formMargules_(0),
29  formTempModel_(0)
30 {
31  warn_deprecated("Class PhaseCombo_Interaction", "To be removed after Cantera 2.4");
32  initThermoFile(inputFile, id_);
33 }
34 
36  const std::string& id_) :
37  numBinaryInteractions_(0),
38  formMargules_(0),
39  formTempModel_(0)
40 {
41  warn_deprecated("Class PhaseCombo_Interaction", "To be removed after Cantera 2.4");
42  importPhase(phaseRoot, this);
43 }
44 
45 // - Activities, Standard States, Activity Concentrations -----------
46 
48 {
49  // Update the activity coefficients
51 
52  // take the exp of the internally stored coefficients.
53  for (size_t k = 0; k < m_kk; k++) {
54  ac[k] = exp(lnActCoeff_Scaled_[k]);
55  }
56 }
57 
58 // ------------ Partial Molar Properties of the Solution ------------
59 
61 {
62  // First get the standard chemical potentials in molar form. This requires
63  // updates of standard state as a function of T and P
65  // Update the activity coefficients
67 
68  for (size_t k = 0; k < m_kk; k++) {
69  double xx = std::max(moleFractions_[k], SmallNumber);
70  mu[k] += RT() * (log(xx) + lnActCoeff_Scaled_[k]);
71  }
72 }
73 
75 {
76  double h = 0;
77  vector_fp hbar(m_kk);
78  getPartialMolarEnthalpies(&hbar[0]);
79  for (size_t i = 0; i < m_kk; i++) {
80  h += moleFractions_[i]*hbar[i];
81  }
82  return h;
83 }
84 
86 {
87  double s = 0;
88  vector_fp sbar(m_kk);
89  getPartialMolarEntropies(&sbar[0]);
90  for (size_t i = 0; i < m_kk; i++) {
91  s += moleFractions_[i]*sbar[i];
92  }
93  return s;
94 }
95 
97 {
98  double cp = 0;
99  vector_fp cpbar(m_kk);
100  getPartialMolarCp(&cpbar[0]);
101  for (size_t i = 0; i < m_kk; i++) {
102  cp += moleFractions_[i]*cpbar[i];
103  }
104  return cp;
105 }
106 
108 {
109  return cp_mole() - GasConstant;
110 }
111 
113 {
114  // Get the nondimensional standard state enthalpies
115  getEnthalpy_RT(hbar);
116  // dimensionalize it.
117  double T = temperature();
118  for (size_t k = 0; k < m_kk; k++) {
119  hbar[k] *= GasConstant * T;
120  }
121 
122  // Update the activity coefficients, This also update the internally stored
123  // molalities.
126  for (size_t k = 0; k < m_kk; k++) {
127  hbar[k] -= GasConstant * T * T * dlnActCoeffdT_Scaled_[k];
128  }
129 }
130 
131 void PhaseCombo_Interaction::getPartialMolarCp(doublereal* cpbar) const
132 {
133  // Get the nondimensional standard state entropies
134  getCp_R(cpbar);
135  double T = temperature();
136 
137  // Update the activity coefficients, This also update the internally stored
138  // molalities.
141 
142  for (size_t k = 0; k < m_kk; k++) {
143  cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k];
144  }
145 
146  // dimensionalize it.
147  for (size_t k = 0; k < m_kk; k++) {
148  cpbar[k] *= GasConstant;
149  }
150 }
151 
153 {
154  // Get the nondimensional standard state entropies
155  getEntropy_R(sbar);
156  double T = temperature();
157 
158  // Update the activity coefficients, This also update the internally stored
159  // molalities.
162 
163  for (size_t k = 0; k < m_kk; k++) {
164  double xx = std::max(moleFractions_[k], SmallNumber);
165  sbar[k] += - lnActCoeff_Scaled_[k] - log(xx) - T * dlnActCoeffdT_Scaled_[k];
166  }
167 
168  // dimensionalize it.
169  for (size_t k = 0; k < m_kk; k++) {
170  sbar[k] *= GasConstant;
171  }
172 }
173 
175 {
176  double T = temperature();
177 
178  // Get the standard state values in m^3 kmol-1
179  getStandardVolumes(vbar);
180 
181  for (size_t iK = 0; iK < m_kk; iK++) {
182  int delAK = 0;
183  int delBK = 0;
184  for (size_t i = 0; i < numBinaryInteractions_; i++) {
185  size_t iA = m_pSpecies_A_ij[i];
186  size_t iB = m_pSpecies_B_ij[i];
187 
188  if (iA==iK) {
189  delAK = 1;
190  } else if (iB==iK) {
191  delBK = 1;
192  }
193 
194  double XA = moleFractions_[iA];
195  double XB = moleFractions_[iB];
196  double g0 = (m_VHE_b_ij[i] - T * m_VSE_b_ij[i]);
197  double g1 = (m_VHE_c_ij[i] - T * m_VSE_c_ij[i]);
198  vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
199  }
200  }
201 }
202 
204 {
205  initLengths();
207 }
208 
210 {
212 }
213 
214 void PhaseCombo_Interaction::initThermoXML(XML_Node& phaseNode, const std::string& id)
215 {
216  if ((int) id.size() > 0 && phaseNode.id() != id) {
217  throw CanteraError("PhaseCombo_Interaction::initThermoXML",
218  "phasenode and Id are incompatible");
219  }
220 
221  // Check on the thermo field. Must have:
222  // <thermo model="PhaseCombo_Interaction" />
223  if (!phaseNode.hasChild("thermo")) {
224  throw CanteraError("PhaseCombo_Interaction::initThermoXML",
225  "no thermo XML node");
226  }
227  XML_Node& thermoNode = phaseNode.child("thermo");
228  if (!caseInsensitiveEquals(thermoNode["model"], "phasecombo_interaction")) {
229  throw CanteraError("PhaseCombo_Interaction::initThermoXML",
230  "model name isn't PhaseCombo_Interaction: " + 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("PhaseCombo_Interaction::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 
258 {
259  doublereal T = temperature();
260  lnActCoeff_Scaled_.assign(m_kk, 0.0);
261 
262  for (size_t iK = 0; iK < m_kk; iK++) {
263  // We never sample the end of the mole fraction domains
264  double xx = std::max(moleFractions_[iK], SmallNumber);
265 
266  // First wipe out the ideal solution mixing term
267  lnActCoeff_Scaled_[iK] = - log(xx);
268 
269  // Then add in the Margules interaction terms. that's it!
270  for (size_t i = 0; i < numBinaryInteractions_; i++) {
271  size_t iA = m_pSpecies_A_ij[i];
272  size_t iB = m_pSpecies_B_ij[i];
273  int delAK = 0;
274  int delBK = 0;
275  if (iA==iK) {
276  delAK = 1;
277  } else if (iB==iK) {
278  delBK = 1;
279  }
280  double XA = moleFractions_[iA];
281  double XB = moleFractions_[iB];
282  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
283  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
284  lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
285  }
286  }
287 }
288 
290 {
291  doublereal T = temperature();
292  dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
293  d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0);
294  for (size_t iK = 0; iK < m_kk; iK++) {
295  for (size_t i = 0; i < numBinaryInteractions_; i++) {
296  size_t iA = m_pSpecies_A_ij[i];
297  size_t iB = m_pSpecies_B_ij[i];
298  int delAK = 0;
299  int delBK = 0;
300  if (iA==iK) {
301  delAK = 1;
302  } else if (iB==iK) {
303  delBK = 1;
304  }
305  double XA = moleFractions_[iA];
306  double XB = moleFractions_[iB];
307  double g0 = -m_HE_b_ij[i] / (GasConstant*T*T);
308  double g1 = -m_HE_c_ij[i] / (GasConstant*T*T);
309  double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
310  dlnActCoeffdT_Scaled_[iK] += temp;
311  d2lnActCoeffdT2_Scaled_[iK] -= 2.0 * temp / T;
312  }
313  }
314 }
315 
316 void PhaseCombo_Interaction::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const
317 {
319  for (size_t k = 0; k < m_kk; k++) {
320  dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k];
321  }
322 }
323 
324 void PhaseCombo_Interaction::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const
325 {
327  for (size_t k = 0; k < m_kk; k++) {
328  d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k];
329  }
330 }
331 
332 void PhaseCombo_Interaction::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
333  doublereal* dlnActCoeffds) const
334 {
335  doublereal T = temperature();
337 
338  for (size_t iK = 0; iK < m_kk; iK++) {
339  // We never sample the end of the mole fraction domains
340  double xx = std::max(moleFractions_[iK], SmallNumber);
341 
342  // First wipe out the ideal solution mixing term
343  if (xx > SmallNumber) {
344  dlnActCoeffds[iK] += - 1.0 / xx;
345  }
346 
347  for (size_t i = 0; i < numBinaryInteractions_; i++) {
348  size_t iA = m_pSpecies_A_ij[i];
349  size_t iB = m_pSpecies_B_ij[i];
350  int delAK = 0;
351  int delBK = 0;
352 
353  if (iA==iK) {
354  delAK = 1;
355  } else if (iB==iK) {
356  delBK = 1;
357  }
358 
359  double XA = moleFractions_[iA];
360  double XB = moleFractions_[iB];
361  double dXA = dXds[iA];
362  double dXB = dXds[iB];
363  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
364  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
365  dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
366  + dlnActCoeffdT_Scaled_[iK]*dTds;
367  }
368  }
369 }
370 
372 {
373  doublereal T = temperature();
374  dlnActCoeffdlnN_diag_.assign(m_kk, 0.0);
375 
376  for (size_t iK = 0; iK < m_kk; iK++) {
377  double XK = moleFractions_[iK];
378  // We never sample the end of the mole fraction domains
379  double xx = std::max(moleFractions_[iK], SmallNumber);
380 
381  // First wipe out the ideal solution mixing term
382  if (xx > SmallNumber) {
383  dlnActCoeffdlnN_diag_[iK] = - 1.0 + xx;
384  }
385 
386  for (size_t i = 0; i < numBinaryInteractions_; i++) {
387  size_t iA = m_pSpecies_A_ij[i];
388  size_t iB = m_pSpecies_B_ij[i];
389  int delAK = 0;
390  int delBK = 0;
391 
392  if (iA==iK) {
393  delAK = 1;
394  } else if (iB==iK) {
395  delBK = 1;
396  }
397 
398  double XA = moleFractions_[iA];
399  double XB = moleFractions_[iB];
400  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
401  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
402  dlnActCoeffdlnN_diag_[iK] += 2*(delBK-XB)*(g0*(delAK-XA)+g1*(2*(delAK-XA)*XB+XA*(delBK-XB)));
403  }
405  }
406 }
407 
409 {
410  double T = temperature();
412 
413  // Loop over the activity coefficient gamma_k
414  for (size_t iK = 0; iK < m_kk; iK++) {
415  // We never sample the end of the mole fraction domains
416  double xx = std::max(moleFractions_[iK], SmallNumber);
417  for (size_t iM = 0; iM < m_kk; iM++) {
418  double XM = moleFractions_[iM];
419  if (xx > SmallNumber) {
420  double delKM = 0.0;
421  if (iK == iM) {
422  delKM = 1.0;
423  }
424  // this gets multiplied by XM at the bottom
425  dlnActCoeffdlnN_(iK,iM) += - delKM/XM + 1.0;
426  }
427 
428  for (size_t i = 0; i < numBinaryInteractions_; i++) {
429  size_t iA = m_pSpecies_A_ij[i];
430  size_t iB = m_pSpecies_B_ij[i];
431  double delAK = 0.0;
432  double delBK = 0.0;
433  double delAM = 0.0;
434  double delBM = 0.0;
435  if (iA==iK) {
436  delAK = 1.0;
437  } else if (iB==iK) {
438  delBK = 1.0;
439  }
440  if (iA==iM) {
441  delAM = 1.0;
442  } else if (iB==iM) {
443  delBM = 1.0;
444  }
445 
446  double XA = moleFractions_[iA];
447  double XB = moleFractions_[iB];
448  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
449  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
450  dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
451  dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
452  }
453  dlnActCoeffdlnN_(iK,iM) = XM * dlnActCoeffdlnN_(iK,iM);
454  }
455  }
456 }
457 
459 {
460  doublereal T = temperature();
461  dlnActCoeffdlnX_diag_.assign(m_kk, 0.0);
462  for (size_t i = 0; i < numBinaryInteractions_; i++) {
463  size_t iA = m_pSpecies_A_ij[i];
464  size_t iB = m_pSpecies_B_ij[i];
465 
466  double XA = moleFractions_[iA];
467  double XB = moleFractions_[iB];
468 
469  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant * T);
470  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant * T);
471 
472  dlnActCoeffdlnX_diag_[iA] += XA*XB*(2*g1*-2*g0-6*g1*XB);
473  dlnActCoeffdlnX_diag_[iB] += XA*XB*(2*g1*-2*g0-6*g1*XB);
474  }
475  throw CanteraError("PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag", "unimplemented");
476 }
477 
478 void PhaseCombo_Interaction::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const
479 {
481  for (size_t k = 0; k < m_kk; k++) {
482  dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k];
483  }
484 }
485 
486 void PhaseCombo_Interaction::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const
487 {
489  for (size_t k = 0; k < m_kk; k++) {
490  dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k];
491  }
492 }
493 
494 void PhaseCombo_Interaction::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN)
495 {
497  double* data = & dlnActCoeffdlnN_(0,0);
498  for (size_t k = 0; k < m_kk; k++) {
499  for (size_t m = 0; m < m_kk; m++) {
500  dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
501  }
502  }
503 }
504 
506 {
508  m_HE_b_ij.resize(num, 0.0);
509  m_HE_c_ij.resize(num, 0.0);
510  m_HE_d_ij.resize(num, 0.0);
511  m_SE_b_ij.resize(num, 0.0);
512  m_SE_c_ij.resize(num, 0.0);
513  m_SE_d_ij.resize(num, 0.0);
514  m_VHE_b_ij.resize(num, 0.0);
515  m_VHE_c_ij.resize(num, 0.0);
516  m_VHE_d_ij.resize(num, 0.0);
517  m_VSE_b_ij.resize(num, 0.0);
518  m_VSE_c_ij.resize(num, 0.0);
519  m_VSE_d_ij.resize(num, 0.0);
520  m_pSpecies_A_ij.resize(num, npos);
521  m_pSpecies_B_ij.resize(num, npos);
522 }
523 
525 {
526  string xname = xmLBinarySpecies.name();
527  if (xname != "binaryNeutralSpeciesParameters") {
528  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies",
529  "Incorrect name for processing this routine: " + xname);
530  }
531  vector_fp vParams;
532  string iName = xmLBinarySpecies.attrib("speciesA");
533  if (iName == "") {
534  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "no speciesA attrib");
535  }
536  string jName = xmLBinarySpecies.attrib("speciesB");
537  if (jName == "") {
538  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "no speciesB attrib");
539  }
540 
541  // Find the index of the species in the current phase. It's not an error to
542  // not find the species
543  size_t iSpecies = speciesIndex(iName);
544  if (iSpecies == npos) {
545  return;
546  }
547  string ispName = speciesName(iSpecies);
548  if (charge(iSpecies) != 0) {
549  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "speciesA charge problem");
550  }
551  size_t jSpecies = speciesIndex(jName);
552  if (jSpecies == npos) {
553  return;
554  }
555  string jspName = speciesName(jSpecies);
556  if (charge(jSpecies) != 0) {
557  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "speciesB charge problem");
558  }
559 
561  size_t iSpot = numBinaryInteractions_ - 1;
562  m_pSpecies_A_ij[iSpot] = iSpecies;
563  m_pSpecies_B_ij[iSpot] = jSpecies;
564 
565  for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) {
566  XML_Node& xmlChild = xmLBinarySpecies.child(iChild);
567  string nodeName = toLowerCopy(xmlChild.name());
568 
569  // Process the binary species interaction child elements
570  if (nodeName == "excessenthalpy") {
571  // Get the string containing all of the values
572  getFloatArray(xmlChild, vParams, true, "toSI", "excessEnthalpy");
573  if (vParams.size() != 2) {
574  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessEnthalpy for " + ispName
575  + "::" + jspName,
576  "wrong number of params found");
577  }
578  m_HE_b_ij[iSpot] = vParams[0];
579  m_HE_c_ij[iSpot] = vParams[1];
580  }
581 
582  if (nodeName == "excessentropy") {
583  // Get the string containing all of the values
584  getFloatArray(xmlChild, vParams, true, "toSI", "excessEntropy");
585  if (vParams.size() != 2) {
586  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessEntropy for " + ispName
587  + "::" + jspName,
588  "wrong number of params found");
589  }
590  m_SE_b_ij[iSpot] = vParams[0];
591  m_SE_c_ij[iSpot] = vParams[1];
592  }
593 
594  if (nodeName == "excessvolume_enthalpy") {
595  // Get the string containing all of the values
596  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Enthalpy");
597  if (vParams.size() != 2) {
598  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
599  + "::" + jspName,
600  "wrong number of params found");
601  }
602  m_VHE_b_ij[iSpot] = vParams[0];
603  m_VHE_c_ij[iSpot] = vParams[1];
604  }
605 
606  if (nodeName == "excessvolume_entropy") {
607  // Get the string containing all of the values
608  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Entropy");
609  if (vParams.size() != 2) {
610  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
611  + "::" + jspName,
612  "wrong number of params found");
613  }
614  m_VSE_b_ij[iSpot] = vParams[0];
615  m_VSE_c_ij[iSpot] = vParams[1];
616  }
617  }
618 }
619 
620 }
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
virtual double size(size_t k) const
Definition: Phase.h:411
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
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...
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
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 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 ...
Header for intermediate ThermoPhase object for phases which employ the Margules Gibbs free energy for...
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
void initLengths()
Initialize lengths of local variables after all species have been identified.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
vector_fp m_HE_d_ij
Enthalpy term for the quaternary 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.
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.
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
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 doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:748
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
vector_fp dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
vector_fp d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:191
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
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 void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector_fp m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
size_t numBinaryInteractions_
number of binary interaction expressions
vector_fp m_SE_c_ij
Entropy term for the ternary 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.
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::string id() const
Return the string id for the phase.
Definition: Phase.cpp:68
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
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
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
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:428
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
Contains declarations for string manipulation functions within Cantera.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
vector_fp m_SE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
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
vector_fp m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
void s_update_lnActCoeff() const
Update the activity coefficients.
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:556
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
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...
vector_fp dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...