100 virtual ~Phase() =
default;
129 void setName(
const string& nm);
220 double nAtoms(
size_t k,
size_t m)
const;
341 virtual void saveState(span<double> state)
const;
605 "Not implemented for thermo model '{}'",
type());
625 virtual void setDensity(
const double density_);
641 "Not implemented for thermo model '{}'",
type());
651 "temperature must be positive. T = {}", temp);
659 "Not implemented for thermo model '{}'",
type());
672 double mean_X(span<const double> Q)
const;
706 size_t addElement(
const string& symbol,
double weight=-12345.0,
720 virtual bool addSpecies(shared_ptr<Species> spec);
729 virtual void modifySpecies(
size_t k, shared_ptr<Species> spec);
757 virtual vector<string>
findIsomers(
const string& comp)
const;
762 shared_ptr<Species>
species(
const string&
name)
const;
767 shared_ptr<Species>
species(
size_t k)
const;
791 virtual bool ready()
const;
838 "Setter '{}' is not available. Density is not an "
839 "independent \nvariable for "
840 "'{}' ('{}')", setter,
name(),
type());
931 mutable vector<double>
m_y;
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.
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298....
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,...
void getMoleFractions(span< double > x) const
Get the species mole fraction vector.
void getMassFractions(span< double > y) const
Get the species mass fractions.
span< const double > inverseMolecularWeights() const
Return a const reference to the internal vector of molecular weights.
virtual vector< string > partialStates() const
Return a vector of settable partial property sets within a phase.
map< string, size_t > m_speciesLower
Map of lower-case species names to indices.
double massFraction(size_t k) const
Return the mass fraction of a single species.
virtual double molarDensity() const
Molar density (kmol/m^3).
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of the phase.
Phase()=default
Default constructor.
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
int changeElementType(int m, int elem_type)
Change the element type of the mth constraint Reassigns an element type.
virtual vector< string > fullStates() const
Return a vector containing full states defining a phase.
void assertCompressible(const string &setter) const
Ensure that phase is compressible.
vector< double > m_workS
Vector of size m_kk, used as a temporary holding area.
vector< double > m_speciesComp
Atomic composition of the species.
ValueCache m_cache
Cached for saved calculations within each ThermoPhase.
double m_temp
Temperature (K).
size_t m_nSpeciesLocks
Reference counter preventing species addition.
vector< string > m_speciesNames
Vector of the species names.
size_t nSpecies() const
Returns the number of species in the phase.
size_t checkElementIndex(size_t m) const
Check that the specified element index is in range.
virtual void setElectronTemperature(double etemp)
Set the internally stored electron temperature of the phase (K).
bool m_caseSensitiveSpecies
Flag determining whether case sensitive species names are enforced.
vector< string > m_elementNames
element names
void ignoreUndefinedElements()
Set behavior when adding a species containing undefined elements to just skip the species.
UndefElement::behavior m_undefinedElementBehavior
Flag determining behavior when adding species with an undefined element.
virtual map< string, size_t > nativeState() const
Return a map of properties defining the native state of a substance.
double chargeDensity() const
Charge density [C/m^3].
void addUndefinedElements()
Set behavior when adding a species containing undefined elements to add those elements to the phase.
virtual string type() const
String indicating the thermodynamic model implemented.
void setNDim(size_t ndim)
Set the number of spatial dimensions (1, 2, or 3).
vector< int > m_atomicNumbers
element atomic numbers
size_t m_kk
Number of species in the phase.
int atomicNumber(size_t m) const
Atomic number of element m.
virtual void modifySpecies(size_t k, shared_ptr< Species > spec)
Modify the thermodynamic data associated with a species.
virtual void setMolesNoTruncate(span< const double > N)
Set the state of the object with moles in [kmol].
double m_mmw
mean molecular weight of the mixture (kg kmol-1)
double elementalMoleFraction(const size_t m) const
Elemental mole fraction of element m.
size_t m_ndim
Dimensionality of the phase.
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
bool caseSensitiveSpecies() const
Returns true if case sensitive species names are enforced.
size_t speciesIndex(const string &name, bool raise=true) const
Returns the index of a species named 'name' within the Phase object.
void massFractionsToMoleFractions(span< const double > Y, span< double > X) const
Converts a mixture composition from mole fractions to mass fractions.
void setCaseSensitiveSpecies(bool cflag=true)
Set flag that determines whether case sensitive species are enforced in look-up operations,...
span< const double > molecularWeights() const
Return a const reference to the internal vector of molecular weights.
void setState_TD(double t, double rho)
Set the internally stored temperature (K) and density (kg/m^3)
vector< double > m_rmolwts
inverse of species molecular weights (kmol kg-1)
double temperature() const
Temperature (K).
virtual void setPressure(double p)
Set the internally stored pressure (Pa) at constant temperature and composition.
virtual bool isCompressible() const
Return whether phase represents a compressible substance.
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual double electronTemperature() const
Electron Temperature (K)
virtual void restorePartialState(span< const double > state)
Set the internal thermodynamic state of the phase, excluding composition.
virtual bool hasPhaseTransition() const
Return whether phase represents a substance with phase transitions.
span< const double > massFractions() const
Return a view of the mass fraction array.
void removeSpeciesLock()
Decrement species lock counter.
void addSpeciesLock()
Lock species list to prevent addition of new species.
Composition getMoleFractionsByName(double threshold=0.0) const
Get the mole fractions by name.
virtual double concentration(const size_t k) const
Concentration of species k.
double atomicWeight(size_t m) const
Atomic weight of element m.
void setMassFractionsByName(const Composition &yMap)
Set the species mass fractions by name.
int elementType(size_t m) const
Return the element constraint type Possible types include:
virtual void setConcentrationsNoNorm(span< const double > conc)
Set the concentrations without ignoring negative concentrations.
string speciesName(size_t k) const
Name of the species with index k.
void getMolecularWeights(span< double > weights) const
Copy the vector of molecular weights into array weights.
void moleFractionsToMassFractions(span< const double > X, span< double > Y) const
Converts a mixture composition from mass fractions to mole fractions.
map< string, size_t > m_speciesIndices
Map of species names to indices.
virtual void setDensity(const double density_)
Set the internally stored density (kg/m^3) of the phase.
Composition getMassFractionsByName(double threshold=0.0) const
Get the mass fractions by name.
virtual size_t stateSize() const
Return size of vector defining internal state of the phase.
string nativeMode() const
Return string acronym representing the native state of a Phase.
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...
map< string, shared_ptr< Species > > m_species
Map of Species objects.
size_t findSpeciesLower(const string &nameStr) const
Find lowercase species name in m_speciesIndices when case sensitive species names are not enforced an...
vector< double > m_molwts
species molecular weights (kg kmol-1)
virtual vector< string > findIsomers(const Composition &compMap) const
Return a vector with isomers names matching a given composition map.
virtual bool isPure() const
Return whether phase represents a pure (single species) substance.
vector< double > m_y
Mass fractions of the species.
void setMoleFractionsByName(const Composition &xMap)
Set the species mole fractions by name.
vector< int > m_elem_type
Vector of element types.
double sum_xlogx() const
Evaluate .
double mean_X(span< const double > Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
string m_name
Name of the phase.
double moleFraction(size_t k) const
Return the mole fraction of a single species.
double m_dens
Density (kg m-3).
virtual void setConcentrations(span< const double > conc)
Set the concentrations to the specified values within the phase.
const vector< string > & elementNames() const
Return a read-only reference to the vector of element names.
virtual void getConcentrations(span< double > c) const
Get the species concentrations (kmol/m^3).
virtual double density() const
Density (kg/m^3).
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
vector< double > m_atomicWeights
element atomic weights (kg kmol-1)
double nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
int stateMFNumber() const
Return the State Mole Fraction Number.
void addSpeciesAlias(const string &name, const string &alias)
Add a species alias (that is, a user-defined alternative species name).
span< const double > atomicWeights() const
Return a read-only reference to the vector of atomic weights.
size_t checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
size_t nElements() const
Number of elements.
void setMolecularWeight(const int k, const double mw)
Set the molecular weight of a single species to a given value.
vector< double > m_entropy298
Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
void getCharges(span< double > charges) const
Copy the vector of species charges into array charges.
virtual void setMoleFractions_NoNorm(span< const double > x)
Set the mole fractions to the specified values without normalizing.
vector< double > m_ym
m_ym[k] = mole fraction of species k divided by the mean molecular weight of mixture.
virtual void setMoleFractions(span< const double > x)
Set the mole fractions to the specified values.
const vector< string > & speciesNames() const
Return a const reference to the vector of species names.
size_t elementIndex(const string &name, bool raise=true) const
Return the index of element named 'name'.
virtual void setMassFractions(span< const double > y)
Set the mass fractions to the specified values and normalize them.
virtual bool ready() const
Returns a bool indicating whether the object is ready for use.
double molecularWeight(size_t k) const
Molecular weight of species k.
double elementalMassFraction(const size_t m) const
Elemental mass fraction of element m.
shared_ptr< Species > species(const string &name) const
Return the Species object for the named species.
virtual double molarVolume() const
Molar volume (m^3/kmol).
virtual void invalidateCache()
Invalidate any cached values which are normally updated only when a change in state is detected.
virtual void setMassFractions_NoNorm(span< const double > y)
Set the mass fractions to the specified values without normalizing.
virtual size_t partialStateSize() const
Get the size of the partial state vector of the phase.
virtual void savePartialState(span< double > state) const
Save the current thermodynamic state of the phase, excluding composition.
virtual void restoreState(span< const double > state)
Restore the state of the phase from a previously saved state vector.
int m_stateNum
State Change variable.
void throwUndefinedElements()
Set the behavior when adding a species containing undefined elements to throw an exception.
void setName(const string &nm)
Sets the string name for the phase.
size_t m_mm
Number of elements.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
string elementName(size_t m) const
Name of the element with index m.
double charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
double entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
vector< double > m_speciesCharge
Vector of species charges.
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.
string name() const
Return the name of the phase.
virtual void saveState(span< double > state) const
Write to array 'state' the current internal state.
Storage for cached values.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
map< string, double > Composition
Map from string names to doubles.