20 LatticeSolidPhase::LatticeSolidPhase() :
70 if (lkstart_[n+1] < k) {
71 return (
m_lattice[n])->minTemp(k-lkstart_[n]);
75 doublereal mm = 1.0E300;
78 mm = std::min(mm, ml);
87 if (lkstart_[n+1] < k) {
88 return (
m_lattice[n])->maxTemp(k - lkstart_[n]);
92 doublereal mm = -1.0E300;
95 mm = std::max(mm, ml);
108 doublereal sum = 0.0;
118 doublereal sum = 0.0;
128 doublereal sum = 0.0;
138 doublereal sum = 0.0;
148 doublereal sum = 0.0;
167 for (
size_t k = 0; k <
m_kk; k++) {
206 m_lattice[n]->setMoleFractions(x + strt);
209 for (
size_t k = 0; k < strt; k++) {
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 if (DEBUG_MODE_ENABLED) {
236 for (
size_t k = 0; k < nsp; k++) {
237 if (fabs((x + strt)[k] -
m_x[strt+k]) > 1.0E-14) {
238 throw CanteraError(
"LatticeSolidPhase::getMoleFractions()",
253 m_lattice[n]->getChemPotentials(mu+strt);
264 m_lattice[n]->getPartialMolarEnthalpies(hbar + strt);
275 m_lattice[n]->getPartialMolarEntropies(sbar + strt);
286 m_lattice[n]->getPartialMolarCp(cpbar + strt);
297 m_lattice[n]->getPartialMolarVolumes(vbar + strt);
307 m_lattice[n]->getStandardChemPotentials(mu0+strt);
316 m_lattice[n]->getGibbs_RT_ref(grt + lkstart_[n]);
323 for (
size_t k = 0; k <
m_kk; k++) {
335 std::vector<XML_Node*> lattices = la.
getChildren(
"phase");
338 vector<doublereal> constArr(lp->
nElements());
340 for (
size_t es = 0; es < lp->
nElements(); es++) {
346 for (
size_t k = 0; k < lp->
nSpecies(); k++) {
354 string econ =
"LC_" +
int2str(n) +
"_" +
id();
358 for (
size_t k = 0; k < nsp0; k++) {
361 for (
size_t k = 0; k < lp->
nSpecies(); k++) {
362 size_t ks = kstart + k;
376 for (
size_t k = 0; k < nsp; k++) {
377 m_x[loc] =
m_lattice[n]->moleFraction(k) / (double) m_nlattice;
412 m_lattice[nn]->setMoleFractionsByName(x);
416 double ndens =
m_lattice[n]->molarDensity();
417 for (
size_t k = 0; k < nsp; k++) {
427 eosdata.
_require(
"model",
"LatticeSolid");
429 std::vector<XML_Node*> lattices = la.
getChildren(
"phase");
434 std::vector<string> pnam;
435 std::vector<string> pval;
436 int np =
getPairs(eosdata.
child(
"LatticeStoichiometry"), pnam, pval);
437 theta_.resize(m_nlattice);
438 for (
int i = 0; i < np; i++) {
443 string idj = tp.
id();
444 if (idj == pnam[i]) {
451 throw CanteraError(
"LatticeSolidPhase::setParametersFromXML",
"not found");
460 if (lkstart_[n+1] < k) {
461 size_t kk = k-lkstart_[n];
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.
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) ...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
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...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
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.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
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.
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.
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.
doublereal m_tlast
last value of the temperature processed by reference state
Pure Virtual base class for the species thermo manager classes.
shared_ptr< Species > species(const std::string &name) const
Return the Species object for the named species.
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...
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.
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...
std::string id() const
Return the string id for the phase.
Base class for exceptions thrown by Cantera classes.
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...
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.
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.
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].
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)=0
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
#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 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.
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...