153 std::string
id()
const;
161 void setID(
const std::string&
id);
167 std::string
name()
const;
171 void setName(
const std::string& nm);
176 virtual std::string
type()
const {
254 doublereal
nAtoms(
size_t k,
size_t m)
const;
260 void getAtoms(
size_t k,
double* atomArray)
const;
321 virtual std::map<std::string, size_t>
nativeState()
const;
340 virtual std::vector<std::string>
fullStates()
const;
361 virtual void saveState(
size_t lenstate, doublereal* state)
const;
370 virtual void restoreState(
size_t lenstate,
const doublereal* state);
405 void setState_TRX(doublereal t, doublereal dens,
const doublereal* x);
419 void setState_TRY(doublereal t, doublereal dens,
const doublereal* y);
434 void setState_TNX(doublereal t, doublereal n,
const doublereal* x);
700 virtual void setDensity(
const double density_);
729 "temperature must be positive. T = {}", temp);
742 doublereal
mean_X(
const doublereal*
const Q)
const;
778 size_t addElement(
const std::string& symbol, doublereal weight=-12345.0,
792 virtual bool addSpecies(shared_ptr<Species> spec);
801 virtual void modifySpecies(
size_t k, shared_ptr<Species> spec);
819 virtual std::vector<std::string>
findIsomers(
const std::string& comp)
const;
824 shared_ptr<Species>
species(
const std::string&
name)
const;
829 shared_ptr<Species>
species(
size_t k)
const;
843 struct UndefElement {
enum behavior {
853 virtual bool ready()
const;
876 virtual void setRoot(std::shared_ptr<Solution> root) {
905 "Setter '{}' is not available. Density is not an "
906 "independent \nvariable for "
907 "'{}' ('{}')", setter,
name(),
type());
955 std::map<std::string, shared_ptr<Species> > m_species;
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....
Declaration for class Cantera::Species.
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,...
const vector_fp & atomicWeights() const
Return a read-only reference to the vector of atomic weights.
Phase()
Default constructor.
doublereal m_mmw
mean molecular weight of the mixture (kg kmol-1)
doublereal entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
void getCharges(double *charges) const
Copy the vector of species charges into array charges.
vector_int m_elem_type
Vector of element types.
void getConcentrations(double *const c) const
Get the species concentrations (kmol/m^3).
double massFraction(size_t k) const
Return the mass fraction of a single species.
void setName(const std::string &nm)
Sets the string name for the phase.
vector_int m_atomicNumbers
element atomic numbers
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.
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
size_t addElement(const std::string &symbol, doublereal weight=-12345.0, int atomicNumber=0, doublereal entropy298=ENTROPY298_UNKNOWN, int elem_type=CT_ELEM_TYPE_ABSPOS)
Add an element.
virtual void setMoleFractions(const double *const x)
Set the mole fractions to the specified values.
virtual std::vector< std::string > fullStates() const
Return a vector containing full states defining a phase.
int changeElementType(int m, int elem_type)
Change the element type of the mth constraint Reassigns an element type.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
vector_fp m_speciesCharge
Vector of species charges. length m_kk.
vector_fp m_rmolwts
inverse of species molecular weights (kmol kg-1)
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
std::map< std::string, size_t > m_speciesIndices
Map of species names to indices.
std::string name() const
Return the name of the phase.
ValueCache m_cache
Cached for saved calculations within each ThermoPhase.
const double * moleFractdivMMW() const
Returns a const pointer to the start of the moleFraction/MW array.
size_t nSpecies() const
Returns the number of species in the phase.
void setMoleFractionsByName(const compositionMap &xMap)
Set the species mole fractions by name.
bool m_caseSensitiveSpecies
Flag determining whether case sensitive species names are enforced.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
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 void setMassFractions_NoNorm(const double *const y)
Set the mass fractions to the specified values without normalizing.
void assertCompressible(const std::string &setter) const
Ensure that phase is compressible.
std::string speciesSPName(int k) const
Returns the expanded species name of a species, including the phase name This is guaranteed to be uni...
vector_fp getCompositionFromMap(const compositionMap &comp) const
Converts a compositionMap to a vector with entries for each species Species that are not specified ar...
vector_fp m_y
Mass fractions of the species.
std::vector< std::string > m_elementNames
element names
void addUndefinedElements()
Set behavior when adding a species containing undefined elements to add those elements to the phase.
virtual void setConcentrationsNoNorm(const double *const conc)
Set the concentrations without ignoring negative concentrations.
vector_fp m_molwts
species molecular weights (kg kmol-1)
void setNDim(size_t ndim)
Set the number of spatial dimensions (1, 2, or 3).
void setState_TRX(doublereal t, doublereal dens, const doublereal *x)
Set the internally stored temperature (K), density, and mole fractions.
XML_Node & xml() const
Returns a const reference to the XML_Node that describes the phase.
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.
std::string m_id
ID of the phase.
std::string id() const
Return the string id for the phase.
void setState_RX(doublereal rho, doublereal *x)
Set the density (kg/m^3) and mole fractions.
doublereal m_temp
Temperature (K). This is an independent variable.
virtual std::vector< std::string > findIsomers(const compositionMap &compMap) const
Return a vector with isomers names matching a given composition map.
std::map< std::string, size_t > m_speciesLower
Map of lower-case species names to indices.
void setXMLdata(XML_Node &xmlPhase)
Stores the XML tree information for the current phase.
size_t m_ndim
Dimensionality of the phase.
void setState_RY(doublereal rho, doublereal *y)
Set the density (kg/m^3) and mass fractions.
std::vector< std::string > m_speciesNames
Vector of the species names.
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
void saveState(vector_fp &state) const
Save the current internal state of the phase.
void setState_TRY(doublereal t, doublereal dens, const doublereal *y)
Set the internally stored temperature (K), density, and mass fractions.
vector_fp m_speciesComp
Atomic composition of the species.
void getMolecularWeights(vector_fp &weights) const
Copy the vector of molecular weights into vector weights.
bool caseSensitiveSpecies() const
Returns true if case sensitive species names are enforced.
void setID(const std::string &id)
Set the string id for the phase.
virtual std::map< std::string, size_t > nativeState() const
Return a map of properties defining the native state of a substance.
void setCaseSensitiveSpecies(bool cflag=true)
Set flag that determines whether case sensitive species are enforced in look-up operations,...
virtual std::vector< std::string > partialStates() const
Return a vector of settable partial property sets within a phase.
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
doublereal atomicWeight(size_t m) const
Atomic weight of element m.
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.
void moleFractionsToMassFractions(const double *X, double *Y) const
Converts a mixture composition from mass fractions to mole fractions.
size_t elementIndex(const std::string &name) const
Return the index of element named 'name'.
void addSpeciesAlias(const std::string &name, const std::string &alias)
Add a species alias (i.e.
virtual bool hasPhaseTransition() const
Return whether phase represents a substance with phase transitions.
virtual void setConcentrations(const double *const conc)
Set the concentrations to the specified values within the phase.
void setState_TNX(doublereal t, doublereal n, const doublereal *x)
Set the internally stored temperature (K), molar density (kmol/m^3), and mole fractions.
virtual void setMolarDensity(const double molarDensity)
Set the internally stored molar density (kmol/m^3) of the phase.
virtual void setRoot(std::shared_ptr< Solution > root)
Set root Solution holding all phase information.
size_t findSpeciesLower(const std::string &nameStr) const
Find lowercase species name in m_speciesIndices when case sensitive species names are not enforced an...
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
vector_fp m_ym
m_ym[k] = mole fraction of species k divided by the mean molecular weight of mixture.
double concentration(const size_t k) const
Concentration of species k.
void checkElementArraySize(size_t mm) const
Check that an array size is at least nElements().
int elementType(size_t m) const
Return the element constraint type Possible types include:
std::string speciesName(size_t k) const
Name of the species with index k.
doublereal elementalMassFraction(const size_t m) const
Elemental mass fraction of element m.
virtual void setDensity(const double density_)
Set the internally stored density (kg/m^3) of the phase.
virtual size_t stateSize() const
Return size of vector defining internal state of the phase.
const double * massFractions() const
Return a const pointer to the mass fraction array.
virtual std::string type() const
String indicating the thermodynamic model implemented.
vector_fp m_entropy298
Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
std::weak_ptr< Solution > m_root
reference to Solution
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual bool isPure() const
Return whether phase represents a pure (single species) substance.
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
void setState_TX(doublereal t, doublereal *x)
Set the internally stored temperature (K) and mole fractions.
vector_fp m_atomicWeights
element atomic weights (kg kmol-1)
compositionMap getMassFractionsByName(double threshold=0.0) const
Get the mass fractions by name.
double moleFraction(size_t k) const
Return the mole fraction of a single species.
void setState_TR(doublereal t, doublereal rho)
Set the internally stored temperature (K) and density (kg/m^3)
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
const std::vector< std::string > & elementNames() const
Return a read-only reference to the vector of element names.
virtual double density() const
Density (kg/m^3).
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies().
int stateMFNumber() const
Return the State Mole Fraction Number.
doublereal m_dens
Density (kg m-3).
doublereal elementalMoleFraction(const size_t m) const
Elemental mole fraction of element m.
doublereal temperature() const
Temperature (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.
XML_Node * m_xml
XML node containing the XML info for this phase.
virtual void setMassFractions(const double *const y)
Set the mass fractions to the specified values and normalize them.
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
std::string m_name
Name of the phase.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
void setState_TY(doublereal t, doublereal *y)
Set the internally stored temperature (K) and mass fractions.
virtual bool ready() const
Returns a bool indicating whether the object is ready for use.
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.
void checkElementIndex(size_t m) const
Check that the specified element index is in range.
void setMassFractionsByName(const compositionMap &yMap)
Set the species mass fractions by name.
void getMassFractions(double *const y) const
Get the species mass fractions.
void getAtoms(size_t k, double *atomArray) const
Get a vector containing the atomic composition of species k.
int m_stateNum
State Change variable.
void throwUndefinedElements()
Set the behavior when adding a species containing undefined elements to throw an exception.
size_t m_mm
Number of elements.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
std::string elementName(size_t m) const
Name of the element with index m.
shared_ptr< Species > species(const std::string &name) const
Return the Species object for the named species.
void massFractionsToMoleFractions(const double *Y, double *X) const
Converts a mixture composition from mole fractions to mass fractions.
compositionMap getMoleFractionsByName(double threshold=0.0) const
Get the mole fractions by name.
virtual void setMoleFractions_NoNorm(const double *const x)
Set the mole fractions to the specified values without normalizing.
doublereal chargeDensity() const
Charge density [C/m^3].
doublereal sum_xlogx() const
Evaluate .
Class XML_Node is a tree-based representation of the contents of an XML file.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
std::vector< int > vector_int
Vector of ints.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
Namespace for the Cantera kernel.