26double X_o_cutoff_default = 0.20;
27double gamma_o_min_default = 0.00001;
28double gamma_k_min_default = 10.0;
29double slopefCut_default = 0.6;
30double slopegCut_default = 0.0;
31double cCut_default = .05;
38 IMS_X_o_cutoff_(X_o_cutoff_default),
39 IMS_gamma_o_min_(gamma_o_min_default),
40 IMS_gamma_k_min_(gamma_k_min_default),
41 IMS_slopefCut_(slopefCut_default),
42 IMS_slopegCut_(slopegCut_default),
43 IMS_cCut_(cCut_default)
82 return Units(1.0, 0, -
static_cast<double>(
nDim()), 0, 0, 0, 1);
91 for (
size_t k = 0; k <
m_kk; k++) {
96 for (
size_t k = 0; k <
m_kk; k++) {
113 throw CanteraError(
"IdealMolalSoln::standardConcentration",
114 "m_formGC is set to an incorrect value. \
115 Allowed values are 0, 1, and 2");
128 for (
size_t k = 0; k <
m_kk; k++) {
135 ac[0] = exp((xmolSolvent - 1.0)/xmolSolvent);
141 for (
size_t k = 1; k <
m_kk; k++) {
152 acMolality.size(),
m_kk);
154 for (
size_t k = 0; k <
m_kk; k++) {
161 acMolality[0] = exp((xmolSolvent - 1.0)/xmolSolvent) / xmolSolvent;
165 for (
size_t k = 0; k <
m_kk; k++) {
166 acMolality[k] = exp(acMolality[k]);
188 for (
size_t k = 1; k <
m_kk; k++) {
190 mu[k] +=
RT() * log(xx);
196 mu[0] += (
RT() * (xmolSolvent - 1.0) / xx);
202 for (
size_t k = 1; k <
m_kk; k++) {
214 for (
size_t k = 0; k <
m_kk; k++) {
222 for (
size_t k = 0; k <
m_kk; k++) {
232 for (
size_t k = 1; k <
m_kk; k++) {
237 sbar[0] -= (
GasConstant * (xmolSolvent - 1.0) / xmolSolvent);
246 for (
size_t k = 1; k <
m_kk; k++) {
266 for (
size_t k = 0; k <
m_kk; k++) {
296 IMS_cCut_ = cutoff.getDouble(
"c_0", cCut_default);
301 for (
size_t k = 0; k <
nSpecies(); k++) {
316 phaseNode[
"standard-concentration-basis"] =
"unity";
318 phaseNode[
"standard-concentration-basis"] =
"species-molar-volume";
323 cutoff[
"model"] =
"poly";
325 cutoff[
"model"] =
"polyexp";
337 if (IMS_cCut_ != cCut_default) {
338 cutoff[
"c_0"] = IMS_cCut_;
348 phaseNode[
"cutoff"] = std::move(cutoff);
363 throw CanteraError(
"IdealMolalSoln::setStandardConcentrationModel",
364 "Unknown standard concentration model '{}'", model);
378 "Unknown cutoff model '{}'", model);
394 for (
size_t k = 1; k <
m_kk; k++) {
401 for (
size_t k = 1; k <
m_kk; k++) {
408 for (
size_t k = 1; k <
m_kk; k++) {
416 double xminus2 = xminus * xminus;
417 double xminus3 = xminus2 * xminus;
421 double h2 = 3.5 * xminus2 /
IMS_X_o_cutoff_ - 2.0 * xminus3 / x_o_cut2;
422 double h2_prime = 7.0 * xminus /
IMS_X_o_cutoff_ - 6.0 * xminus2 / x_o_cut2;
424 double h1 = (1.0 - 3.0 * xminus2 / x_o_cut2 + 2.0 * xminus3/ x_o_cut3);
425 double h1_prime = (- 6.0 * xminus / x_o_cut2 + 6.0 * xminus2/ x_o_cut3);
431 double h1_f = h1 * alpha;
432 double h1_f_prime = h1_prime * alpha;
434 double f = h2 + h1_f;
435 double f_prime = h2_prime + h1_f_prime;
437 double g = h2 + h1_g;
438 double g_prime = h2_prime + h1_g_prime;
440 double tmp = (xmolSolvent/ g * g_prime + (1.0-xmolSolvent) / f * f_prime);
441 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
442 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
444 tmp = log(xmolSolvent) + lngammak;
445 for (
size_t k = 1; k <
m_kk; k++) {
453 for (
size_t k = 1; k <
m_kk; k++) {
459 double xoverc = xmolSolvent/IMS_cCut_;
460 double eterm = std::exp(-xoverc);
462 double fptmp = IMS_bfCut_ - IMS_afCut_ / IMS_cCut_ - IMS_bfCut_*xoverc
463 + 2.0*IMS_dfCut_*xmolSolvent - IMS_dfCut_*xmolSolvent*xoverc;
464 double f_prime = 1.0 + eterm*fptmp;
465 double f = xmolSolvent + IMS_efCut_ + eterm * (IMS_afCut_ + xmolSolvent * (IMS_bfCut_ + IMS_dfCut_*xmolSolvent));
467 double gptmp = IMS_bgCut_ - IMS_agCut_ / IMS_cCut_ - IMS_bgCut_*xoverc
468 + 2.0*IMS_dgCut_*xmolSolvent - IMS_dgCut_*xmolSolvent*xoverc;
469 double g_prime = 1.0 + eterm*gptmp;
470 double g = xmolSolvent + IMS_egCut_ + eterm * (IMS_agCut_ + xmolSolvent * (IMS_bgCut_ + IMS_dgCut_*xmolSolvent));
472 double tmp = (xmolSolvent / g * g_prime + (1.0 - xmolSolvent) / f * f_prime);
473 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
474 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
476 tmp = log(xx) + lngammak;
477 for (
size_t k = 1; k <
m_kk; k++) {
489 bool converged =
false;
490 for (
int its = 0; its < 100 && !converged; its++) {
491 double oldV = IMS_efCut_;
494 IMS_dfCut_ = ((- IMS_afCut_/IMS_cCut_ + IMS_bfCut_ - IMS_bfCut_*
IMS_X_o_cutoff_/IMS_cCut_)
499 IMS_efCut_ = - eterm * (tmp);
500 if (fabs(IMS_efCut_ - oldV) < 1.0E-14) {
506 "failed to converge on the f polynomial");
509 double f_0 = IMS_afCut_ + IMS_efCut_;
510 double f_prime_0 = 1.0 - IMS_afCut_ / IMS_cCut_ + IMS_bfCut_;
512 for (
int its = 0; its < 100 && !converged; its++) {
513 double oldV = IMS_egCut_;
515 IMS_agCut_ = exp(lng_0) - IMS_egCut_;
517 IMS_dgCut_ = ((- IMS_agCut_/IMS_cCut_ + IMS_bgCut_ - IMS_bgCut_*
IMS_X_o_cutoff_/IMS_cCut_)
522 IMS_egCut_ = - eterm * (tmp);
523 if (fabs(IMS_egCut_ - oldV) < 1.0E-14) {
529 "failed to converge on the g polynomial");
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
Declarations for the virtual base class PDSS (pressure dependent standard state) which handles calcul...
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.
size_t size() const
Returns the number of elements in this map.
bool hasKey(const 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 getMolalityActivityCoefficients(span< double > acMolality) const override
Get the array of non-dimensional molality-based activity coefficients at the current solution tempera...
void getPartialMolarIntEnergies(span< double > hbar) const override
Returns an array of partial molar internal energies for the species in the mixture.
double thermalExpansionCoeff() const override
The thermal expansion coefficient. Units: 1/K.
double IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
double IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
void getPartialMolarEnthalpies(span< double > hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
int IMS_typeCutoff_
Cutoff type.
IdealMolalSoln(const string &inputFile="", const string &id="")
Constructor for phase initialization.
void getPartialMolarCp(span< double > cpbar) const override
Partial molar heat capacity of the solution:. UnitsL J/kmol/K.
void getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
double internalPressure() const override
Return the internal pressure [Pa].
void getActivities(span< double > ac) const override
Get the array of non-dimensional activities at the current solution temperature, pressure,...
vector< double > IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.
void setStandardConcentrationModel(const string &model)
Set the standard concentration model.
double IMS_slopefCut_
Parameter in the polyExp cutoff treatment.
double isothermalCompressibility() const override
The isothermal compressibility. Units: 1/Pa.
double intEnergy_mole() const override
Molar internal energy of the solution: Units: J/kmol.
void setCutoffModel(const string &model)
Set cutoff model. Must be one of 'none', 'poly', or 'polyExp'.
double IMS_gamma_k_min_
gamma_k minimum 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 = 'species-molar-vo...
vector< double > m_speciesMolarVolume
Species molar volume .
double IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process;
void getPartialMolarVolumes(span< double > vbar) const override
For this solution, the partial molar volumes are equal to the constant species molar volumes.
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
void getPartialMolarEntropies(span< double > sbar) const override
Returns an array of partial molar entropies of the species in the solution.
double standardConcentration(size_t k=0) const override
Return the standard concentration for the kth species.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void getChemPotentials(span< double > mu) const override
Get the species chemical potentials: Units: J/kmol.
void getActivityConcentrations(span< double > c) const override
This method returns an array of generalized concentrations.
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
double m_xmolSolventMIN
In any molality implementation, it makes sense to have a minimum solvent mole fraction requirement,...
vector< double > m_molalities
Current value of the molalities of the species in the phase.
void setMoleFSolventMin(double xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
virtual double molarVolume() const
Return the molar volume at standard state.
vector< double > m_workS
Vector of size m_kk, used as a temporary holding area.
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)
double mean_X(span< const double > Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
double moleFraction(size_t k) const
Return the mole fraction of a single species.
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
double RT() const
Return the Gas Constant multiplied by the current temperature.
void initThermoFile(const string &inputFile, const string &id)
Initialize a ThermoPhase object using an input file.
AnyMap m_input
Data supplied via setParameters.
A representation of the units associated with a dimensional quantity.
void getCp_R(span< double > cpr) const override
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
void getIntEnergy_RT(span< double > urt) const override
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
virtual void _updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
void getStandardChemPotentials(span< double > mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void getEnthalpy_RT(span< double > hrt) const override
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
void getEntropy_R(span< double > sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void getStandardVolumes(span< double > vol) const override
Get the molar volumes of the species standard states at the current T and P of the solution.
bool caseInsensitiveEquals(const string &input, const string &test)
Case insensitive equality predicate.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
const double SmallNumber
smallest number to compare to zero.
void checkArraySize(const char *procedure, size_t available, size_t required)
Wrapper for throwing ArraySizeError.
Contains declarations for string manipulation functions within Cantera.