28 IdealMolalSoln::IdealMolalSoln() :
32 IMS_X_o_cutoff_(0.20),
33 IMS_gamma_o_min_(0.00001),
34 IMS_gamma_k_min_(10.0),
70 IMS_cCut_ = b.IMS_cCut_;
72 IMS_dfCut_ = b.IMS_dfCut_;
73 IMS_efCut_ = b.IMS_efCut_;
74 IMS_afCut_ = b.IMS_afCut_;
75 IMS_bfCut_ = b.IMS_bfCut_;
77 IMS_dgCut_ = b.IMS_dgCut_;
78 IMS_egCut_ = b.IMS_egCut_;
79 IMS_agCut_ = b.IMS_agCut_;
80 IMS_bgCut_ = b.IMS_bgCut_;
89 const std::string& id_) :
94 IMS_gamma_o_min_(0.00001),
95 IMS_gamma_k_min_(10.0),
115 IMS_X_o_cutoff_(0.2),
116 IMS_gamma_o_min_(0.00001),
117 IMS_gamma_k_min_(10.0),
171 return err(
"not implemented");
185 double* vbar = &
m_pp[0];
189 doublereal vtotal = 0.0;
190 for (
size_t i = 0; i <
m_kk; i++) {
191 vtotal += vbar[i] * x[i];
212 "Density is not an independent variable");
221 "molarDensity/denisty is not an independent variable");
243 for (
size_t k = 0; k <
m_kk; k++) {
248 for (
size_t k = 0; k <
m_kk; k++) {
257 double c0 = 1.0, mvSolvent;
266 c0 = 1.0 / mvSolvent;
282 for (
int i = 0; i < sizeUA; i++) {
286 for (
int i = 0; i < sizeUA; i++) {
291 uA[1] = -int(
nDim());
318 for (
size_t k = 0; k <
m_kk; k++) {
326 exp((xmolSolvent - 1.0)/xmolSolvent);
333 for (
size_t k = 1; k <
m_kk; k++) {
347 for (
size_t k = 0; k <
m_kk; k++) {
355 exp((xmolSolvent - 1.0)/xmolSolvent) / xmolSolvent;
359 for (
size_t k = 0; k <
m_kk; k++) {
360 acMolality[k] = exp(acMolality[k]);
396 for (
size_t k = 1; k <
m_kk; k++) {
398 mu[k] += RT * log(xx);
407 (RT * (xmolSolvent - 1.0) / xx);
416 for (
size_t k = 1; k <
m_kk; k++) {
430 doublereal RT =
_RT();
431 for (
size_t k = 0; k <
m_kk; k++) {
442 for (
size_t k = 0; k <
m_kk; k++) {
445 sbar[k] -= R * log(mm);
461 for (
size_t k = 0; k <
m_kk; k++) {
487 for (
size_t k = 0; k <
m_kk; k++) {
507 if (!phaseNode.
hasChild(
"thermo")) {
509 "no thermo XML node");
517 if (id_.size() > 0) {
518 std::string idp = phaseNode.
id();
521 "phasenode and Id are incompatible");
528 if (!phaseNode.
hasChild(
"thermo")) {
530 "no thermo XML node");
537 if (thermoNode.
hasChild(
"standardConc")) {
540 std::string formString = scNode.
attrib(
"model");
541 if (formString !=
"") {
542 if (formString ==
"unity") {
544 }
else if (formString ==
"molar_volume") {
546 }
else if (formString ==
"solvent_volume") {
550 "Unknown standardConc model: " + formString);
559 std::string solventName =
"";
560 if (thermoNode.
hasChild(
"solvent")) {
562 std::vector<std::string> nameSolventa;
564 int nsp =
static_cast<int>(nameSolventa.size());
567 "badly formed solvent XML node");
569 solventName = nameSolventa[0];
572 if (thermoNode.
hasChild(
"activityCoefficients")) {
574 std::string modelString = acNode.
attrib(
"model");
576 if (modelString !=
"IdealMolalSoln") {
578 "unknown ActivityCoefficient model: " + modelString);
580 if (acNode.
hasChild(
"idealMolalSolnCutoff")) {
582 modelString = ccNode.
attrib(
"model");
583 if (modelString !=
"") {
584 if (modelString ==
"polyExp") {
586 }
else if (modelString ==
"poly") {
590 "Unknown idealMolalSolnCutoff form: " + modelString);
593 if (ccNode.
hasChild(
"gamma_o_limit")) {
596 if (ccNode.
hasChild(
"gamma_k_limit")) {
599 if (ccNode.
hasChild(
"X_o_cutoff")) {
603 IMS_cCut_ =
getFloat(ccNode,
"c_0_param");
605 if (ccNode.
hasChild(
"slope_f_limit")) {
608 if (ccNode.
hasChild(
"slope_g_limit")) {
620 for (
size_t k = 0; k <
m_kk; k++) {
622 if (solventName == sname) {
628 std::cout <<
"IdealMolalSoln::initThermo: Solvent Name not found"
631 "Solvent name not found");
635 "Solvent " + solventName +
636 " should be first species");
649 for (
size_t k = 0; k <
m_kk; k++) {
699 "Unfinished func called: " + msg);
717 for (
size_t k = 1; k <
m_kk; k++) {
724 for (
size_t k = 1; k <
m_kk; k++) {
731 for (
size_t k = 1; k <
m_kk; k++) {
742 double xminus2 = xminus * xminus;
743 double xminus3 = xminus2 * xminus;
747 double h2 = 3.5 * xminus2 / IMS_X_o_cutoff_ - 2.0 * xminus3 / x_o_cut2;
748 double h2_prime = 7.0 * xminus / IMS_X_o_cutoff_ - 6.0 * xminus2 / x_o_cut2;
750 double h1 = (1.0 - 3.0 * xminus2 / x_o_cut2 + 2.0 * xminus3/ x_o_cut3);
751 double h1_prime = (- 6.0 * xminus / x_o_cut2 + 6.0 * xminus2/ x_o_cut3);
757 double h1_f = h1 * alpha;
758 double h1_f_prime = h1_prime * alpha;
760 double f = h2 + h1_f;
761 double f_prime = h2_prime + h1_f_prime;
763 double g = h2 + h1_g;
764 double g_prime = h2_prime + h1_g_prime;
766 tmp = (xmolSolvent/ g * g_prime + (1.0-xmolSolvent) / f * f_prime);
767 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
768 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
770 tmp = log(xmolSolvent) + lngammak;
771 for (
size_t k = 1; k <
m_kk; k++) {
781 for (
size_t k = 1; k <
m_kk; k++) {
788 double xoverc = xmolSolvent/IMS_cCut_;
789 double eterm = std::exp(-xoverc);
791 double fptmp = IMS_bfCut_ - IMS_afCut_ / IMS_cCut_ - IMS_bfCut_*xoverc
792 + 2.0*IMS_dfCut_*xmolSolvent - IMS_dfCut_*xmolSolvent*xoverc;
793 double f_prime = 1.0 + eterm*fptmp;
794 double f = xmolSolvent + IMS_efCut_ + eterm * (IMS_afCut_ + xmolSolvent * (IMS_bfCut_ + IMS_dfCut_*xmolSolvent));
796 double gptmp = IMS_bgCut_ - IMS_agCut_ / IMS_cCut_ - IMS_bgCut_*xoverc
797 + 2.0*IMS_dgCut_*xmolSolvent - IMS_dgCut_*xmolSolvent*xoverc;
798 double g_prime = 1.0 + eterm*gptmp;
799 double g = xmolSolvent + IMS_egCut_ + eterm * (IMS_agCut_ + xmolSolvent * (IMS_bgCut_ + IMS_dgCut_*xmolSolvent));
801 tmp = (xmolSolvent / g * g_prime + (1.0 - xmolSolvent) / f * f_prime);
802 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
803 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
805 tmp = log(xx) + lngammak;
806 for (
size_t k = 1; k <
m_kk; k++) {
832 bool converged =
false;
835 for (its = 0; its < 100 && !converged; its++) {
839 IMS_dfCut_ = ((- IMS_afCut_/IMS_cCut_ + IMS_bfCut_ - IMS_bfCut_*
IMS_X_o_cutoff_/IMS_cCut_)
844 IMS_efCut_ = - eterm * (tmp);
845 if (fabs(IMS_efCut_ - oldV) < 1.0E-14) {
850 throw CanteraError(
" IdealMolalSoln::calcCutoffParams_()",
851 " failed to converge on the f polynomial");
854 double f_0 = IMS_afCut_ + IMS_efCut_;
855 double f_prime_0 = 1.0 - IMS_afCut_ / IMS_cCut_ + IMS_bfCut_;
857 for (its = 0; its < 100 && !converged; its++) {
860 IMS_agCut_ = exp(lng_0) - IMS_egCut_;
862 IMS_dgCut_ = ((- IMS_agCut_/IMS_cCut_ + IMS_bgCut_ - IMS_bgCut_*
IMS_X_o_cutoff_/IMS_cCut_)
867 IMS_egCut_ = - eterm * (tmp);
868 if (fabs(IMS_egCut_ - oldV) < 1.0E-14) {
873 throw CanteraError(
" IdealMolalSoln::calcCutoffParams_()",
874 " failed to converge on the g polynomial");
IdealMolalSoln & operator=(const IdealMolalSoln &)
Assignment operator.
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...
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
virtual doublereal density() const
Density (kg/m^3).
virtual void setPressure(doublereal p)
Set the pressure at constant temperature.
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
virtual void setState_TP(doublereal t, doublereal p)
Set the temperature (K) and pressure (Pa)
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
doublereal IMS_slopefCut_
Parameter in the polyExp cutoff treatment.
doublereal IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
doublereal _RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of each species in their standard states at the current T and P of the solution...
IdealMolalSoln()
Constructor.
const size_t npos
index returned by functions to indicate "no position"
virtual void getPartialMolarVolumes(doublereal *vbar) const
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the standard state of the species at ...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
virtual doublereal enthalpy_mole() const
Molar enthalpy of the solution. Units: J/kmol.
virtual void getActivityConcentrations(doublereal *c) const
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
virtual doublereal standardConcentration(size_t k=0) const
The standard concentration used to normalize the generalized concentration.
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual void updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
doublereal getFloat(const Cantera::XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
ThermoPhase * duplMyselfAsThermoPhase() const
Duplication function.
doublereal IMS_gamma_k_min_
gamma_k minimum for the cutoff process at the zero solvent point
doublereal err(const std::string &msg) const
Internal error message.
doublereal m_xmolSolventMIN
void setDensity(const doublereal rho)
Overwritten setDensity() function is necessary because the density is not an independent variable...
doublereal molarDensity() const
Molar density (kmol/m^3).
void initLengths()
This internal function adjusts the lengths of arrays.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
void setMolarDensity(const doublereal rho)
Overwritten setMolarDensity() function is necessary because the density is not an independent variabl...
doublereal IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
vector_fp m_pp
Temporary array used in equilibrium calculations.
vector_fp m_speciesMolarVolume
Species molar volume .
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual doublereal gibbs_mole() const
Molar Gibbs function for the solution: Units J/kmol.
Base class for a phase with thermodynamic properties.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials: Units: J/kmol.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
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...
virtual void getActivities(doublereal *ac) const
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty thermophase object.
virtual doublereal isothermalCompressibility() const
The isothermal compressibility. Units: 1/Pa.
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
virtual doublereal cv_mole() const
Molar heat capacity of the solution at constant volume. Units: J/kmol/K.
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id="")
Import and initialize an IdealMolalSoln phase specification in an XML tree into the current object...
virtual doublereal entropy_mole() const
Molar entropy of the solution. Units: J/kmol/K.
MolalityVPSSTP & operator=(const MolalityVPSSTP &b)
Assignment operator.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution. Units: J/kmol...
virtual doublereal cp_mole() const
Molar heat capacity of the solution at constant pressure. Units: J/kmol/K.
#define AssertThrow(expr, procedure)
Assertion must be true or an error is thrown.
Base class for exceptions thrown by Cantera classes.
virtual void getParameters(int &n, doublereal *const c) const
virtual doublereal intEnergy_mole() const
Molar internal energy of the solution: Units: J/kmol.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
virtual void getPartialMolarCp(doublereal *cpbar) const
Partial molar heat capacity of the solution:. UnitsL J/kmol/K.
int IMS_typeCutoff_
Cutoff type.
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
size_t nSpecies() const
Returns the number of species in the phase.
virtual doublereal logStandardConc(size_t k=0) const
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Enthalpy functions for the standard state species at the current T an...
doublereal temperature() const
Temperature (K).
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
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...
std::string id() const
Return the id attribute, if present.
const doublereal SmallNumber
smallest number to compare to zero.
virtual void initThermo()
Initialization routine for an IdealMolalSoln phase.
void getStringArray(const Cantera::XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
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].
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
virtual int eosType() const
Equation of state type flag.
size_t m_kk
Number of species in the phase.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
doublereal m_Pcurrent
Current value of the pressure - state variable.
This phase is based upon the mixing-rule assumption that all molality-based activity coefficients are...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity.
XML_Node & root() const
Return the root of the current XML_Node tree.
size_t m_indexSolvent
Index of the solvent.
virtual void setParametersFromXML(const XML_Node &eosdata)
void calcIMSCutoffParams_()
Calculate parameters for cutoff treatments of activity coefficients.
virtual void setParameters(int n, doublereal *const c)
doublereal IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
std::string speciesName(size_t k) const
Name of the species with index k.
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 setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase Note the density of a phase is an independent...
void setMoleFSolventMin(doublereal xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.
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.
vector_fp IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.