24 LatticeSolidPhase::LatticeSolidPhase() :
33 for (
size_t n = 0; n <
m_lattice.size(); n++) {
34 if (lkstart_[n+1] < k) {
35 return m_lattice[n]->minTemp(k-lkstart_[n]);
39 doublereal mm = 1.0E300;
40 for (
size_t n = 0; n <
m_lattice.size(); n++) {
42 mm = std::min(mm, ml);
50 for (
size_t n = 0; n <
m_lattice.size(); n++) {
51 if (lkstart_[n+1] < k) {
52 return (
m_lattice[n])->maxTemp(k - lkstart_[n]);
56 doublereal mm = -1.0E300;
57 for (
size_t n = 0; n <
m_lattice.size(); n++) {
59 mm = std::max(mm, ml);
73 for (
size_t n = 0; n <
m_lattice.size(); n++) {
83 for (
size_t n = 0; n <
m_lattice.size(); n++) {
93 for (
size_t n = 0; n <
m_lattice.size(); n++) {
102 doublereal sum = 0.0;
103 for (
size_t n = 0; n <
m_lattice.size(); n++) {
112 doublereal sum = 0.0;
113 for (
size_t n = 0; n <
m_lattice.size(); n++) {
123 for (
size_t n = 0; n <
m_lattice.size(); n++) {
131 for (
size_t k = 0; k <
m_kk; k++) {
149 for (
size_t n = 0; n <
m_lattice.size(); n++) {
158 for (
size_t n = 0; n <
m_lattice.size(); n++) {
168 for (
size_t n = 0; n <
m_lattice.size(); n++) {
170 m_lattice[n]->setMoleFractions(x + strt);
173 for (
size_t k = 0; k < strt; k++) {
185 for (
size_t n = 0; n <
m_lattice.size(); n++) {
188 for (
size_t k = 0; k < nsp; k++) {
189 sum += (x + strt)[k];
191 for (
size_t k = 0; k < nsp; k++) {
192 (x + strt)[k] /= sum;
198 for (
size_t k = 0; k < nsp; k++) {
199 if (fabs((x + strt)[k] -
m_x[strt+k]) > 1.0E-14) {
200 throw CanteraError(
"LatticeSolidPhase::getMoleFractions()",
212 for (
size_t n = 0; n <
m_lattice.size(); n++) {
214 m_lattice[n]->getChemPotentials(mu+strt);
223 for (
size_t n = 0; n <
m_lattice.size(); n++) {
225 m_lattice[n]->getPartialMolarEnthalpies(hbar + strt);
234 for (
size_t n = 0; n <
m_lattice.size(); n++) {
236 m_lattice[n]->getPartialMolarEntropies(sbar + strt);
245 for (
size_t n = 0; n <
m_lattice.size(); n++) {
247 m_lattice[n]->getPartialMolarCp(cpbar + strt);
256 for (
size_t n = 0; n <
m_lattice.size(); n++) {
258 m_lattice[n]->getPartialMolarVolumes(vbar + strt);
267 for (
size_t n = 0; n <
m_lattice.size(); n++) {
268 m_lattice[n]->getStandardChemPotentials(mu0+strt);
276 for (
size_t n = 0; n <
m_lattice.size(); n++) {
277 m_lattice[n]->getGibbs_RT_ref(grt + lkstart_[n]);
284 for (
size_t k = 0; k <
m_kk; k++) {
296 for (
size_t n = 0; n <
m_lattice.size(); n++) {
297 shared_ptr<ThermoPhase>& lp =
m_lattice[n];
299 const vector_fp& aws = lp->atomicWeights();
300 for (
size_t es = 0; es < lp->nElements(); es++) {
301 addElement(lp->elementName(es), aws[es], lp->atomicNumber(es),
302 lp->entropyElement298(es), lp->elementType(es));
306 for (
size_t k = 0; k < lp->nSpecies(); k++) {
312 string econ = fmt::format(
"LC_{}_{}", n,
id());
316 for (
size_t k = 0; k < nsp0; k++) {
319 for (
size_t k = 0; k < lp->nSpecies(); k++) {
320 size_t ks = kstart + k;
326 for (
size_t k = 0; k < nsp; k++) {
342 tmpV_.push_back(0.0);
359 for (
size_t i = 0; i <
m_lattice.size(); i++) {
370 for (
size_t n = 0; n <
m_lattice.size(); n++) {
382 m_lattice[nn]->setMoleFractionsByName(x);
384 for (
size_t n = 0; n <
m_lattice.size(); n++) {
386 double ndens =
m_lattice[n]->molarDensity();
387 for (
size_t k = 0; k < nsp; k++) {
397 eosdata.
_require(
"model",
"LatticeSolid");
399 std::vector<XML_Node*> lattices = la.
getChildren(
"phase");
400 for (
auto lattice : lattices) {
408 for (
size_t n = 0; n <
m_lattice.size(); n++) {
409 if (lkstart_[n+1] < k) {
410 size_t kk = k-lkstart_[n];
422 for (
size_t n = 0; n <
m_lattice.size(); n++) {
423 if (lkstart_[n+1] < k) {
424 size_t kk = k-lkstart_[n];
425 m_lattice[n]->speciesThermo().resetHf298(kk);
429 for (
size_t n = 0; n <
m_lattice.size(); n++) {
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
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.
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.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
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.
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.
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 void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
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).
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
vector_fp tmpV_
Temporary vector.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
const U & getValue(const std::map< T, U > &m, const T &key, const U &default_val)
Const accessor for a value in a std::map.
Base class for exceptions thrown by Cantera classes.
std::string value() const
Return the value of an XML node as a string.
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 addLattice(shared_ptr< ThermoPhase > lattice)
Add a lattice to this phase.
void setLatticeStoichiometry(const compositionMap &comp)
Set the lattice stoichiometric coefficients, .
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.
compositionMap parseCompString(const std::string &ss, const std::vector< std::string > &names)
Parse a composition string into a map consisting of individual key:composition pairs.
vector_fp m_x
Vector of mole fractions.
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
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.
virtual bool addSpecies(shared_ptr< Species > spec)
std::string name() const
Return the name of the phase.
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
std::vector< shared_ptr< ThermoPhase > > m_lattice
Vector of sublattic ThermoPhase objects.
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...
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
virtual doublereal gibbs_mole() const
Return the Molar Gibbs energy. Units: J/kmol.
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase.