Cantera  2.3.0
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 
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 
14 #include "cantera/base/ctml.h"
15 #include "cantera/base/utilities.h"
16 
17 #include <fstream>
18 
19 using namespace std;
20 
21 namespace Cantera
22 {
23 
24 MolalityVPSSTP::MolalityVPSSTP() :
25  m_indexSolvent(0),
26  m_pHScalingType(PHSCALE_PITZER),
27  m_indexCLM(npos),
28  m_weightSolvent(18.01528),
29  m_xmolSolventMIN(0.01),
30  m_Mnaught(18.01528E-3)
31 {
32  // Change the default to be that charge neutrality in the phase is necessary
33  // condition for the proper specification of thermodynamic functions within
34  // the phase
36 }
37 
39  m_indexSolvent(b.m_indexSolvent),
40  m_pHScalingType(b.m_pHScalingType),
41  m_indexCLM(b.m_indexCLM),
42  m_xmolSolventMIN(b.m_xmolSolventMIN),
43  m_Mnaught(b.m_Mnaught),
44  m_molalities(b.m_molalities)
45 {
46  *this = b;
47 }
48 
49 MolalityVPSSTP& MolalityVPSSTP::operator=(const MolalityVPSSTP& b)
50 {
51  if (&b != this) {
52  VPStandardStateTP::operator=(b);
53  m_indexSolvent = b.m_indexSolvent;
54  m_pHScalingType = b.m_pHScalingType;
55  m_indexCLM = b.m_indexCLM;
56  m_weightSolvent = b.m_weightSolvent;
57  m_xmolSolventMIN = b.m_xmolSolventMIN;
58  m_Mnaught = b.m_Mnaught;
59  m_molalities = b.m_molalities;
60  }
61  return *this;
62 }
63 
65 {
66  return new MolalityVPSSTP(*this);
67 }
68 
69 // -------------- Utilities -------------------------------
70 
71 void MolalityVPSSTP::setpHScale(const int pHscaleType)
72 {
73  m_pHScalingType = pHscaleType;
74  if (pHscaleType != PHSCALE_PITZER && pHscaleType != PHSCALE_NBS) {
75  throw CanteraError("MolalityVPSSTP::setpHScale",
76  "Unknown scale type: {}", pHscaleType);
77  }
78 }
79 
81 {
82  return m_pHScalingType;
83 }
84 
86 {
87  if (k >= m_kk) {
88  throw CanteraError("MolalityVPSSTP::setSolute ",
89  "bad value");
90  }
91  m_indexSolvent = k;
92  AssertThrowMsg(m_indexSolvent==0, "MolalityVPSSTP::setSolvent",
93  "Molality-based methods limit solvent id to being 0");
95  m_Mnaught = m_weightSolvent / 1000.;
96 }
97 
99 {
100  return m_indexSolvent;
101 }
102 
103 void MolalityVPSSTP::setMoleFSolventMin(doublereal xmolSolventMIN)
104 {
105  if (xmolSolventMIN <= 0.0) {
106  throw CanteraError("MolalityVPSSTP::setSolute ", "trouble");
107  } else if (xmolSolventMIN > 0.9) {
108  throw CanteraError("MolalityVPSSTP::setSolute ", "trouble");
109  }
110  m_xmolSolventMIN = xmolSolventMIN;
111 }
112 
114 {
115  return m_xmolSolventMIN;
116 }
117 
119 {
121  double xmolSolvent = std::max(m_molalities[m_indexSolvent], m_xmolSolventMIN);
122  double denomInv = 1.0/ (m_Mnaught * xmolSolvent);
123  for (size_t k = 0; k < m_kk; k++) {
124  m_molalities[k] *= denomInv;
125  }
126 }
127 
128 void MolalityVPSSTP::getMolalities(doublereal* const molal) const
129 {
130  calcMolalities();
131  for (size_t k = 0; k < m_kk; k++) {
132  molal[k] = m_molalities[k];
133  }
134 }
135 
136 void MolalityVPSSTP::setMolalities(const doublereal* const molal)
137 {
138  double Lsum = 1.0 / m_Mnaught;
139  for (size_t k = 1; k < m_kk; k++) {
140  m_molalities[k] = molal[k];
141  Lsum += molal[k];
142  }
143  double tmp = 1.0 / Lsum;
145  double sum = m_molalities[m_indexSolvent];
146  for (size_t k = 1; k < m_kk; k++) {
147  m_molalities[k] = tmp * molal[k];
148  sum += m_molalities[k];
149  }
150  if (sum != 1.0) {
151  tmp = 1.0 / sum;
152  for (size_t k = 0; k < m_kk; k++) {
153  m_molalities[k] *= tmp;
154  }
155  }
157 
158  // Essentially we don't trust the input: We calculate the molalities from
159  // the mole fractions that we just obtained.
160  calcMolalities();
161 }
162 
164 {
165  // HKM -> Might need to be more complicated here, setting neutrals so that
166  // the existing mole fractions are preserved.
167 
168  // Get a vector of mole fractions
169  vector_fp mf(m_kk, 0.0);
170  getMoleFractions(mf.data());
171  double xmolSmin = std::max(mf[m_indexSolvent], m_xmolSolventMIN);
172  for (size_t k = 0; k < m_kk; k++) {
173  double mol_k = getValue(mMap, speciesName(k), 0.0);
174  if (mol_k > 0) {
175  mf[k] = mol_k * m_Mnaught * xmolSmin;
176  }
177  }
178 
179  // check charge neutrality
180  size_t largePos = npos;
181  double cPos = 0.0;
182  size_t largeNeg = npos;
183  double cNeg = 0.0;
184  double sum = 0.0;
185  for (size_t k = 0; k < m_kk; k++) {
186  double ch = charge(k);
187  if (mf[k] > 0.0) {
188  if (ch > 0.0 && ch * mf[k] > cPos) {
189  largePos = k;
190  cPos = ch * mf[k];
191  }
192  if (ch < 0.0 && fabs(ch) * mf[k] > cNeg) {
193  largeNeg = k;
194  cNeg = fabs(ch) * mf[k];
195  }
196  }
197  sum += mf[k] * ch;
198  }
199  if (sum != 0.0) {
200  if (sum > 0.0) {
201  if (cPos > sum) {
202  mf[largePos] -= sum / charge(largePos);
203  } else {
204  throw CanteraError("MolalityVPSSTP:setMolalitiesbyName",
205  "unbalanced charges");
206  }
207  } else {
208  if (cNeg > (-sum)) {
209  mf[largeNeg] -= (-sum) / fabs(charge(largeNeg));
210  } else {
211  throw CanteraError("MolalityVPSSTP:setMolalitiesbyName",
212  "unbalanced charges");
213  }
214  }
215  }
216  sum = 0.0;
217  for (size_t k = 0; k < m_kk; k++) {
218  sum += mf[k];
219  }
220  sum = 1.0/sum;
221  for (size_t k = 0; k < m_kk; k++) {
222  mf[k] *= sum;
223  }
224  setMoleFractions(mf.data());
225 
226  // After we formally set the mole fractions, we calculate the molalities
227  // again and store it in this object.
228  calcMolalities();
229 }
230 
231 void MolalityVPSSTP::setMolalitiesByName(const std::string& x)
232 {
235 }
236 
237 // - Activities, Standard States, Activity Concentrations -----------
238 
240 {
242 }
243 
245 {
246  throw NotImplementedError("MolalityVPSSTP::getActivityConcentrations");
247 }
248 
249 doublereal MolalityVPSSTP::standardConcentration(size_t k) const
250 {
251  throw NotImplementedError("MolalityVPSSTP::standardConcentration");
252 }
253 
254 void MolalityVPSSTP::getActivities(doublereal* ac) const
255 {
256  throw NotImplementedError("MolalityVPSSTP::getActivities");
257 }
258 
259 void MolalityVPSSTP::getActivityCoefficients(doublereal* ac) const
260 {
262  AssertThrow(m_indexSolvent==0, "MolalityVPSSTP::getActivityCoefficients");
263  double xmolSolvent = std::max(moleFraction(m_indexSolvent), m_xmolSolventMIN);
264  for (size_t k = 1; k < m_kk; k++) {
265  ac[k] /= xmolSolvent;
266  }
267 }
268 
269 void MolalityVPSSTP::getMolalityActivityCoefficients(doublereal* acMolality) const
270 {
272  applyphScale(acMolality);
273 }
274 
276 {
277  // First, we calculate the activities all over again
278  vector_fp act(m_kk);
279  getActivities(act.data());
280 
281  // Then, we calculate the sum of the solvent molalities
282  double sum = 0;
283  for (size_t k = 1; k < m_kk; k++) {
284  sum += std::max(m_molalities[k], 0.0);
285  }
286  double oc = 1.0;
287  if (sum > 1.0E-200) {
288  oc = - log(act[m_indexSolvent]) / (m_Mnaught * sum);
289  }
290  return oc;
291 }
292 
294 {
296  string comp = getChildValue(state,"soluteMolalities");
297  if (comp != "") {
298  setMolalitiesByName(comp);
299  }
300  if (state.hasChild("pressure")) {
301  double p = getFloat(state, "pressure", "pressure");
302  setPressure(p);
303  }
304 }
305 
306 void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p,
307  const doublereal* const molalities)
308 {
309  setMolalities(molalities);
310  setState_TP(t, p);
311 }
312 
313 void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p, const compositionMap& m)
314 {
316  setState_TP(t, p);
317 }
318 
319 void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p, const std::string& m)
320 {
322  setState_TP(t, p);
323 }
324 
326 {
328 
329  // Find the Cl- species
331 }
332 
334 {
335  throw NotImplementedError("MolalityVPSSTP::getUnscaledMolalityActivityCoefficients");
336 }
337 
338 void MolalityVPSSTP::applyphScale(doublereal* acMolality) const
339 {
340  throw NotImplementedError("MolalityVPSSTP::applyphScale");
341 }
342 
344 {
345  size_t indexCLM = npos;
346  size_t eCl = npos;
347  size_t eE = npos;
348  size_t ne = nElements();
349  for (size_t e = 0; e < ne; e++) {
350  string sn = elementName(e);
351  if (sn == "Cl" || sn == "CL") {
352  eCl = e;
353  break;
354  }
355  }
356  // We have failed if we can't find the Cl element index
357  if (eCl == npos) {
358  return npos;
359  }
360  for (size_t e = 0; e < ne; e++) {
361  string sn = elementName(e);
362  if (sn == "E" || sn == "e") {
363  eE = e;
364  break;
365  }
366  }
367  // We have failed if we can't find the E element index
368  if (eE == npos) {
369  return npos;
370  }
371  for (size_t k = 1; k < m_kk; k++) {
372  doublereal nCl = nAtoms(k, eCl);
373  if (nCl != 1.0) {
374  continue;
375  }
376  doublereal nE = nAtoms(k, eE);
377  if (nE != 1.0) {
378  continue;
379  }
380  for (size_t e = 0; e < ne; e++) {
381  if (e != eE && e != eCl) {
382  doublereal nA = nAtoms(k, e);
383  if (nA != 0.0) {
384  continue;
385  }
386  }
387  }
388  string sn = speciesName(k);
389  if (sn != "Cl-" && sn != "CL-") {
390  continue;
391  }
392 
393  indexCLM = k;
394  break;
395  }
396  return indexCLM;
397 }
398 
399 bool MolalityVPSSTP::addSpecies(shared_ptr<Species> spec)
400 {
401  bool added = VPStandardStateTP::addSpecies(spec);
402  if (added) {
403  if (m_kk == 1) {
404  // The solvent defaults to species 0
405  setSolvent(0);
406  }
407  m_molalities.push_back(0.0);
408  }
409  return added;
410 }
411 
412 std::string MolalityVPSSTP::report(bool show_thermo, doublereal threshold) const
413 {
414  fmt::MemoryWriter b;
415  try {
416  if (name() != "") {
417  b.write("\n {}:\n", name());
418  }
419  b.write("\n");
420  b.write(" temperature {:12.6g} K\n", temperature());
421  b.write(" pressure {:12.6g} Pa\n", pressure());
422  b.write(" density {:12.6g} kg/m^3\n", density());
423  b.write(" mean mol. weight {:12.6g} amu\n", meanMolecularWeight());
424 
425  doublereal phi = electricPotential();
426  b.write(" potential {:12.6g} V\n", phi);
427 
428  vector_fp x(m_kk);
429  vector_fp molal(m_kk);
430  vector_fp mu(m_kk);
431  vector_fp muss(m_kk);
432  vector_fp acMolal(m_kk);
433  vector_fp actMolal(m_kk);
434  getMoleFractions(&x[0]);
435  getMolalities(&molal[0]);
436  getChemPotentials(&mu[0]);
437  getStandardChemPotentials(&muss[0]);
438  getMolalityActivityCoefficients(&acMolal[0]);
439  getActivities(&actMolal[0]);
440 
441  size_t iHp = speciesIndex("H+");
442  if (iHp != npos) {
443  double pH = -log(actMolal[iHp]) / log(10.0);
444  b.write(" pH {:12.4g}\n", pH);
445  }
446 
447  if (show_thermo) {
448  b.write("\n");
449  b.write(" 1 kg 1 kmol\n");
450  b.write(" ----------- ------------\n");
451  b.write(" enthalpy {:12.6g} {:12.4g} J\n",
453  b.write(" internal energy {:12.6g} {:12.4g} J\n",
455  b.write(" entropy {:12.6g} {:12.4g} J/K\n",
457  b.write(" Gibbs function {:12.6g} {:12.4g} J\n",
458  gibbs_mass(), gibbs_mole());
459  b.write(" heat capacity c_p {:12.6g} {:12.4g} J/K\n",
460  cp_mass(), cp_mole());
461  try {
462  b.write(" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
463  cv_mass(), cv_mole());
464  } catch (NotImplementedError&) {
465  b.write(" heat capacity c_v <not implemented>\n");
466  }
467  }
468 
469  b.write("\n");
470  int nMinor = 0;
471  doublereal xMinor = 0.0;
472  if (show_thermo) {
473  b.write(" X "
474  " Molalities Chem.Pot. ChemPotSS ActCoeffMolal\n");
475  b.write(" "
476  " (J/kmol) (J/kmol)\n");
477  b.write(" ------------- "
478  " ------------ ------------ ------------ ------------\n");
479  for (size_t k = 0; k < m_kk; k++) {
480  if (x[k] > threshold) {
481  if (x[k] > SmallNumber) {
482  b.write("{:>18s} {:12.6g} {:12.6g} {:12.6g} {:12.6g} {:12.6g}\n",
483  speciesName(k), x[k], molal[k], mu[k], muss[k], acMolal[k]);
484  } else {
485  b.write("{:>18s} {:12.6g} {:12.6g} N/A {:12.6g} {:12.6g}\n",
486  speciesName(k), x[k], molal[k], muss[k], acMolal[k]);
487  }
488  } else {
489  nMinor++;
490  xMinor += x[k];
491  }
492  }
493  } else {
494  b.write(" X"
495  "Molalities\n");
496  b.write(" -------------"
497  " ------------\n");
498  for (size_t k = 0; k < m_kk; k++) {
499  if (x[k] > threshold) {
500  b.write("{:>18s} {:12.6g} {:12.6g}\n",
501  speciesName(k), x[k], molal[k]);
502  } else {
503  nMinor++;
504  xMinor += x[k];
505  }
506  }
507  }
508  if (nMinor) {
509  b.write(" [{:+5d} minor] {:12.6g}\n", nMinor, xMinor);
510  }
511  } catch (CanteraError& err) {
512  return b.str() + err.what();
513  }
514  return b.str();
515 }
516 
517 void MolalityVPSSTP::getCsvReportData(std::vector<std::string>& names,
518  std::vector<vector_fp>& data) const
519 {
520  names.clear();
521  data.assign(10, vector_fp(nSpecies()));
522 
523  names.push_back("X");
524  getMoleFractions(&data[0][0]);
525 
526  names.push_back("Molal");
527  getMolalities(&data[1][0]);
528 
529  names.push_back("Chem. Pot. (J/kmol)");
530  getChemPotentials(&data[2][0]);
531 
532  names.push_back("Chem. Pot. SS (J/kmol)");
533  getStandardChemPotentials(&data[3][0]);
534 
535  names.push_back("Molal Act. Coeff.");
536  getMolalityActivityCoefficients(&data[4][0]);
537 
538  names.push_back("Molal Activity");
539  getActivities(&data[5][0]);
540 
541  names.push_back("Part. Mol Enthalpy (J/kmol)");
542  getPartialMolarEnthalpies(&data[5][0]);
543 
544  names.push_back("Part. Mol. Entropy (J/K/kmol)");
545  getPartialMolarEntropies(&data[6][0]);
546 
547  names.push_back("Part. Mol. Energy (J/kmol)");
548  getPartialMolarIntEnergies(&data[7][0]);
549 
550  names.push_back("Part. Mol. Cp (J/K/kmol");
551  getPartialMolarCp(&data[8][0]);
552 
553  names.push_back("Part. Mol. Cv (J/K/kmol)");
554  getPartialMolarVolumes(&data[9][0]);
555 }
556 
557 }
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:149
size_t nElements() const
Number of elements.
Definition: Phase.cpp:161
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
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:145
void setSolvent(size_t k)
This routine sets the index number of the solvent for the phase.
doublereal temperature() const
Temperature (K).
Definition: Phase.h:601
int activityConvention() const
We set the convention to molality here.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: ThermoPhase.h:263
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:193
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
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 size_t findCLMIndex() const
Returns the index of the Cl- species.
doublereal m_Mnaught
This is the multiplication factor that goes inside log expressions involving the molalities of specie...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: ThermoPhase.h:530
doublereal cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
Definition: ThermoPhase.h:784
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition: Phase.cpp:547
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: ThermoPhase.h:494
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.
const char * what() const
Get a description of the error.
virtual void applyphScale(doublereal *acMolality) const
Apply the current phScale to a set of activity Coefficients or activities.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:262
STL namespace.
virtual doublereal density() const
Density (kg/m^3).
Definition: Phase.h:607
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
Definition: ThermoPhase.h:764
virtual bool addSpecies(shared_ptr< Species > spec)
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: ThermoPhase.h:238
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: ThermoPhase.h:561
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
doublereal moleFSolventMin() const
Returns the minimum mole fraction in the molality formulation.
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
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of non-dimensional molality based activity coefficients at the current solution tempera...
size_t solventIndex() const
Returns the solvent index.
virtual double osmoticCoefficient() const
Calculate the osmotic coefficient.
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
Definition: Phase.cpp:273
Header for intermediate ThermoPhase object for phases which employ molality based activity coefficien...
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual bool addSpecies(shared_ptr< Species > spec)
bool m_chargeNeutralityNecessary
Boolean indicating whether a charge neutrality condition is a necessity.
Definition: ThermoPhase.h:1721
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:243
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: ThermoPhase.h:253
void setMolalitiesByName(const compositionMap &xMap)
Set the molalities of a phase.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
void getMolalities(doublereal *const molal) const
This function will return the molalities of the species.
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:267
int pHScale() const
Reports the pH scale, which determines the scale for single-ion activity coefficients.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
doublereal electricPotential() const
Returns the electric potential of this phase (V).
Definition: ThermoPhase.h:335
const int PHSCALE_NBS
Scale to be used for evaluation of single-ion activity coefficients is that used by the NBS standard ...
doublereal entropy_mass() const
Specific entropy. Units: J/kg/K.
Definition: ThermoPhase.h:774
#define AssertThrow(expr, procedure)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:253
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 getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: ThermoPhase.h:520
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:28
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
Definition: ThermoPhase.h:540
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: ThermoPhase.h:258
const U & getValue(const std::map< T, U > &m, const T &key)
Const accessor for a value in a std::map.
Definition: utilities.h:537
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values.
Definition: Phase.cpp:327
virtual void getUnscaledMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
int m_pHScalingType
Scaling to be used for output of single-ion species activity coefficients.
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
Definition: Phase.cpp:542
virtual doublereal pressure() const
Returns the current pressure of the phase.
void setMolalities(const doublereal *const molal)
Set the molalities of the solutes in a phase.
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...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:536
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.
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.
doublereal cv_mass() const
Specific heat at constant volume. Units: J/kg/K.
Definition: ThermoPhase.h:789
#define AssertThrowMsg(expr, procedure,...)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:270
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 meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition: Phase.h:661
doublereal gibbs_mass() const
Specific Gibbs function. Units: J/kg.
Definition: ThermoPhase.h:779
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:151
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:178
doublereal m_weightSolvent
Molecular weight of the Solvent.
size_t m_kk
Number of species in the phase.
Definition: Phase.h:784
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
Definition: Phase.cpp:496
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: ThermoPhase.h:551
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
Namespace for the Cantera kernel.
Definition: application.cpp:29
doublereal intEnergy_mass() const
Specific internal energy. Units: J/kg.
Definition: ThermoPhase.h:769
size_t m_indexSolvent
Index of the solvent.
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition: Phase.cpp:237
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: ThermoPhase.h:248
MolalityVPSSTP()
Default Constructor.
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
std::string elementName(size_t m) const
Name of the element with index m.
Definition: Phase.cpp:180
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.