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++) {
128 for (
size_t n = 0; n <
m_lattice.size(); n++) {
136 for (
size_t k = 0; k <
m_kk; k++) {
154 for (
size_t n = 0; n <
m_lattice.size(); n++) {
163 for (
size_t n = 0; n <
m_lattice.size(); n++) {
173 for (
size_t n = 0; n <
m_lattice.size(); n++) {
175 m_lattice[n]->setMoleFractions(x + strt);
178 for (
size_t k = 0; k < strt; k++) {
190 for (
size_t n = 0; n <
m_lattice.size(); n++) {
193 for (
size_t k = 0; k < nsp; k++) {
194 sum += (x + strt)[k];
196 for (
size_t k = 0; k < nsp; k++) {
197 (x + strt)[k] /= sum;
203 for (
size_t k = 0; k < nsp; k++) {
204 if (fabs((x + strt)[k] -
m_x[strt+k]) > 1.0E-14) {
205 throw CanteraError(
"LatticeSolidPhase::getMoleFractions",
217 for (
size_t n = 0; n <
m_lattice.size(); n++) {
219 m_lattice[n]->getChemPotentials(mu+strt);
228 for (
size_t n = 0; n <
m_lattice.size(); n++) {
230 m_lattice[n]->getPartialMolarEnthalpies(hbar + strt);
239 for (
size_t n = 0; n <
m_lattice.size(); n++) {
241 m_lattice[n]->getPartialMolarEntropies(sbar + strt);
250 for (
size_t n = 0; n <
m_lattice.size(); n++) {
252 m_lattice[n]->getPartialMolarCp(cpbar + strt);
261 for (
size_t n = 0; n <
m_lattice.size(); n++) {
263 m_lattice[n]->getPartialMolarVolumes(vbar + strt);
272 for (
size_t n = 0; n <
m_lattice.size(); n++) {
273 m_lattice[n]->getStandardChemPotentials(mu0+strt);
281 for (
size_t n = 0; n <
m_lattice.size(); n++) {
282 m_lattice[n]->getGibbs_RT_ref(grt + lkstart_[n]);
289 for (
size_t k = 0; k <
m_kk; k++) {
305 for (
auto& item : composition) {
325 if (lkstart_.empty()) {
326 lkstart_.push_back(0);
328 lkstart_.push_back(lkstart_.back() + lattice->nSpecies());
336 for (
size_t k = 0; k < lattice->nSpecies(); k++) {
338 vector_fp constArr(lattice->nElements());
339 const vector_fp& aws = lattice->atomicWeights();
340 for (
size_t es = 0; es < lattice->nElements(); es++) {
341 addElement(lattice->elementName(es), aws[es], lattice->atomicNumber(es),
342 lattice->entropyElement298(es), lattice->elementType(es));
344 m_x.push_back(lattice->moleFraction(k));
345 tmpV_.push_back(0.0);
351 for (
size_t i = 0; i <
m_lattice.size(); i++) {
355 for (
size_t i = 1; i <
m_lattice.size(); i++) {
356 string econ = fmt::format(
"LC_{}_{}", i,
name());
359 for (
size_t k = 0; k <
m_lattice[0]->nSpecies(); k++) {
362 for (
size_t k = 0; k <
m_lattice[i]->nSpecies(); k++) {
363 size_t ks = lkstart_[i] + k;
375 for (
size_t n = 0; n <
m_lattice.size(); n++) {
387 m_lattice[nn]->setMoleFractionsByName(x);
389 for (
size_t n = 0; n <
m_lattice.size(); n++) {
391 double ndens =
m_lattice[n]->molarDensity();
392 for (
size_t k = 0; k < nsp; k++) {
402 eosdata.
_require(
"model",
"LatticeSolid");
404 std::vector<XML_Node*> lattices = la.
getChildren(
"phase");
405 for (
auto lattice : lattices) {
413 for (
size_t n = 0; n <
m_lattice.size(); n++) {
414 if (lkstart_[n+1] < k) {
415 size_t kk = k-lkstart_[n];
427 for (
size_t n = 0; n <
m_lattice.size(); n++) {
428 if (lkstart_[n+1] < k) {
429 size_t kk = k-lkstart_[n];
430 m_lattice[n]->speciesThermo().resetHf298(kk);
434 for (
size_t n = 0; n <
m_lattice.size(); n++) {
#define CT_ELEM_TYPE_LATTICERATIO
Constraint associated with maintaining a fixed lattice stoichiometry in a solid.
Header for a simple thermodynamics model of a bulk solid phase derived from ThermoPhase,...
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
A map of string keys to values whose type can vary at runtime.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Base class for exceptions thrown by Cantera classes.
virtual void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
doublereal m_press
Current value of the pressure.
AnyMap m_rootNode
Root node of the AnyMap which contains this phase definition.
virtual bool addSpecies(shared_ptr< Species > spec)
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 setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap())
Set equation of state parameters from an AnyMap phase description.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
vector_fp m_x
Vector of mole fractions.
std::vector< shared_ptr< ThermoPhase > > m_lattice
Vector of sublattic ThermoPhase objects.
virtual doublereal cp_mole() const
Return the constant pressure heat capacity. Units: J/kmol/K.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
virtual void getPartialMolarVolumes(doublereal *vbar) const
returns an array of partial molar volumes of the species in the solution.
doublereal calcDensity()
Calculate the density of the solid mixture.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
void setLatticeMoleFractionsByName(int n, const std::string &x)
Set the Lattice mole fractions using a string.
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 getStandardChemPotentials(doublereal *mu0) const
Get the array of standard state chemical potentials at unit activity for the species at their standar...
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
virtual doublereal entropy_mole() const
Return the Molar Entropy. Units: J/kmol/K.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
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....
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
vector_fp theta_
Lattice stoichiometric coefficients.
virtual doublereal gibbs_mole() const
Return the Molar Gibbs energy. Units: J/kmol.
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
void setLatticeStoichiometry(const compositionMap &comp)
Set the lattice stoichiometric coefficients, .
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)
void addLattice(shared_ptr< ThermoPhase > lattice)
Add a lattice to this phase.
void _updateThermo() const
Update the reference thermodynamic functions.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
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...
vector_fp tmpV_
Temporary vector.
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual doublereal intEnergy_mole() const
Return the Molar Internal Energy. Units: J/kmol.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
A species thermodynamic property manager for a phase.
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 ...
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of 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.
virtual void setMoleFractions(const double *const x)
Set the mole fractions to the specified values.
std::string name() const
Return the name of the phase.
size_t m_kk
Number of species in the phase.
vector_fp m_speciesComp
Atomic composition of the species.
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
doublereal temperature() const
Temperature (K).
size_t nElements() const
Number of elements.
virtual bool addSpecies(shared_ptr< Species > spec)
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
doublereal m_tlast
last value of the temperature processed by reference state
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters.
AnyMap m_input
Data supplied via setParameters.
virtual void invalidateCache()
Invalidate any cached values which are normally updated only when a change in state is detected.
A representation of the units associated with a dimensional quantity.
Class XML_Node is a tree-based representation of the contents of an XML file.
void _require(const std::string &a, const std::string &v) const
Require that the current XML node has an attribute named by the first argument, a,...
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...
std::string value() const
Return the value of an XML node as a string.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
const size_t npos
index returned by functions to indicate "no position"
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.
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.
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.
Contains declarations for string manipulation functions within Cantera.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...