Cantera 2.6.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 https://cantera.org/license.txt for license and copyright information.
11
12#include "cantera/thermo/MolalityVPSSTP.h"
13#include "cantera/base/stringUtils.h"
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
34 m_chargeNeutralityNecessary = true;
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
48 int MolalityVPSSTP::pHScale() const
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
63doublereal MolalityVPSSTP::moleFSolventMin() const
64{
65 return m_xmolSolventMIN;
66}
67
68 void MolalityVPSSTP::calcMolalities() const
69{
70 getMoleFractions(m_molalities.data());
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{
80 calcMolalities();
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 }
106 setMoleFractions(m_molalities.data());
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
113 void MolalityVPSSTP::setMolalitiesByName(const compositionMap& mMap)
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{
183 compositionMap xx = parseCompString(x, speciesNames());
184 setMolalitiesByName(xx);
185}
186
187// - Activities, Standard States, Activity Concentrations -----------
188
189 int MolalityVPSSTP::activityConvention() const
190{
191 return cAC_CONVENTION_MOLALITY;
192}
193
194 void MolalityVPSSTP::getActivityConcentrations(doublereal* c) const
195{
196 throw NotImplementedError("MolalityVPSSTP::getActivityConcentrations");
197}
198
199doublereal 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{
211 getMolalityActivityCoefficients(ac);
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{
220 getUnscaledMolalityActivityCoefficients(acMolality);
221 applyphScale(acMolality);
222}
223
224doublereal MolalityVPSSTP::osmoticCoefficient() const
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
242 void MolalityVPSSTP::setStateFromXML(const XML_Node& state)
243{
244 VPStandardStateTP::setStateFromXML(state);
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{
264 setMolalitiesByName(m);
265 setState_TP(t, p);
266}
267
268 void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p, const std::string& m)
269{
270 setMolalitiesByName(m);
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
288 VPStandardStateTP::setState(state);
289}
290
291 void MolalityVPSSTP::initThermo()
292{
293 VPStandardStateTP::initThermo();
294
295 // Find the Cl- species
296 m_indexCLM = findCLMIndex();
297}
298
299 void MolalityVPSSTP::getUnscaledMolalityActivityCoefficients(doublereal* acMolality) const
300{
301 throw NotImplementedError("MolalityVPSSTP::getUnscaledMolalityActivityCoefficients");
302}
303
304 void MolalityVPSSTP::applyphScale(doublereal* acMolality) const
305{
306 throw NotImplementedError("MolalityVPSSTP::applyphScale");
307}
308
309 size_t MolalityVPSSTP::findCLMIndex() const
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
371 m_weightSolvent = molecularWeight(0);
372 m_Mnaught = m_weightSolvent / 1000.;
373 }
374 m_molalities.push_back(0.0);
375 }
376 return added;
377}
378
379std::string MolalityVPSSTP::report(bool show_thermo, doublereal threshold) const
380{
381 fmt::memory_buffer b;
382 try {
383 if (name() != "") {
384 fmt_append(b, "\n {}:\n", name());
385 }
386 fmt_append(b, "\n");
387 fmt_append(b, " temperature {:12.6g} K\n", temperature());
388 fmt_append(b, " pressure {:12.6g} Pa\n", pressure());
389 fmt_append(b, " density {:12.6g} kg/m^3\n", density());
390 fmt_append(b, " mean mol. weight {:12.6g} amu\n", meanMolecularWeight());
391
392 doublereal phi = electricPotential();
393 fmt_append(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 fmt_append(b,
412 " pH {:12.4g}\n", pH);
413 }
414
415 if (show_thermo) {
416 fmt_append(b, "\n");
417 fmt_append(b, " 1 kg 1 kmol\n");
418 fmt_append(b, " ----------- ------------\n");
419 fmt_append(b, " enthalpy {:12.6g} {:12.4g} J\n",
420 enthalpy_mass(), enthalpy_mole());
421 fmt_append(b, " internal energy {:12.6g} {:12.4g} J\n",
422 intEnergy_mass(), intEnergy_mole());
423 fmt_append(b, " entropy {:12.6g} {:12.4g} J/K\n",
424 entropy_mass(), entropy_mole());
425 fmt_append(b, " Gibbs function {:12.6g} {:12.4g} J\n",
426 gibbs_mass(), gibbs_mole());
427 fmt_append(b, " heat capacity c_p {:12.6g} {:12.4g} J/K\n",
428 cp_mass(), cp_mole());
429 try {
430 fmt_append(b, " heat capacity c_v {:12.6g} {:12.4g} J/K\n",
431 cv_mass(), cv_mole());
432 } catch (NotImplementedError&) {
433 fmt_append(b, " heat capacity c_v <not implemented>\n");
434 }
435 }
436
437 fmt_append(b, "\n");
438 int nMinor = 0;
439 doublereal xMinor = 0.0;
440 if (show_thermo) {
441 fmt_append(b, " X "
442 " Molalities Chem.Pot. ChemPotSS ActCoeffMolal\n");
443 fmt_append(b, " "
444 " (J/kmol) (J/kmol)\n");
445 fmt_append(b, " ------------- "
446 " ------------ ------------ ------------ ------------\n");
447 for (size_t k = 0; k < m_kk; k++) {
448 if (x[k] > threshold) {
449 if (x[k] > SmallNumber) {
450 fmt_append(b,
451 "{:>18s} {:12.6g} {:12.6g} {:12.6g} "
452 "{:12.6g} {:12.6g}\n", speciesName(k),
453 x[k], molal[k], mu[k], muss[k], acMolal[k]);
454 } else {
455 fmt_append(b,
456 "{:>18s} {:12.6g} {:12.6g} N/A "
457 "{:12.6g} {:12.6g}\n", speciesName(k),
458 x[k], molal[k], muss[k], acMolal[k]);
459 }
460 } else {
461 nMinor++;
462 xMinor += x[k];
463 }
464 }
465 } else {
466 fmt_append(b, " X Molalities\n");
467 fmt_append(b, " ------------- ------------\n");
468 for (size_t k = 0; k < m_kk; k++) {
469 if (x[k] > threshold) {
470 fmt_append(b, "{:>18s} {:12.6g} {:12.6g}\n",
471 speciesName(k), x[k], molal[k]);
472 } else {
473 nMinor++;
474 xMinor += x[k];
475 }
476 }
477 }
478 if (nMinor) {
479 fmt_append(b, " [{:+5d} minor] {:12.6g}\n", nMinor, xMinor);
480 }
481 } catch (CanteraError& err) {
482 return to_string(b) + err.what();
483 }
484 return to_string(b);
485}
486
487 void MolalityVPSSTP::getCsvReportData(std::vector<std::string>& names,
488 std::vector<vector_fp>& data) const
489{
490 names.clear();
491 data.assign(10, vector_fp(nSpecies()));
492
493 names.push_back("X");
494 getMoleFractions(&data[0][0]);
495
496 names.push_back("Molal");
497 getMolalities(&data[1][0]);
498
499 names.push_back("Chem. Pot. (J/kmol)");
500 getChemPotentials(&data[2][0]);
501
502 names.push_back("Chem. Pot. SS (J/kmol)");
503 getStandardChemPotentials(&data[3][0]);
504
505 names.push_back("Molal Act. Coeff.");
506 getMolalityActivityCoefficients(&data[4][0]);
507
508 names.push_back("Molal Activity");
509 getActivities(&data[5][0]);
510
511 names.push_back("Part. Mol Enthalpy (J/kmol)");
512 getPartialMolarEnthalpies(&data[5][0]);
513
514 names.push_back("Part. Mol. Entropy (J/K/kmol)");
515 getPartialMolarEntropies(&data[6][0]);
516
517 names.push_back("Part. Mol. Energy (J/kmol)");
518 getPartialMolarIntEnergies(&data[7][0]);
519
520 names.push_back("Part. Mol. Cp (J/K/kmol");
521 getPartialMolarCp(&data[8][0]);
522
523 names.push_back("Part. Mol. Cv (J/K/kmol)");
524 getPartialMolarVolumes(&data[9][0]);
525}
526
527}
MolalityVPSSTP.h
Header for intermediate ThermoPhase object for phases which employ molality based activity coefficien...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Cantera::AnyMap::hasKey
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Definition: AnyMap.cpp:1406
Cantera::AnyValue
A wrapper for a variable whose type is determined at runtime.
Definition: AnyMap.h:84
Cantera::AnyValue::asString
const std::string & asString() const
Return the held value, if it is a string.
Definition: AnyMap.cpp:716
Cantera::AnyValue::is
bool is() const
Returns true if the held value is of the specified type.
Definition: AnyMap.inl.h:58
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:125
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Cantera::CanteraError::what
const char * what() const
Get a description of the error.
Definition: ctexceptions.cpp:25
Cantera::MolalityVPSSTP::setStateFromXML
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
Definition: MolalityVPSSTP.cpp:242
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::MolalityVPSSTP::addSpecies
virtual bool addSpecies(shared_ptr< Species > spec)
Definition: MolalityVPSSTP.cpp:365
Cantera::MolalityVPSSTP::setMolalitiesByName
void setMolalitiesByName(const compositionMap &xMap)
Set the molalities of a phase.
Definition: MolalityVPSSTP.cpp:113
Cantera::MolalityVPSSTP::moleFSolventMin
doublereal moleFSolventMin() const
Returns the minimum mole fraction in the molality formulation.
Definition: MolalityVPSSTP.cpp:63
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::MolalityVPSSTP::getMolalities
void getMolalities(doublereal *const molal) const
This function will return the molalities of the species.
Definition: MolalityVPSSTP.cpp:78
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::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
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::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::MolalityVPSSTP::m_indexCLM
size_t m_indexCLM
Index of the phScale species.
Definition: MolalityVPSSTP.h:583
Cantera::MolalityVPSSTP::findCLMIndex
virtual size_t findCLMIndex() const
Returns the index of the Cl- species.
Definition: MolalityVPSSTP.cpp:309
Cantera::MolalityVPSSTP::osmoticCoefficient
virtual double osmoticCoefficient() const
Calculate the osmotic coefficient.
Definition: MolalityVPSSTP.cpp:224
Cantera::MolalityVPSSTP::setMolalities
void setMolalities(const doublereal *const molal)
Set the molalities of the solutes in a phase.
Definition: MolalityVPSSTP.cpp:86
Cantera::MolalityVPSSTP::getActivityConcentrations
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Definition: MolalityVPSSTP.cpp:194
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::setpHScale
void setpHScale(const int pHscaleType)
Set the pH scale, which determines the scale for single-ion activity coefficients.
Definition: MolalityVPSSTP.cpp:39
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:487
Cantera::MolalityVPSSTP::setMoleFSolventMin
void setMoleFSolventMin(doublereal xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.
Definition: MolalityVPSSTP.cpp:53
Cantera::MolalityVPSSTP::activityConvention
int activityConvention() const
We set the convention to molality here.
Definition: MolalityVPSSTP.cpp:189
Cantera::MolalityVPSSTP::initThermo
virtual void initThermo()
Definition: MolalityVPSSTP.cpp:291
Cantera::MolalityVPSSTP::m_xmolSolventMIN
doublereal m_xmolSolventMIN
Definition: MolalityVPSSTP.h:595
Cantera::MolalityVPSSTP::m_pHScalingType
int m_pHScalingType
Scaling to be used for output of single-ion species activity coefficients.
Definition: MolalityVPSSTP.h:576
Cantera::MolalityVPSSTP::MolalityVPSSTP
MolalityVPSSTP()
Default Constructor.
Definition: MolalityVPSSTP.cpp:24
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:600
Cantera::MolalityVPSSTP::calcMolalities
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
Definition: MolalityVPSSTP.cpp:68
Cantera::MolalityVPSSTP::m_molalities
vector_fp m_molalities
Current value of the molalities of the species in the phase.
Definition: MolalityVPSSTP.h:604
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::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::MolalityVPSSTP::m_weightSolvent
doublereal m_weightSolvent
Molecular weight of the Solvent.
Definition: MolalityVPSSTP.h:586
Cantera::MolalityVPSSTP::standardConcentration
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: MolalityVPSSTP.cpp:199
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
Cantera::Phase::setMoleFractions
virtual void setMoleFractions(const double *const x)
Set the mole fractions to the specified values.
Definition: Phase.cpp:339
Cantera::Phase::name
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:70
Cantera::Phase::nSpecies
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:273
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:630
Cantera::Phase::m_kk
size_t m_kk
Number of species in the phase.
Definition: Phase.h:943
Cantera::Phase::molecularWeight
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
Definition: Phase.cpp:492
Cantera::Phase::speciesName
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:200
Cantera::Phase::meanMolecularWeight
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition: Phase.h:751
Cantera::Phase::getMoleFractions
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
Definition: Phase.cpp:543
Cantera::Phase::moleFraction
double moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition: Phase.cpp:548
Cantera::Phase::nAtoms
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition: Phase.cpp:154
Cantera::Phase::density
virtual double density() const
Density (kg/m^3).
Definition: Phase.h:679
Cantera::Phase::temperature
doublereal temperature() const
Temperature (K).
Definition: Phase.h:654
Cantera::Phase::nElements
size_t nElements() const
Number of elements.
Definition: Phase.cpp:81
Cantera::Phase::speciesNames
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
Definition: Phase.cpp:206
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:187
Cantera::Phase::elementName
std::string elementName(size_t m) const
Name of the element with index m.
Definition: Phase.cpp:100
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:1278
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:531
Cantera::ThermoPhase::gibbs_mole
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: ThermoPhase.h:254
Cantera::ThermoPhase::entropy_mass
doublereal entropy_mass() const
Specific entropy. Units: J/kg/K.
Definition: ThermoPhase.h:758
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:521
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:210
Cantera::ThermoPhase::getChemPotentials
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: ThermoPhase.h:495
Cantera::ThermoPhase::gibbs_mass
doublereal gibbs_mass() const
Specific Gibbs function. Units: J/kg.
Definition: ThermoPhase.h:763
Cantera::ThermoPhase::entropy_mole
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: ThermoPhase.h:249
Cantera::ThermoPhase::m_chargeNeutralityNecessary
bool m_chargeNeutralityNecessary
Boolean indicating whether a charge neutrality condition is a necessity.
Definition: ThermoPhase.h:1922
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:562
Cantera::ThermoPhase::cp_mass
doublereal cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
Definition: ThermoPhase.h:768
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:552
Cantera::ThermoPhase::cp_mole
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: ThermoPhase.h:259
Cantera::ThermoPhase::cv_mole
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: ThermoPhase.h:264
Cantera::ThermoPhase::intEnergy_mole
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
Definition: ThermoPhase.h:244
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:541
Cantera::ThermoPhase::cv_mass
doublereal cv_mass() const
Specific heat at constant volume. Units: J/kg/K.
Definition: ThermoPhase.h:773
Cantera::ThermoPhase::intEnergy_mass
doublereal intEnergy_mass() const
Specific internal energy. Units: J/kg.
Definition: ThermoPhase.h:753
Cantera::ThermoPhase::enthalpy_mole
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: ThermoPhase.h:239
Cantera::ThermoPhase::enthalpy_mass
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
Definition: ThermoPhase.h:748
Cantera::ThermoPhase::electricPotential
doublereal electricPotential() const
Returns the electric potential of this phase (V).
Definition: ThermoPhase.h:326
Cantera::VPStandardStateTP::addSpecies
virtual bool addSpecies(shared_ptr< Species > spec)
Definition: VPStandardStateTP.cpp:176
Cantera::VPStandardStateTP::setState_TP
virtual void setState_TP(doublereal T, doublereal pres)
Set the temperature and pressure at the same time.
Definition: VPStandardStateTP.cpp:217
Cantera::VPStandardStateTP::setPressure
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: VPStandardStateTP.cpp:206
Cantera::VPStandardStateTP::initThermo
virtual void initThermo()
Definition: VPStandardStateTP.cpp:154
Cantera::VPStandardStateTP::pressure
virtual doublereal pressure() const
Returns the current pressure of the phase.
Definition: VPStandardStateTP.h:140
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::XML_Node
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
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:529
ctml.h
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
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:166
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:133
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:626
Cantera::SmallNumber
const double SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:153
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:184
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:651
Cantera::compositionMap
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:176
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:59
Cantera::cAC_CONVENTION_MOLALITY
const int cAC_CONVENTION_MOLALITY
Standard state uses the molality convention.
Definition: ThermoPhase.h:29
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:184
stringUtils.h
Contains declarations for string manipulation functions within Cantera.
utilities.h
Various templated functions that carry out common vector operations (see Templated Utility Functions)...