35 class ElementsFrozen :
public CanteraError
41 :
CanteraError(func,
"Elements cannot be added after species.") {}
137 std::string
id()
const;
141 void setID(
const std::string&
id);
144 std::string
name()
const;
148 void setName(
const std::string& nm);
221 doublereal
nAtoms(
size_t k,
size_t m)
const;
227 void getAtoms(
size_t k,
double* atomArray)
const;
277 void saveState(
size_t lenstate, doublereal* state)
const;
286 void restoreState(
size_t lenstate,
const doublereal* state);
321 void setState_TRX(doublereal t, doublereal dens,
const doublereal* x);
335 void setState_TRY(doublereal t, doublereal dens,
const doublereal* y);
349 void setState_TNX(doublereal t, doublereal n,
const doublereal* x);
398 doublereal
size(
size_t k)
const {
550 if (density_ <= 0.0) {
551 throw CanteraError(
"Phase::setDensity()",
"density must be positive");
565 "temperature must be positive");
579 doublereal
mean_X(
const doublereal*
const Q)
const;
585 doublereal
mean_Y(
const doublereal*
const Q)
const;
599 doublereal
sum_xlogQ(doublereal*
const Q)
const;
614 void addElement(
const std::string& symbol, doublereal weight=-12345.0);
632 void addUniqueElement(
const std::string& symbol, doublereal weight=-12345.0,
633 int atomicNumber = 0,
665 doublereal weight,
int atomicNumber,
669 void addSpecies(
const std::string& name,
const doublereal* comp,
670 doublereal
charge = 0.0, doublereal
size = 1.0);
682 doublereal
size = 1.0);
694 virtual bool ready()
const;
Phase()
Default constructor.
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
doublereal nAtoms(size_t k, size_t m) const
Number of atoms of element m in species k.
virtual void setMoleFractions_NoNorm(const doublereal *const x)
Set the mole fractions to the specified values without normalizing.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
vector_fp m_y
species mass fractions
void setState_RY(doublereal rho, doublereal *y)
Set the density (kg/m^3) and mass fractions.
std::vector< std::string > m_elementNames
element names
virtual doublereal density() const
Density (kg/m^3).
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
bool m_elementsFrozen
If this is true, then no elements may be added to the object.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
void setState_TRY(doublereal t, doublereal dens, const doublereal *y)
Set the internally stored temperature (K), density, and mass fractions.
size_t nElements() const
Number of elements.
vector_fp m_atomicWeights
element atomic weights (kg kmol-1)
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
vector_fp m_speciesCharge
Vector of species charges. length m_kk.
vector_fp m_entropy298
Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
doublereal atomicWeight(size_t m) const
Atomic weight of element m.
Class XML_Node is a tree-based representation of the contents of an XML file.
doublereal size(size_t k) const
This routine returns the size of species k.
Contains the LookupWtElements function and the definitions of element constraint types.
vector_fp m_speciesSize
Vector of species sizes.
doublereal m_mmw
mean molecular weight of the mixture (kg kmol-1)
Base class for phases of matter.
void addElement(const std::string &symbol, doublereal weight=-12345.0)
Add an element.
#define CT_ELEM_TYPE_ABSPOS
Normal element constraint consisting of positive coefficients for the formula matrix.
int stateMFNumber() const
Return the State Mole Fraction Number.
doublereal molarDensity() const
Molar density (kmol/m^3).
void getMoleFractionsByName(compositionMap &x) const
Get the mole fractions by name.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
void checkElementIndex(size_t m) const
Check that the specified element index is in range Throws an exception if m is greater than nElements...
void getConcentrations(doublereal *const c) const
Get the species concentrations (kmol/m^3).
std::string name() const
Return the name of the phase.
std::string m_name
Name of the phase.
void checkElementArraySize(size_t mm) const
Check that an array size is at least nElements() Throws an exception if mm is less than nElements()...
doublereal concentration(const size_t k) const
Concentration of species k.
doublereal sum_xlogQ(doublereal *const Q) const
Evaluate .
doublereal entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range Throws an exception if k is greater than nSpecies(...
void setName(const std::string &nm)
Sets the string name for the phase.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
std::vector< int > vector_int
Vector of ints.
const vector_fp & atomicWeights() const
Return a read-only reference to the vector of atomic weights.
void setMassFractionsByName(compositionMap &yMap)
Set the species mass fractions by name.
int m_stateNum
State Change variable.
size_t m_ndim
Dimensionality of the phase.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
std::vector< std::string > m_speciesNames
Vector of the species names.
void setState_TRX(doublereal t, doublereal dens, const doublereal *x)
Set the internally stored temperature (K), density, and mole fractions.
void getAtoms(size_t k, double *atomArray) const
Get a vector containing the atomic composition of species k.
bool elementsFrozen()
True if freezeElements has been called.
void addUniqueElement(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, checking for uniqueness The uniqueness is checked by comparing the string symbol...
doublereal molarVolume() const
Molar volume (m^3/kmol).
ElementsFrozen(const std::string &func)
Constructor for class.
doublereal sum_xlogx() const
Evaluate .
bool speciesFrozen()
True if freezeSpecies has been called.
int atomicNumber(size_t m) const
Atomic number of element m.
doublereal chargeDensity() const
Charge density [C/m^3].
const doublereal * massFractions() const
Return a const pointer to the mass fraction array.
std::string id() const
Return the string id for the phase.
Base class for exceptions thrown by Cantera classes.
void setState_TNX(doublereal t, doublereal n, const doublereal *x)
Set the internally stored temperature (K), molar density (kmol/m^3), and mole fractions.
void setMoleFractionsByName(compositionMap &xMap)
Set the species mole fractions by name.
void addElementsFromXML(const XML_Node &phase)
Add all elements referenced in an XML_Node tree.
virtual void setConcentrations(const doublereal *const conc)
Set the concentrations to the specified values within the phase.
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values There is no restriction on the sum of the mole fractio...
virtual ~Phase()
Destructor.
const std::vector< std::string > & elementNames() const
Return a read-only reference to the vector of element names.
doublereal massFraction(size_t k) const
Return the mass fraction of a single species.
virtual void setMolarDensity(const doublereal molarDensity)
Set the internally stored molar density (kmol/m^3) of the phase.
virtual void freezeSpecies()
Call when finished adding species.
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298...
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions to the specified values without normalizing.
size_t nSpecies() const
Returns the number of species in the phase.
void setNDim(size_t ndim)
Set the number of spatial dimensions (1, 2, or 3).
void setState_TX(doublereal t, doublereal *x)
Set the internally stored temperature (K) and mole fractions.
vector_int m_elem_type
Vector of element types.
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
void setMolecularWeight(const int k, const double mw)
Set the molecular weight of a single species to a given value.
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
bool m_speciesFrozen
Boolean indicating whether the number of species has been frozen.
doublereal temperature() const
Temperature (K).
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
void freezeElements()
Prohibit addition of more elements, and prepare to add species.
vector_fp m_molwts
species molecular weights (kg kmol-1)
void setState_TY(doublereal t, doublereal *y)
Set the internally stored temperature (K) and mass fractions.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies() Throws an exception if kk is less than nSpecies()...
size_t elementIndex(const std::string &name) const
Return the index of element named 'name'.
Templates for operations on vector-like objects.
Phase & operator=(const Phase &right)
Assignment operator.
size_t m_mm
Number of elements.
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
std::string m_id
ID of the phase.
doublereal m_dens
Density (kg m-3).
vector_fp m_ym
m_ym[k] = mole fraction of species k divided by the mean molecular weight of mixture.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
XML_Node * m_xml
XML node containing the XML info for this phase.
vector_int m_atomicNumbers
element atomic numbers
std::string speciesSPName(int k) const
Returns the expanded species name of a species, including the phase name This is guaranteed to be uni...
void getMolecularWeights(vector_fp &weights) const
Copy the vector of molecular weights into vector weights.
std::string elementName(size_t m) const
Name of the element with index m.
doublereal m_temp
Temperature (K). This is an independent variable.
void saveState(vector_fp &state) const
Save the current internal state of the phase Write to vector 'state' the current internal state...
XML_Node & xml()
Returns a reference to the XML_Node stored for the phase.
virtual void setMassFractions(const doublereal *const y)
Set the mass fractions to the specified values and normalize them.
int elementType(size_t m) const
Return the element constraint type Possible types include:
void init(const vector_fp &mw)
vector_fp m_rmolwts
inverse of species molecular weights (kmol kg-1)
vector_fp m_speciesComp
Atomic composition of the species.
void setState_RX(doublereal rho, doublereal *x)
Set the density (kg/m^3) and mole fractions.
size_t m_kk
Number of species in the phase.
size_t addUniqueElementAfterFreeze(const std::string &symbol, doublereal weight, int atomicNumber, doublereal entropy298=ENTROPY298_UNKNOWN, int elem_type=CT_ELEM_TYPE_ABSPOS)
Add an element after elements have been frozen, checking for uniqueness The uniqueness is checked by ...
int changeElementType(int m, int elem_type)
Change the element type of the mth constraint Reassigns an element type.
void setID(const std::string &id)
Set the string id for the phase.
void setState_TR(doublereal t, doublereal rho)
Set the internally stored temperature (K) and density (kg/m^3)
std::string speciesName(size_t k) const
Name of the species with index k.
void addUniqueSpecies(const std::string &name, const doublereal *comp, doublereal charge=0.0, doublereal size=1.0)
Add a species to the phase, checking for uniqueness of the name This routine checks for uniqueness of...
const doublereal * moleFractdivMMW() const
Returns a const pointer to the start of the moleFraction/MW array.
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase Note the density of a phase is an independent...
doublereal mean_Y(const doublereal *const Q) const
Evaluate the mass-fraction-weighted mean of an array Q.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...