22 LatticeSolidPhase::LatticeSolidPhase() :
82 if (lkstart_[n+1] < k) {
83 return (
m_lattice[n])->minTemp(k-lkstart_[n]);
87 doublereal mm = 1.0E300;
90 mm = std::min(mm, ml);
99 if (lkstart_[n+1] < k) {
100 return (
m_lattice[n])->maxTemp(k - lkstart_[n]);
104 doublereal mm = -1.0E300;
107 mm = std::max(mm, ml);
120 doublereal sum = 0.0;
130 doublereal sum = 0.0;
140 doublereal sum = 0.0;
150 doublereal sum = 0.0;
160 doublereal sum = 0.0;
179 for (
size_t k = 0; k <
m_kk; k++) {
215 size_t nsp, strt = 0;
218 m_lattice[n]->setMoleFractions(x + strt);
221 for (
size_t k = 0; k < strt; k++) {
230 size_t nsp, strt = 0;
237 for (
size_t k = 0; k < nsp; k++) {
238 sum += (x + strt)[k];
240 for (
size_t k = 0; k < nsp; k++) {
241 (x + strt)[k] /= sum;
249 for (
size_t k = 0; k < nsp; k++) {
250 if (fabs((x + strt)[k] -
m_x[strt+k]) > 1.0E-14) {
251 throw CanteraError(
"LatticeSolidPhase::getMoleFractions()",
266 m_lattice[n]->getChemPotentials(mu+strt);
277 m_lattice[n]->getPartialMolarEnthalpies(hbar + strt);
288 m_lattice[n]->getPartialMolarEntropies(sbar + strt);
299 m_lattice[n]->getPartialMolarCp(cpbar + strt);
310 m_lattice[n]->getPartialMolarVolumes(vbar + strt);
320 m_lattice[n]->getStandardChemPotentials(mu0+strt);
329 m_lattice[n]->getGibbs_RT_ref(grt + lkstart_[n]);
336 for (
size_t k = 0; k <
m_kk; k++) {
352 std::vector<XML_Node*> lattices;
356 XML_Node* phaseNode_ptr = lattices[n];
358 vector<doublereal> constArr(lp->
nElements());
360 for (
size_t es = 0; es < lp->
nElements(); es++) {
368 const std::vector<const XML_Node*> & spNode = lp->
speciesData();
372 for (
size_t k = 0; k < nsp; k++) {
374 std::map<std::string, double> comp;
378 for (
size_t m = 0; m < lp->
nElements(); m++) {
379 if (constArr[m] != 0.0) {
382 if (newIndex ==
npos) {
383 throw CanteraError(
"LatticeSolidPhase::installSlavePhases",
"confused");
385 ecomp[newIndex] = constArr[m];
388 double chrg = lp->
charge(k);
389 double sz = lp->
size(k);
407 for (
size_t k = 0; k < nsp0; k++) {
410 for (
size_t k = 0; k < nsp; k++) {
411 size_t ks = kstart + k;
425 for (
size_t k = 0; k < nsp; k++) {
426 m_x[loc] =
m_lattice[n]->moleFraction(k) / (double) m_nlattice;
465 m_lattice[nn]->setMoleFractionsByName(x);
471 for (
size_t k = 0; k < nsp; k++) {
481 eosdata.
_require(
"model",
"LatticeSolid");
483 std::vector<XML_Node*> lattices;
485 size_t nl = lattices.size();
487 for (
size_t n = 0; n < nl; n++) {
491 std::vector<string> pnam;
492 std::vector<string> pval;
496 for (
int i = 0; i < np; i++) {
499 for (
size_t j = 0; j < nl; j++) {
501 string idj = tp.
id();
502 if (idj == pnam[i]) {
515 #ifdef H298MODIFY_CAPABILITY
519 if (lkstart_[n+1] < k) {
520 size_t kk = k-lkstart_[n];
522 l_spthermo.modifyOneHf298(kk, Hf298New);
532 throw CanteraError(
"LatticeSolidPhase",
"Unimplemented " + msg);
Factory to build instances of classes that manage the standard-state thermodynamic properties of a se...
void _require(const std::string &a, const std::string &v) const
Require that the current xml node have an attribute named by the first argument, a, and that this attribute have the the string value listed in the second argument, v.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
std::vector< LatticePhase * > m_lattice
Vector of sublattic ThermoPhase objects.
virtual void installSlavePhases(Cantera::XML_Node *phaseNode)
Add in species from Slave phases.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution...
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
size_t nElements() const
Number of elements.
std::vector< const XML_Node * > m_speciesData
Vector of pointers to the species databases.
doublereal calcDensity()
Calculate the density of the solid mixture.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
const size_t npos
index returned by functions to indicate "no position"
ThermoPhase & operator=(const ThermoPhase &right)
Assignment operator.
LatticeSolidPhase & operator=(const LatticeSolidPhase &right)
Assignment operator.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
LatticeSolidPhase()
Base empty constructor.
static SpeciesThermoFactory * factory()
Static method to return an instance of this class.
virtual void modifyOneHf298SS(const int k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) ...
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values, and then normalize them so that they sum to 1...
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual doublereal cp_mole() const
Return the constant pressure heat capacity. Units: J/kmol/K.
doublereal size(size_t k) const
This routine returns the size of species k.
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
virtual ~LatticeSolidPhase()
Destructor.
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms. ...
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
void installThermoForSpecies(size_t k, const XML_Node &speciesNode, ThermoPhase *th_ptr, SpeciesThermo &spthermo, const XML_Node *phaseNode_ptr=0) const
Install a species thermodynamic property parameterization for the reference state for one species int...
Pure Virtual base class for the species thermo manager classes.
doublereal m_tlast
Last temperature at which the reference thermo was calculated.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
doublereal entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
Base class for a phase with thermodynamic properties.
void _updateThermo() const
Update the reference thermodynamic functions.
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of standard state chemical potentials at unit activity for the species at their standar...
const vector_fp & atomicWeights() const
Return a read-only reference to the vector of atomic weights.
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the gibbs function of the reference state at the current temperatureof the solu...
A species thermodynamic property manager for a phase.
void getAtoms(size_t k, double *atomArray) const
Get a vector containing the atomic composition of species k.
Header for a simple thermodynamics model of a bulk solid phase derived from ThermoPhase, assuming an ideal solution model based on a lattice of solid atoms (see Thermodynamic Properties and class LatticeSolidPhase).
void initLengths()
Initialize vectors that depend on the number of species and sublattices.
ThermoPhase * duplMyselfAsThermoPhase() const
Duplication function.
doublereal m_molar_density
Current value of the molar density.
int atomicNumber(size_t m) const
Atomic number of element m.
vector_fp tmpV_
Temporary vector.
doublereal err(const std::string &msg) const
error routine
std::string id() const
Return the string id for the phase.
Base class for exceptions thrown by Cantera classes.
int getPairs(const Cantera::XML_Node &node, std::vector< std::string > &key, std::vector< std::string > &val)
This function interprets the value portion of an XML element as a series of "Pairs" separated by whit...
doublereal m_press
Current value of the pressure.
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 doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual void getPartialMolarVolumes(doublereal *vbar) const
returns an array of partial molar volumes of the species in the solution.
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
virtual doublereal intEnergy_mole() const
Return the Molar Internal Energy. Units: J/kmol.
void setLatticeMoleFractionsByName(int n, const std::string &x)
Set the Lattice mole fractions using a string.
size_t nSpecies() const
Returns the number of species in the phase.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid...
doublereal temperature() const
Temperature (K).
vector_fp m_x
Vector of mole fractions.
Header for factory to build instances of classes that manage the standard-state thermodynamic propert...
Headers for a completely general species thermodynamic property manager for a phase (see Managers for...
std::vector< doublereal > theta_
Lattice stoichiometric coefficients.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
size_t elementIndex(const std::string &name) const
Return the index of element named 'name'.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized activity concentrations.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
A phase that is comprised of a fixed additive combination of other lattice phases.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
const std::vector< const XML_Node * > & speciesData() const
Return a pointer to the vector of XML nodes containing the species data for this phase.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
virtual doublereal entropy_mole() const
Return the Molar Entropy. Units: J/kmol/K.
std::string elementName(size_t m) const
Name of the element with index m.
int elementType(size_t m) const
Return the element constraint type Possible types include:
vector_fp m_speciesComp
Atomic composition of the species.
#define CT_ELEM_TYPE_LATTICERATIO
Constraint associated with maintaining a fixed lattice stoichiometry in a solid.
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 ...
void setSpeciesThermo(SpeciesThermo *spthermo)
Install a species thermodynamic property manager.
size_t m_nlattice
Number of sublattice phases.
virtual void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
virtual doublereal gibbs_mole() const
Return the Molar Gibbs energy. Units: J/kmol.
SpeciesThermo * m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
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...
Header for a simple thermodynamics model of a bulk phase derived from ThermoPhase, assuming a lattice of solid atoms (see Thermodynamic Properties and class LatticePhase).
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
void getChildren(const std::string &name, std::vector< XML_Node * > &children) const
Get a vector of pointers to XML_Node containing all of the children of the current node which matches...
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 charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...