31 IMS_X_o_cutoff_(0.20),
32 IMS_gamma_o_min_(0.00001),
33 IMS_gamma_k_min_(10.0),
49 const std::string& id_) :
54 IMS_gamma_o_min_(0.00001),
55 IMS_gamma_k_min_(10.0),
76 IMS_gamma_o_min_(0.00001),
77 IMS_gamma_k_min_(10.0),
145 "Overloaded function to be removed after Cantera 2.5. "
146 "Error will be thrown by Phase::setDensity instead");
149 "Density is not an independent variable");
156 "Overloaded function to be removed after Cantera 2.5. "
157 "Error will be thrown by Phase::setMolarDensity instead");
160 "molarDensity/density is not an independent variable");
172 return Units(1.0, 0, -
static_cast<double>(
nDim()), 0, 0, 0, 1);
181 for (
size_t k = 0; k <
m_kk; k++) {
186 for (
size_t k = 0; k <
m_kk; k++) {
203 throw CanteraError(
"IdealMolalSoln::standardConcentration",
204 "m_formGC is set to an incorrect value. \
205 Allowed values are 0, 1, and 2");
217 for (
size_t k = 0; k <
m_kk; k++) {
224 ac[0] = exp((xmolSolvent - 1.0)/xmolSolvent);
230 for (
size_t k = 1; k <
m_kk; k++) {
241 for (
size_t k = 0; k <
m_kk; k++) {
248 acMolality[0] = exp((xmolSolvent - 1.0)/xmolSolvent) / xmolSolvent;
252 for (
size_t k = 0; k <
m_kk; k++) {
253 acMolality[k] = exp(acMolality[k]);
275 for (
size_t k = 1; k <
m_kk; k++) {
277 mu[k] +=
RT() * log(xx);
283 mu[0] += (
RT() * (xmolSolvent - 1.0) / xx);
289 for (
size_t k = 1; k <
m_kk; k++) {
301 for (
size_t k = 0; k <
m_kk; k++) {
311 for (
size_t k = 1; k <
m_kk; k++) {
316 sbar[0] -= (
GasConstant * (xmolSolvent - 1.0) / xmolSolvent);
325 for (
size_t k = 1; k <
m_kk; k++) {
345 for (
size_t k = 0; k <
m_kk; k++) {
367 if (id_.size() > 0 && phaseNode.
id() != id_) {
369 "phasenode and Id are incompatible");
373 if (!phaseNode.
hasChild(
"thermo")) {
375 "no thermo XML node");
380 if (thermoNode.
hasChild(
"standardConc")) {
385 if (thermoNode.
hasChild(
"activityCoefficients")) {
387 std::string modelString = acNode.
attrib(
"model");
388 if (modelString !=
"IdealMolalSoln") {
390 "unknown ActivityCoefficient model: " + modelString);
392 if (acNode.
hasChild(
"idealMolalSolnCutoff")) {
394 modelString = ccNode.
attrib(
"model");
395 if (modelString !=
"") {
397 if (ccNode.
hasChild(
"gamma_o_limit")) {
400 if (ccNode.
hasChild(
"gamma_k_limit")) {
403 if (ccNode.
hasChild(
"X_o_cutoff")) {
407 IMS_cCut_ =
getFloat(ccNode,
"c_0_param");
409 if (ccNode.
hasChild(
"slope_f_limit")) {
412 if (ccNode.
hasChild(
"slope_g_limit")) {
432 if (cutoff.hasKey(
"gamma_o")) {
435 if (cutoff.hasKey(
"gamma_k")) {
438 if (cutoff.hasKey(
"X_o")) {
441 if (cutoff.hasKey(
"c_0")) {
442 IMS_cCut_ = cutoff[
"c_0"].asDouble();
444 if (cutoff.hasKey(
"slope_f")) {
447 if (cutoff.hasKey(
"slope_g")) {
452 for (
size_t k = 0; k <
nSpecies(); k++) {
472 throw CanteraError(
"IdealMolalSoln::setStandardConcentrationModel",
473 "Unknown standard concentration model '{}'", model);
487 "Unknown cutoff model '{}'", model);
503 for (
size_t k = 1; k <
m_kk; k++) {
510 for (
size_t k = 1; k <
m_kk; k++) {
517 for (
size_t k = 1; k <
m_kk; k++) {
525 double xminus2 = xminus * xminus;
526 double xminus3 = xminus2 * xminus;
530 double h2 = 3.5 * xminus2 /
IMS_X_o_cutoff_ - 2.0 * xminus3 / x_o_cut2;
531 double h2_prime = 7.0 * xminus /
IMS_X_o_cutoff_ - 6.0 * xminus2 / x_o_cut2;
533 double h1 = (1.0 - 3.0 * xminus2 / x_o_cut2 + 2.0 * xminus3/ x_o_cut3);
534 double h1_prime = (- 6.0 * xminus / x_o_cut2 + 6.0 * xminus2/ x_o_cut3);
540 double h1_f = h1 * alpha;
541 double h1_f_prime = h1_prime * alpha;
543 double f = h2 + h1_f;
544 double f_prime = h2_prime + h1_f_prime;
546 double g = h2 + h1_g;
547 double g_prime = h2_prime + h1_g_prime;
549 double tmp = (xmolSolvent/ g * g_prime + (1.0-xmolSolvent) / f * f_prime);
550 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
551 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
553 tmp = log(xmolSolvent) + lngammak;
554 for (
size_t k = 1; k <
m_kk; k++) {
562 for (
size_t k = 1; k <
m_kk; k++) {
568 double xoverc = xmolSolvent/IMS_cCut_;
569 double eterm = std::exp(-xoverc);
571 double fptmp = IMS_bfCut_ - IMS_afCut_ / IMS_cCut_ - IMS_bfCut_*xoverc
572 + 2.0*IMS_dfCut_*xmolSolvent - IMS_dfCut_*xmolSolvent*xoverc;
573 double f_prime = 1.0 + eterm*fptmp;
574 double f = xmolSolvent + IMS_efCut_ + eterm * (IMS_afCut_ + xmolSolvent * (IMS_bfCut_ + IMS_dfCut_*xmolSolvent));
576 double gptmp = IMS_bgCut_ - IMS_agCut_ / IMS_cCut_ - IMS_bgCut_*xoverc
577 + 2.0*IMS_dgCut_*xmolSolvent - IMS_dgCut_*xmolSolvent*xoverc;
578 double g_prime = 1.0 + eterm*gptmp;
579 double g = xmolSolvent + IMS_egCut_ + eterm * (IMS_agCut_ + xmolSolvent * (IMS_bgCut_ + IMS_dgCut_*xmolSolvent));
581 double tmp = (xmolSolvent / g * g_prime + (1.0 - xmolSolvent) / f * f_prime);
582 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
583 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
585 tmp = log(xx) + lngammak;
586 for (
size_t k = 1; k <
m_kk; k++) {
598 bool converged =
false;
599 for (
int its = 0; its < 100 && !converged; its++) {
600 double oldV = IMS_efCut_;
603 IMS_dfCut_ = ((- IMS_afCut_/IMS_cCut_ + IMS_bfCut_ - IMS_bfCut_*
IMS_X_o_cutoff_/IMS_cCut_)
608 IMS_efCut_ = - eterm * (tmp);
609 if (fabs(IMS_efCut_ - oldV) < 1.0E-14) {
615 "failed to converge on the f polynomial");
618 double f_0 = IMS_afCut_ + IMS_efCut_;
619 double f_prime_0 = 1.0 - IMS_afCut_ / IMS_cCut_ + IMS_bfCut_;
621 for (
int its = 0; its < 100 && !converged; its++) {
622 double oldV = IMS_egCut_;
624 IMS_agCut_ = exp(lng_0) - IMS_egCut_;
626 IMS_dgCut_ = ((- IMS_agCut_/IMS_cCut_ + IMS_bgCut_ - IMS_bgCut_*
IMS_X_o_cutoff_/IMS_cCut_)
631 IMS_egCut_ = - eterm * (tmp);
632 if (fabs(IMS_egCut_ - oldV) < 1.0E-14) {
638 "failed to converge on the g polynomial");
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
A map of string keys to values whose type can vary at runtime.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
Base class for exceptions thrown by Cantera classes.
void calcIMSCutoffParams_()
Calculate parameters for cutoff treatments of activity coefficients.
void setCutoffModel(const std::string &model)
Set cutoff model. Must be one of 'none', 'poly', or 'polyExp'.
doublereal IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
int IMS_typeCutoff_
Cutoff type.
virtual doublereal cp_mole() const
Molar heat capacity of the solution at constant pressure. Units: J/kmol/K.
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
doublereal IMS_slopefCut_
Parameter in the polyExp cutoff treatment.
virtual doublereal enthalpy_mole() const
Molar enthalpy of the solution. Units: J/kmol.
doublereal IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process;
virtual void getPartialMolarVolumes(doublereal *vbar) const
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual doublereal thermalExpansionCoeff() const
The thermal expansion coefficient. Units: 1/K.
virtual void getPartialMolarCp(doublereal *cpbar) const
Partial molar heat capacity of the solution:. UnitsL J/kmol/K.
IdealMolalSoln()
Constructor.
virtual void setDensity(const doublereal rho)
Overridden setDensity() function is necessary because the density is not an independent variable.
vector_fp m_speciesMolarVolume
Species molar volume .
virtual doublereal entropy_mole() const
Molar entropy of the solution. Units: J/kmol/K.
virtual void initThermo()
doublereal IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
int m_formGC
The standard concentrations can have one of three different forms: 0 = 'unity', 1 = 'molar_volume',...
virtual doublereal gibbs_mole() const
Molar Gibbs function for the solution: Units J/kmol.
vector_fp IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
doublereal IMS_gamma_k_min_
gamma_k minimum for the cutoff process at the zero solvent point
void setStandardConcentrationModel(const std::string &model)
Set the standard concentration model.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials: Units: J/kmol.
virtual void setMolarDensity(const doublereal rho)
Overridden setMolarDensity() function is necessary because the density is not an independent variable...
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id="")
Import and initialize a ThermoPhase object using an XML tree.
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
virtual void getActivities(doublereal *ac) const
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
virtual doublereal intEnergy_mole() const
Molar internal energy of the solution: Units: J/kmol.
void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
virtual doublereal isothermalCompressibility() const
The isothermal compressibility. Units: 1/Pa.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
void setMoleFSolventMin(doublereal xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.
virtual void initThermo()
doublereal m_xmolSolventMIN
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
vector_fp m_molalities
Current value of the molalities of the species in the phase.
virtual doublereal molarVolume() const
Return the molar volume at standard state.
double molarDensity() const
Molar density (kmol/m^3).
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of the phase.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
size_t nSpecies() const
Returns the number of species in the phase.
size_t m_kk
Number of species in the phase.
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
double moleFraction(size_t k) const
Return the mole fraction of a single species.
virtual double density() const
Density (kg/m^3).
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
AnyMap m_input
Data supplied via setParameters.
A representation of the units associated with a dimensional quantity.
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
virtual void _updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
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 getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Class XML_Node is a tree-based representation of the contents of an XML file.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
std::string id() const
Return the id attribute, if present.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
const double SmallNumber
smallest number to compare to zero.
const double GasConstant
Universal Gas Constant [J/kmol/K].
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
Namespace for the Cantera kernel.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
Contains declarations for string manipulation functions within Cantera.