24 LatticeSolidPhase::LatticeSolidPhase() :
37 LatticeSolidPhase& LatticeSolidPhase::operator=(
const LatticeSolidPhase& right)
44 deepStdVectorPointerCopy<LatticePhase>(right.m_lattice,
m_lattice);
52 LatticeSolidPhase::~LatticeSolidPhase()
55 for (
size_t n = 0; n <
m_lattice.size(); n++) {
69 for (
size_t n = 0; n <
m_lattice.size(); n++) {
70 if (lkstart_[n+1] < k) {
71 return m_lattice[n]->minTemp(k-lkstart_[n]);
75 doublereal mm = 1.0E300;
76 for (
size_t n = 0; n <
m_lattice.size(); n++) {
78 mm = std::min(mm, ml);
86 for (
size_t n = 0; n <
m_lattice.size(); n++) {
87 if (lkstart_[n+1] < k) {
88 return (
m_lattice[n])->maxTemp(k - lkstart_[n]);
92 doublereal mm = -1.0E300;
93 for (
size_t n = 0; n <
m_lattice.size(); n++) {
95 mm = std::max(mm, ml);
108 doublereal sum = 0.0;
109 for (
size_t n = 0; n <
m_lattice.size(); n++) {
118 doublereal sum = 0.0;
119 for (
size_t n = 0; n <
m_lattice.size(); n++) {
128 doublereal sum = 0.0;
129 for (
size_t n = 0; n <
m_lattice.size(); n++) {
138 doublereal sum = 0.0;
139 for (
size_t n = 0; n <
m_lattice.size(); n++) {
148 doublereal sum = 0.0;
149 for (
size_t n = 0; n <
m_lattice.size(); n++) {
159 for (
size_t n = 0; n <
m_lattice.size(); n++) {
167 for (
size_t k = 0; k <
m_kk; k++) {
185 for (
size_t n = 0; n <
m_lattice.size(); n++) {
194 for (
size_t n = 0; n <
m_lattice.size(); n++) {
204 for (
size_t n = 0; n <
m_lattice.size(); n++) {
206 m_lattice[n]->setMoleFractions(x + strt);
209 for (
size_t k = 0; k < strt; k++) {
221 for (
size_t n = 0; n <
m_lattice.size(); n++) {
224 for (
size_t k = 0; k < nsp; k++) {
225 sum += (x + strt)[k];
227 for (
size_t k = 0; k < nsp; k++) {
228 (x + strt)[k] /= sum;
234 for (
size_t k = 0; k < nsp; k++) {
235 if (fabs((x + strt)[k] -
m_x[strt+k]) > 1.0E-14) {
236 throw CanteraError(
"LatticeSolidPhase::getMoleFractions()",
248 for (
size_t n = 0; n <
m_lattice.size(); n++) {
250 m_lattice[n]->getChemPotentials(mu+strt);
259 for (
size_t n = 0; n <
m_lattice.size(); n++) {
261 m_lattice[n]->getPartialMolarEnthalpies(hbar + strt);
270 for (
size_t n = 0; n <
m_lattice.size(); n++) {
272 m_lattice[n]->getPartialMolarEntropies(sbar + strt);
281 for (
size_t n = 0; n <
m_lattice.size(); n++) {
283 m_lattice[n]->getPartialMolarCp(cpbar + strt);
292 for (
size_t n = 0; n <
m_lattice.size(); n++) {
294 m_lattice[n]->getPartialMolarVolumes(vbar + strt);
303 for (
size_t n = 0; n <
m_lattice.size(); n++) {
304 m_lattice[n]->getStandardChemPotentials(mu0+strt);
312 for (
size_t n = 0; n <
m_lattice.size(); n++) {
313 m_lattice[n]->getGibbs_RT_ref(grt + lkstart_[n]);
320 for (
size_t k = 0; k <
m_kk; k++) {
332 for (
size_t n = 0; n <
m_lattice.size(); n++) {
336 for (
size_t es = 0; es < lp->
nElements(); es++) {
342 for (
size_t k = 0; k < lp->
nSpecies(); k++) {
348 string econ = fmt::format(
"LC_{}_{}", n,
id());
352 for (
size_t k = 0; k < nsp0; k++) {
355 for (
size_t k = 0; k < lp->
nSpecies(); k++) {
356 size_t ks = kstart + k;
362 for (
size_t k = 0; k < nsp; k++) {
378 tmpV_.push_back(0.0);
389 for (
size_t n = 0; n <
m_lattice.size(); n++) {
401 m_lattice[nn]->setMoleFractionsByName(x);
403 for (
size_t n = 0; n <
m_lattice.size(); n++) {
405 double ndens =
m_lattice[n]->molarDensity();
406 for (
size_t k = 0; k < nsp; k++) {
416 eosdata.
_require(
"model",
"LatticeSolid");
418 std::vector<XML_Node*> lattices = la.
getChildren(
"phase");
419 for (
size_t n = 0; n < lattices.size(); n++) {
422 std::vector<string> pnam;
423 std::vector<string> pval;
424 int np =
getPairs(eosdata.
child(
"LatticeStoichiometry"), pnam, pval);
426 for (
int i = 0; i < np; i++) {
429 for (
size_t j = 0; j <
m_lattice.size(); j++) {
431 string idj = tp.
id();
432 if (idj == pnam[i]) {
439 throw CanteraError(
"LatticeSolidPhase::setParametersFromXML",
"not found");
446 for (
size_t n = 0; n <
m_lattice.size(); n++) {
447 if (lkstart_[n+1] < k) {
448 size_t kk = k-lkstart_[n];
460 for (
size_t n = 0; n <
m_lattice.size(); n++) {
461 if (lkstart_[n+1] < k) {
462 size_t kk = k-lkstart_[n];
463 m_lattice[n]->speciesThermo().resetHf298(kk);
467 for (
size_t n = 0; n <
m_lattice.size(); n++) {
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
std::vector< XML_Node * > getChildren(const std::string &name) const
Get a vector of pointers to XML_Node containing all of the children of the current node which match t...
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) ...
size_t nElements() const
Number of elements.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
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.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
doublereal temperature() const
Temperature (K).
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
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"
vector_fp theta_
Lattice stoichiometric coefficients.
ThermoPhase & operator=(const ThermoPhase &right)
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
LatticeSolidPhase()
Base empty constructor.
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
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.
size_t nSpecies() const
Returns the number of species in the phase.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution...
virtual doublereal intEnergy_mole() const
Return the Molar Internal Energy. Units: J/kmol.
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms. ...
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
doublereal m_tlast
last value of the temperature processed by reference state
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Base class for a phase with thermodynamic properties.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
int atomicNumber(size_t m) const
Atomic number of element m.
virtual void invalidateCache()
Invalidate any cached values which are normally updated only when a change in state is detected...
void _updateThermo() const
Update the reference thermodynamic functions.
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.
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).
shared_ptr< Species > species(const std::string &name) const
Return the Species object for the named species.
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
doublereal m_molar_density
Current value of the molar density.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
vector_fp tmpV_
Temporary vector.
doublereal entropyElement298(size_t m) const
Entropy of the element in its standard state at 298 K and 1 bar.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
int getPairs(const 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...
Base class for exceptions thrown by Cantera classes.
doublereal m_press
Current value of the pressure.
virtual doublereal entropy_mole() const
Return the Molar Entropy. Units: J/kmol/K.
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
void setLatticeMoleFractionsByName(int n, const std::string &x)
Set the Lattice mole fractions using a string.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
vector_fp m_x
Vector of mole fractions.
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
std::string id() const
Return the string id for the 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.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
int elementType(size_t m) const
Return the element constraint type Possible types include:
A phase that is comprised of a fixed additive combination of other lattice phases.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
Contains declarations for string manipulation functions within Cantera.
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid...
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.
virtual void getPartialMolarVolumes(doublereal *vbar) const
returns an array of partial molar volumes of the species in the solution.
A species thermodynamic property manager for a phase.
Namespace for the Cantera kernel.
virtual doublereal cp_mole() const
Return the constant pressure heat capacity. Units: J/kmol/K.
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of standard state chemical potentials at unit activity for the species at their standar...
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
const vector_fp & atomicWeights() const
Return a read-only reference to the vector of atomic weights.
virtual doublereal gibbs_mole() const
Return the Molar Gibbs energy. Units: J/kmol.
std::string elementName(size_t m) const
Name of the element with index m.
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase.