30 MineralEQ3::MineralEQ3(
const std::string& infile, std::string id_)
39 "Couldn't find phase name in file:" + id_);
42 std::string model = xphase->
child(
"thermo")[
"model"];
43 if (model !=
"StoichSubstance" && model !=
"MineralEQ3") {
45 "thermo model attribute must be StoichSubstance");
50 MineralEQ3::MineralEQ3(
XML_Node& xmlphase,
const std::string& id_)
53 if (id_ != xmlphase[
"id"]) {
58 std::string model = xmlphase.
child(
"thermo")[
"model"];
59 if (model !=
"StoichSubstance" && model !=
"MineralEQ3") {
61 "thermo model attribute must be StoichSubstance");
77 StoichSubstanceSSTP::operator=(right);
99 int MineralEQ3::eosType()
const
101 return cStoichSubstance;
108 doublereal MineralEQ3::pressure()
const
113 void MineralEQ3::setPressure(doublereal p)
118 doublereal MineralEQ3::isothermalCompressibility()
const
123 doublereal MineralEQ3::thermalExpansionCoeff()
const
132 void MineralEQ3::getActivityConcentrations(doublereal* c)
const
137 doublereal MineralEQ3::standardConcentration(
size_t k)
const
142 doublereal MineralEQ3::logStandardConc(
size_t k)
const
147 void MineralEQ3::getUnitsStandardConc(doublereal* uA,
int k,
int sizeUA)
const
150 "To be removed after Cantera 2.2.");
152 for (
int i = 0; i < 6; i++) {
161 void MineralEQ3::getStandardChemPotentials(doublereal* mu0)
const
164 mu0[0] *= GasConstant * temperature();
167 void MineralEQ3::getEnthalpy_RT(doublereal* hrt)
const
169 getEnthalpy_RT_ref(hrt);
170 doublereal RT = GasConstant * temperature();
171 doublereal presCorrect = (m_press - m_p0) / molarDensity();
172 hrt[0] += presCorrect / RT;
175 void MineralEQ3::getEntropy_R(doublereal* sr)
const
177 getEntropy_R_ref(sr);
180 void MineralEQ3::getGibbs_RT(doublereal* grt)
const
186 void MineralEQ3::getCp_R(doublereal* cpr)
const
192 void MineralEQ3::getIntEnergy_RT(doublereal* urt)
const
195 doublereal RT = GasConstant * temperature();
196 urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT;
203 void MineralEQ3::getIntEnergy_RT_ref(doublereal* urt)
const
206 doublereal RT = GasConstant * temperature();
207 urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT;
214 void MineralEQ3::setParameters(
int n, doublereal*
const c)
219 void MineralEQ3::getParameters(
int& n, doublereal*
const c)
const
225 void MineralEQ3::initThermoXML(
XML_Node& phaseNode,
const std::string& id_)
230 if (!phaseNode.
hasChild(
"thermo")) {
232 "no thermo XML node");
235 const XML_Node* xsp = speciesData()[0];
238 if (xsp->
hasChild(
"standardState")) {
239 aStandardState = &xsp->
child(
"standardState");
242 "no standard state mode");
244 doublereal volVal = 0.0;
245 if (aStandardState->
attrib(
"model") !=
"constantVolume") {
247 "wrong standard state mode");
249 if (aStandardState->
hasChild(
"V0_Pr_Tr")) {
251 double Afactor =
toSI(
"cm3/gmol");
255 volVal =
getFloat(*aStandardState,
"V0_Pr_Tr");
258 m_speciesSize[0] = volVal;
261 "wrong standard state mode");
263 setDensity(molecularWeight(0) / volVal);
267 m_deltaG_formation_pr_tr =
269 m_deltaH_formation_pr_tr =
276 convertDGFormation();
279 void MineralEQ3::setParametersFromXML(
const XML_Node& eosdata)
281 if (eosdata[
"model"] !=
"MineralEQ3") {
283 "thermo model attribute must be MineralEQ3");
287 doublereal MineralEQ3::LookupGe(
const std::string& elemName)
289 size_t iE = elementIndex(elemName);
291 throw CanteraError(
"PDSS_HKFT::LookupGe",
"element " + elemName +
" not found");
293 doublereal geValue = entropyElement298(iE);
295 throw CanteraError(
"PDSS_HKFT::LookupGe",
296 "element " + elemName +
" does not have a supplied entropy298");
298 geValue *= (-298.15);
302 void MineralEQ3::convertDGFormation()
308 doublereal totalSum = 0.0;
309 for (
size_t m = 0; m < nElements(); m++) {
310 double na = nAtoms(0, m);
312 totalSum += na * LookupGe(elementName(m));
316 doublereal dg = m_deltaG_formation_pr_tr * 4.184 * 1.0E3;
318 m_Mu0_pr_tr = dg + totalSum;
320 double Hcalc = m_Mu0_pr_tr + 298.15 * m_Entrop_pr_tr * 4184.0;
321 double DHjmol = m_deltaH_formation_pr_tr * 4184.0;
324 if (fabs(Hcalc -DHjmol) > 10.* 1.0E6 * 4.184) {
325 throw CanteraError(
"installMinEQ3asShomateThermoFromXML()",
326 "DHjmol is not consistent with G and S" +
doublereal m_Entrop_pr_tr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
doublereal m_deltaH_formation_pr_tr
Input Value of deltaH of Formation at Tr and Pr (cal gmol-1)
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
const size_t npos
index returned by functions to indicate "no position"
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Class XML_Node is a tree-based representation of the contents of an XML file.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
doublereal m_deltaG_formation_pr_tr
Input Value of deltaG of Formation at Tr and Pr (cal gmol-1)
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Base class for a phase with thermodynamic properties.
doublereal m_c
c coefficient (cal K gmol-1 K) x 10^-5
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty ThermoPhase object.
doublereal m_a
a coefficient (cal gmol-1 K-1)
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Base class for exceptions thrown by Cantera classes.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298...
doublereal m_V0_pr_tr
Input Value of the molar volume at T_r and P_r.
doublereal m_b
b coefficient (cal gmol-1 K-2) x 10^3
Header file for the MineralEQ3 class, which represents a fixed-composition incompressible substance b...
Contains declarations for string manipulation functions within Cantera.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
doublereal getFloatDefaultUnits(const XML_Node &parent, const std::string &name, const std::string &defaultUnits, const std::string &type)
Get a floating-point value from a child element with a defined units field.
Class MineralEQ3 represents a stoichiometric (fixed composition) incompressible substance based on EQ...
XML_Node * get_XML_NameID(const std::string &nameTarget, const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
doublereal m_Mu0_pr_tr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.