Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MolalityVPSSTP.cpp
Go to the documentation of this file.
1 /**
2  * @file MolalityVPSSTP.cpp
3  * Definitions for intermediate ThermoPhase object for phases which
4  * employ molality based activity coefficient formulations
5  * (see \ref thermoprops
6  * and class \link Cantera::MolalityVPSSTP MolalityVPSSTP\endlink).
7  *
8  * Header file for a derived class of ThermoPhase that handles
9  * variable pressure standard state methods for calculating
10  * thermodynamic properties that are further based upon activities
11  * based on the molality scale. These include most of the methods for
12  * calculating liquid electrolyte thermodynamics.
13  */
14 /*
15  * Copyright (2005) Sandia Corporation. Under the terms of
16  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
17  * U.S. Government retains certain rights in this software.
18  */
21 #include "cantera/base/ctml.h"
22 #include "cantera/base/utilities.h"
23 
24 #include <fstream>
25 
26 using namespace std;
27 
28 namespace Cantera
29 {
30 
31 MolalityVPSSTP::MolalityVPSSTP() :
32  m_indexSolvent(0),
33  m_pHScalingType(PHSCALE_PITZER),
34  m_indexCLM(npos),
35  m_weightSolvent(18.01528),
36  m_xmolSolventMIN(0.01),
37  m_Mnaught(18.01528E-3)
38 {
39  /*
40  * Change the default to be that charge neutrality in the
41  * phase is necessary condition for the proper specification
42  * of thermodynamic functions within the phase
43  */
45 }
46 
48  m_indexSolvent(b.m_indexSolvent),
49  m_pHScalingType(b.m_pHScalingType),
50  m_indexCLM(b.m_indexCLM),
51  m_xmolSolventMIN(b.m_xmolSolventMIN),
52  m_Mnaught(b.m_Mnaught),
53  m_molalities(b.m_molalities)
54 {
55  *this = b;
56 }
57 
59 {
60  if (&b != this) {
67  m_Mnaught = b.m_Mnaught;
69  }
70  return *this;
71 }
72 
74 {
75  return new MolalityVPSSTP(*this);
76 }
77 
78 /*
79  * -------------- Utilities -------------------------------
80  */
81 
82 void MolalityVPSSTP::setpHScale(const int pHscaleType)
83 {
84  m_pHScalingType = pHscaleType;
85  if (pHscaleType != PHSCALE_PITZER && pHscaleType != PHSCALE_NBS) {
86  throw CanteraError("MolalityVPSSTP::setpHScale",
87  "Unknown scale type: " + int2str(pHscaleType));
88  }
89 }
90 
92 {
93  return m_pHScalingType;
94 }
95 
97 {
98  if (k >= m_kk) {
99  throw CanteraError("MolalityVPSSTP::setSolute ",
100  "bad value");
101  }
102  m_indexSolvent = k;
103  AssertThrowMsg(m_indexSolvent==0, "MolalityVPSSTP::setSolvent",
104  "Molality-based methods limit solvent id to being 0");
106  m_Mnaught = m_weightSolvent / 1000.;
107 }
108 
110 {
111  return m_indexSolvent;
112 }
113 
114 void MolalityVPSSTP::setMoleFSolventMin(doublereal xmolSolventMIN)
115 {
116  if (xmolSolventMIN <= 0.0) {
117  throw CanteraError("MolalityVPSSTP::setSolute ", "trouble");
118  } else if (xmolSolventMIN > 0.9) {
119  throw CanteraError("MolalityVPSSTP::setSolute ", "trouble");
120  }
121  m_xmolSolventMIN = xmolSolventMIN;
122 }
123 
125 {
126  return m_xmolSolventMIN;
127 }
128 
130 {
132  double xmolSolvent = std::max(m_molalities[m_indexSolvent], m_xmolSolventMIN);
133  double denomInv = 1.0/ (m_Mnaught * xmolSolvent);
134  for (size_t k = 0; k < m_kk; k++) {
135  m_molalities[k] *= denomInv;
136  }
137 }
138 
139 void MolalityVPSSTP::getMolalities(doublereal* const molal) const
140 {
141  calcMolalities();
142  for (size_t k = 0; k < m_kk; k++) {
143  molal[k] = m_molalities[k];
144  }
145 }
146 
147 void MolalityVPSSTP::setMolalities(const doublereal* const molal)
148 {
149  double Lsum = 1.0 / m_Mnaught;
150  for (size_t k = 1; k < m_kk; k++) {
151  m_molalities[k] = molal[k];
152  Lsum += molal[k];
153  }
154  double tmp = 1.0 / Lsum;
156  double sum = m_molalities[m_indexSolvent];
157  for (size_t k = 1; k < m_kk; k++) {
158  m_molalities[k] = tmp * molal[k];
159  sum += m_molalities[k];
160  }
161  if (sum != 1.0) {
162  tmp = 1.0 / sum;
163  for (size_t k = 0; k < m_kk; k++) {
164  m_molalities[k] *= tmp;
165  }
166  }
168  /*
169  * Essentially we don't trust the input: We calculate
170  * the molalities from the mole fractions that we
171  * just obtained.
172  */
173  calcMolalities();
174 }
175 
177 {
178  /*
179  * HKM -> Might need to be more complicated here, setting
180  * neutrals so that the existing mole fractions are
181  * preserved.
182  */
183  /*
184  * Get a vector of mole fractions
185  */
186  vector_fp mf(m_kk, 0.0);
188  double xmolSmin = std::max(mf[m_indexSolvent], m_xmolSolventMIN);
189  for (size_t k = 0; k < m_kk; k++) {
190  double mol_k = getValue(mMap, speciesName(k), 0.0);
191  if (mol_k > 0) {
192  mf[k] = mol_k * m_Mnaught * xmolSmin;
193  }
194  }
195  /*
196  * check charge neutrality
197  */
198  size_t largePos = npos;
199  double cPos = 0.0;
200  size_t largeNeg = npos;
201  double cNeg = 0.0;
202  double sum = 0.0;
203  for (size_t k = 0; k < m_kk; k++) {
204  double ch = charge(k);
205  if (mf[k] > 0.0) {
206  if (ch > 0.0) {
207  if (ch * mf[k] > cPos) {
208  largePos = k;
209  cPos = ch * mf[k];
210  }
211  }
212  if (ch < 0.0) {
213  if (fabs(ch) * mf[k] > cNeg) {
214  largeNeg = k;
215  cNeg = fabs(ch) * mf[k];
216  }
217  }
218  }
219  sum += mf[k] * ch;
220  }
221  if (sum != 0.0) {
222  if (sum > 0.0) {
223  if (cPos > sum) {
224  mf[largePos] -= sum / charge(largePos);
225  } else {
226  throw CanteraError("MolalityVPSSTP:setMolalitiesbyName",
227  "unbalanced charges");
228  }
229  } else {
230  if (cNeg > (-sum)) {
231  mf[largeNeg] -= (-sum) / fabs(charge(largeNeg));
232  } else {
233  throw CanteraError("MolalityVPSSTP:setMolalitiesbyName",
234  "unbalanced charges");
235  }
236  }
237 
238  }
239  sum = 0.0;
240  for (size_t k = 0; k < m_kk; k++) {
241  sum += mf[k];
242  }
243  sum = 1.0/sum;
244  for (size_t k = 0; k < m_kk; k++) {
245  mf[k] *= sum;
246  }
248  /*
249  * After we formally set the mole fractions, we
250  * calculate the molalities again and store it in
251  * this object.
252  */
253  calcMolalities();
254 }
255 
256 void MolalityVPSSTP::setMolalitiesByName(const std::string& x)
257 {
260 }
261 
262 /*
263  * - Activities, Standard States, Activity Concentrations -----------
264  */
265 
267 {
269 }
270 
272 {
273  throw NotImplementedError("MolalityVPSSTP::getActivityConcentrations");
274 }
275 
276 doublereal MolalityVPSSTP::standardConcentration(size_t k) const
277 {
278  throw NotImplementedError("MolalityVPSSTP::standardConcentration");
279 }
280 
281 void MolalityVPSSTP::getActivities(doublereal* ac) const
282 {
283  throw NotImplementedError("MolalityVPSSTP::getActivities");
284 }
285 
286 void MolalityVPSSTP::getActivityCoefficients(doublereal* ac) const
287 {
289  AssertThrow(m_indexSolvent==0, "MolalityVPSSTP::getActivityCoefficients");
290  double xmolSolvent = std::max(moleFraction(m_indexSolvent), m_xmolSolventMIN);
291  for (size_t k = 1; k < m_kk; k++) {
292  ac[k] /= xmolSolvent;
293  }
294 }
295 
296 void MolalityVPSSTP::getMolalityActivityCoefficients(doublereal* acMolality) const
297 {
299  applyphScale(acMolality);
300 }
301 
303 {
304  /*
305  * First, we calculate the activities all over again
306  */
307  vector_fp act(m_kk);
308  getActivities(DATA_PTR(act));
309  /*
310  * Then, we calculate the sum of the solvent molalities
311  */
312  double sum = 0;
313  for (size_t k = 1; k < m_kk; k++) {
314  sum += std::max(m_molalities[k], 0.0);
315  }
316  double oc = 1.0;
317  if (sum > 1.0E-200) {
318  oc = - log(act[m_indexSolvent]) / (m_Mnaught * sum);
319  }
320  return oc;
321 }
322 
324 {
325  getChemPotentials(mu);
326  double ve = Faraday * electricPotential();
327  for (size_t k = 0; k < m_kk; k++) {
328  mu[k] += ve*charge(k);
329  }
330 }
331 
332 void MolalityVPSSTP::getUnitsStandardConc(double* uA, int k, int sizeUA) const
333 {
334  warn_deprecated("MolalityVPSSTP::getUnitsStandardConc",
335  "To be removed after Cantera 2.2.");
336 
337  for (int i = 0; i < sizeUA; i++) {
338  if (i == 0) {
339  uA[0] = 1.0;
340  }
341  if (i == 1) {
342  uA[1] = -int(nDim());
343  }
344  if (i == 2) {
345  uA[2] = 0.0;
346  }
347  if (i == 3) {
348  uA[3] = 0.0;
349  }
350  if (i == 4) {
351  uA[4] = 0.0;
352  }
353  if (i == 5) {
354  uA[5] = 0.0;
355  }
356  }
357 }
358 
359 void MolalityVPSSTP::setToEquilState(const doublereal* lambda_RT)
360 {
362  throw NotImplementedError("MolalityVPSSTP::setToEquilState");
363 }
364 
366 {
368  string comp = getChildValue(state,"soluteMolalities");
369  if (comp != "") {
370  setMolalitiesByName(comp);
371  }
372  if (state.hasChild("pressure")) {
373  double p = getFloat(state, "pressure", "pressure");
374  setPressure(p);
375  }
376 }
377 
378 void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p,
379  const doublereal* const molalities)
380 {
381  setMolalities(molalities);
382  setState_TP(t, p);
383 }
384 
385 void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p, const compositionMap& m)
386 {
388  setState_TP(t, p);
389 }
390 
391 void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p, const std::string& m)
392 {
394  setState_TP(t, p);
395 }
396 
397 
399 {
400  initLengths();
402 
403  /*
404  * The solvent defaults to species 0
405  */
406  setSolvent(0);
407  /*
408  * Find the Cl- species
409  */
411 }
412 
414 {
415  throw NotImplementedError("MolalityVPSSTP::getUnscaledMolalityActivityCoefficients");
416 }
417 
418 void MolalityVPSSTP::applyphScale(doublereal* acMolality) const
419 {
420  throw NotImplementedError("MolalityVPSSTP::applyphScale");
421 }
422 
424 {
425  size_t indexCLM = npos;
426  size_t eCl = npos;
427  size_t eE = npos;
428  size_t ne = nElements();
429  for (size_t e = 0; e < ne; e++) {
430  string sn = elementName(e);
431  if (sn == "Cl" || sn == "CL") {
432  eCl = e;
433  break;
434  }
435  }
436  // We have failed if we can't find the Cl element index
437  if (eCl == npos) {
438  return npos;
439  }
440  for (size_t e = 0; e < ne; e++) {
441  string sn = elementName(e);
442  if (sn == "E" || sn == "e") {
443  eE = e;
444  break;
445  }
446  }
447  // We have failed if we can't find the E element index
448  if (eE == npos) {
449  return npos;
450  }
451  for (size_t k = 1; k < m_kk; k++) {
452  doublereal nCl = nAtoms(k, eCl);
453  if (nCl != 1.0) {
454  continue;
455  }
456  doublereal nE = nAtoms(k, eE);
457  if (nE != 1.0) {
458  continue;
459  }
460  for (size_t e = 0; e < ne; e++) {
461  if (e != eE && e != eCl) {
462  doublereal nA = nAtoms(k, e);
463  if (nA != 0.0) {
464  continue;
465  }
466  }
467  }
468  string sn = speciesName(k);
469  if (sn != "Cl-" && sn != "CL-") {
470  continue;
471  }
472 
473  indexCLM = k;
474  break;
475  }
476  return indexCLM;
477 }
478 
479 // Initialize lengths of local variables after all species have
480 // been identified.
482 {
483  m_molalities.resize(m_kk);
484 }
485 
486 void MolalityVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_)
487 {
488 
489  initLengths();
490  /*
491  * The solvent defaults to species 0
492  */
493  setSolvent(0);
494 
495  VPStandardStateTP::initThermoXML(phaseNode, id_);
496 }
497 
498 /**
499  * Format a summary of the mixture state for output.
500  */
501 std::string MolalityVPSSTP::report(bool show_thermo, doublereal threshold) const
502 {
503  char p[800];
504  string s = "";
505  try {
506  if (name() != "") {
507  sprintf(p, " \n %s:\n", name().c_str());
508  s += p;
509  }
510  sprintf(p, " \n temperature %12.6g K\n", temperature());
511  s += p;
512  sprintf(p, " pressure %12.6g Pa\n", pressure());
513  s += p;
514  sprintf(p, " density %12.6g kg/m^3\n", density());
515  s += p;
516  sprintf(p, " mean mol. weight %12.6g amu\n", meanMolecularWeight());
517  s += p;
518 
519  doublereal phi = electricPotential();
520  sprintf(p, " potential %12.6g V\n", phi);
521  s += p;
522 
523  vector_fp x(m_kk);
524  vector_fp molal(m_kk);
525  vector_fp mu(m_kk);
526  vector_fp muss(m_kk);
527  vector_fp acMolal(m_kk);
528  vector_fp actMolal(m_kk);
529  getMoleFractions(&x[0]);
530  getMolalities(&molal[0]);
531  getChemPotentials(&mu[0]);
532  getStandardChemPotentials(&muss[0]);
533  getMolalityActivityCoefficients(&acMolal[0]);
534  getActivities(&actMolal[0]);
535 
536  size_t iHp = speciesIndex("H+");
537  if (iHp != npos) {
538  double pH = -log(actMolal[iHp]) / log(10.0);
539  sprintf(p, " pH %12.4g \n", pH);
540  s += p;
541  }
542 
543  if (show_thermo) {
544  sprintf(p, " \n");
545  s += p;
546  sprintf(p, " 1 kg 1 kmol\n");
547  s += p;
548  sprintf(p, " ----------- ------------\n");
549  s += p;
550  sprintf(p, " enthalpy %12.6g %12.4g J\n",
552  s += p;
553  sprintf(p, " internal energy %12.6g %12.4g J\n",
555  s += p;
556  sprintf(p, " entropy %12.6g %12.4g J/K\n",
558  s += p;
559  sprintf(p, " Gibbs function %12.6g %12.4g J\n",
560  gibbs_mass(), gibbs_mole());
561  s += p;
562  sprintf(p, " heat capacity c_p %12.6g %12.4g J/K\n",
563  cp_mass(), cp_mole());
564  s += p;
565  try {
566  sprintf(p, " heat capacity c_v %12.6g %12.4g J/K\n",
567  cv_mass(), cv_mole());
568  s += p;
569  } catch (CanteraError& e) {
570  e.save();
571  sprintf(p, " heat capacity c_v <not implemented> \n");
572  s += p;
573  }
574  }
575 
576  sprintf(p, " \n");
577  s += p;
578  int nMinor = 0;
579  doublereal xMinor = 0.0;
580  if (show_thermo) {
581  sprintf(p, " X "
582  " Molalities Chem.Pot. ChemPotSS ActCoeffMolal\n");
583  s += p;
584  sprintf(p, " "
585  " (J/kmol) (J/kmol) \n");
586  s += p;
587  sprintf(p, " ------------- "
588  " ------------ ------------ ------------ ------------\n");
589  s += p;
590  for (size_t k = 0; k < m_kk; k++) {
591  if (x[k] > threshold) {
592  if (x[k] > SmallNumber) {
593  sprintf(p, "%18s %12.6g %12.6g %12.6g %12.6g %12.6g\n",
594  speciesName(k).c_str(), x[k], molal[k], mu[k], muss[k], acMolal[k]);
595  } else {
596  sprintf(p, "%18s %12.6g %12.6g N/A %12.6g %12.6g \n",
597  speciesName(k).c_str(), x[k], molal[k], muss[k], acMolal[k]);
598  }
599  s += p;
600  } else {
601  nMinor++;
602  xMinor += x[k];
603  }
604  }
605  } else {
606  sprintf(p, " X"
607  "Molalities\n");
608  s += p;
609  sprintf(p, " -------------"
610  " ------------\n");
611  s += p;
612  for (size_t k = 0; k < m_kk; k++) {
613  if (x[k] > threshold) {
614  sprintf(p, "%18s %12.6g %12.6g\n",
615  speciesName(k).c_str(), x[k], molal[k]);
616  s += p;
617  } else {
618  nMinor++;
619  xMinor += x[k];
620  }
621  }
622  }
623  if (nMinor) {
624  sprintf(p, " [%+5i minor] %12.6g\n", nMinor, xMinor);
625  s += p;
626  }
627  } catch (CanteraError& err) {
628  err.save();
629  }
630  return s;
631 }
632 
633 void MolalityVPSSTP::getCsvReportData(std::vector<std::string>& names,
634  std::vector<vector_fp>& data) const
635 {
636  names.clear();
637  data.assign(10, vector_fp(nSpecies()));
638 
639  names.push_back("X");
640  getMoleFractions(&data[0][0]);
641 
642  names.push_back("Molal");
643  getMolalities(&data[1][0]);
644 
645  names.push_back("Chem. Pot. (J/kmol)");
646  getChemPotentials(&data[2][0]);
647 
648  names.push_back("Chem. Pot. SS (J/kmol)");
649  getStandardChemPotentials(&data[3][0]);
650 
651  names.push_back("Molal Act. Coeff.");
652  getMolalityActivityCoefficients(&data[4][0]);
653 
654  names.push_back("Molal Activity");
655  getActivities(&data[5][0]);
656 
657  names.push_back("Part. Mol Enthalpy (J/kmol)");
658  getPartialMolarEnthalpies(&data[5][0]);
659 
660  names.push_back("Part. Mol. Entropy (J/K/kmol)");
661  getPartialMolarEntropies(&data[6][0]);
662 
663  names.push_back("Part. Mol. Energy (J/kmol)");
664  getPartialMolarIntEnergies(&data[7][0]);
665 
666  names.push_back("Part. Mol. Cp (J/K/kmol");
667  getPartialMolarCp(&data[8][0]);
668 
669  names.push_back("Part. Mol. Cv (J/K/kmol)");
670  getPartialMolarVolumes(&data[9][0]);
671 }
672 
673 }
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:149
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition: Phase.cpp:243
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
Definition: Phase.cpp:494
virtual doublereal density() const
Density (kg/m^3).
Definition: Phase.h:608
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:39
virtual double osmoticCoefficient() const
Calculate the osmotic coefficient.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
Definition: ThermoPhase.h:352
void initLengths()
Initialize lengths of local variables after all species have been identified.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: ThermoPhase.h:242
std::string getChildValue(const XML_Node &parent, const std::string &nameString)
This function reads a child node with the name, nameString, and returns its XML value as the return s...
Definition: ctml.cpp:142
size_t nElements() const
Number of elements.
Definition: Phase.cpp:167
void setSolvent(size_t k)
This routine sets the index number of the solvent for the phase.
virtual void applyphScale(doublereal *acMolality) const
Apply the current phScale to a set of activity Coefficients or activities.
virtual std::string report(bool show_thermo=true, doublereal threshold=1e-14) const
returns a summary of the state of the phase as a string
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:213
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
doublereal m_Mnaught
This is the multiplication factor that goes inside log expressions involving the molalities of specie...
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
void setpHScale(const int pHscaleType)
Set the pH scale, which determines the scale for single-ion activity coefficients.
size_t m_indexCLM
Index of the phScale species.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual void updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:78
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: ThermoPhase.h:628
virtual void getUnscaledMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
Definition: Phase.cpp:556
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:157
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: ThermoPhase.h:237
#define AssertThrowMsg(expr, procedure, message)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:301
Header for intermediate ThermoPhase object for phases which employ molality based activity coefficien...
doublereal intEnergy_mass() const
Specific internal energy.
Definition: ThermoPhase.h:899
VPStandardStateTP & operator=(const VPStandardStateTP &b)
Assignment operator.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
size_t solventIndex() const
Returns the solvent index.
bool m_chargeNeutralityNecessary
Boolean indicating whether a charge neutrality condition is a necessity.
Definition: ThermoPhase.h:1641
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
Definition: Phase.cpp:257
virtual void setStateFromXML(const XML_Node &state)
Set the initial state of the phase to the conditions specified in the state XML element.
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
Definition: ThermoPhase.h:232
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: ThermoPhase.h:227
doublereal gibbs_mass() const
Specific Gibbs function.
Definition: ThermoPhase.h:913
doublereal entropy_mass() const
Specific entropy.
Definition: ThermoPhase.h:906
void setMolalitiesByName(const compositionMap &xMap)
Set the molalities of a phase.
doublereal pressure() const
Returns the current pressure of the phase.
MolalityVPSSTP & operator=(const MolalityVPSSTP &b)
Assignment operator.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: ThermoPhase.h:554
doublereal cp_mass() const
Specific heat at constant pressure.
Definition: ThermoPhase.h:920
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of non-dimensional molality based activity coefficients at the current solution tempera...
virtual void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil element-potential based equilibrium solver.
const int PHSCALE_NBS
Scale to be used for evaluation of single-ion activity coefficients is that used by the NBS standard ...
#define AssertThrow(expr, procedure)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:283
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: ThermoPhase.h:597
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations that are defined such that where is a s...
const int PHSCALE_PITZER
Scale to be used for the output of single-ion activity coefficients is that used by Pitzer...
const int cAC_CONVENTION_MOLALITY
Standard state uses the molality convention.
Definition: ThermoPhase.h:26
doublereal cv_mass() const
Specific heat at constant volume.
Definition: ThermoPhase.h:927
const U & getValue(const std::map< T, U > &m, const T &key)
Const accessor for a value in a std::map.
Definition: utilities.h:714
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values There is no restriction on the sum of the mole fractio...
Definition: Phase.cpp:331
int m_pHScalingType
Scaling to be used for output of single-ion species activity coefficients.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:563
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
Definition: ThermoPhase.h:607
virtual size_t findCLMIndex() const
Returns the index of the Cl- species.
void setMolalities(const doublereal *const molal)
Set the molalities of the solutes in a phase.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: ThermoPhase.h:252
void setState_TPM(doublereal t, doublereal p, const doublereal *const molalities)
Set the temperature (K), pressure (Pa), and molalities (gmol kg-1) of the solutes.
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:265
compositionMap parseCompString(const std::string &ss, const std::vector< std::string > &names)
Parse a composition string into a map consisting of individual key:composition pairs.
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
Definition: Phase.cpp:278
doublereal moleFSolventMin() const
Returns the minimum mole fraction in the molality formulation.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition: Phase.cpp:561
doublereal temperature() const
Temperature (K).
Definition: Phase.h:602
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
Definition: Phase.h:586
void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.
vector_fp m_molalities
Current value of the molalities of the species in the phase.
const doublereal SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:126
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
doublereal enthalpy_mass() const
Specific enthalpy.
Definition: ThermoPhase.h:892
virtual void getCsvReportData(std::vector< std::string > &names, std::vector< vector_fp > &data) const
Fills names and data with the column names and species thermo properties to be included in the output...
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition: Phase.h:669
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Initialize a ThermoPhase object, potentially reading activity coefficient information from an XML dat...
void getMolalities(doublereal *const molal) const
This function will return the molalities of the species.
Contains declarations for string manipulation functions within Cantera.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:194
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
Definition: ct_defs.h:36
doublereal m_weightSolvent
Molecular weight of the Solvent.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
std::string elementName(size_t m) const
Name of the element with index m.
Definition: Phase.cpp:186
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: ThermoPhase.h:587
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: ThermoPhase.h:247
size_t m_kk
Number of species in the phase.
Definition: Phase.h:843
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: ThermoPhase.h:618
int activityConvention() const
This method returns the activity convention.
int pHScale() const
Reports the pH scale, which determines the scale for single-ion activity coefficients.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity.
size_t m_indexSolvent
Index of the solvent.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
MolalityVPSSTP()
Default Constructor.
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:272
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and generalized concentrations Note they have the same units...
virtual void setState_TP(doublereal T, doublereal pres)
Set the temperature and pressure at the same time.
void setMoleFSolventMin(doublereal xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.
virtual doublereal standardConcentration(size_t k=0) const
The standard concentration used to normalize the generalized concentration.
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:578
void save()
Function to put this error onto Cantera's error stack.