Cantera  2.3.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 MargulesVPSSTP::MargulesVPSSTP(const MargulesVPSSTP& b)
45 {
46  MargulesVPSSTP::operator=(b);
47 }
48 
49 MargulesVPSSTP& MargulesVPSSTP::operator=(const MargulesVPSSTP& b)
50 {
51  if (&b == this) {
52  return *this;
53  }
54 
55  GibbsExcessVPSSTP::operator=(b);
56 
57  numBinaryInteractions_ = b.numBinaryInteractions_;
58  m_HE_b_ij = b.m_HE_b_ij;
59  m_HE_c_ij = b.m_HE_c_ij;
60  m_HE_d_ij = b.m_HE_d_ij;
61  m_SE_b_ij = b.m_SE_b_ij;
62  m_SE_c_ij = b.m_SE_c_ij;
63  m_SE_d_ij = b.m_SE_d_ij;
64  m_VHE_b_ij = b.m_VHE_b_ij;
65  m_VHE_c_ij = b.m_VHE_c_ij;
66  m_VHE_d_ij = b.m_VHE_d_ij;
67  m_VSE_b_ij = b.m_VSE_b_ij;
68  m_VSE_c_ij = b.m_VSE_c_ij;
69  m_VSE_d_ij = b.m_VSE_d_ij;
70  m_pSpecies_A_ij = b.m_pSpecies_A_ij;
71  m_pSpecies_B_ij = b.m_pSpecies_B_ij;
72  formMargules_ = b.formMargules_;
73  formTempModel_ = b.formTempModel_;
74 
75  return *this;
76 }
77 
79 {
80  return new MargulesVPSSTP(*this);
81 }
82 
83 // -- Activities, Standard States, Activity Concentrations -----------
84 
85 void MargulesVPSSTP::getLnActivityCoefficients(doublereal* lnac) const
86 {
87  // Update the activity coefficients
89 
90  // take the exp of the internally stored coefficients.
91  for (size_t k = 0; k < m_kk; k++) {
92  lnac[k] = lnActCoeff_Scaled_[k];
93  }
94 }
95 
96 // ------------ Partial Molar Properties of the Solution ------------
97 
98 void MargulesVPSSTP::getChemPotentials(doublereal* mu) const
99 {
100  // First get the standard chemical potentials in molar form. This requires
101  // updates of standard state as a function of T and P
103 
104  // Update the activity coefficients
106  for (size_t k = 0; k < m_kk; k++) {
107  double xx = std::max(moleFractions_[k], SmallNumber);
108  mu[k] += RT() * (log(xx) + lnActCoeff_Scaled_[k]);
109  }
110 }
111 
113 {
114  size_t kk = nSpecies();
115  double h = 0;
116  vector_fp hbar(kk);
117  getPartialMolarEnthalpies(&hbar[0]);
118  for (size_t i = 0; i < kk; i++) {
119  h += moleFractions_[i]*hbar[i];
120  }
121  return h;
122 }
123 
125 {
126  size_t kk = nSpecies();
127  double s = 0;
128  vector_fp sbar(kk);
129  getPartialMolarEntropies(&sbar[0]);
130  for (size_t i = 0; i < kk; i++) {
131  s += moleFractions_[i]*sbar[i];
132  }
133  return s;
134 }
135 
136 doublereal MargulesVPSSTP::cp_mole() const
137 {
138  size_t kk = nSpecies();
139  double cp = 0;
140  vector_fp cpbar(kk);
141  getPartialMolarCp(&cpbar[0]);
142  for (size_t i = 0; i < kk; i++) {
143  cp += moleFractions_[i]*cpbar[i];
144  }
145  return cp;
146 }
147 
148 doublereal MargulesVPSSTP::cv_mole() const
149 {
150  return cp_mole() - GasConstant;
151 }
152 
153 void MargulesVPSSTP::getPartialMolarEnthalpies(doublereal* hbar) const
154 {
155  // Get the nondimensional standard state enthalpies
156  getEnthalpy_RT(hbar);
157 
158  // dimensionalize it.
159  for (size_t k = 0; k < m_kk; k++) {
160  hbar[k] *= RT();
161  }
162 
163  // Update the activity coefficients, This also update the internally stored
164  // molalities.
167  for (size_t k = 0; k < m_kk; k++) {
168  hbar[k] -= RT() * temperature() * dlnActCoeffdT_Scaled_[k];
169  }
170 }
171 
172 void MargulesVPSSTP::getPartialMolarCp(doublereal* cpbar) const
173 {
174  // Get the nondimensional standard state entropies
175  getCp_R(cpbar);
176  double T = temperature();
177 
178  // Update the activity coefficients, This also update the internally stored
179  // molalities.
182 
183  for (size_t k = 0; k < m_kk; k++) {
184  cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k];
185  }
186  // dimensionalize it.
187  for (size_t k = 0; k < m_kk; k++) {
188  cpbar[k] *= GasConstant;
189  }
190 }
191 
192 void MargulesVPSSTP::getPartialMolarEntropies(doublereal* sbar) const
193 {
194  // Get the nondimensional standard state entropies
195  getEntropy_R(sbar);
196  double T = temperature();
197 
198  // Update the activity coefficients, This also update the internally stored
199  // molalities.
202 
203  for (size_t k = 0; k < m_kk; k++) {
204  double xx = std::max(moleFractions_[k], SmallNumber);
205  sbar[k] += - lnActCoeff_Scaled_[k] -log(xx) - T * dlnActCoeffdT_Scaled_[k];
206  }
207 
208  // dimensionalize it.
209  for (size_t k = 0; k < m_kk; k++) {
210  sbar[k] *= GasConstant;
211  }
212 }
213 
214 void MargulesVPSSTP::getPartialMolarVolumes(doublereal* vbar) const
215 {
216  double T = temperature();
217 
218  // Get the standard state values in m^3 kmol-1
219  getStandardVolumes(vbar);
220 
221  for (size_t i = 0; i < numBinaryInteractions_; i++) {
222  size_t iA = m_pSpecies_A_ij[i];
223  size_t iB = m_pSpecies_B_ij[i];
224  double XA = moleFractions_[iA];
225  double XB = moleFractions_[iB];
226  double g0 = (m_VHE_b_ij[i] - T * m_VSE_b_ij[i]);
227  double g1 = (m_VHE_c_ij[i] - T * m_VSE_c_ij[i]);
228  const doublereal temp1 = g0 + g1 * XB;
229  const doublereal all = -1.0*XA*XB*temp1 - XA*XB*XB*g1;
230 
231  for (size_t iK = 0; iK < m_kk; iK++) {
232  vbar[iK] += all;
233  }
234  vbar[iA] += XB * temp1;
235  vbar[iB] += XA * temp1 + XA*XB*g1;
236  }
237 }
238 
240 {
241  initLengths();
243 }
244 
246 {
248 }
249 
250 void MargulesVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_)
251 {
252  if ((int) id_.size() > 0) {
253  string idp = phaseNode.id();
254  if (idp != id_) {
255  throw CanteraError("MargulesVPSSTP::initThermoXML", "phasenode and Id are incompatible");
256  }
257  }
258 
259  // Find the Thermo XML node
260  if (!phaseNode.hasChild("thermo")) {
261  throw CanteraError("MargulesVPSSTP::initThermoXML",
262  "no thermo XML node");
263  }
264  XML_Node& thermoNode = phaseNode.child("thermo");
265 
266  // Make sure that the thermo model is Margules
267  if (!ba::iequals(thermoNode["model"], "margules")) {
268  throw CanteraError("MargulesVPSSTP::initThermoXML",
269  "model name isn't Margules: " + thermoNode["model"]);
270  }
271 
272  // Go get all of the coefficients and factors in the activityCoefficients
273  // XML block
274  if (thermoNode.hasChild("activityCoefficients")) {
275  XML_Node& acNode = thermoNode.child("activityCoefficients");
276  if (!ba::iequals(acNode["model"], "margules")) {
277  throw CanteraError("MargulesVPSSTP::initThermoXML",
278  "Unknown activity coefficient model: " + acNode["model"]);
279  }
280  for (size_t i = 0; i < acNode.nChildren(); i++) {
281  XML_Node& xmlACChild = acNode.child(i);
282 
283  // Process a binary salt field, or any of the other XML fields that
284  // make up the Pitzer Database. Entries will be ignored if any of
285  // the species in the entry isn't in the solution.
286  if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) {
287  readXMLBinarySpecies(xmlACChild);
288  }
289  }
290  }
291 
292  // Go down the chain
293  GibbsExcessVPSSTP::initThermoXML(phaseNode, id_);
294 }
295 
297 {
298  double T = temperature();
299  lnActCoeff_Scaled_.assign(m_kk, 0.0);
300  for (size_t i = 0; i < numBinaryInteractions_; i++) {
301  size_t iA = m_pSpecies_A_ij[i];
302  size_t iB = m_pSpecies_B_ij[i];
303  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
304  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
305  double XA = moleFractions_[iA];
306  double XB = moleFractions_[iB];
307  const doublereal XAXB = XA * XB;
308  const doublereal g0g1XB = (g0 + g1 * XB);
309  const doublereal all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
310  for (size_t iK = 0; iK < m_kk; iK++) {
311  lnActCoeff_Scaled_[iK] += all;
312  }
313  lnActCoeff_Scaled_[iA] += XB * g0g1XB;
314  lnActCoeff_Scaled_[iB] += XA * g0g1XB + XAXB * g1;
315  }
316 }
317 
319 {
320  doublereal invT = 1.0 / temperature();
321  doublereal invRTT = 1.0 / GasConstant*invT*invT;
322  dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
323  d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0);
324  for (size_t i = 0; i < numBinaryInteractions_; i++) {
325  size_t iA = m_pSpecies_A_ij[i];
326  size_t iB = m_pSpecies_B_ij[i];
327  double XA = moleFractions_[iA];
328  double XB = moleFractions_[iB];
329  double g0 = -m_HE_b_ij[i] * invRTT;
330  double g1 = -m_HE_c_ij[i] * invRTT;
331  const doublereal XAXB = XA * XB;
332  const doublereal g0g1XB = (g0 + g1 * XB);
333  const doublereal all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
334  const doublereal mult = 2.0 * invT;
335  const doublereal dT2all = mult * all;
336  for (size_t iK = 0; iK < m_kk; iK++) {
337  dlnActCoeffdT_Scaled_[iK] += all;
338  d2lnActCoeffdT2_Scaled_[iK] -= dT2all;
339  }
340  dlnActCoeffdT_Scaled_[iA] += XB * g0g1XB;
341  dlnActCoeffdT_Scaled_[iB] += XA * g0g1XB + XAXB * g1;
342  d2lnActCoeffdT2_Scaled_[iA] -= mult * XB * g0g1XB;
343  d2lnActCoeffdT2_Scaled_[iB] -= mult * (XA * g0g1XB + XAXB * g1);
344  }
345 }
346 
347 void MargulesVPSSTP::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const
348 {
350  for (size_t k = 0; k < m_kk; k++) {
351  dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k];
352  }
353 }
354 
355 void MargulesVPSSTP::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const
356 {
358  for (size_t k = 0; k < m_kk; k++) {
359  d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k];
360  }
361 }
362 
363 void MargulesVPSSTP::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
364  doublereal* dlnActCoeffds) const
365 {
366  double T = temperature();
368  for (size_t iK = 0; iK < m_kk; iK++) {
369  dlnActCoeffds[iK] = 0.0;
370  }
371 
372  for (size_t i = 0; i < numBinaryInteractions_; i++) {
373  size_t iA = m_pSpecies_A_ij[i];
374  size_t iB = m_pSpecies_B_ij[i];
375  double XA = moleFractions_[iA];
376  double XB = moleFractions_[iB];
377  double dXA = dXds[iA];
378  double dXB = dXds[iB];
379  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
380  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
381  const doublereal g02g1XB = g0 + 2*g1*XB;
382  const doublereal g2XAdXB = 2*g1*XA*dXB;
383  const doublereal all = (-XB * dXA - XA *dXB) * g02g1XB - XB *g2XAdXB;
384  for (size_t iK = 0; iK < m_kk; iK++) {
385  dlnActCoeffds[iK] += all + dlnActCoeffdT_Scaled_[iK]*dTds;
386  }
387  dlnActCoeffds[iA] += dXB * g02g1XB;
388  dlnActCoeffds[iB] += dXA * g02g1XB + g2XAdXB;
389  }
390 }
391 
393 {
394  double T = temperature();
395  dlnActCoeffdlnN_diag_.assign(m_kk, 0.0);
396 
397  for (size_t iK = 0; iK < m_kk; iK++) {
398  double XK = moleFractions_[iK];
399 
400  for (size_t i = 0; i < numBinaryInteractions_; i++) {
401  size_t iA = m_pSpecies_A_ij[i];
402  size_t iB = m_pSpecies_B_ij[i];
403  size_t delAK = 0;
404  size_t delBK = 0;
405 
406  if (iA==iK) {
407  delAK = 1;
408  } else if (iB==iK) {
409  delBK = 1;
410  }
411 
412  double XA = moleFractions_[iA];
413  double XB = moleFractions_[iB];
414 
415  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
416  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
417 
418  dlnActCoeffdlnN_diag_[iK] += 2*(delBK-XB)*(g0*(delAK-XA)+g1*(2*(delAK-XA)*XB+XA*(delBK-XB)));
419  }
421  }
422 }
423 
425 {
426  double T = temperature();
428 
429  // Loop over the activity coefficient gamma_k
430  for (size_t iK = 0; iK < m_kk; iK++) {
431  for (size_t iM = 0; iM < m_kk; iM++) {
432  double XM = moleFractions_[iM];
433  for (size_t i = 0; i < numBinaryInteractions_; i++) {
434  size_t iA = m_pSpecies_A_ij[i];
435  size_t iB = m_pSpecies_B_ij[i];
436  double delAK = 0.0;
437  double delBK = 0.0;
438  double delAM = 0.0;
439  double delBM = 0.0;
440  if (iA==iK) {
441  delAK = 1.0;
442  } else if (iB==iK) {
443  delBK = 1.0;
444  }
445  if (iA==iM) {
446  delAM = 1.0;
447  } else if (iB==iM) {
448  delBM = 1.0;
449  }
450 
451  double XA = moleFractions_[iA];
452  double XB = moleFractions_[iB];
453  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
454  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
455  dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
456  dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
457  }
458  dlnActCoeffdlnN_(iK,iM) = XM*dlnActCoeffdlnN_(iK,iM);
459  }
460  }
461 }
462 
464 {
465  doublereal T = temperature();
466  dlnActCoeffdlnX_diag_.assign(m_kk, 0.0);
467 
468  for (size_t i = 0; i < numBinaryInteractions_; i++) {
469  size_t iA = m_pSpecies_A_ij[i];
470  size_t iB = m_pSpecies_B_ij[i];
471 
472  doublereal XA = moleFractions_[iA];
473  doublereal XB = moleFractions_[iB];
474 
475  doublereal g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT();
476  doublereal g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT();
477 
478  dlnActCoeffdlnX_diag_[iA] += XA*XB*(2*g1*-2*g0-6*g1*XB);
479  dlnActCoeffdlnX_diag_[iB] += XA*XB*(2*g1*-2*g0-6*g1*XB);
480  }
481 }
482 
483 void MargulesVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const
484 {
486  for (size_t k = 0; k < m_kk; k++) {
487  dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k];
488  }
489 }
490 
491 void MargulesVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const
492 {
494  for (size_t k = 0; k < m_kk; k++) {
495  dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k];
496  }
497 }
498 
499 void MargulesVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN)
500 {
502  double* data = & dlnActCoeffdlnN_(0,0);
503  for (size_t k = 0; k < m_kk; k++) {
504  for (size_t m = 0; m < m_kk; m++) {
505  dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
506  }
507  }
508 }
509 
511 {
513  m_HE_b_ij.resize(num, 0.0);
514  m_HE_c_ij.resize(num, 0.0);
515  m_HE_d_ij.resize(num, 0.0);
516  m_SE_b_ij.resize(num, 0.0);
517  m_SE_c_ij.resize(num, 0.0);
518  m_SE_d_ij.resize(num, 0.0);
519  m_VHE_b_ij.resize(num, 0.0);
520  m_VHE_c_ij.resize(num, 0.0);
521  m_VHE_d_ij.resize(num, 0.0);
522  m_VSE_b_ij.resize(num, 0.0);
523  m_VSE_c_ij.resize(num, 0.0);
524  m_VSE_d_ij.resize(num, 0.0);
525 
526  m_pSpecies_A_ij.resize(num, npos);
527  m_pSpecies_B_ij.resize(num, npos);
528 }
529 
531 {
532  string xname = xmLBinarySpecies.name();
533  if (xname != "binaryNeutralSpeciesParameters") {
534  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies",
535  "Incorrect name for processing this routine: " + xname);
536  }
537  vector_fp vParams;
538  string aName = xmLBinarySpecies.attrib("speciesA");
539  if (aName == "") {
540  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies", "no speciesA attrib");
541  }
542  string bName = xmLBinarySpecies.attrib("speciesB");
543  if (bName == "") {
544  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies", "no speciesB attrib");
545  }
546 
547  // Find the index of the species in the current phase. It's not an error to
548  // not find the species. What this means is that the A-B interaction
549  // referred to in this block will be ignored.
550  size_t aSpecies = speciesIndex(aName);
551  if (aSpecies == npos) {
552  return;
553  }
554  string aspName = speciesName(aSpecies);
555 
556  // @TODO Figure out what the original reason is for putting an error
557  // condition for charged species. Seems OK to me.
558  if (charge(aSpecies) != 0.0) {
559  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies",
560  "speciesA has a charge: {}", charge(aSpecies));
561  }
562  size_t bSpecies = speciesIndex(bName);
563  if (bSpecies == npos) {
564  return;
565  }
566  string bspName = speciesName(bSpecies);
567  if (charge(bSpecies) != 0.0) {
568  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies",
569  "speciesB has a charge: {}", charge(bSpecies));
570  }
571 
573  size_t iSpot = numBinaryInteractions_ - 1;
574  m_pSpecies_A_ij[iSpot] = aSpecies;
575  m_pSpecies_B_ij[iSpot] = bSpecies;
576 
577  for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) {
578  XML_Node& xmlChild = xmLBinarySpecies.child(iChild);
579  string nodeName = ba::to_lower_copy(xmlChild.name());
580 
581  // Process the binary species interaction parameters.
582  // They are in subblocks labeled:
583  // excessEnthalpy
584  // excessEntropy
585  // excessVolume_Enthalpy
586  // excessVolume_Entropy
587  // Other blocks are currently ignored.
588  // @TODO determine a policy about ignoring blocks that should or shouldn't be there.
589  if (nodeName == "excessenthalpy") {
590  // Get the string containing all of the values
591  getFloatArray(xmlChild, vParams, true, "toSI", "excessEnthalpy");
592  if (vParams.size() != 2) {
593  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies::excessEnthalpy for " + aspName
594  + "::" + bspName,
595  "wrong number of params found. Need 2");
596  }
597  m_HE_b_ij[iSpot] = vParams[0];
598  m_HE_c_ij[iSpot] = vParams[1];
599  }
600 
601  if (nodeName == "excessentropy") {
602  // Get the string containing all of the values
603  getFloatArray(xmlChild, vParams, true, "toSI", "excessEntropy");
604  if (vParams.size() != 2) {
605  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies::excessEntropy for " + aspName
606  + "::" + bspName,
607  "wrong number of params found. Need 2");
608  }
609  m_SE_b_ij[iSpot] = vParams[0];
610  m_SE_c_ij[iSpot] = vParams[1];
611  }
612 
613  if (nodeName == "excessvolume_enthalpy") {
614  // Get the string containing all of the values
615  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Enthalpy");
616  if (vParams.size() != 2) {
617  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies::excessVolume_Enthalpy for " + aspName
618  + "::" + bspName,
619  "wrong number of params found. Need 2");
620  }
621  m_VHE_b_ij[iSpot] = vParams[0];
622  m_VHE_c_ij[iSpot] = vParams[1];
623  }
624 
625  if (nodeName == "excessvolume_entropy") {
626  // Get the string containing all of the values
627  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Entropy");
628  if (vParams.size() != 2) {
629  throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies::excessVolume_Entropy for " + aspName
630  + "::" + bspName,
631  "wrong number of params found. Need 2");
632  }
633  m_VSE_b_ij[iSpot] = vParams[0];
634  m_VSE_c_ij[iSpot] = vParams[1];
635  }
636  }
637 }
638 
639 }
int formMargules_
form of the Margules interaction expression
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
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
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".
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
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...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary 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 speciesIndex(const std::string &name) const
Returns the index of a species named &#39;name&#39; within the Phase object.
Definition: Phase.cpp:251
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...
vector_fp m_HE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy 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...
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:262
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 resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
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:809
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
vector_fp m_SE_d_ij
Entropy term for the quaternary 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 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.
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...
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:267
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.
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...
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
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.
vector_fp m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Margules approximation for th...
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.
int formTempModel_
form of the temperature dependence of the Margules interaction expression
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:784
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:220
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
Namespace for the Cantera kernel.
Definition: application.cpp:29
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...
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 ...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.