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