29 IMS_X_o_cutoff_(0.20),
30 IMS_gamma_o_min_(0.00001),
31 IMS_gamma_k_min_(10.0),
54 IdealMolalSoln& IdealMolalSoln::operator=(
const IdealMolalSoln& b)
57 MolalityVPSSTP::operator=(b);
64 IMS_cCut_ = b.IMS_cCut_;
66 IMS_dfCut_ = b.IMS_dfCut_;
67 IMS_efCut_ = b.IMS_efCut_;
68 IMS_afCut_ = b.IMS_afCut_;
69 IMS_bfCut_ = b.IMS_bfCut_;
71 IMS_dgCut_ = b.IMS_dgCut_;
72 IMS_egCut_ = b.IMS_egCut_;
73 IMS_agCut_ = b.IMS_agCut_;
74 IMS_bgCut_ = b.IMS_bgCut_;
82 const std::string& id_) :
87 IMS_gamma_o_min_(0.00001),
88 IMS_gamma_k_min_(10.0),
108 IMS_X_o_cutoff_(0.2),
109 IMS_gamma_o_min_(0.00001),
110 IMS_gamma_k_min_(10.0),
184 "Density is not an independent variable");
192 "molarDensity/denisty is not an independent variable");
203 for (
size_t k = 0; k <
m_kk; k++) {
208 for (
size_t k = 0; k <
m_kk; k++) {
239 for (
size_t k = 0; k <
m_kk; k++) {
247 exp((xmolSolvent - 1.0)/xmolSolvent);
253 for (
size_t k = 1; k <
m_kk; k++) {
265 for (
size_t k = 0; k <
m_kk; k++) {
273 exp((xmolSolvent - 1.0)/xmolSolvent) / xmolSolvent;
277 for (
size_t k = 0; k <
m_kk; k++) {
278 acMolality[k] = exp(acMolality[k]);
303 for (
size_t k = 1; k <
m_kk; k++) {
305 mu[k] +=
RT() * log(xx);
312 (
RT() * (xmolSolvent - 1.0) / xx);
318 for (
size_t k = 1; k <
m_kk; k++) {
331 for (
size_t k = 0; k <
m_kk; k++) {
341 for (
size_t k = 0; k <
m_kk; k++) {
357 for (
size_t k = 0; k <
m_kk; k++) {
379 for (
size_t k = 0; k <
m_kk; k++) {
402 if (id_.size() > 0 && phaseNode.
id() != id_) {
404 "phasenode and Id are incompatible");
408 if (!phaseNode.
hasChild(
"thermo")) {
410 "no thermo XML node");
415 if (thermoNode.
hasChild(
"standardConc")) {
418 std::string formString = scNode.
attrib(
"model");
419 if (formString !=
"") {
420 if (formString ==
"unity") {
422 }
else if (formString ==
"molar_volume") {
424 }
else if (formString ==
"solvent_volume") {
428 "Unknown standardConc model: " + formString);
435 std::string solventName =
"";
436 if (thermoNode.
hasChild(
"solvent")) {
437 std::vector<std::string> nameSolventa;
439 if (nameSolventa.size() != 1) {
441 "badly formed solvent XML node");
443 solventName = nameSolventa[0];
446 if (thermoNode.
hasChild(
"activityCoefficients")) {
448 std::string modelString = acNode.
attrib(
"model");
450 if (modelString !=
"IdealMolalSoln") {
452 "unknown ActivityCoefficient model: " + modelString);
454 if (acNode.
hasChild(
"idealMolalSolnCutoff")) {
456 modelString = ccNode.
attrib(
"model");
457 if (modelString !=
"") {
458 if (modelString ==
"polyExp") {
460 }
else if (modelString ==
"poly") {
464 "Unknown idealMolalSolnCutoff form: " + modelString);
467 if (ccNode.
hasChild(
"gamma_o_limit")) {
470 if (ccNode.
hasChild(
"gamma_k_limit")) {
473 if (ccNode.
hasChild(
"X_o_cutoff")) {
477 IMS_cCut_ =
getFloat(ccNode,
"c_0_param");
479 if (ccNode.
hasChild(
"slope_f_limit")) {
482 if (ccNode.
hasChild(
"slope_g_limit")) {
490 for (
size_t k = 0; k <
m_kk; k++) {
497 std::cout <<
"IdealMolalSoln::initThermo: Solvent Name not found" 500 "Solvent name not found");
504 "Solvent " + solventName +
505 " should be first species");
515 for (
size_t k = 0; k <
m_kk; k++) {
548 for (
size_t k = 1; k <
m_kk; k++) {
555 for (
size_t k = 1; k <
m_kk; k++) {
562 for (
size_t k = 1; k <
m_kk; k++) {
570 double xminus2 = xminus * xminus;
571 double xminus3 = xminus2 * xminus;
575 double h2 = 3.5 * xminus2 /
IMS_X_o_cutoff_ - 2.0 * xminus3 / x_o_cut2;
576 double h2_prime = 7.0 * xminus /
IMS_X_o_cutoff_ - 6.0 * xminus2 / x_o_cut2;
578 double h1 = (1.0 - 3.0 * xminus2 / x_o_cut2 + 2.0 * xminus3/ x_o_cut3);
579 double h1_prime = (- 6.0 * xminus / x_o_cut2 + 6.0 * xminus2/ x_o_cut3);
585 double h1_f = h1 * alpha;
586 double h1_f_prime = h1_prime * alpha;
588 double f = h2 + h1_f;
589 double f_prime = h2_prime + h1_f_prime;
591 double g = h2 + h1_g;
592 double g_prime = h2_prime + h1_g_prime;
594 double tmp = (xmolSolvent/ g * g_prime + (1.0-xmolSolvent) / f * f_prime);
595 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
596 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
598 tmp = log(xmolSolvent) + lngammak;
599 for (
size_t k = 1; k <
m_kk; k++) {
607 for (
size_t k = 1; k <
m_kk; k++) {
613 double xoverc = xmolSolvent/IMS_cCut_;
614 double eterm = std::exp(-xoverc);
616 double fptmp = IMS_bfCut_ - IMS_afCut_ / IMS_cCut_ - IMS_bfCut_*xoverc
617 + 2.0*IMS_dfCut_*xmolSolvent - IMS_dfCut_*xmolSolvent*xoverc;
618 double f_prime = 1.0 + eterm*fptmp;
619 double f = xmolSolvent + IMS_efCut_ + eterm * (IMS_afCut_ + xmolSolvent * (IMS_bfCut_ + IMS_dfCut_*xmolSolvent));
621 double gptmp = IMS_bgCut_ - IMS_agCut_ / IMS_cCut_ - IMS_bgCut_*xoverc
622 + 2.0*IMS_dgCut_*xmolSolvent - IMS_dgCut_*xmolSolvent*xoverc;
623 double g_prime = 1.0 + eterm*gptmp;
624 double g = xmolSolvent + IMS_egCut_ + eterm * (IMS_agCut_ + xmolSolvent * (IMS_bgCut_ + IMS_dgCut_*xmolSolvent));
626 double tmp = (xmolSolvent / g * g_prime + (1.0 - xmolSolvent) / f * f_prime);
627 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
628 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
630 tmp = log(xx) + lngammak;
631 for (
size_t k = 1; k <
m_kk; k++) {
643 bool converged =
false;
644 for (
int its = 0; its < 100 && !converged; its++) {
645 double oldV = IMS_efCut_;
648 IMS_dfCut_ = ((- IMS_afCut_/IMS_cCut_ + IMS_bfCut_ - IMS_bfCut_*
IMS_X_o_cutoff_/IMS_cCut_)
653 IMS_efCut_ = - eterm * (tmp);
654 if (fabs(IMS_efCut_ - oldV) < 1.0E-14) {
659 throw CanteraError(
" IdealMolalSoln::calcCutoffParams_()",
660 " failed to converge on the f polynomial");
663 double f_0 = IMS_afCut_ + IMS_efCut_;
664 double f_prime_0 = 1.0 - IMS_afCut_ / IMS_cCut_ + IMS_bfCut_;
666 for (
int its = 0; its < 100 && !converged; its++) {
667 double oldV = IMS_egCut_;
669 IMS_agCut_ = exp(lng_0) - IMS_egCut_;
671 IMS_dgCut_ = ((- IMS_agCut_/IMS_cCut_ + IMS_bgCut_ - IMS_bgCut_*
IMS_X_o_cutoff_/IMS_cCut_)
676 IMS_egCut_ = - eterm * (tmp);
677 if (fabs(IMS_egCut_ - oldV) < 1.0E-14) {
682 throw CanteraError(
" IdealMolalSoln::calcCutoffParams_()",
683 " failed to converge on the g polynomial");
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
virtual doublereal intEnergy_mole() const
Molar internal energy of the solution: Units: J/kmol.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void getPartialMolarVolumes(doublereal *vbar) const
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
const XML_Node * findByName(const std::string &nm, int depth=100000) const
This routine carries out a recursive search for an XML node based on the name of the node...
doublereal IMS_slopefCut_
Parameter in the polyExp cutoff treatment.
doublereal IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
IdealMolalSoln()
Constructor.
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...
virtual void getActivities(doublereal *ac) const
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
virtual doublereal density() const
Density (kg/m^3).
virtual void getPartialMolarCp(doublereal *cpbar) const
Partial molar heat capacity of the solution:. UnitsL J/kmol/K.
doublereal IMS_gamma_k_min_
gamma_k minimum for the cutoff process at the zero solvent point
doublereal m_xmolSolventMIN
virtual void setDensity(const doublereal rho)
Overridden setDensity() function is necessary because the density is not an independent variable...
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void setMolarDensity(const doublereal rho)
Overridden setMolarDensity() function is necessary because the density is not an independent variable...
virtual doublereal cp_mole() const
Molar heat capacity of the solution at constant pressure. Units: J/kmol/K.
doublereal IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
vector_fp m_speciesMolarVolume
Species molar volume .
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Base class for a phase with thermodynamic properties.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
doublereal molarDensity() const
Molar density (kmol/m^3).
virtual doublereal entropy_mole() const
Molar entropy of the solution. Units: J/kmol/K.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id="")
Import and initialize a ThermoPhase object using an XML tree.
std::string speciesName(size_t k) const
Name of the species with index k.
virtual doublereal thermalExpansionCoeff() const
The thermal expansion coefficient. Units: 1/K.
virtual void _updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
#define AssertThrow(expr, procedure)
Assertion must be true or an error is thrown.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Base class for exceptions thrown by Cantera classes.
virtual doublereal enthalpy_mole() const
Molar enthalpy of the solution. Units: J/kmol.
virtual bool addSpecies(shared_ptr< Species > spec)
int IMS_typeCutoff_
Cutoff type.
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
XML_Node & root() const
Return the root of the current XML_Node tree.
vector_fp m_molalities
Current value of the molalities of the species in the phase.
int m_formGC
The standard concentrations can have three different forms depending on the value of the member attri...
const doublereal SmallNumber
smallest number to compare to zero.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
virtual doublereal isothermalCompressibility() const
The isothermal compressibility. Units: 1/Pa.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
void getStringArray(const XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials: Units: J/kmol.
virtual void initThermo()
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
std::string id() const
Return the id attribute, if present.
void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
size_t m_kk
Number of species in the phase.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
XML_Node * findByAttr(const std::string &attr, const std::string &val, int depth=100000) const
This routine carries out a recursive search for an XML node based on an attribute of each XML node...
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
This phase is based upon the mixing-rule assumption that all molality-based activity coefficients are...
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
Namespace for the Cantera kernel.
size_t m_indexSolvent
Index of the solvent.
virtual doublereal gibbs_mole() const
Molar Gibbs function for the solution: Units J/kmol.
void calcIMSCutoffParams_()
Calculate parameters for cutoff treatments of activity coefficients.
doublereal IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
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 ...
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 setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase.
void setMoleFSolventMin(doublereal xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.
vector_fp IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.