Cantera  2.5.1
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 https://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();
203  if (m_input.hasKey("interactions")) {
204  for (auto& item : m_input["interactions"].asVector<AnyMap>()) {
205  auto& species = item["species"].asVector<string>(2);
206  vector_fp h(2), s(2), vh(2), vs(2);
207  if (item.hasKey("excess-enthalpy")) {
208  h = item.convertVector("excess-enthalpy", "J/kmol", 2);
209  }
210  if (item.hasKey("excess-entropy")) {
211  s = item.convertVector("excess-entropy", "J/kmol/K", 2);
212  }
213  if (item.hasKey("excess-volume-enthalpy")) {
214  vh = item.convertVector("excess-volume-enthalpy", "m^3/kmol/K", 2);
215  }
216  if (item.hasKey("excess-volume-entropy")) {
217  vs = item.convertVector("excess-volume-entropy", "m^3/kmol/K", 2);
218  }
220  h[0], h[1], s[0], s[1], vh[0], vh[1], vs[0], vs[1]);
221  }
222  }
224 }
225 
227 {
229 }
230 
231 void MargulesVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_)
232 {
233  if ((int) id_.size() > 0) {
234  string idp = phaseNode.id();
235  if (idp != id_) {
236  throw CanteraError("MargulesVPSSTP::initThermoXML", "phasenode and Id are incompatible");
237  }
238  }
239 
240  // Find the Thermo XML node
241  if (!phaseNode.hasChild("thermo")) {
242  throw CanteraError("MargulesVPSSTP::initThermoXML",
243  "no thermo XML node");
244  }
245  XML_Node& thermoNode = phaseNode.child("thermo");
246 
247  // Make sure that the thermo model is Margules
248  if (!caseInsensitiveEquals(thermoNode["model"], "margules")) {
249  throw CanteraError("MargulesVPSSTP::initThermoXML",
250  "model name isn't Margules: " + thermoNode["model"]);
251  }
252 
253  // Go get all of the coefficients and factors in the activityCoefficients
254  // XML block
255  if (thermoNode.hasChild("activityCoefficients")) {
256  XML_Node& acNode = thermoNode.child("activityCoefficients");
257  if (!caseInsensitiveEquals(acNode["model"], "margules")) {
258  throw CanteraError("MargulesVPSSTP::initThermoXML",
259  "Unknown activity coefficient model: " + acNode["model"]);
260  }
261  for (size_t i = 0; i < acNode.nChildren(); i++) {
262  XML_Node& xmlACChild = acNode.child(i);
263 
264  // Process a binary salt field, or any of the other XML fields that
265  // make up the Pitzer Database. Entries will be ignored if any of
266  // the species in the entry isn't in the solution.
267  if (caseInsensitiveEquals(xmlACChild.name(), "binaryneutralspeciesparameters")) {
268  readXMLBinarySpecies(xmlACChild);
269  }
270  }
271  }
272 
273  // Go down the chain
274  GibbsExcessVPSSTP::initThermoXML(phaseNode, id_);
275 }
276 
277 void MargulesVPSSTP::addBinaryInteraction(const std::string& speciesA,
278  const std::string& speciesB, double h0, double h1, double s0, double s1,
279  double vh0, double vh1, double vs0, double vs1)
280 {
281  size_t kA = speciesIndex(speciesA);
282  size_t kB = speciesIndex(speciesB);
283  // The interaction is silently ignored if either species is not defined in
284  // the current phase.
285  if (kA == npos || kB == npos) {
286  return;
287  }
288  m_pSpecies_A_ij.push_back(kA);
289  m_pSpecies_B_ij.push_back(kB);
290 
291  m_HE_b_ij.push_back(h0);
292  m_HE_c_ij.push_back(h1);
293  m_SE_b_ij.push_back(s0);
294  m_SE_c_ij.push_back(s1);
295  m_VHE_b_ij.push_back(vh0);
296  m_VHE_c_ij.push_back(vh1);
297  m_VSE_b_ij.push_back(vs0);
298  m_VSE_c_ij.push_back(vs1);
300 }
301 
302 
304 {
305  double T = temperature();
306  lnActCoeff_Scaled_.assign(m_kk, 0.0);
307  for (size_t i = 0; i < numBinaryInteractions_; i++) {
308  size_t iA = m_pSpecies_A_ij[i];
309  size_t iB = m_pSpecies_B_ij[i];
310  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
311  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
312  double XA = moleFractions_[iA];
313  double XB = moleFractions_[iB];
314  const doublereal XAXB = XA * XB;
315  const doublereal g0g1XB = (g0 + g1 * XB);
316  const doublereal all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
317  for (size_t iK = 0; iK < m_kk; iK++) {
318  lnActCoeff_Scaled_[iK] += all;
319  }
320  lnActCoeff_Scaled_[iA] += XB * g0g1XB;
321  lnActCoeff_Scaled_[iB] += XA * g0g1XB + XAXB * g1;
322  }
323 }
324 
326 {
327  doublereal invT = 1.0 / temperature();
328  doublereal invRTT = 1.0 / GasConstant*invT*invT;
329  dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
330  d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0);
331  for (size_t i = 0; i < numBinaryInteractions_; i++) {
332  size_t iA = m_pSpecies_A_ij[i];
333  size_t iB = m_pSpecies_B_ij[i];
334  double XA = moleFractions_[iA];
335  double XB = moleFractions_[iB];
336  double g0 = -m_HE_b_ij[i] * invRTT;
337  double g1 = -m_HE_c_ij[i] * invRTT;
338  const doublereal XAXB = XA * XB;
339  const doublereal g0g1XB = (g0 + g1 * XB);
340  const doublereal all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
341  const doublereal mult = 2.0 * invT;
342  const doublereal dT2all = mult * all;
343  for (size_t iK = 0; iK < m_kk; iK++) {
344  dlnActCoeffdT_Scaled_[iK] += all;
345  d2lnActCoeffdT2_Scaled_[iK] -= dT2all;
346  }
347  dlnActCoeffdT_Scaled_[iA] += XB * g0g1XB;
348  dlnActCoeffdT_Scaled_[iB] += XA * g0g1XB + XAXB * g1;
349  d2lnActCoeffdT2_Scaled_[iA] -= mult * XB * g0g1XB;
350  d2lnActCoeffdT2_Scaled_[iB] -= mult * (XA * g0g1XB + XAXB * g1);
351  }
352 }
353 
354 void MargulesVPSSTP::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const
355 {
357  for (size_t k = 0; k < m_kk; k++) {
358  dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k];
359  }
360 }
361 
362 void MargulesVPSSTP::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const
363 {
365  for (size_t k = 0; k < m_kk; k++) {
366  d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k];
367  }
368 }
369 
370 void MargulesVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
371  doublereal* dlnActCoeffds) const
372 {
373  double T = temperature();
375  for (size_t iK = 0; iK < m_kk; iK++) {
376  dlnActCoeffds[iK] = 0.0;
377  }
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 dXA = dXds[iA];
385  double dXB = dXds[iB];
386  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
387  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
388  const doublereal g02g1XB = g0 + 2*g1*XB;
389  const doublereal g2XAdXB = 2*g1*XA*dXB;
390  const doublereal all = (-XB * dXA - XA *dXB) * g02g1XB - XB *g2XAdXB;
391  for (size_t iK = 0; iK < m_kk; iK++) {
392  dlnActCoeffds[iK] += all + dlnActCoeffdT_Scaled_[iK]*dTds;
393  }
394  dlnActCoeffds[iA] += dXB * g02g1XB;
395  dlnActCoeffds[iB] += dXA * g02g1XB + g2XAdXB;
396  }
397 }
398 
400 {
401  double T = temperature();
402  dlnActCoeffdlnN_diag_.assign(m_kk, 0.0);
403 
404  for (size_t iK = 0; iK < m_kk; iK++) {
405  double XK = moleFractions_[iK];
406 
407  for (size_t i = 0; i < numBinaryInteractions_; i++) {
408  size_t iA = m_pSpecies_A_ij[i];
409  size_t iB = m_pSpecies_B_ij[i];
410  size_t delAK = 0;
411  size_t delBK = 0;
412 
413  if (iA==iK) {
414  delAK = 1;
415  } else if (iB==iK) {
416  delBK = 1;
417  }
418 
419  double XA = moleFractions_[iA];
420  double XB = moleFractions_[iB];
421 
422  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
423  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
424 
425  dlnActCoeffdlnN_diag_[iK] += 2*(delBK-XB)*(g0*(delAK-XA)+g1*(2*(delAK-XA)*XB+XA*(delBK-XB)));
426  }
428  }
429 }
430 
432 {
433  double T = temperature();
435 
436  // Loop over the activity coefficient gamma_k
437  for (size_t iK = 0; iK < m_kk; iK++) {
438  for (size_t iM = 0; iM < m_kk; iM++) {
439  double XM = moleFractions_[iM];
440  for (size_t i = 0; i < numBinaryInteractions_; i++) {
441  size_t iA = m_pSpecies_A_ij[i];
442  size_t iB = m_pSpecies_B_ij[i];
443  double delAK = 0.0;
444  double delBK = 0.0;
445  double delAM = 0.0;
446  double delBM = 0.0;
447  if (iA==iK) {
448  delAK = 1.0;
449  } else if (iB==iK) {
450  delBK = 1.0;
451  }
452  if (iA==iM) {
453  delAM = 1.0;
454  } else if (iB==iM) {
455  delBM = 1.0;
456  }
457 
458  double XA = moleFractions_[iA];
459  double XB = moleFractions_[iB];
460  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
461  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
462  dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
463  dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
464  }
465  dlnActCoeffdlnN_(iK,iM) = XM*dlnActCoeffdlnN_(iK,iM);
466  }
467  }
468 }
469 
471 {
472  doublereal T = temperature();
473  dlnActCoeffdlnX_diag_.assign(m_kk, 0.0);
474 
475  for (size_t i = 0; i < numBinaryInteractions_; i++) {
476  size_t iA = m_pSpecies_A_ij[i];
477  size_t iB = m_pSpecies_B_ij[i];
478 
479  doublereal XA = moleFractions_[iA];
480  doublereal XB = moleFractions_[iB];
481 
482  doublereal g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
483  doublereal g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
484 
485  dlnActCoeffdlnX_diag_[iA] += XA*XB*(2*g1*-2*g0-6*g1*XB);
486  dlnActCoeffdlnX_diag_[iB] += XA*XB*(2*g1*-2*g0-6*g1*XB);
487  }
488 }
489 
490 void MargulesVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const
491 {
493  for (size_t k = 0; k < m_kk; k++) {
494  dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k];
495  }
496 }
497 
498 void MargulesVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const
499 {
501  for (size_t k = 0; k < m_kk; k++) {
502  dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k];
503  }
504 }
505 
506 void MargulesVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN)
507 {
509  double* data = & dlnActCoeffdlnN_(0,0);
510  for (size_t k = 0; k < m_kk; k++) {
511  for (size_t m = 0; m < m_kk; m++) {
512  dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
513  }
514  }
515 }
516 
518 {
519  string xname = xmLBinarySpecies.name();
520  if (xname != "binaryNeutralSpeciesParameters") {
521  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies",
522  "Incorrect name for processing this routine: " + xname);
523  }
524  string aName = xmLBinarySpecies.attrib("speciesA");
525  if (aName == "") {
526  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies", "no speciesA attrib");
527  }
528  string bName = xmLBinarySpecies.attrib("speciesB");
529  if (bName == "") {
530  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies", "no speciesB attrib");
531  }
532 
533  vector_fp vParams;
534  double h0 = 0.0;
535  double h1 = 0.0;
536  double s0 = 0.0;
537  double s1 = 0.0;
538  double vh0 = 0.0;
539  double vh1 = 0.0;
540  double vs0 = 0.0;
541  double vs1 = 0.0;
542 
543  for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) {
544  XML_Node& xmlChild = xmLBinarySpecies.child(iChild);
545  string nodeName = toLowerCopy(xmlChild.name());
546 
547  // Process the binary species interaction parameters.
548  // They are in subblocks labeled:
549  // excessEnthalpy
550  // excessEntropy
551  // excessVolume_Enthalpy
552  // excessVolume_Entropy
553  // Other blocks are currently ignored.
554  // @TODO determine a policy about ignoring blocks that should or shouldn't be there.
555  if (nodeName == "excessenthalpy") {
556  // Get the string containing all of the values
557  getFloatArray(xmlChild, vParams, true, "toSI", "excessEnthalpy");
558  if (vParams.size() != 2) {
559  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
560  "excessEnthalpy for {} : {}: wrong number of params found."
561  " Need 2", aName, bName);
562  }
563  h0 = vParams[0];
564  h1 = vParams[1];
565  } else if (nodeName == "excessentropy") {
566  // Get the string containing all of the values
567  getFloatArray(xmlChild, vParams, true, "toSI", "excessEntropy");
568  if (vParams.size() != 2) {
569  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
570  "excessEntropy for {} : {}: wrong number of params found."
571  " Need 2", aName, bName);
572  }
573  s0 = vParams[0];
574  s1 = vParams[1];
575  } else if (nodeName == "excessvolume_enthalpy") {
576  // Get the string containing all of the values
577  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Enthalpy");
578  if (vParams.size() != 2) {
579  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
580  "excessVolume_Enthalpy for {} : {}: wrong number of params"
581  " found. Need 2", aName, bName);
582  }
583  vh0 = vParams[0];
584  vh1 = vParams[1];
585  } else if (nodeName == "excessvolume_entropy") {
586  // Get the string containing all of the values
587  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Entropy");
588  if (vParams.size() != 2) {
589  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies"
590  "excessVolume_Entropy for {} : {}: wrong number of params"
591  " found. Need 2", aName, bName);
592  }
593  vs0 = vParams[0];
594  vs1 = vParams[1];
595  }
596  }
597  addBinaryInteraction(aName, bName, h0, h1, s0, s1, vh0, vh1, vs0, vs1);
598 }
599 
600 }
(see Thermodynamic Properties and class MargulesVPSSTP).
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Definition: AnyMap.cpp:984
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
Definition: Array.h:112
void zero()
Set all of the entries to zero.
Definition: Array.h:198
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
vector_fp dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
vector_fp lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
vector_fp d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
vector_fp dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
vector_fp dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
vector_fp m_SE_c_ij
Entropy term for the ternary 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.
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...
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
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 for the species in the mixture.
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
size_t numBinaryInteractions_
number of binary interaction expressions
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
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 readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
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 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.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
vector_fp m_SE_b_ij
Entropy term for the binary 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.
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
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,...
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
void initLengths()
Initialize lengths of local variables after all species have been identified.
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction)
void s_update_lnActCoeff() const
Update the activity coefficients.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:285
size_t m_kk
Number of species in the phase.
Definition: Phase.h:942
doublereal temperature() const
Temperature (K).
Definition: Phase.h:667
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
Definition: Phase.cpp:201
shared_ptr< Species > species(const std::string &name) const
Return the Species object for the named species.
Definition: Phase.cpp:980
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:776
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
AnyMap m_input
Data supplied via setParameters.
Definition: ThermoPhase.h:1874
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 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...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:104
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:492
std::string name() const
Returns the name of the XML node.
Definition: xml.h:372
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:528
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:538
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:556
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:546
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:188
const double SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:149
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:180
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:109
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
std::string toLowerCopy(const std::string &input)
Convert to lower case.
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
Contains declarations for string manipulation functions within Cantera.