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