Go to the documentation of this file.
20 MaskellSolidSolnPhase::MaskellSolidSolnPhase() :
23 product_species_index(-1),
24 reactant_species_index(-1)
31 for (
size_t sp = 0; sp <
m_kk; ++sp) {
42 const doublereal fmval = fm(r);
46 doublereal xlogx(doublereal x)
48 return x * std::log(x);
55 const doublereal fmval = fm(r);
56 const doublereal rfm = r * fmval;
57 return s0 +
GasConstant * (xlogx(1-rfm) - xlogx(rfm) - xlogx(1-r-rfm) - xlogx((1-fmval)*r) - xlogx(1-r) - xlogx(r));
68 "Overloaded function to be removed after Cantera 2.5. "
69 "Error will be thrown by Phase::setDensity instead");
73 "Density is not an independent variable");
83 doublereal vtotal = 0.0;
84 for (
size_t i = 0; i <
m_kk; i++) {
85 vtotal += vbar[i] * moleFracs[i];
98 "Overloaded function to be removed after Cantera 2.5. "
99 "Error will be thrown by Phase::setMolarDensity instead");
100 throw CanteraError(
"MaskellSolidSolnPhase::setMolarDensity",
101 "Density is not an independent variable");
111 cached.
value.resize(2);
114 const doublereal pval = p(r);
115 const doublereal rfm = r * fm(r);
116 const doublereal A = (std::pow(1 - rfm, pval) * std::pow(rfm, pval) * std::pow(r - rfm, 1 - pval)) /
117 (std::pow(1 - r - rfm, 1 + pval) * (1 - r));
120 cached.
value[reactant_species_index] = 1 / (A * r * (1-r) ) * std::exp(-B);
122 std::copy(cached.
value.begin(), cached.
value.end(), ac);
128 const doublereal pval = p(r);
129 const doublereal rfm = r * fm(r);
130 const doublereal DgbarDr = pval *
h_mixing +
132 std::log( (std::pow(1 - rfm, pval) * std::pow(rfm, pval) * std::pow(r - rfm, 1 - pval) * r) /
133 (std::pow(1 - r - rfm, 1 + pval) * (1 - r)) );
135 mu[reactant_species_index] =
RT() *
m_g0_RT[reactant_species_index] - DgbarDr;
141 for (
size_t sp=0; sp <
m_kk; ++sp) {
142 mu[sp] *= 1.0 /
RT();
170 for (
size_t sp=0; sp <
m_kk; ++sp) {
198 if (id_.size() > 0 && phaseNode.
id() != id_) {
199 throw CanteraError(
"MaskellSolidSolnPhase::initThermoXML",
200 "phasenode and Id are incompatible");
208 throw CanteraError(
"MaskellSolidSolnPhase::initThermoXML",
209 "Unknown thermo model: " + thNode[
"model"]);
216 throw CanteraError(
"MaskellSolidSolnPhase::initThermoXML",
217 "Mixing enthalpy parameter not specified.");
220 if (thNode.
hasChild(
"product_species")) {
226 throw CanteraError(
"MaskellSolidSolnPhase::initThermoXML",
227 "Unspecified thermo model");
232 throw CanteraError(
"MaskellSolidSolnPhase::initThermoXML",
233 "MaskellSolidSolution model requires exactly 2 species.");
244 throw CanteraError(
"MaskellSolidSolnPhase::setProductSpecies",
245 "Species '{}' not found",
name);
250 doublereal MaskellSolidSolnPhase::s()
const
255 doublereal MaskellSolidSolnPhase::fm(
const doublereal r)
const
257 return (1 - std::sqrt(1 - 4*r*(1-r)/s())) / (2*r);
260 doublereal MaskellSolidSolnPhase::p(
const doublereal r)
const
262 const doublereal sval = s();
263 return (1 - 2*r) / std::sqrt(sval*sval - 4 * sval * r + 4 * sval * r * r);
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
vector_fp m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast and P = p_ref.
ValueCache m_cache
Cached for saved calculations within each ThermoPhase.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
double convert(const std::string &key, const std::string &units) const
Convert the item stored by the given key to the units specified in units.
int stateMFNumber() const
Return the State Mole Fraction Number.
vector_fp m_s0_R
Vector containing the species reference entropies at T = m_tlast and P = p_ref.
CachedArray getArray(int id)
Get a reference to a CachedValue object representing an array (vector_fp) with the given id.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
An error indicating that an unimplemented function has been called.
std::string id() const
Return the id attribute, if present.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of the phase.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
std::string name() const
Return the name of the phase.
double moleFraction(size_t k) const
Return the mole fraction of a single species.
virtual void getChemPotentials_RT(doublereal *mu) const
Get the array of non-dimensional species chemical potentials.
virtual void getPureGibbs(doublereal *gpure) const
Get the Gibbs functions for the standard state of the species at the current T and P of the solution.
doublereal m_Pcurrent
m_Pcurrent = The current pressure.
size_t m_kk
Number of species in the phase.
std::string value() const
Return the value of an XML node as a string.
AnyMap m_input
Data supplied via setParameters.
virtual double density() const
Density (kg/m^3).
int getId()
Get a unique id for a cached value.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
vector_fp m_h0_RT
Vector containing the species reference enthalpies at T = m_tlast and P = p_ref.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void initThermo()
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
const double OneAtm
One atmosphere [Pa].
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void setDensity(const doublereal rho)
Overridden setDensity() function is necessary because the density is not an independent variable.
doublereal temperature() const
Temperature (K).
virtual doublereal pressure() const
Pressure.
virtual void initThermo()
virtual void setMolarDensity(const doublereal rho)
Overridden setMolarDensity() function is necessary because the density is not an independent variable...
int product_species_index
Index of the species whose mole fraction defines the extent of reduction r.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
virtual void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
T value
The value of the cached property.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
const double GasConstant
Universal Gas Constant [J/kmol/K].
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Base class for exceptions thrown by Cantera classes.
doublereal h_mixing
Value of the enthalpy change on mixing due to protons changing from type B to type A configurations.
void setProductSpecies(const std::string &name)
Set the product Species. Must be called after species have been added.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Namespace for the Cantera kernel.
bool validate(double state1New)
Check whether the currently cached value is valid based on a single state variable.
std::string speciesName(size_t k) const
Name of the species with index k.
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.