Cantera  2.3.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 }
23 
25  const std::string& id_) :
26  numBinaryInteractions_(0),
27  formMargules_(0),
28  formTempModel_(0)
29 {
30  initThermoFile(inputFile, id_);
31 }
32 
34  const std::string& id_) :
35  numBinaryInteractions_(0),
36  formMargules_(0),
37  formTempModel_(0)
38 {
39  importPhase(phaseRoot, this);
40 }
41 
43 {
44  PhaseCombo_Interaction::operator=(b);
45 }
46 
47 PhaseCombo_Interaction& PhaseCombo_Interaction::operator=(const PhaseCombo_Interaction& b)
48 {
49  if (&b == this) {
50  return *this;
51  }
52 
53  GibbsExcessVPSSTP::operator=(b);
54 
55  numBinaryInteractions_ = b.numBinaryInteractions_;
56  m_HE_b_ij = b.m_HE_b_ij;
57  m_HE_c_ij = b.m_HE_c_ij;
58  m_HE_d_ij = b.m_HE_d_ij;
59  m_SE_b_ij = b.m_SE_b_ij;
60  m_SE_c_ij = b.m_SE_c_ij;
61  m_SE_d_ij = b.m_SE_d_ij;
62  m_VHE_b_ij = b.m_VHE_b_ij;
63  m_VHE_c_ij = b.m_VHE_c_ij;
64  m_VHE_d_ij = b.m_VHE_d_ij;
65  m_VSE_b_ij = b.m_VSE_b_ij;
66  m_VSE_c_ij = b.m_VSE_c_ij;
67  m_VSE_d_ij = b.m_VSE_d_ij;
68  m_pSpecies_A_ij = b.m_pSpecies_A_ij;
69  m_pSpecies_B_ij = b.m_pSpecies_B_ij;
70  formMargules_ = b.formMargules_;
71  formTempModel_ = b.formTempModel_;
72 
73  return *this;
74 }
75 
77 {
78  return new PhaseCombo_Interaction(*this);
79 }
80 
81 // -------------- Utilities -------------------------------
82 
84 {
85  warn_deprecated("PhaseCombo_Interaction::eosType",
86  "To be removed after Cantera 2.3.");
87  return cPhaseCombo_Interaction;
88 }
89 
90 // - Activities, Standard States, Activity Concentrations -----------
91 
93 {
94  // Update the activity coefficients
96 
97  // take the exp of the internally stored coefficients.
98  for (size_t k = 0; k < m_kk; k++) {
99  ac[k] = exp(lnActCoeff_Scaled_[k]);
100  }
101 }
102 
103 // ------------ Partial Molar Properties of the Solution ------------
104 
106 {
107  // First get the standard chemical potentials in molar form. This requires
108  // updates of standard state as a function of T and P
110  // Update the activity coefficients
112 
113  for (size_t k = 0; k < m_kk; k++) {
114  double xx = std::max(moleFractions_[k], SmallNumber);
115  mu[k] += RT() * (log(xx) + lnActCoeff_Scaled_[k]);
116  }
117 }
118 
120 {
121  double h = 0;
122  vector_fp hbar(m_kk);
123  getPartialMolarEnthalpies(&hbar[0]);
124  for (size_t i = 0; i < m_kk; i++) {
125  h += moleFractions_[i]*hbar[i];
126  }
127  return h;
128 }
129 
131 {
132  double s = 0;
133  vector_fp sbar(m_kk);
134  getPartialMolarEntropies(&sbar[0]);
135  for (size_t i = 0; i < m_kk; i++) {
136  s += moleFractions_[i]*sbar[i];
137  }
138  return s;
139 }
140 
142 {
143  double cp = 0;
144  vector_fp cpbar(m_kk);
145  getPartialMolarCp(&cpbar[0]);
146  for (size_t i = 0; i < m_kk; i++) {
147  cp += moleFractions_[i]*cpbar[i];
148  }
149  return cp;
150 }
151 
153 {
154  return cp_mole() - GasConstant;
155 }
156 
158 {
159  // Get the nondimensional standard state enthalpies
160  getEnthalpy_RT(hbar);
161  // dimensionalize it.
162  double T = temperature();
163  for (size_t k = 0; k < m_kk; k++) {
164  hbar[k] *= GasConstant * T;
165  }
166 
167  // Update the activity coefficients, This also update the internally stored
168  // molalities.
171  for (size_t k = 0; k < m_kk; k++) {
172  hbar[k] -= GasConstant * T * T * dlnActCoeffdT_Scaled_[k];
173  }
174 }
175 
176 void PhaseCombo_Interaction::getPartialMolarCp(doublereal* cpbar) const
177 {
178  // Get the nondimensional standard state entropies
179  getCp_R(cpbar);
180  double T = temperature();
181 
182  // Update the activity coefficients, This also update the internally stored
183  // molalities.
186 
187  for (size_t k = 0; k < m_kk; k++) {
188  cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k];
189  }
190 
191  // dimensionalize it.
192  for (size_t k = 0; k < m_kk; k++) {
193  cpbar[k] *= GasConstant;
194  }
195 }
196 
198 {
199  // Get the nondimensional standard state entropies
200  getEntropy_R(sbar);
201  double T = temperature();
202 
203  // Update the activity coefficients, This also update the internally stored
204  // molalities.
207 
208  for (size_t k = 0; k < m_kk; k++) {
209  double xx = std::max(moleFractions_[k], SmallNumber);
210  sbar[k] += - lnActCoeff_Scaled_[k] - log(xx) - T * dlnActCoeffdT_Scaled_[k];
211  }
212 
213  // dimensionalize it.
214  for (size_t k = 0; k < m_kk; k++) {
215  sbar[k] *= GasConstant;
216  }
217 }
218 
220 {
221  double T = temperature();
222 
223  // Get the standard state values in m^3 kmol-1
224  getStandardVolumes(vbar);
225 
226  for (size_t iK = 0; iK < m_kk; iK++) {
227  int delAK = 0;
228  int delBK = 0;
229  for (size_t i = 0; i < numBinaryInteractions_; i++) {
230  size_t iA = m_pSpecies_A_ij[i];
231  size_t iB = m_pSpecies_B_ij[i];
232 
233  if (iA==iK) {
234  delAK = 1;
235  } else if (iB==iK) {
236  delBK = 1;
237  }
238 
239  double XA = moleFractions_[iA];
240  double XB = moleFractions_[iB];
241  double g0 = (m_VHE_b_ij[i] - T * m_VSE_b_ij[i]);
242  double g1 = (m_VHE_c_ij[i] - T * m_VSE_c_ij[i]);
243  vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
244  }
245  }
246 }
247 
249 {
250  initLengths();
252 }
253 
255 {
257 }
258 
259 void PhaseCombo_Interaction::initThermoXML(XML_Node& phaseNode, const std::string& id)
260 {
261  if ((int) id.size() > 0 && phaseNode.id() != id) {
262  throw CanteraError("PhaseCombo_Interaction::initThermoXML",
263  "phasenode and Id are incompatible");
264  }
265 
266  // Check on the thermo field. Must have:
267  // <thermo model="PhaseCombo_Interaction" />
268  if (!phaseNode.hasChild("thermo")) {
269  throw CanteraError("PhaseCombo_Interaction::initThermoXML",
270  "no thermo XML node");
271  }
272  XML_Node& thermoNode = phaseNode.child("thermo");
273  if (!ba::iequals(thermoNode["model"], "phasecombo_interaction")) {
274  throw CanteraError("PhaseCombo_Interaction::initThermoXML",
275  "model name isn't PhaseCombo_Interaction: " + thermoNode["model"]);
276  }
277 
278  // Go get all of the coefficients and factors in the activityCoefficients
279  // XML block
280  if (thermoNode.hasChild("activityCoefficients")) {
281  XML_Node& acNode = thermoNode.child("activityCoefficients");
282  if (!ba::iequals(acNode["model"], "margules")) {
283  throw CanteraError("PhaseCombo_Interaction::initThermoXML",
284  "Unknown activity coefficient model: " + acNode["model"]);
285  }
286  for (size_t i = 0; i < acNode.nChildren(); i++) {
287  XML_Node& xmlACChild = acNode.child(i);
288 
289  // Process a binary salt field, or any of the other XML fields that
290  // make up the Pitzer Database. Entries will be ignored if any of
291  // the species in the entry isn't in the solution.
292  if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) {
293  readXMLBinarySpecies(xmlACChild);
294  }
295  }
296  }
297 
298  // Go down the chain
299  GibbsExcessVPSSTP::initThermoXML(phaseNode, id);
300 }
301 
303 {
304  doublereal T = temperature();
305  lnActCoeff_Scaled_.assign(m_kk, 0.0);
306 
307  for (size_t iK = 0; iK < m_kk; iK++) {
308  // We never sample the end of the mole fraction domains
309  double xx = std::max(moleFractions_[iK], SmallNumber);
310 
311  // First wipe out the ideal solution mixing term
312  lnActCoeff_Scaled_[iK] = - log(xx);
313 
314  // Then add in the Margules interaction terms. that's it!
315  for (size_t i = 0; i < numBinaryInteractions_; i++) {
316  size_t iA = m_pSpecies_A_ij[i];
317  size_t iB = m_pSpecies_B_ij[i];
318  int delAK = 0;
319  int delBK = 0;
320  if (iA==iK) {
321  delAK = 1;
322  } else if (iB==iK) {
323  delBK = 1;
324  }
325  double XA = moleFractions_[iA];
326  double XB = moleFractions_[iB];
327  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
328  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
329  lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
330  }
331  }
332 }
333 
335 {
336  doublereal T = temperature();
337  dlnActCoeffdT_Scaled_.assign(m_kk, 0.0);
338  d2lnActCoeffdT2_Scaled_.assign(m_kk, 0.0);
339  for (size_t iK = 0; iK < m_kk; iK++) {
340  for (size_t i = 0; i < numBinaryInteractions_; i++) {
341  size_t iA = m_pSpecies_A_ij[i];
342  size_t iB = m_pSpecies_B_ij[i];
343  int delAK = 0;
344  int delBK = 0;
345  if (iA==iK) {
346  delAK = 1;
347  } else if (iB==iK) {
348  delBK = 1;
349  }
350  double XA = moleFractions_[iA];
351  double XB = moleFractions_[iB];
352  double g0 = -m_HE_b_ij[i] / (GasConstant*T*T);
353  double g1 = -m_HE_c_ij[i] / (GasConstant*T*T);
354  double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
355  dlnActCoeffdT_Scaled_[iK] += temp;
356  d2lnActCoeffdT2_Scaled_[iK] -= 2.0 * temp / T;
357  }
358  }
359 }
360 
361 void PhaseCombo_Interaction::getdlnActCoeffdT(doublereal* dlnActCoeffdT) const
362 {
364  for (size_t k = 0; k < m_kk; k++) {
365  dlnActCoeffdT[k] = dlnActCoeffdT_Scaled_[k];
366  }
367 }
368 
369 void PhaseCombo_Interaction::getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const
370 {
372  for (size_t k = 0; k < m_kk; k++) {
373  d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k];
374  }
375 }
376 
377 void PhaseCombo_Interaction::getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
378  doublereal* dlnActCoeffds) const
379 {
380  doublereal T = temperature();
382 
383  for (size_t iK = 0; iK < m_kk; iK++) {
384  // We never sample the end of the mole fraction domains
385  double xx = std::max(moleFractions_[iK], SmallNumber);
386 
387  // First wipe out the ideal solution mixing term
388  if (xx > SmallNumber) {
389  dlnActCoeffds[iK] += - 1.0 / xx;
390  }
391 
392  for (size_t i = 0; i < numBinaryInteractions_; i++) {
393  size_t iA = m_pSpecies_A_ij[i];
394  size_t iB = m_pSpecies_B_ij[i];
395  int delAK = 0;
396  int delBK = 0;
397 
398  if (iA==iK) {
399  delAK = 1;
400  } else if (iB==iK) {
401  delBK = 1;
402  }
403 
404  double XA = moleFractions_[iA];
405  double XB = moleFractions_[iB];
406  double dXA = dXds[iA];
407  double dXB = dXds[iB];
408  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
409  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
410  dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
411  + dlnActCoeffdT_Scaled_[iK]*dTds;
412  }
413  }
414 }
415 
417 {
418  doublereal T = temperature();
419  dlnActCoeffdlnN_diag_.assign(m_kk, 0.0);
420 
421  for (size_t iK = 0; iK < m_kk; iK++) {
422  double XK = moleFractions_[iK];
423  // We never sample the end of the mole fraction domains
424  double xx = std::max(moleFractions_[iK], SmallNumber);
425 
426  // First wipe out the ideal solution mixing term
427  if (xx > SmallNumber) {
428  dlnActCoeffdlnN_diag_[iK] = - 1.0 + xx;
429  }
430 
431  for (size_t i = 0; i < numBinaryInteractions_; i++) {
432  size_t iA = m_pSpecies_A_ij[i];
433  size_t iB = m_pSpecies_B_ij[i];
434  int delAK = 0;
435  int delBK = 0;
436 
437  if (iA==iK) {
438  delAK = 1;
439  } else if (iB==iK) {
440  delBK = 1;
441  }
442 
443  double XA = moleFractions_[iA];
444  double XB = moleFractions_[iB];
445  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
446  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
447  dlnActCoeffdlnN_diag_[iK] += 2*(delBK-XB)*(g0*(delAK-XA)+g1*(2*(delAK-XA)*XB+XA*(delBK-XB)));
448  }
450  }
451 }
452 
454 {
455  double T = temperature();
457 
458  // Loop over the activity coefficient gamma_k
459  for (size_t iK = 0; iK < m_kk; iK++) {
460  // We never sample the end of the mole fraction domains
461  double xx = std::max(moleFractions_[iK], SmallNumber);
462  for (size_t iM = 0; iM < m_kk; iM++) {
463  double XM = moleFractions_[iM];
464  if (xx > SmallNumber) {
465  double delKM = 0.0;
466  if (iK == iM) {
467  delKM = 1.0;
468  }
469  // this gets multiplied by XM at the bottom
470  dlnActCoeffdlnN_(iK,iM) += - delKM/XM + 1.0;
471  }
472 
473  for (size_t i = 0; i < numBinaryInteractions_; i++) {
474  size_t iA = m_pSpecies_A_ij[i];
475  size_t iB = m_pSpecies_B_ij[i];
476  double delAK = 0.0;
477  double delBK = 0.0;
478  double delAM = 0.0;
479  double delBM = 0.0;
480  if (iA==iK) {
481  delAK = 1.0;
482  } else if (iB==iK) {
483  delBK = 1.0;
484  }
485  if (iA==iM) {
486  delAM = 1.0;
487  } else if (iB==iM) {
488  delBM = 1.0;
489  }
490 
491  double XA = moleFractions_[iA];
492  double XB = moleFractions_[iB];
493  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant*T);
494  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant*T);
495  dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
496  dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
497  }
498  dlnActCoeffdlnN_(iK,iM) = XM * dlnActCoeffdlnN_(iK,iM);
499  }
500  }
501 }
502 
504 {
505  doublereal T = temperature();
506  dlnActCoeffdlnX_diag_.assign(m_kk, 0.0);
507  for (size_t i = 0; i < numBinaryInteractions_; i++) {
508  size_t iA = m_pSpecies_A_ij[i];
509  size_t iB = m_pSpecies_B_ij[i];
510 
511  double XA = moleFractions_[iA];
512  double XB = moleFractions_[iB];
513 
514  double g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / (GasConstant * T);
515  double g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / (GasConstant * T);
516 
517  dlnActCoeffdlnX_diag_[iA] += XA*XB*(2*g1*-2*g0-6*g1*XB);
518  dlnActCoeffdlnX_diag_[iB] += XA*XB*(2*g1*-2*g0-6*g1*XB);
519  }
520  throw CanteraError("PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag", "unimplemented");
521 }
522 
523 void PhaseCombo_Interaction::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const
524 {
526  for (size_t k = 0; k < m_kk; k++) {
527  dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k];
528  }
529 }
530 
531 void PhaseCombo_Interaction::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const
532 {
534  for (size_t k = 0; k < m_kk; k++) {
535  dlnActCoeffdlnX_diag[k] = dlnActCoeffdlnX_diag_[k];
536  }
537 }
538 
539 void PhaseCombo_Interaction::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN)
540 {
542  double* data = & dlnActCoeffdlnN_(0,0);
543  for (size_t k = 0; k < m_kk; k++) {
544  for (size_t m = 0; m < m_kk; m++) {
545  dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
546  }
547  }
548 }
549 
551 {
553  m_HE_b_ij.resize(num, 0.0);
554  m_HE_c_ij.resize(num, 0.0);
555  m_HE_d_ij.resize(num, 0.0);
556  m_SE_b_ij.resize(num, 0.0);
557  m_SE_c_ij.resize(num, 0.0);
558  m_SE_d_ij.resize(num, 0.0);
559  m_VHE_b_ij.resize(num, 0.0);
560  m_VHE_c_ij.resize(num, 0.0);
561  m_VHE_d_ij.resize(num, 0.0);
562  m_VSE_b_ij.resize(num, 0.0);
563  m_VSE_c_ij.resize(num, 0.0);
564  m_VSE_d_ij.resize(num, 0.0);
565  m_pSpecies_A_ij.resize(num, npos);
566  m_pSpecies_B_ij.resize(num, npos);
567 }
568 
570 {
571  string xname = xmLBinarySpecies.name();
572  if (xname != "binaryNeutralSpeciesParameters") {
573  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies",
574  "Incorrect name for processing this routine: " + xname);
575  }
576  vector_fp vParams;
577  string iName = xmLBinarySpecies.attrib("speciesA");
578  if (iName == "") {
579  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "no speciesA attrib");
580  }
581  string jName = xmLBinarySpecies.attrib("speciesB");
582  if (jName == "") {
583  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "no speciesB attrib");
584  }
585 
586  // Find the index of the species in the current phase. It's not an error to
587  // not find the species
588  size_t iSpecies = speciesIndex(iName);
589  if (iSpecies == npos) {
590  return;
591  }
592  string ispName = speciesName(iSpecies);
593  if (charge(iSpecies) != 0) {
594  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "speciesA charge problem");
595  }
596  size_t jSpecies = speciesIndex(jName);
597  if (jSpecies == npos) {
598  return;
599  }
600  string jspName = speciesName(jSpecies);
601  if (charge(jSpecies) != 0) {
602  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "speciesB charge problem");
603  }
604 
606  size_t iSpot = numBinaryInteractions_ - 1;
607  m_pSpecies_A_ij[iSpot] = iSpecies;
608  m_pSpecies_B_ij[iSpot] = jSpecies;
609 
610  for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) {
611  XML_Node& xmlChild = xmLBinarySpecies.child(iChild);
612  string nodeName = ba::to_lower_copy(xmlChild.name());
613 
614  // Process the binary species interaction child elements
615  if (nodeName == "excessenthalpy") {
616  // Get the string containing all of the values
617  getFloatArray(xmlChild, vParams, true, "toSI", "excessEnthalpy");
618  if (vParams.size() != 2) {
619  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessEnthalpy for " + ispName
620  + "::" + jspName,
621  "wrong number of params found");
622  }
623  m_HE_b_ij[iSpot] = vParams[0];
624  m_HE_c_ij[iSpot] = vParams[1];
625  }
626 
627  if (nodeName == "excessentropy") {
628  // Get the string containing all of the values
629  getFloatArray(xmlChild, vParams, true, "toSI", "excessEntropy");
630  if (vParams.size() != 2) {
631  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessEntropy for " + ispName
632  + "::" + jspName,
633  "wrong number of params found");
634  }
635  m_SE_b_ij[iSpot] = vParams[0];
636  m_SE_c_ij[iSpot] = vParams[1];
637  }
638 
639  if (nodeName == "excessvolume_enthalpy") {
640  // Get the string containing all of the values
641  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Enthalpy");
642  if (vParams.size() != 2) {
643  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
644  + "::" + jspName,
645  "wrong number of params found");
646  }
647  m_VHE_b_ij[iSpot] = vParams[0];
648  m_VHE_c_ij[iSpot] = vParams[1];
649  }
650 
651  if (nodeName == "excessvolume_entropy") {
652  // Get the string containing all of the values
653  getFloatArray(xmlChild, vParams, true, "toSI", "excessVolume_Entropy");
654  if (vParams.size() != 2) {
655  throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
656  + "::" + jspName,
657  "wrong number of params found");
658  }
659  m_VSE_b_ij[iSpot] = vParams[0];
660  m_VSE_c_ij[iSpot] = vParams[1];
661  }
662  }
663 }
664 
665 }
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...
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
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
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
int formTempModel_
form of the temperature dependence of the Margules interaction expression
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 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 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.
int formMargules_
form of the Margules interaction expression
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:809
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual 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:267
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
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
std::string id() const
Return the string id for the phase.
Definition: Phase.cpp:141
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
PhaseCombo_Interaction is a derived class of GibbsExcessVPSSTP that employs the Margules approximatio...
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
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
Contains declarations for string manipulation functions within Cantera.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
doublereal size(size_t k) const
This routine returns the size of species k.
Definition: Phase.h:414
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: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
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 ...
virtual int eosType() const
Equation of state type flag.