Cantera  4.0.0a1
Loading...
Searching...
No Matches
Phase.h
Go to the documentation of this file.
1/**
2 * @file Phase.h
3 * Header file for class Phase.
4 */
5
6// This file is part of Cantera. See License.txt in the top-level directory or
7// at https://cantera.org/license.txt for license and copyright information.
8
9#ifndef CT_PHASE_H
10#define CT_PHASE_H
11
15
16
17namespace Cantera
18{
19
20class Solution;
21class Species;
22class Kinetics;
23
24//! Class Phase is the base class for phases of matter, managing the species and
25//! elements in a phase, as well as the independent variables of temperature,
26//! mass density (compressible substances) or pressure (incompressible
27//! substances), species mass/mole fraction, and other generalized forces and
28//! intrinsic properties (such as electric potential) that define the
29//! thermodynamic state.
30/*!
31 *
32 * Class Phase provides information about the elements and species in a
33 * phase - names, index numbers (location in arrays), atomic or molecular
34 * weights, etc. The set of elements must include all those that compose the
35 * species, but may include additional elements.
36 *
37 * It also stores an array of species molecular weights, which are used to
38 * convert between mole and mass representations of the composition. For
39 * efficiency in mass/mole conversion, the vector of mass fractions divided
40 * by molecular weight @f$ Y_k/M_k @f$ is also stored.
41 *
42 * Class Phase is not usually used directly. Its primary use is as a base class
43 * for class ThermoPhase. It is not generally necessary to overloaded any of
44 * class Phase's methods, which handles both compressible and incompressible
45 * phases. For incompressible phases, the density is replaced by the pressure
46 * as the independent variable, and can no longer be set directly. In this case,
47 * the density needs to be calculated from a suitable equation of state, and
48 * assigned to the object using the assignDensity() method. This also applies
49 * for nearly-incompressible phases or phases which utilize standard states
50 * based on a T and P, in which case they need to overload these functions too.
51 *
52 * Class Phase contains a number of utility functions that will set the state
53 * of the phase in its entirety, by first setting the composition, and then
54 * temperature and pressure. An example of this is the function
55 * Phase::setState_TPY(double t, double p, span<const double> y).
56 *
57 * For bulk (3-dimensional) phases, the mass density has units of kg/m^3, and the molar
58 * density and concentrations have units of kmol/m^3, and the units listed in the
59 * methods of the Phase class assume a bulk phase. However, for surface (2-dimensional)
60 * phases have units of kg/m^2 and kmol/m^2, respectively. And for edge (1-dimensional)
61 * phases, these units kg/m and kmol/m.
62 *
63 * Class Phase contains methods for saving and restoring the full internal state
64 * of a given phase. These are saveState() and restoreState(). These functions
65 * operate on a state vector, which by default uses the first two entries for
66 * temperature and density (compressible substances) or temperature and
67 * pressure (incompressible substances). If the substance is not pure in a
68 * thermodynamic sense (that is, it may contain multiple species), the state also
69 * contains nSpecies() entries that specify the composition by corresponding
70 * mass fractions. Default definitions can be overloaded by derived classes.
71 * For any phase, the native definition of its thermodynamic state is defined
72 * the method nativeState(), with the length of the state vector returned by
73 * by stateSize(). In addition, methods isPure() and isCompressible() provide
74 * information on the implementation of a Phase object.
75 *
76 * A species name is referred to via speciesName(), which is unique within a
77 * given phase. Note that within multiphase mixtures (MultiPhase()), both a
78 * phase name/index as well as species name are required to access information
79 * about a species in a particular phase. For surfaces, the species names are
80 * unique among the phases.
81 *
82 * @todo
83 * - Specify that the input mole, mass, and volume fraction vectors must sum
84 * to one on entry to the set state routines. Non-conforming mole/mass
85 * fraction vectors are not thermodynamically consistent. Moreover, unless
86 * we do this, the calculation of Jacobians will be altered whenever the
87 * treatment of non- conforming mole fractions is changed. Add setState
88 * functions corresponding to specifying mole numbers, which is actually
89 * what is being done (well one of the options, there are many) when non-
90 * conforming mole fractions are input. Note, we realize that most numerical
91 * Jacobian and some analytical Jacobians use non-conforming calculations.
92 * These can easily be changed to the set mole number setState functions.
93 *
94 * @ingroup thermoprops
95 */
96class Phase
97{
98public:
99 Phase() = default; //!< Default constructor.
100 virtual ~Phase() = default;
101
102 // Phase objects are not copyable or assignable
103 Phase(const Phase&) = delete;
104 Phase& operator=(const Phase&) = delete;
105
106 /**
107 * @name Name
108 * Class Phase uses the string name to identify a phase. For phases instantiated
109 * from YAML input files, the name is the value of the corresponding key in the
110 * phase map.
111 *
112 * However, the name field may be changed to another value during the
113 * course of a calculation. For example, if duplicates of a phase object
114 * are instantiated and used in multiple places (such as a ReactorNet), they
115 * will have the same constitutive input, that is, the names of the phases will
116 * be the same. Note that this is not a problem for %Cantera internally;
117 * however, a user may want to rename phase objects in order to clarify.
118 */
119 //!@{
120
121 //! Return the name of the phase.
122 /*!
123 * Names are unique within a %Cantera problem.
124 */
125 string name() const;
126
127 //! Sets the string name for the phase.
128 //! @param nm String name of the phase
129 void setName(const string& nm);
130
131 //! String indicating the thermodynamic model implemented. Usually
132 //! corresponds to the name of the derived class, less any suffixes such as
133 //! "Phase", TP", "VPSS", etc.
134 //! @since Starting in %Cantera 3.0, the name returned by this method corresponds
135 //! to the canonical name used in the YAML input format.
136 virtual string type() const {
137 return "Phase";
138 }
139
140 //! @} end group Name
141
142 //! @name Element and Species Information
143 //! @{
144
145 //! Name of the element with index m.
146 //! @param m Element index.
147 string elementName(size_t m) const;
148
149 //! Return the index of element named 'name'.
150 /*!
151 * The index is an integer assigned to each element in the order it was added.
152 * Returns @ref npos if the specified element is not found.
153 * @param name Name of the element.
154 * @param raise If `true`, raise exception if the specified element is not found;
155 * otherwise, return @ref npos.
156 * @since Added the `raise` argument in %Cantera 3.2. In %Cantera 4.0, changed the
157 * default value of `raise` to `true`.
158 * @exception Throws a CanteraError if the specified element is not found and
159 * `raise` is `true`.
160 */
161 size_t elementIndex(const string& name, bool raise=true) const;
162
163 //! Return a read-only reference to the vector of element names.
164 const vector<string>& elementNames() const;
165
166 //! Atomic weight of element m.
167 //! @param m Element index
168 double atomicWeight(size_t m) const;
169
170 //! Entropy of the element in its standard state at 298 K and 1 bar.
171 //! If no entropy value was provided when the phase was constructed,
172 //! returns the value `ENTROPY298_UNKNOWN`.
173 //! @param m Element index
174 double entropyElement298(size_t m) const;
175
176 //! Atomic number of element m.
177 //! @param m Element index
178 int atomicNumber(size_t m) const;
179
180 //! Return the element constraint type
181 //! Possible types include:
182 //!
183 //! - `CT_ELEM_TYPE_TURNEDOFF -1`
184 //! - `CT_ELEM_TYPE_ABSPOS 0`
185 //! - `CT_ELEM_TYPE_ELECTRONCHARGE 1`
186 //! - `CT_ELEM_TYPE_CHARGENEUTRALITY 2`
187 //! - `CT_ELEM_TYPE_LATTICERATIO 3`
188 //! - `CT_ELEM_TYPE_KINETICFROZEN 4`
189 //! - `CT_ELEM_TYPE_SURFACECONSTRAINT 5`
190 //! - `CT_ELEM_TYPE_OTHERCONSTRAINT 6`
191 //!
192 //! The default is `CT_ELEM_TYPE_ABSPOS`.
193 //! @param m Element index
194 //! @returns the element type
195 int elementType(size_t m) const;
196
197 //! Change the element type of the mth constraint
198 //! Reassigns an element type.
199 //! @param m Element index
200 //! @param elem_type New elem type to be assigned
201 //! @returns the old element type
202 int changeElementType(int m, int elem_type);
203
204 //! Return a read-only reference to the vector of atomic weights.
205 span<const double> atomicWeights() const;
206
207 //! Number of elements.
208 size_t nElements() const;
209
210 //! Check that the specified element index is in range.
211 /*!
212 * @since Starting in %Cantera 3.2, returns the input element index, if valid.
213 * @exception Throws an IndexError if m is greater than nElements()-1
214 */
215 size_t checkElementIndex(size_t m) const;
216
217 //! Number of atoms of element @c m in species @c k.
218 //! @param k species index
219 //! @param m element index
220 double nAtoms(size_t k, size_t m) const;
221
222 //! Returns the index of a species named 'name' within the Phase object.
223 /*!
224 * The first species in the phase will have an index 0, and the last one
225 * will have an index of nSpecies() - 1.
226 * @param name String name of the species. It may also be in the form
227 * phaseName:speciesName
228 * @param raise If `true`, raise exception if the specified species is not found;
229 * otherwise, return @ref npos.
230 * @return The index of the species.
231 * @since Added the `raise` argument in %Cantera 3.2. In %Cantera 4.0, changed the
232 * default value of `raise` to `true`.
233 * @exception Throws a CanteraError if the specified species is not found and
234 * `raise` is `true`.
235 */
236 size_t speciesIndex(const string& name, bool raise=true) const;
237
238 //! Name of the species with index k
239 //! @param k index of the species
240 string speciesName(size_t k) const;
241
242 //! Return a const reference to the vector of species names
243 const vector<string>& speciesNames() const;
244
245 //! Returns the number of species in the phase
246 size_t nSpecies() const {
247 return m_kk;
248 }
249
250 //! Check that the specified species index is in range.
251 /*!
252 * @since Starting in %Cantera 3.2, returns the input phase index, if valid.
253 * @exception Throws an IndexError if k is greater than nSpecies()-1
254 */
255 size_t checkSpeciesIndex(size_t k) const;
256
257 //! @} end group Element and Species Information
258
259 //! Return whether phase represents a pure (single species) substance
260 virtual bool isPure() const {
261 return false;
262 }
263
264 //! Return whether phase represents a substance with phase transitions
265 virtual bool hasPhaseTransition() const {
266 return false;
267 }
268
269 //! Return whether phase represents a compressible substance
270 virtual bool isCompressible() const {
271 return true;
272 }
273
274 //! Return a map of properties defining the native state of a substance.
275 //! By default, entries include "T", "D", "Y" for a compressible substance
276 //! and "T", "P", "Y" for an incompressible substance, with offsets 0, 1 and
277 //! 2, respectively. Mass fractions "Y" are omitted for pure species.
278 //! In all cases, offsets into the state vector are used by saveState()
279 //! and restoreState().
280 virtual map<string, size_t> nativeState() const;
281
282 //! Return string acronym representing the native state of a Phase.
283 //! Examples: "TP", "TDY", "TPY".
284 //! @see nativeState
285 //! @since New in %Cantera 3.0
286 string nativeMode() const;
287
288 //! Return a vector containing full states defining a phase.
289 //! Full states list combinations of properties that allow for the
290 //! specification of a thermodynamic state based on user input.
291 //! Properties and states are represented by single letter acronyms, and
292 //! combinations of letters, respectively (for example, "TDY", "TPX", "SVX").
293 //! Supported property acronyms are:
294 //! "T": temperature
295 //! "P": pressure
296 //! "D": density
297 //! "X": mole fractions
298 //! "Y": mass fractions
299 //! "T": temperature
300 //! "U": specific internal energy
301 //! "V": specific volume
302 //! "H": specific enthalpy
303 //! "S": specific entropy
304 //! "Q": vapor fraction
305 virtual vector<string> fullStates() const;
306
307 //! Return a vector of settable partial property sets within a phase.
308 //! Partial states encompass all valid combinations of properties that allow
309 //! for the specification of a state while ignoring species concentrations
310 //! (such as "TD", "TP", "SV").
311 virtual vector<string> partialStates() const;
312
313 //! Get the size of the partial state vector of the phase.
314 //! The partial state vector excludes composition. Vectors of this size are used by
315 //! savePartialState() and restorePartialState().
316 //! @since New in %Cantera 3.2
317 virtual size_t partialStateSize() const { return 2; }
318
319 //! Save the current thermodynamic state of the phase, excluding composition.
320 //! The default implementation corresponds to the default implementation of
321 //! nativeState().
322 //! @param[out] state Array of state variables, in the order defined by
323 //! nativeState(). Size must be >= partialStateSize().
324 //! @since New in %Cantera 3.2
325 virtual void savePartialState(span<double> state) const;
326
327 //! Set the internal thermodynamic state of the phase, excluding composition.
328 //! The default implementation corresponds to the default implementation of
329 //! nativeState().
330 //! @param[in] state Array of state variables, in the order defined by
331 //! nativeState(). Size must be >= partialStateSize().
332 //! @since New in %Cantera 3.2
333 virtual void restorePartialState(span<const double> state);
334
335 //! Return size of vector defining internal state of the phase.
336 //! Used by saveState() and restoreState().
337 virtual size_t stateSize() const;
338
339 //! Write to array 'state' the current internal state.
340 //! @param state output vector. Size must be >= stateSize().
341 virtual void saveState(span<double> state) const;
342
343 //! Restore the state of the phase from a previously saved state vector.
344 //! @param state Vector of state conditions.
345 virtual void restoreState(span<const double> state);
346
347 //! @name Set Thermodynamic State
348 //!
349 //! Set the internal thermodynamic state by setting the internally stored
350 //! temperature, density and species composition. Note that the composition
351 //! is always set first.
352 //!
353 //! Temperature and density are held constant if not explicitly set.
354 //! @{
355
356 //! Set the species mole fractions by name.
357 //! Species not listed by name in @c xMap are set to zero.
358 //! @param xMap map from species names to mole fraction values.
359 void setMoleFractionsByName(const Composition& xMap);
360
361 //! Set the mole fractions of a group of species by name. Species which
362 //! are not listed by name in the composition map are set to zero.
363 //! @param x string x in the form of a composition map
364 void setMoleFractionsByName(const string& x);
365
366 //! Set the species mass fractions by name.
367 //! Species not listed by name in @c yMap are set to zero.
368 //! @param yMap map from species names to mass fraction values.
369 void setMassFractionsByName(const Composition& yMap);
370
371 //! Set the species mass fractions by name.
372 //! Species not listed by name in @c x are set to zero.
373 //! @param x String containing a composition map
374 void setMassFractionsByName(const string& x);
375
376 //! Set the internally stored temperature (K) and density (kg/m^3)
377 //! @param t Temperature in kelvin
378 //! @param rho Density (kg/m^3)
379 //! @since New in %Cantera 3.0.
380 void setState_TD(double t, double rho);
381
382 //! @} end group set thermo state
383
384 //! Molecular weight of species @c k.
385 //! @param k index of species @c k
386 //! @returns the molecular weight of species @c k.
387 double molecularWeight(size_t k) const;
388
389 //! Copy the vector of molecular weights into array weights.
390 //! @param weights Output array of molecular weights (kg/kmol)
391 void getMolecularWeights(span<double> weights) const;
392
393 //! Return a const reference to the internal vector of molecular weights.
394 //! units = kg / kmol
395 span<const double> molecularWeights() const;
396
397 //! Return a const reference to the internal vector of molecular weights.
398 //! units = kmol / kg
399 span<const double> inverseMolecularWeights() const;
400
401 //! Copy the vector of species charges into array charges.
402 //! @param charges Output array of species charges (elem. charge)
403 void getCharges(span<double> charges) const;
404
405 //! @name Composition
406 //! @{
407
408 //! Get the mole fractions by name.
409 //! @param threshold Exclude species with mole fractions less than or
410 //! equal to this threshold.
411 //! @return Map of species names to mole fractions
412 Composition getMoleFractionsByName(double threshold=0.0) const;
413
414 //! Return the mole fraction of a single species
415 //! @param k species index
416 //! @return Mole fraction of the species
417 double moleFraction(size_t k) const;
418
419 //! Return the mole fraction of a single species
420 //! @param name String name of the species
421 //! @return Mole fraction of the species
422 double moleFraction(const string& name) const;
423
424 //! Get the mass fractions by name.
425 //! @param threshold Exclude species with mass fractions less than or
426 //! equal to this threshold.
427 //! @return Map of species names to mass fractions
428 Composition getMassFractionsByName(double threshold=0.0) const;
429
430 //! Return the mass fraction of a single species
431 //! @param k species index
432 //! @return Mass fraction of the species
433 double massFraction(size_t k) const;
434
435 //! Return the mass fraction of a single species
436 //! @param name String name of the species
437 //! @return Mass Fraction of the species
438 double massFraction(const string& name) const;
439
440 //! Get the species mole fraction vector.
441 //! @param x On return, x contains the mole fractions. Must have a
442 //! size greater than or equal to the number of species.
443 void getMoleFractions(span<double> x) const;
444
445 //! Set the mole fractions to the specified values.
446 //! There is no restriction on the sum of the mole fraction vector.
447 //! Internally, the Phase object will normalize this vector before storing
448 //! its contents.
449 //! @param x Array of unnormalized mole fraction values (input). Must
450 //! have a size greater than or equal to the number of species, m_kk.
451 virtual void setMoleFractions(span<const double> x);
452
453 //! Set the mole fractions to the specified values without normalizing.
454 //! This is useful when the normalization condition is being handled by
455 //! some other means, for example by a constraint equation as part of a
456 //! larger set of equations.
457 //! @param x Input vector of mole fractions. Length is m_kk.
458 virtual void setMoleFractions_NoNorm(span<const double> x);
459
460 //! Get the species mass fractions.
461 //! @param[out] y Array of mass fractions, length nSpecies()
462 void getMassFractions(span<double> y) const;
463
464 //! Return a view of the mass fraction array
465 span<const double> massFractions() const {
466 return m_y;
467 }
468
469 //! Set the mass fractions to the specified values and normalize them.
470 //! @param[in] y Array of unnormalized mass fraction values. Length
471 //! must be greater than or equal to the number of
472 //! species. The Phase object will normalize this vector
473 //! before storing its contents.
474 virtual void setMassFractions(span<const double> y);
475
476 //! Set the mass fractions to the specified values without normalizing.
477 //! This is useful when the normalization condition is being handled by
478 //! some other means, for example by a constraint equation as part of a
479 //! larger set of equations.
480 //! @param y Input vector of mass fractions. Length is m_kk.
481 virtual void setMassFractions_NoNorm(span<const double> y);
482
483 //! Get the species concentrations (kmol/m^3).
484 /*!
485 * @param[out] c The vector of species concentrations. Units are
486 * kmol/m^3. The length of the vector must be greater than
487 * or equal to the number of species within the phase.
488 */
489 virtual void getConcentrations(span<double> c) const;
490
491 //! Concentration of species k.
492 //! If k is outside the valid range, an exception will be thrown.
493 /*!
494 * @param[in] k Index of the species within the phase.
495 *
496 * @returns the concentration of species k (kmol m-3).
497 */
498 virtual double concentration(const size_t k) const;
499
500 //! Set the concentrations to the specified values within the phase.
501 //! We set the concentrations here and therefore we set the overall density
502 //! of the phase. We hold the temperature constant during this operation.
503 //! Therefore, we have possibly changed the pressure of the phase by
504 //! calling this routine.
505 //! @param[in] conc Array of concentrations in dimensional units. For
506 //! bulk phases c[k] is the concentration of the kth
507 //! species in kmol/m3. For surface phases, c[k] is the
508 //! concentration in kmol/m2. The length of the vector
509 //! is the number of species in the phase.
510 virtual void setConcentrations(span<const double> conc);
511
512 //! Set the concentrations without ignoring negative concentrations
513 virtual void setConcentrationsNoNorm(span<const double> conc);
514 //! @}
515
516 //! Set the state of the object with moles in [kmol]
517 virtual void setMolesNoTruncate(span<const double> N);
518
519 //! Elemental mass fraction of element m
520 /*!
521 * The elemental mass fraction @f$ Z_{\mathrm{mass},m} @f$ of element @f$ m @f$
522 * is defined as
523 * @f[
524 * Z_{\mathrm{mass},m} = \sum_k \frac{a_{m,k} M_m}{M_k} Y_k
525 * @f]
526 * with @f$ a_{m,k} @f$ being the number of atoms of element @f$ m @f$ in
527 * species @f$ k @f$, @f$ M_m @f$ the atomic weight of element @f$ m @f$,
528 * @f$ M_k @f$ the molecular weight of species @f$ k @f$, and @f$ Y_k @f$
529 * the mass fraction of species @f$ k @f$.
530 *
531 * @param[in] m Index of the element within the phase. If m is outside
532 * the valid range, an exception will be thrown.
533 *
534 * @return the elemental mass fraction of element m.
535 */
536 double elementalMassFraction(const size_t m) const;
537
538 //! Elemental mole fraction of element m
539 /*!
540 * The elemental mole fraction @f$ Z_{\mathrm{mole},m} @f$ of element @f$ m @f$
541 * is the number of atoms of element *m* divided by the total number of
542 * atoms. It is defined as:
543 *
544 * @f[
545 * Z_{\mathrm{mole},m} = \frac{\sum_k a_{m,k} X_k}
546 * {\sum_k \sum_j a_{j,k} X_k}
547 * @f]
548 * with @f$ a_{m,k} @f$ being the number of atoms of element @f$ m @f$ in
549 * species @f$ k @f$, @f$ \sum_j @f$ being a sum over all elements, and
550 * @f$ X_k @f$ being the mole fraction of species @f$ k @f$.
551 *
552 * @param[in] m Index of the element within the phase. If m is outside the
553 * valid range, an exception will be thrown.
554 * @return the elemental mole fraction of element m.
555 */
556 double elementalMoleFraction(const size_t m) const;
557
558 //! Dimensionless electrical charge of a single molecule of species k
559 //! The charge is normalized by the the magnitude of the electron charge
560 //! @param k species index
561 double charge(size_t k) const {
562 return m_speciesCharge[k];
563 }
564
565 //! Charge density [C/m^3].
566 double chargeDensity() const;
567
568 //! Returns the number of spatial dimensions (1, 2, or 3)
569 size_t nDim() const {
570 return m_ndim;
571 }
572
573 //! Set the number of spatial dimensions (1, 2, or 3). The number of
574 //! spatial dimensions is used for vector involving directions.
575 //! @param ndim Input number of dimensions.
576 void setNDim(size_t ndim) {
577 m_ndim = ndim;
578 }
579
580 //! @name Thermodynamic Properties
581 //! @{
582
583 //! Temperature (K).
584 //! @return The temperature of the phase
585 double temperature() const {
586 return m_temp;
587 }
588
589 //! Electron Temperature (K)
590 //! @return The electron temperature of the phase
591 virtual double electronTemperature() const {
592 return m_temp;
593 }
594
595 //! Return the thermodynamic pressure (Pa).
596 /*!
597 * This method must be overloaded in derived classes. Within %Cantera, the
598 * independent variable is either density or pressure. If the state is
599 * defined by temperature, density, and mass fractions, this method should
600 * use these values to implement the mechanical equation of state @f$ P(T,
601 * \rho, Y_1, \dots, Y_K) @f$. Alternatively, it returns a stored value.
602 */
603 virtual double pressure() const {
604 throw NotImplementedError("Phase::pressure",
605 "Not implemented for thermo model '{}'", type());
606 }
607
608 //! Density (kg/m^3).
609 //! @return The density of the phase
610 virtual double density() const {
611 return m_dens;
612 }
613
614 //! Molar density (kmol/m^3).
615 //! @return The molar density of the phase
616 virtual double molarDensity() const;
617
618 //! Molar volume (m^3/kmol).
619 //! @return The molar volume of the phase
620 virtual double molarVolume() const;
621
622 //! Set the internally stored density (kg/m^3) of the phase.
623 //! Note the density of a phase is an independent variable.
624 //! @param[in] density_ density (kg/m^3).
625 virtual void setDensity(const double density_);
626
627 //! Set the internally stored pressure (Pa) at constant temperature and
628 //! composition
629 /*!
630 * This method must be reimplemented in derived classes, where it may
631 * involve the solution of a nonlinear equation. Within %Cantera, the
632 * independent variable is either density or pressure. Therefore, this
633 * function may either solve for the density that will yield the desired
634 * input pressure or set an independent variable. The temperature
635 * and composition are held constant during this process.
636 *
637 * @param p input Pressure (Pa)
638 */
639 virtual void setPressure(double p) {
640 throw NotImplementedError("Phase::setPressure",
641 "Not implemented for thermo model '{}'", type());
642 }
643
644 //! Set the internally stored temperature of the phase (K).
645 //! @param temp Temperature in Kelvin
646 virtual void setTemperature(double temp) {
647 if (temp > 0) {
648 m_temp = temp;
649 } else {
650 throw CanteraError("Phase::setTemperature",
651 "temperature must be positive. T = {}", temp);
652 }
653 }
654
655 //! Set the internally stored electron temperature of the phase (K).
656 //! @param etemp Electron temperature in Kelvin
657 virtual void setElectronTemperature(double etemp) {
658 throw NotImplementedError("Phase::setElectronTemperature",
659 "Not implemented for thermo model '{}'", type());
660 }
661
662 //! @}
663
664 //! @name Mean Properties
665 //! @{
666
667 //! Evaluate the mole-fraction-weighted mean of an array Q.
668 //! @f[ \sum_k X_k Q_k. @f]
669 //! Q should contain pure-species molar property values.
670 //! @param[in] Q Array of length m_kk that is to be averaged.
671 //! @return mole-fraction-weighted mean of Q
672 double mean_X(span<const double> Q) const;
673
674
675 //! The mean molecular weight. Units: (kg/kmol)
676 double meanMolecularWeight() const {
677 return m_mmw;
678 }
679
680 //! Evaluate @f$ \sum_k X_k \ln X_k @f$.
681 //! @return The indicated sum. Dimensionless.
682 double sum_xlogx() const;
683
684 //! @}
685 //! @name Adding Elements and Species
686 //!
687 //! These methods are used to add new elements or species. These are not
688 //! usually called by user programs.
689 //!
690 //! Since species are checked to insure that they are only composed of
691 //! declared elements, it is necessary to first add all elements before
692 //! adding any species.
693 //! @{
694
695 //! Add an element.
696 //! @param symbol Atomic symbol string.
697 //! @param weight Atomic mass in amu.
698 //! @param atomicNumber Atomic number of the element (unitless)
699 //! @param entropy298 Entropy of the element at 298 K and 1 bar in its
700 //! most stable form. The default is the value ENTROPY298_UNKNOWN,
701 //! which is interpreted as an unknown, and if used will cause
702 //! %Cantera to throw an error.
703 //! @param elem_type Specifies the type of the element constraint
704 //! equation. This defaults to CT_ELEM_TYPE_ABSPOS, that is, an element.
705 //! @return index of the element added
706 size_t addElement(const string& symbol, double weight=-12345.0,
707 int atomicNumber=0, double entropy298=ENTROPY298_UNKNOWN,
708 int elem_type=CT_ELEM_TYPE_ABSPOS);
709
710 //! Add a Species to this Phase. Returns `true` if the species was
711 //! successfully added, or `false` if the species was ignored.
712 //!
713 //! Derived classes which need to size arrays according to the number of
714 //! species should overload this method. The derived class implementation
715 //! should call the base class method, and, if this returns `true`
716 //! (indicating that the species has been added), adjust their array sizes
717 //! accordingly.
718 //!
719 //! @see ignoreUndefinedElements addUndefinedElements throwUndefinedElements
720 virtual bool addSpecies(shared_ptr<Species> spec);
721
722 //! Modify the thermodynamic data associated with a species.
723 /*!
724 * The species name, elemental composition, and type of thermo
725 * parameterization must be unchanged. If there are Kinetics objects that
726 * depend on this phase, Kinetics::invalidateCache() should be called on
727 * those objects after calling this function.
728 */
729 virtual void modifySpecies(size_t k, shared_ptr<Species> spec);
730
731 //! Add a species alias (that is, a user-defined alternative species name).
732 //! Aliases are case-sensitive.
733 //! @param name original species name
734 //! @param alias alternate name
735 void addSpeciesAlias(const string& name, const string& alias);
736
737 //! Lock species list to prevent addition of new species.
738 //! Increments a reference counter used to track whether the Phase is being used by
739 //! a Reactor, Domain1D, or MultiPhase object, which require the number of species
740 //! to remain constant. Should be called in C++ by the object owning the reference.
743 }
744
745 //! Decrement species lock counter.
746 //! Should only be called in C++ by the object owning the reference.
747 void removeSpeciesLock();
748
749 //! Return a vector with isomers names matching a given composition map
750 //! @param compMap Composition of the species.
751 //! @return A vector of species names for matching species.
752 virtual vector<string> findIsomers(const Composition& compMap) const;
753
754 //! Return a vector with isomers names matching a given composition string
755 //! @param comp String containing a composition map
756 //! @return A vector of species names for matching species.
757 virtual vector<string> findIsomers(const string& comp) const;
758
759 //! Return the Species object for the named species. Changes to this object
760 //! do not affect the ThermoPhase object until the #modifySpecies function
761 //! is called.
762 shared_ptr<Species> species(const string& name) const;
763
764 //! Return the Species object for species whose index is *k*. Changes to
765 //! this object do not affect the ThermoPhase object until the
766 //! #modifySpecies function is called.
767 shared_ptr<Species> species(size_t k) const;
768
769 //! Set behavior when adding a species containing undefined elements to just
770 //! skip the species.
772
773 //! Set behavior when adding a species containing undefined elements to add
774 //! those elements to the phase. This is the default behavior.
776
777 //! Set the behavior when adding a species containing undefined elements to
778 //! throw an exception.
780
781 struct UndefElement { enum behavior {
782 error, ignore, add
783 }; };
784
785 //! @} end group adding species and elements
786
787 //! Returns a bool indicating whether the object is ready for use
788 /*!
789 * @returns true if the object is ready for calculation, false otherwise.
790 */
791 virtual bool ready() const;
792
793 //! Return the State Mole Fraction Number
794 int stateMFNumber() const {
795 return m_stateNum;
796 }
797
798 //! Invalidate any cached values which are normally updated only when a
799 //! change in state is detected
800 virtual void invalidateCache();
801
802 //! Returns `true` if case sensitive species names are enforced
803 bool caseSensitiveSpecies() const {
805 }
806
807 //! Set flag that determines whether case sensitive species are enforced
808 //! in look-up operations, for example speciesIndex
809 void setCaseSensitiveSpecies(bool cflag = true) {
811 }
812
813 //! Converts a Composition to a vector with entries for each species
814 //! Species that are not specified are set to zero in the vector
815 /*!
816 * @param[in] comp Composition containing the mixture composition
817 * @return vector with length m_kk
818 */
819 vector<double> getCompositionFromMap(const Composition& comp) const;
820
821 //! Converts a mixture composition from mole fractions to mass fractions
822 //! @param[in] Y mixture composition in mass fractions (length m_kk)
823 //! @param[out] X mixture composition in mole fractions (length m_kk)
824 void massFractionsToMoleFractions(span<const double> Y, span<double> X) const;
825
826 //! Converts a mixture composition from mass fractions to mole fractions
827 //! @param[in] X mixture composition in mole fractions (length m_kk)
828 //! @param[out] Y mixture composition in mass fractions (length m_kk)
829 void moleFractionsToMassFractions(span<const double> X, span<double> Y) const;
830
831protected:
832 //! Ensure that phase is compressible.
833 //! An error is raised if the state is incompressible
834 //! @param setter name of setter (used for exception handling)
835 void assertCompressible(const string& setter) const {
836 if (!isCompressible()) {
837 throw CanteraError("Phase::assertCompressible",
838 "Setter '{}' is not available. Density is not an "
839 "independent \nvariable for "
840 "'{}' ('{}')", setter, name(), type());
841 }
842 }
843
844 //! Set the internally stored constant density (kg/m^3) of the phase.
845 //! Used for incompressible phases where the density is not an independent
846 //! variable, that is, density does not affect pressure in state calculations.
847 //! @param[in] density_ density (kg/m^3).
848 void assignDensity(const double density_);
849
850 //! Cached for saved calculations within each ThermoPhase.
851 /*!
852 * For more information on how to use this, see examples within the source
853 * code and documentation for this within ValueCache class itself.
854 */
856
857 //! Set the molecular weight of a single species to a given value.
858 //!
859 //! Used by phases where the equation of state is defined for a specific
860 //! value of the molecular weight which may not exactly correspond to the
861 //! value computed from the chemical formula.
862 //! @param k id of the species
863 //! @param mw Molecular Weight (kg kmol-1)
864 void setMolecularWeight(const int k, const double mw);
865
866 //! Apply changes to the state which are needed after the composition
867 //! changes. This function is called after any call to setMassFractions(),
868 //! setMoleFractions(), or similar. For phases which need to execute a
869 //! callback after any change to the composition, it should be done by
870 //! overriding this function rather than overriding all of the composition-
871 //! setting functions. Derived class implementations of compositionChanged()
872 //! should call the parent class method as well.
873 virtual void compositionChanged();
874
875 size_t m_kk = 0; //!< Number of species in the phase.
876
877 //! Dimensionality of the phase. Volumetric phases have dimensionality 3
878 //! and surface phases have dimensionality 2.
879 size_t m_ndim = 3;
880
881 //! Atomic composition of the species. The number of atoms of element i
882 //! in species k is equal to m_speciesComp[k * m_mm + i]
883 //! The length of this vector is equal to m_kk * m_mm
884 vector<double> m_speciesComp;
885
886 vector<double> m_speciesCharge; //!< Vector of species charges. length m_kk.
887
888 map<string, shared_ptr<Species>> m_species; //!< Map of Species objects
889
890 size_t m_nSpeciesLocks = 0; //!< Reference counter preventing species addition
891
892 //! Flag determining behavior when adding species with an undefined element
893 UndefElement::behavior m_undefinedElementBehavior = UndefElement::add;
894
895 //! Flag determining whether case sensitive species names are enforced
897
898 //! Vector of size m_kk, used as a temporary holding area.
899 mutable vector<double> m_workS;
900
901private:
902 //! Find lowercase species name in m_speciesIndices when case sensitive
903 //! species names are not enforced and a user specifies a non-canonical
904 //! species name. Raise exception if lowercase name is not unique.
905 size_t findSpeciesLower(const string& nameStr) const;
906
907 //! Name of the phase.
908 //! Initially, this is the name specified in the YAML input file. It may be changed
909 //! to another value during the course of a calculation.
910 string m_name;
911
912 double m_temp = 0.001; //!< Temperature (K). This is an independent variable
913
914 //! Density (kg m-3). This is an independent variable except in the case
915 //! of incompressible phases, where it has to be changed using the
916 //! assignDensity() method. For compressible substances, the pressure is
917 //! determined from this variable rather than other way round.
918 double m_dens = 0.001;
919
920 double m_mmw = 0.0; //!< mean molecular weight of the mixture (kg kmol-1)
921
922 //! m_ym[k] = mole fraction of species k divided by the mean molecular
923 //! weight of mixture.
924 mutable vector<double> m_ym;
925
926 //! Mass fractions of the species
927 /*!
928 * Note, this vector
929 * Length is m_kk
930 */
931 mutable vector<double> m_y;
932
933 vector<double> m_molwts; //!< species molecular weights (kg kmol-1)
934
935 vector<double> m_rmolwts; //!< inverse of species molecular weights (kmol kg-1)
936
937 //! State Change variable. Whenever the mole fraction vector changes,
938 //! this int is incremented.
939 int m_stateNum = -1;
940
941 //! Vector of the species names
942 vector<string> m_speciesNames;
943
944 //! Map of species names to indices
945 map<string, size_t> m_speciesIndices;
946
947 //! Map of lower-case species names to indices
948 map<string, size_t> m_speciesLower;
949
950 size_t m_mm = 0; //!< Number of elements.
951 vector<double> m_atomicWeights; //!< element atomic weights (kg kmol-1)
952 vector<int> m_atomicNumbers; //!< element atomic numbers
953 vector<string> m_elementNames; //!< element names
954 vector<int> m_elem_type; //!< Vector of element types
955
956 //! Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
957 vector<double> m_entropy298;
958};
959
960}
961
962#endif
Contains the getElementWeight function and the definitions of element constraint types.
#define CT_ELEM_TYPE_ABSPOS
Normal element constraint consisting of positive coefficients for the formula matrix.
Definition Elements.h:35
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298....
Definition Elements.h:85
Base class for exceptions thrown by Cantera classes.
An error indicating that an unimplemented function has been called.
Class Phase is the base class for phases of matter, managing the species and elements in a phase,...
Definition Phase.h:97
void getMoleFractions(span< double > x) const
Get the species mole fraction vector.
Definition Phase.cpp:441
void getMassFractions(span< double > y) const
Get the species mass fractions.
Definition Phase.cpp:479
span< const double > inverseMolecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition Phase.cpp:406
virtual vector< string > partialStates() const
Return a vector of settable partial property sets within a phase.
Definition Phase.cpp:212
map< string, size_t > m_speciesLower
Map of lower-case species names to indices.
Definition Phase.h:948
double massFraction(size_t k) const
Return the mass fraction of a single species.
Definition Phase.cpp:463
virtual double molarDensity() const
Molar density (kmol/m^3).
Definition Phase.cpp:587
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of the phase.
Definition Phase.cpp:608
Phase()=default
Default constructor.
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
Definition Phase.cpp:708
int changeElementType(int m, int elem_type)
Change the element type of the mth constraint Reassigns an element type.
Definition Phase.cpp:94
virtual vector< string > fullStates() const
Return a vector containing full states defining a phase.
Definition Phase.cpp:194
void assertCompressible(const string &setter) const
Ensure that phase is compressible.
Definition Phase.h:835
vector< double > m_workS
Vector of size m_kk, used as a temporary holding area.
Definition Phase.h:899
vector< double > m_speciesComp
Atomic composition of the species.
Definition Phase.h:884
ValueCache m_cache
Cached for saved calculations within each ThermoPhase.
Definition Phase.h:855
double m_temp
Temperature (K).
Definition Phase.h:912
size_t m_nSpeciesLocks
Reference counter preventing species addition.
Definition Phase.h:890
vector< string > m_speciesNames
Vector of the species names.
Definition Phase.h:942
size_t nSpecies() const
Returns the number of species in the phase.
Definition Phase.h:246
size_t checkElementIndex(size_t m) const
Check that the specified element index is in range.
Definition Phase.cpp:35
virtual void setElectronTemperature(double etemp)
Set the internally stored electron temperature of the phase (K).
Definition Phase.h:657
bool m_caseSensitiveSpecies
Flag determining whether case sensitive species names are enforced.
Definition Phase.h:896
vector< string > m_elementNames
element names
Definition Phase.h:953
void ignoreUndefinedElements()
Set behavior when adding a species containing undefined elements to just skip the species.
Definition Phase.cpp:893
UndefElement::behavior m_undefinedElementBehavior
Flag determining behavior when adding species with an undefined element.
Definition Phase.h:893
virtual map< string, size_t > nativeState() const
Return a map of properties defining the native state of a substance.
Definition Phase.cpp:164
double chargeDensity() const
Charge density [C/m^3].
Definition Phase.cpp:618
void addUndefinedElements()
Set behavior when adding a species containing undefined elements to add those elements to the phase.
Definition Phase.cpp:897
virtual string type() const
String indicating the thermodynamic model implemented.
Definition Phase.h:136
void setNDim(size_t ndim)
Set the number of spatial dimensions (1, 2, or 3).
Definition Phase.h:576
vector< int > m_atomicNumbers
element atomic numbers
Definition Phase.h:952
size_t m_kk
Number of species in the phase.
Definition Phase.h:875
int atomicNumber(size_t m) const
Atomic number of element m.
Definition Phase.cpp:84
virtual void modifySpecies(size_t k, shared_ptr< Species > spec)
Modify the thermodynamic data associated with a species.
Definition Phase.cpp:821
virtual void setMolesNoTruncate(span< const double > N)
Set the state of the object with moles in [kmol].
Definition Phase.cpp:540
double m_mmw
mean molecular weight of the mixture (kg kmol-1)
Definition Phase.h:920
double elementalMoleFraction(const size_t m) const
Elemental mole fraction of element m.
Definition Phase.cpp:570
size_t m_ndim
Dimensionality of the phase.
Definition Phase.h:879
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
Definition Phase.h:569
bool caseSensitiveSpecies() const
Returns true if case sensitive species names are enforced.
Definition Phase.h:803
size_t speciesIndex(const string &name, bool raise=true) const
Returns the index of a species named 'name' within the Phase object.
Definition Phase.cpp:127
void massFractionsToMoleFractions(span< const double > Y, span< double > X) const
Converts a mixture composition from mole fractions to mass fractions.
Definition Phase.cpp:939
void setCaseSensitiveSpecies(bool cflag=true)
Set flag that determines whether case sensitive species are enforced in look-up operations,...
Definition Phase.h:809
span< const double > molecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition Phase.cpp:401
void setState_TD(double t, double rho)
Set the internally stored temperature (K) and density (kg/m^3)
Definition Phase.cpp:375
vector< double > m_rmolwts
inverse of species molecular weights (kmol kg-1)
Definition Phase.h:935
double temperature() const
Temperature (K).
Definition Phase.h:585
virtual void setPressure(double p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition Phase.h:639
virtual bool isCompressible() const
Return whether phase represents a compressible substance.
Definition Phase.h:270
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition Phase.h:676
virtual double electronTemperature() const
Electron Temperature (K)
Definition Phase.h:591
virtual void restorePartialState(span< const double > state)
Set the internal thermodynamic state of the phase, excluding composition.
Definition Phase.cpp:237
virtual bool hasPhaseTransition() const
Return whether phase represents a substance with phase transitions.
Definition Phase.h:265
span< const double > massFractions() const
Return a view of the mass fraction array.
Definition Phase.h:465
void removeSpeciesLock()
Decrement species lock counter.
Definition Phase.cpp:854
void addSpeciesLock()
Lock species list to prevent addition of new species.
Definition Phase.h:741
Composition getMoleFractionsByName(double threshold=0.0) const
Get the mole fractions by name.
Definition Phase.cpp:417
virtual double concentration(const size_t k) const
Concentration of species k.
Definition Phase.cpp:485
double atomicWeight(size_t m) const
Atomic weight of element m.
Definition Phase.cpp:69
void setMassFractionsByName(const Composition &yMap)
Set the species mass fractions by name.
Definition Phase.cpp:364
int elementType(size_t m) const
Return the element constraint type Possible types include:
Definition Phase.cpp:89
virtual void setConcentrationsNoNorm(span< const double > conc)
Set the concentrations without ignoring negative concentrations.
Definition Phase.cpp:520
string speciesName(size_t k) const
Name of the species with index k.
Definition Phase.cpp:143
void getMolecularWeights(span< double > weights) const
Copy the vector of molecular weights into array weights.
Definition Phase.cpp:394
void moleFractionsToMassFractions(span< const double > X, span< double > Y) const
Converts a mixture composition from mass fractions to mole fractions.
Definition Phase.cpp:956
map< string, size_t > m_speciesIndices
Map of species names to indices.
Definition Phase.h:945
virtual void setDensity(const double density_)
Set the internally stored density (kg/m^3) of the phase.
Definition Phase.cpp:597
Composition getMassFractionsByName(double threshold=0.0) const
Get the mass fractions by name.
Definition Phase.cpp:429
virtual size_t stateSize() const
Return size of vector defining internal state of the phase.
Definition Phase.cpp:249
string nativeMode() const
Return string acronym representing the native state of a Phase.
Definition Phase.cpp:181
vector< double > getCompositionFromMap(const Composition &comp) const
Converts a Composition to a vector with entries for each species Species that are not specified are s...
Definition Phase.cpp:929
map< string, shared_ptr< Species > > m_species
Map of Species objects.
Definition Phase.h:888
size_t findSpeciesLower(const string &nameStr) const
Find lowercase species name in m_speciesIndices when case sensitive species names are not enforced an...
Definition Phase.cpp:108
vector< double > m_molwts
species molecular weights (kg kmol-1)
Definition Phase.h:933
virtual vector< string > findIsomers(const Composition &compMap) const
Return a vector with isomers names matching a given composition map.
Definition Phase.cpp:863
virtual bool isPure() const
Return whether phase represents a pure (single species) substance.
Definition Phase.h:260
vector< double > m_y
Mass fractions of the species.
Definition Phase.h:931
void setMoleFractionsByName(const Composition &xMap)
Set the species mole fractions by name.
Definition Phase.cpp:326
vector< int > m_elem_type
Vector of element types.
Definition Phase.h:954
double sum_xlogx() const
Evaluate .
Definition Phase.cpp:633
double mean_X(span< const double > Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
Definition Phase.cpp:627
string m_name
Name of the phase.
Definition Phase.h:910
double moleFraction(size_t k) const
Return the mole fraction of a single species.
Definition Phase.cpp:447
double m_dens
Density (kg m-3).
Definition Phase.h:918
virtual void setConcentrations(span< const double > conc)
Set the concentrations to the specified values within the phase.
Definition Phase.cpp:497
const vector< string > & elementNames() const
Return a read-only reference to the vector of element names.
Definition Phase.cpp:64
virtual void getConcentrations(span< double > c) const
Get the species concentrations (kmol/m^3).
Definition Phase.cpp:491
virtual double density() const
Density (kg/m^3).
Definition Phase.h:610
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
Definition Phase.cpp:925
vector< double > m_atomicWeights
element atomic weights (kg kmol-1)
Definition Phase.h:951
double nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
Definition Phase.cpp:101
int stateMFNumber() const
Return the State Mole Fraction Number.
Definition Phase.h:794
void addSpeciesAlias(const string &name, const string &alias)
Add a species alias (that is, a user-defined alternative species name).
Definition Phase.cpp:838
span< const double > atomicWeights() const
Return a read-only reference to the vector of atomic weights.
Definition Phase.cpp:79
size_t checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
Definition Phase.cpp:156
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
Definition Phase.h:646
size_t nElements() const
Number of elements.
Definition Phase.cpp:30
void setMolecularWeight(const int k, const double mw)
Set the molecular weight of a single species to a given value.
Definition Phase.cpp:915
vector< double > m_entropy298
Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
Definition Phase.h:957
void getCharges(span< double > charges) const
Copy the vector of species charges into array charges.
Definition Phase.cpp:411
virtual void setMoleFractions_NoNorm(span< const double > x)
Set the mole fractions to the specified values without normalizing.
Definition Phase.cpp:316
vector< double > m_ym
m_ym[k] = mole fraction of species k divided by the mean molecular weight of mixture.
Definition Phase.h:924
virtual void setMoleFractions(span< const double > x)
Set the mole fractions to the specified values.
Definition Phase.cpp:283
const vector< string > & speciesNames() const
Return a const reference to the vector of species names.
Definition Phase.cpp:151
size_t elementIndex(const string &name, bool raise=true) const
Return the index of element named 'name'.
Definition Phase.cpp:51
virtual void setMassFractions(span< const double > y)
Set the mass fractions to the specified values and normalize them.
Definition Phase.cpp:337
virtual bool ready() const
Returns a bool indicating whether the object is ready for use.
Definition Phase.cpp:905
double molecularWeight(size_t k) const
Molecular weight of species k.
Definition Phase.cpp:388
double elementalMassFraction(const size_t m) const
Elemental mass fraction of element m.
Definition Phase.cpp:560
shared_ptr< Species > species(const string &name) const
Return the Species object for the named species.
Definition Phase.cpp:881
virtual double molarVolume() const
Molar volume (m^3/kmol).
Definition Phase.cpp:592
virtual void invalidateCache()
Invalidate any cached values which are normally updated only when a change in state is detected.
Definition Phase.cpp:910
virtual void setMassFractions_NoNorm(span< const double > y)
Set the mass fractions to the specified values without normalizing.
Definition Phase.cpp:352
virtual size_t partialStateSize() const
Get the size of the partial state vector of the phase.
Definition Phase.h:317
virtual void savePartialState(span< double > state) const
Save the current thermodynamic state of the phase, excluding composition.
Definition Phase.cpp:225
virtual void restoreState(span< const double > state)
Restore the state of the phase from a previously saved state vector.
Definition Phase.cpp:269
int m_stateNum
State Change variable.
Definition Phase.h:939
void throwUndefinedElements()
Set the behavior when adding a species containing undefined elements to throw an exception.
Definition Phase.cpp:901
void setName(const string &nm)
Sets the string name for the phase.
Definition Phase.cpp:25
size_t m_mm
Number of elements.
Definition Phase.h:950
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Definition Phase.h:603
string elementName(size_t m) const
Name of the element with index m.
Definition Phase.cpp:43
double 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:561
double entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
Definition Phase.cpp:74
vector< double > m_speciesCharge
Vector of species charges.
Definition Phase.h:886
size_t addElement(const string &symbol, double weight=-12345.0, int atomicNumber=0, double entropy298=ENTROPY298_UNKNOWN, int elem_type=CT_ELEM_TYPE_ABSPOS)
Add an element.
Definition Phase.cpp:642
string name() const
Return the name of the phase.
Definition Phase.cpp:20
virtual void saveState(span< double > state) const
Write to array 'state' the current internal state.
Definition Phase.cpp:257
Storage for cached values.
Definition ValueCache.h:153
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
map< string, double > Composition
Map from string names to doubles.
Definition ct_defs.h:180