Overloads the virtual methods of class IdealSolidSolnPhase to implement tabulated standard state thermodynamics for one species in a binary solution. More...
#include <BinarySolutionTabulatedThermo.h>
Overloads the virtual methods of class IdealSolidSolnPhase to implement tabulated standard state thermodynamics for one species in a binary solution.
BinarySolutionTabulatedThermo is derived from IdealSolidSolnPhase, but overwrites the standard state thermodynamic data using tabulated data, as provided by the user in the input file. This ends up being useful for certain non-ideal / non-dilute species where the interaction potentials, as a function of composition / solute mole fraction, are not easily represented by any closed-form equation of state.
A good example of this type of phase is intercalation-based lithium storage materials used for lithium-ion battery electrodes. Measuring the open circuit voltage \( E_eq \), relative to a reference electrode, as a function of lithium mole fraction and as a function of temperature, provides a means to evaluate the gibbs free energy of reaction:
\[ \Delta g_{\rm rxn} = -\frac{E_eq}{nF} \]
where \( n \) is the charge number transferred to the phase, via the reaction, and \( F \) is Faraday's constant. The gibbs energy of reaction, in turn, can be separated into enthalpy and entropy of reaction components:
\[ \Delta g_{\rm rxn} = \Delta h_{\rm rxn} - T\Delta s_{\rm rxn} \]
\[ \frac{d\Delta g_{\rm rxn}}{dT} = - \Delta s_{\rm rxn} \]
For the tabulated binary phase, the user identifies a 'tabulated' species, while the other is considered the 'reference' species. The standard state thermo variables for the tabulated species therefore incorporate any and all excess energy contributions, and are calculated according to the reaction energy terms:
\[ \Delta h_{\rm rxn} = \sum_k \nu_k h^{\rm o}_k \]
\[ \Delta s_{\rm rxn} = \sum_k \nu_k s^{\rm o}_k + RT\ln\left(\prod_k\left(\frac{c_k}{c^{\rm o}_k} \right)^{\nu_k}\right) \]
Where the 'reference' species is automatically assigned standard state thermo variables \( h^{\rm o} = 0 \) and \( s^{\rm o} = 0 \), and standard state thermo variables for species in any other phases are calculated according to the rules specified in that phase definition.
The present model is intended for modeling non-ideal, tabulated thermodynamics for binary solutions where the tabulated species is incorporated via an electrochemical reaction, such that the open circuit voltage can be measured, relative to a counter electrode species with standard state thermo properties \( h^{\rm o} = 0 \). It is possible that this can be generalized such that this assumption about the counter-electrode is not required. At present, this is left as future work.
The user therefore provides a table of three equally-sized vectors of tabulated data:
where \( E_{\rm eq}\left(x,T^{\rm o} \right) \) and \( \frac{dE_{\rm eq}\left(x,T^{\rm o} \right)}{dT} \) are the experimentally-measured open circuit voltage and derivative in open circuit voltage with respect to temperature, respectively, both measured as a mole fraction of \( x \) for the tabulated species and at a temperature of \( T^{\rm o} \). The arrays \( h_{\rm tab} \) and \( s_{\rm tab} \) must be the same length as the \( x_{\rm tab} \) array.
From these tabulated inputs, the standard state thermodynamic properties for the tabulated species (subscript \( k \), tab) are calculated as:
\[ h^{\rm o}_{k,\,{\rm tab}} = h_{\rm tab} \]
\[ s^{\rm o}_{k,\,{\rm tab}} = s_{\rm tab} + R\ln\frac{x_{k,\,{\rm tab}}}{1-x_{k,\,{\rm tab}}} + \frac{R}{F} \ln\left(\frac{c^{\rm o}_{k,\,{\rm ref}}}{c^{\rm o}_{k,\,{\rm tab}}}\right) \]
Now, whenever the composition has changed, the lookup/interpolation of the tabulated thermo data is performed to update the standard state thermodynamic data for the tabulated species.
Furthermore, there is an optional feature to include non-ideal effects regarding partial molar volumes of the species, \( \bar V_k \). Being derived from IdealSolidSolnPhase, the default assumption in BinarySolutionTabulatedThermo is that the species comprising the binary solution have constant partial molar volumes equal to their pure species molar volumes. However, this assumption only holds true if there is no or only weak interactions between the two species in the binary mixture. In non-ideal solid materials, for example intercalation-based lithium storage materials, the partial molar volumes of the species typically show a strong non-linear dependency on the composition of the mixture. These dependencies can most often only be determined experimentally, for example via X-ray diffraction (XRD) measurements of the unit cell volume. Therefore, the user can provide an optional fourth vector of tabulated molar volume data with the same size as the other tabulated data:
The partial molar volumes \( \bar V_1 \) of the tabulated species and \( \bar V_2 \) of the 'reference' species, respectively, can then be derived from the provided molar volume:
\[ \bar V_1 = V_{\mathrm{m,tab}} + \left(1-x_{\mathrm {tab}}\right) \cdot \frac{\mathrm{d}V_{\mathrm{m,tab}}}{\mathrm{d}x_{\mathrm {tab}}} \\ \bar V_2 = V_{\mathrm{m,tab}} - x_{\mathrm {tab}} \cdot \frac{\mathrm{d}V_{\mathrm{m,tab}}}{\mathrm{d}x_{\mathrm {tab}}} \]
The derivation is implemented using forward differences at the boundaries of the input vector and a central differencing scheme at interior points. As the derivative is determined numerically, the input data should be relatively smooth (recommended is one data point for every mole fraction per cent). The calculated partial molar volumes are accessible to the user via getPartialMolarVolumes().
The calculation of the mass density incorporates the non-ideal behavior by using the provided molar volume in the equation:
\[ \rho = \frac{\sum_k{x_k W_k}}{V_\mathrm{m}} \]
where \( x_k \) are the mole fractions, \( W_k \) are the molecular weights, and \( V_\mathrm{m} \) is the molar volume interpolated from \( V_{\mathrm{m,tab}} \).
If the optional fourth input vector is not specified, the molar volume is calculated by using the pure species molar volumes, as in IdealSolidSolnPhase. Regardless if the molarVolume key is provided or not, the equation-of-state field in the pure species entries has to be defined.
Definition at line 161 of file BinarySolutionTabulatedThermo.h.
Public Member Functions | |
BinarySolutionTabulatedThermo (const string &infile="", const string &id="") | |
Construct and initialize an BinarySolutionTabulatedThermo ThermoPhase object directly from an input file. | |
string | type () const override |
String indicating the thermodynamic model implemented. | |
bool | addSpecies (shared_ptr< Species > spec) override |
Add a Species to this Phase. | |
void | initThermo () override |
Initialize the ThermoPhase object after all species have been set up. | |
bool | ready () const override |
Returns a bool indicating whether the object is ready for use. | |
void | getParameters (AnyMap &phaseNode) const override |
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using the newThermo(AnyMap&) function. | |
void | getPartialMolarVolumes (double *vbar) const override |
returns an array of partial molar volumes of the species in the solution. | |
void | calcDensity () override |
Overloads the calcDensity() method of IdealSolidSoln to also consider non-ideal behavior. | |
Public Member Functions inherited from IdealSolidSolnPhase | |
IdealSolidSolnPhase (const string &infile="", const string &id="") | |
Construct and initialize an IdealSolidSolnPhase ThermoPhase object directly from an input file. | |
string | type () const override |
String indicating the thermodynamic model implemented. | |
bool | isIdeal () const override |
Boolean indicating whether phase is ideal. | |
bool | isCompressible () const override |
Return whether phase represents a compressible substance. | |
double | enthalpy_mole () const override |
Molar enthalpy of the solution. | |
double | entropy_mole () const override |
Molar entropy of the solution. | |
double | gibbs_mole () const override |
Molar Gibbs free energy of the solution. | |
double | cp_mole () const override |
Molar heat capacity at constant pressure of the solution. | |
double | cv_mole () const override |
Molar heat capacity at constant volume of the solution. | |
double | pressure () const override |
Pressure. | |
void | setPressure (double p) override |
Set the pressure at constant temperature. | |
Units | standardConcentrationUnits () const override |
Returns the units of the "standard concentration" for this phase. | |
void | getActivityConcentrations (double *c) const override |
This method returns the array of generalized concentrations. | |
double | standardConcentration (size_t k) const override |
The standard concentration \( C^0_k \) used to normalize the generalized concentration. | |
void | getActivityCoefficients (double *ac) const override |
Get the array of species activity coefficients. | |
void | getChemPotentials (double *mu) const override |
Get the species chemical potentials. | |
void | getPartialMolarEnthalpies (double *hbar) const override |
Returns an array of partial molar enthalpies for the species in the mixture. | |
void | getPartialMolarEntropies (double *sbar) const override |
Returns an array of partial molar entropies of the species in the solution. | |
void | getPartialMolarCp (double *cpbar) const override |
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution. | |
void | getPartialMolarVolumes (double *vbar) const override |
returns an array of partial molar volumes of the species in the solution. | |
void | getStandardChemPotentials (double *mu0) const override |
Get the standard state chemical potentials of the species. | |
void | getEnthalpy_RT (double *hrt) const override |
Get the array of nondimensional Enthalpy functions for the standard state species at the current T and P of the solution. | |
void | getEntropy_R (double *sr) const override |
Get the nondimensional Entropies for the species standard states at the current T and P of the solution. | |
void | getGibbs_RT (double *grt) const override |
Get the nondimensional Gibbs function for the species standard states at the current T and P of the solution. | |
void | getPureGibbs (double *gpure) const override |
Get the Gibbs functions for the pure species at the current T and P of the solution. | |
void | getIntEnergy_RT (double *urt) const override |
Returns the vector of nondimensional Internal Energies of the standard state species at the current T and P of the solution. | |
void | getCp_R (double *cpr) const override |
Get the nondimensional heat capacity at constant pressure function for the species standard states at the current T and P of the solution. | |
void | getStandardVolumes (double *vol) const override |
Get the molar volumes of the species standard states at the current T and P of the solution. | |
void | getEnthalpy_RT_ref (double *hrt) const override |
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of the solution and the reference pressure for the species. | |
void | getGibbs_RT_ref (double *grt) const override |
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temperature of the solution and the reference pressure for the species. | |
void | getGibbs_ref (double *g) const override |
Returns the vector of the Gibbs function of the reference state at the current temperature of the solution and the reference pressure for the species. | |
void | getEntropy_R_ref (double *er) const override |
Returns the vector of nondimensional entropies of the reference state at the current temperature of the solution and the reference pressure for each species. | |
void | getIntEnergy_RT_ref (double *urt) const override |
Returns the vector of nondimensional internal Energies of the reference state at the current temperature of the solution and the reference pressure for each species. | |
void | getCp_R_ref (double *cprt) const override |
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the current temperature of the solution and reference pressure for each species. | |
const vector< double > & | enthalpy_RT_ref () const |
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current temperature. | |
const vector< double > & | gibbs_RT_ref () const |
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current temperature. | |
const vector< double > & | entropy_R_ref () const |
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current temperature. | |
const vector< double > & | cp_R_ref () const |
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current temperature. | |
bool | addSpecies (shared_ptr< Species > spec) override |
Add a Species to this Phase. | |
void | initThermo () override |
Initialize the ThermoPhase object after all species have been set up. | |
void | getParameters (AnyMap &phaseNode) const override |
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using the newThermo(AnyMap&) function. | |
void | getSpeciesParameters (const string &name, AnyMap &speciesNode) const override |
Get phase-specific parameters of a Species object such that an identical one could be reconstructed and added to this phase. | |
void | setToEquilState (const double *mu_RT) override |
This method is used by the ChemEquil equilibrium solver. | |
void | setStandardConcentrationModel (const string &model) |
Set the form for the standard and generalized concentrations. | |
double | speciesMolarVolume (int k) const |
Report the molar volume of species k. | |
void | getSpeciesMolarVolumes (double *smv) const |
Fill in a return vector containing the species molar volumes. | |
Public Member Functions inherited from ThermoPhase | |
ThermoPhase ()=default | |
Constructor. | |
double | RT () const |
Return the Gas Constant multiplied by the current temperature. | |
double | equivalenceRatio () const |
Compute the equivalence ratio for the current mixture from available oxygen and required oxygen. | |
virtual AnyMap | getAuxiliaryData () |
Return intermediate or model-specific parameters used by particular derived classes. | |
string | type () const override |
String indicating the thermodynamic model implemented. | |
virtual string | phaseOfMatter () const |
String indicating the mechanical phase of the matter in this Phase. | |
virtual double | refPressure () const |
Returns the reference pressure in Pa. | |
virtual double | minTemp (size_t k=npos) const |
Minimum temperature for which the thermodynamic data for the species or phase are valid. | |
double | Hf298SS (const size_t k) const |
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) | |
virtual void | modifyOneHf298SS (const size_t k, const double Hf298New) |
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) | |
virtual void | resetHf298 (const size_t k=npos) |
Restore the original heat of formation of one or more species. | |
virtual double | maxTemp (size_t k=npos) const |
Maximum temperature for which the thermodynamic data for the species are valid. | |
bool | chargeNeutralityNecessary () const |
Returns the chargeNeutralityNecessity boolean. | |
virtual double | intEnergy_mole () const |
Molar internal energy. Units: J/kmol. | |
virtual double | isothermalCompressibility () const |
Returns the isothermal compressibility. Units: 1/Pa. | |
virtual double | thermalExpansionCoeff () const |
Return the volumetric thermal expansion coefficient. Units: 1/K. | |
virtual double | soundSpeed () const |
Return the speed of sound. Units: m/s. | |
void | setElectricPotential (double v) |
Set the electric potential of this phase (V). | |
double | electricPotential () const |
Returns the electric potential of this phase (V). | |
virtual int | activityConvention () const |
This method returns the convention used in specification of the activities, of which there are currently two, molar- and molality-based conventions. | |
virtual int | standardStateConvention () const |
This method returns the convention used in specification of the standard state, of which there are currently two, temperature based, and variable pressure based. | |
virtual double | logStandardConc (size_t k=0) const |
Natural logarithm of the standard concentration of the kth species. | |
virtual void | getActivities (double *a) const |
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration. | |
virtual void | getLnActivityCoefficients (double *lnac) const |
Get the array of non-dimensional molar-based ln activity coefficients at the current solution temperature, pressure, and solution concentration. | |
void | getElectrochemPotentials (double *mu) const |
Get the species electrochemical potentials. | |
virtual void | getPartialMolarIntEnergies (double *ubar) const |
Return an array of partial molar internal energies for the species in the mixture. | |
virtual void | getStandardVolumes_ref (double *vol) const |
Get the molar volumes of the species reference states at the current T and P_ref of the solution. | |
double | enthalpy_mass () const |
Specific enthalpy. Units: J/kg. | |
double | intEnergy_mass () const |
Specific internal energy. Units: J/kg. | |
double | entropy_mass () const |
Specific entropy. Units: J/kg/K. | |
double | gibbs_mass () const |
Specific Gibbs function. Units: J/kg. | |
double | cp_mass () const |
Specific heat at constant pressure. Units: J/kg/K. | |
double | cv_mass () const |
Specific heat at constant volume. Units: J/kg/K. | |
virtual void | setState_TPX (double t, double p, const double *x) |
Set the temperature (K), pressure (Pa), and mole fractions. | |
virtual void | setState_TPX (double t, double p, const Composition &x) |
Set the temperature (K), pressure (Pa), and mole fractions. | |
virtual void | setState_TPX (double t, double p, const string &x) |
Set the temperature (K), pressure (Pa), and mole fractions. | |
virtual void | setState_TPY (double t, double p, const double *y) |
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase. | |
virtual void | setState_TPY (double t, double p, const Composition &y) |
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase. | |
virtual void | setState_TPY (double t, double p, const string &y) |
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase. | |
virtual void | setState_TP (double t, double p) |
Set the temperature (K) and pressure (Pa) | |
virtual void | setState_HP (double h, double p, double tol=1e-9) |
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase. | |
virtual void | setState_UV (double u, double v, double tol=1e-9) |
Set the specific internal energy (J/kg) and specific volume (m^3/kg). | |
virtual void | setState_SP (double s, double p, double tol=1e-9) |
Set the specific entropy (J/kg/K) and pressure (Pa). | |
virtual void | setState_SV (double s, double v, double tol=1e-9) |
Set the specific entropy (J/kg/K) and specific volume (m^3/kg). | |
virtual void | setState_ST (double s, double t, double tol=1e-9) |
Set the specific entropy (J/kg/K) and temperature (K). | |
virtual void | setState_TV (double t, double v, double tol=1e-9) |
Set the temperature (K) and specific volume (m^3/kg). | |
virtual void | setState_PV (double p, double v, double tol=1e-9) |
Set the pressure (Pa) and specific volume (m^3/kg). | |
virtual void | setState_UP (double u, double p, double tol=1e-9) |
Set the specific internal energy (J/kg) and pressure (Pa). | |
virtual void | setState_VH (double v, double h, double tol=1e-9) |
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg) | |
virtual void | setState_TH (double t, double h, double tol=1e-9) |
Set the temperature (K) and the specific enthalpy (J/kg) | |
virtual void | setState_SH (double s, double h, double tol=1e-9) |
Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg) | |
virtual void | setState_DP (double rho, double p) |
Set the density (kg/m**3) and pressure (Pa) at constant composition. | |
virtual void | setState (const AnyMap &state) |
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic model. | |
void | setMixtureFraction (double mixFrac, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar) |
Set the mixture composition according to the mixture fraction = kg fuel / (kg oxidizer + kg fuel) | |
void | setMixtureFraction (double mixFrac, const string &fuelComp, const string &oxComp, ThermoBasis basis=ThermoBasis::molar) |
Set the mixture composition according to the mixture fraction = kg fuel / (kg oxidizer + kg fuel) | |
void | setMixtureFraction (double mixFrac, const Composition &fuelComp, const Composition &oxComp, ThermoBasis basis=ThermoBasis::molar) |
Set the mixture composition according to the mixture fraction = kg fuel / (kg oxidizer + kg fuel) | |
double | mixtureFraction (const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar, const string &element="Bilger") const |
Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for the current mixture given fuel and oxidizer compositions. | |
double | mixtureFraction (const string &fuelComp, const string &oxComp, ThermoBasis basis=ThermoBasis::molar, const string &element="Bilger") const |
Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for the current mixture given fuel and oxidizer compositions. | |
double | mixtureFraction (const Composition &fuelComp, const Composition &oxComp, ThermoBasis basis=ThermoBasis::molar, const string &element="Bilger") const |
Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for the current mixture given fuel and oxidizer compositions. | |
void | setEquivalenceRatio (double phi, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar) |
Set the mixture composition according to the equivalence ratio. | |
void | setEquivalenceRatio (double phi, const string &fuelComp, const string &oxComp, ThermoBasis basis=ThermoBasis::molar) |
Set the mixture composition according to the equivalence ratio. | |
void | setEquivalenceRatio (double phi, const Composition &fuelComp, const Composition &oxComp, ThermoBasis basis=ThermoBasis::molar) |
Set the mixture composition according to the equivalence ratio. | |
double | equivalenceRatio (const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar) const |
Compute the equivalence ratio for the current mixture given the compositions of fuel and oxidizer. | |
double | equivalenceRatio (const string &fuelComp, const string &oxComp, ThermoBasis basis=ThermoBasis::molar) const |
Compute the equivalence ratio for the current mixture given the compositions of fuel and oxidizer. | |
double | equivalenceRatio (const Composition &fuelComp, const Composition &oxComp, ThermoBasis basis=ThermoBasis::molar) const |
Compute the equivalence ratio for the current mixture given the compositions of fuel and oxidizer. | |
double | stoichAirFuelRatio (const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar) const |
Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel) given fuel and oxidizer compositions. | |
double | stoichAirFuelRatio (const string &fuelComp, const string &oxComp, ThermoBasis basis=ThermoBasis::molar) const |
Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel) given fuel and oxidizer compositions. | |
double | stoichAirFuelRatio (const Composition &fuelComp, const Composition &oxComp, ThermoBasis basis=ThermoBasis::molar) const |
Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel) given fuel and oxidizer compositions. | |
void | equilibrate (const string &XY, const string &solver="auto", double rtol=1e-9, int max_steps=50000, int max_iter=100, int estimate_equil=0, int log_level=0) |
Equilibrate a ThermoPhase object. | |
virtual bool | compatibleWithMultiPhase () const |
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations. | |
virtual double | critTemperature () const |
Critical temperature (K). | |
virtual double | critPressure () const |
Critical pressure (Pa). | |
virtual double | critVolume () const |
Critical volume (m3/kmol). | |
virtual double | critCompressibility () const |
Critical compressibility (unitless). | |
virtual double | critDensity () const |
Critical density (kg/m3). | |
virtual double | satTemperature (double p) const |
Return the saturation temperature given the pressure. | |
virtual double | satPressure (double t) |
Return the saturation pressure given the temperature. | |
virtual double | vaporFraction () const |
Return the fraction of vapor at the current conditions. | |
virtual void | setState_Tsat (double t, double x) |
Set the state to a saturated system at a particular temperature. | |
virtual void | setState_Psat (double p, double x) |
Set the state to a saturated system at a particular pressure. | |
void | setState_TPQ (double T, double P, double Q) |
Set the temperature, pressure, and vapor fraction (quality). | |
bool | addSpecies (shared_ptr< Species > spec) override |
Add a Species to this Phase. | |
void | modifySpecies (size_t k, shared_ptr< Species > spec) override |
Modify the thermodynamic data associated with a species. | |
virtual MultiSpeciesThermo & | speciesThermo (int k=-1) |
Return a changeable reference to the calculation manager for species reference-state thermodynamic properties. | |
virtual const MultiSpeciesThermo & | speciesThermo (int k=-1) const |
void | initThermoFile (const string &inputFile, const string &id) |
Initialize a ThermoPhase object using an input file. | |
virtual void | setParameters (const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap()) |
Set equation of state parameters from an AnyMap phase description. | |
AnyMap | parameters (bool withInput=true) const |
Returns the parameters of a ThermoPhase object such that an identical one could be reconstructed using the newThermo(AnyMap&) function. | |
const AnyMap & | input () const |
Access input data associated with the phase description. | |
AnyMap & | input () |
void | invalidateCache () override |
Invalidate any cached values which are normally updated only when a change in state is detected. | |
virtual void | getdlnActCoeffds (const double dTds, const double *const dXds, double *dlnActCoeffds) const |
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space. | |
virtual void | getdlnActCoeffdlnX_diag (double *dlnActCoeffdlnX_diag) const |
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component only. | |
virtual void | getdlnActCoeffdlnN_diag (double *dlnActCoeffdlnN_diag) const |
Get the array of log species mole number derivatives of the log activity coefficients. | |
virtual void | getdlnActCoeffdlnN (const size_t ld, double *const dlnActCoeffdlnN) |
Get the array of derivatives of the log activity coefficients with respect to the log of the species mole numbers. | |
virtual void | getdlnActCoeffdlnN_numderiv (const size_t ld, double *const dlnActCoeffdlnN) |
virtual string | report (bool show_thermo=true, double threshold=-1e-14) const |
returns a summary of the state of the phase as a string | |
Public Member Functions inherited from Phase | |
Phase ()=default | |
Default constructor. | |
Phase (const Phase &)=delete | |
Phase & | operator= (const Phase &)=delete |
virtual bool | isPure () const |
Return whether phase represents a pure (single species) substance. | |
virtual bool | hasPhaseTransition () const |
Return whether phase represents a substance with phase transitions. | |
virtual bool | isCompressible () const |
Return whether phase represents a compressible substance. | |
virtual map< string, size_t > | nativeState () const |
Return a map of properties defining the native state of a substance. | |
string | nativeMode () const |
Return string acronym representing the native state of a Phase. | |
virtual vector< string > | fullStates () const |
Return a vector containing full states defining a phase. | |
virtual vector< string > | partialStates () const |
Return a vector of settable partial property sets within a phase. | |
virtual size_t | stateSize () const |
Return size of vector defining internal state of the phase. | |
void | saveState (vector< double > &state) const |
Save the current internal state of the phase. | |
virtual void | saveState (size_t lenstate, double *state) const |
Write to array 'state' the current internal state. | |
void | restoreState (const vector< double > &state) |
Restore a state saved on a previous call to saveState. | |
virtual void | restoreState (size_t lenstate, const double *state) |
Restore the state of the phase from a previously saved state vector. | |
double | molecularWeight (size_t k) const |
Molecular weight of species k . | |
void | getMolecularWeights (double *weights) const |
Copy the vector of molecular weights into array weights. | |
const vector< double > & | molecularWeights () const |
Return a const reference to the internal vector of molecular weights. | |
const vector< double > & | inverseMolecularWeights () const |
Return a const reference to the internal vector of molecular weights. | |
void | getCharges (double *charges) const |
Copy the vector of species charges into array charges. | |
virtual void | setMolesNoTruncate (const double *const N) |
Set the state of the object with moles in [kmol]. | |
double | elementalMassFraction (const size_t m) const |
Elemental mass fraction of element m. | |
double | elementalMoleFraction (const size_t m) const |
Elemental mole fraction of element m. | |
double | charge (size_t k) const |
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the magnitude of the electron charge. | |
double | chargeDensity () const |
Charge density [C/m^3]. | |
size_t | nDim () const |
Returns the number of spatial dimensions (1, 2, or 3) | |
void | setNDim (size_t ndim) |
Set the number of spatial dimensions (1, 2, or 3). | |
virtual bool | ready () const |
Returns a bool indicating whether the object is ready for use. | |
int | stateMFNumber () const |
Return the State Mole Fraction Number. | |
virtual void | invalidateCache () |
Invalidate any cached values which are normally updated only when a change in state is detected. | |
bool | caseSensitiveSpecies () const |
Returns true if case sensitive species names are enforced. | |
void | setCaseSensitiveSpecies (bool cflag=true) |
Set flag that determines whether case sensitive species are enforced in look-up operations, for example speciesIndex. | |
vector< double > | getCompositionFromMap (const Composition &comp) const |
Converts a Composition to a vector with entries for each species Species that are not specified are set to zero in the vector. | |
void | massFractionsToMoleFractions (const double *Y, double *X) const |
Converts a mixture composition from mole fractions to mass fractions. | |
void | moleFractionsToMassFractions (const double *X, double *Y) const |
Converts a mixture composition from mass fractions to mole fractions. | |
string | name () const |
Return the name of the phase. | |
void | setName (const string &nm) |
Sets the string name for the phase. | |
string | elementName (size_t m) const |
Name of the element with index m. | |
size_t | elementIndex (const string &name) const |
Return the index of element named 'name'. | |
const vector< string > & | elementNames () const |
Return a read-only reference to the vector of element names. | |
double | atomicWeight (size_t m) const |
Atomic weight of element m. | |
double | entropyElement298 (size_t m) const |
Entropy of the element in its standard state at 298 K and 1 bar. | |
int | atomicNumber (size_t m) const |
Atomic number of element m. | |
int | elementType (size_t m) const |
Return the element constraint type Possible types include: | |
int | changeElementType (int m, int elem_type) |
Change the element type of the mth constraint Reassigns an element type. | |
const vector< double > & | atomicWeights () const |
Return a read-only reference to the vector of atomic weights. | |
size_t | nElements () const |
Number of elements. | |
void | checkElementIndex (size_t m) const |
Check that the specified element index is in range. | |
void | checkElementArraySize (size_t mm) const |
Check that an array size is at least nElements(). | |
double | nAtoms (size_t k, size_t m) const |
Number of atoms of element m in species k . | |
size_t | speciesIndex (const string &name) const |
Returns the index of a species named 'name' within the Phase object. | |
string | speciesName (size_t k) const |
Name of the species with index k. | |
const vector< string > & | speciesNames () const |
Return a const reference to the vector of species names. | |
size_t | nSpecies () const |
Returns the number of species in the phase. | |
void | checkSpeciesIndex (size_t k) const |
Check that the specified species index is in range. | |
void | checkSpeciesArraySize (size_t kk) const |
Check that an array size is at least nSpecies(). | |
void | setMoleFractionsByName (const Composition &xMap) |
Set the species mole fractions by name. | |
void | setMoleFractionsByName (const string &x) |
Set the mole fractions of a group of species by name. | |
void | setMassFractionsByName (const Composition &yMap) |
Set the species mass fractions by name. | |
void | setMassFractionsByName (const string &x) |
Set the species mass fractions by name. | |
void | setState_TD (double t, double rho) |
Set the internally stored temperature (K) and density (kg/m^3) | |
Composition | getMoleFractionsByName (double threshold=0.0) const |
Get the mole fractions by name. | |
double | moleFraction (size_t k) const |
Return the mole fraction of a single species. | |
double | moleFraction (const string &name) const |
Return the mole fraction of a single species. | |
Composition | getMassFractionsByName (double threshold=0.0) const |
Get the mass fractions by name. | |
double | massFraction (size_t k) const |
Return the mass fraction of a single species. | |
double | massFraction (const string &name) const |
Return the mass fraction of a single species. | |
void | getMoleFractions (double *const x) const |
Get the species mole fraction vector. | |
virtual void | setMoleFractions (const double *const x) |
Set the mole fractions to the specified values. | |
virtual void | setMoleFractions_NoNorm (const double *const x) |
Set the mole fractions to the specified values without normalizing. | |
void | getMassFractions (double *const y) const |
Get the species mass fractions. | |
const double * | massFractions () const |
Return a const pointer to the mass fraction array. | |
virtual void | setMassFractions (const double *const y) |
Set the mass fractions to the specified values and normalize them. | |
virtual void | setMassFractions_NoNorm (const double *const y) |
Set the mass fractions to the specified values without normalizing. | |
virtual void | getConcentrations (double *const c) const |
Get the species concentrations (kmol/m^3). | |
virtual double | concentration (const size_t k) const |
Concentration of species k. | |
virtual void | setConcentrations (const double *const conc) |
Set the concentrations to the specified values within the phase. | |
virtual void | setConcentrationsNoNorm (const double *const conc) |
Set the concentrations without ignoring negative concentrations. | |
double | temperature () const |
Temperature (K). | |
virtual double | electronTemperature () const |
Electron Temperature (K) | |
virtual double | density () const |
Density (kg/m^3). | |
virtual double | molarDensity () const |
Molar density (kmol/m^3). | |
virtual double | molarVolume () const |
Molar volume (m^3/kmol). | |
virtual void | setDensity (const double density_) |
Set the internally stored density (kg/m^3) of the phase. | |
virtual void | setTemperature (double temp) |
Set the internally stored temperature of the phase (K). | |
virtual void | setElectronTemperature (double etemp) |
Set the internally stored electron temperature of the phase (K). | |
double | mean_X (const double *const Q) const |
Evaluate the mole-fraction-weighted mean of an array Q. | |
double | mean_X (const vector< double > &Q) const |
Evaluate the mole-fraction-weighted mean of an array Q. | |
double | meanMolecularWeight () const |
The mean molecular weight. Units: (kg/kmol) | |
double | sum_xlogx () const |
Evaluate \( \sum_k X_k \ln X_k \). | |
size_t | addElement (const string &symbol, double weight=-12345.0, int atomicNumber=0, double entropy298=ENTROPY298_UNKNOWN, int elem_type=CT_ELEM_TYPE_ABSPOS) |
Add an element. | |
void | addSpeciesAlias (const string &name, const string &alias) |
Add a species alias (that is, a user-defined alternative species name). | |
void | addSpeciesLock () |
Lock species list to prevent addition of new species. | |
void | removeSpeciesLock () |
Decrement species lock counter. | |
virtual vector< string > | findIsomers (const Composition &compMap) const |
Return a vector with isomers names matching a given composition map. | |
virtual vector< string > | findIsomers (const string &comp) const |
Return a vector with isomers names matching a given composition string. | |
shared_ptr< Species > | species (const string &name) const |
Return the Species object for the named species. | |
shared_ptr< Species > | species (size_t k) const |
Return the Species object for species whose index is k. | |
void | ignoreUndefinedElements () |
Set behavior when adding a species containing undefined elements to just skip the species. | |
void | addUndefinedElements () |
Set behavior when adding a species containing undefined elements to add those elements to the phase. | |
void | throwUndefinedElements () |
Set the behavior when adding a species containing undefined elements to throw an exception. | |
Protected Member Functions | |
void | compositionChanged () override |
If the compositions have changed, update the tabulated thermo lookup. | |
double | interpolate (const double x, const vector< double > &inputData) const |
Species thermodynamics linear interpolation function. | |
void | diff (const vector< double > &inputData, vector< double > &derivedData) const |
Numerical derivative of the molar volume table. | |
Protected Member Functions inherited from IdealSolidSolnPhase | |
void | compositionChanged () override |
Apply changes to the state which are needed after the composition changes. | |
virtual void | getParameters (AnyMap &phaseNode) const |
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using the newThermo(AnyMap&) function. | |
Protected Member Functions inherited from Phase | |
void | assertCompressible (const string &setter) const |
Ensure that phase is compressible. | |
void | assignDensity (const double density_) |
Set the internally stored constant density (kg/m^3) of the phase. | |
void | setMolecularWeight (const int k, const double mw) |
Set the molecular weight of a single species to a given value. | |
virtual void | compositionChanged () |
Apply changes to the state which are needed after the composition changes. | |
Protected Attributes | |
size_t | m_kk_tab = npos |
Current tabulated species index. | |
double | m_h0_tab |
Tabulated contribution to h0[m_kk_tab] at the current composition. | |
double | m_s0_tab |
Tabulated contribution to s0[m_kk_tab] at the current composition. | |
vector< double > | m_molefrac_tab |
Vector for storing tabulated thermo. | |
vector< double > | m_enthalpy_tab |
vector< double > | m_entropy_tab |
vector< double > | m_molar_volume_tab |
vector< double > | m_derived_molar_volume_tab |
Protected Attributes inherited from IdealSolidSolnPhase | |
int | m_formGC = 0 |
The standard concentrations can have one of three different forms: 0 = 'unity', 1 = 'species-molar-volume', 2 = 'solvent-molar-volume'. | |
double | m_Pref = OneAtm |
Value of the reference pressure for all species in this phase. | |
double | m_Pcurrent = OneAtm |
m_Pcurrent = The current pressure Since the density isn't a function of pressure, but only of the mole fractions, we need to independently specify the pressure. | |
vector< double > | m_speciesMolarVolume |
Vector of molar volumes for each species in the solution. | |
vector< double > | m_h0_RT |
Vector containing the species reference enthalpies at T = m_tlast. | |
vector< double > | m_cp0_R |
Vector containing the species reference constant pressure heat capacities at T = m_tlast. | |
vector< double > | m_g0_RT |
Vector containing the species reference Gibbs functions at T = m_tlast. | |
vector< double > | m_s0_R |
Vector containing the species reference entropies at T = m_tlast. | |
vector< double > | m_expg0_RT |
Vector containing the species reference exp(-G/RT) functions at T = m_tlast. | |
vector< double > | m_pp |
Temporary array used in equilibrium calculations. | |
Protected Attributes inherited from ThermoPhase | |
MultiSpeciesThermo | m_spthermo |
Pointer to the calculation manager for species reference-state thermodynamic properties. | |
AnyMap | m_input |
Data supplied via setParameters. | |
double | m_phi = 0.0 |
Stored value of the electric potential for this phase. Units are Volts. | |
bool | m_chargeNeutralityNecessary = false |
Boolean indicating whether a charge neutrality condition is a necessity. | |
int | m_ssConvention = cSS_CONVENTION_TEMPERATURE |
Contains the standard state convention. | |
double | m_tlast = 0.0 |
last value of the temperature processed by reference state | |
Protected Attributes inherited from Phase | |
ValueCache | m_cache |
Cached for saved calculations within each ThermoPhase. | |
size_t | m_kk = 0 |
Number of species in the phase. | |
size_t | m_ndim = 3 |
Dimensionality of the phase. | |
vector< double > | m_speciesComp |
Atomic composition of the species. | |
vector< double > | m_speciesCharge |
Vector of species charges. length m_kk. | |
map< string, shared_ptr< Species > > | m_species |
Map of Species objects. | |
size_t | m_nSpeciesLocks = 0 |
Reference counter preventing species addition. | |
UndefElement::behavior | m_undefinedElementBehavior = UndefElement::add |
Flag determining behavior when adding species with an undefined element. | |
bool | m_caseSensitiveSpecies = false |
Flag determining whether case sensitive species names are enforced. | |
Private Member Functions | |
void | _updateThermo () const override |
This function gets called for every call to functions in this class. | |
|
explicit |
Construct and initialize an BinarySolutionTabulatedThermo ThermoPhase object directly from an input file.
This constructor will also fully initialize the object.
infile | File name for the input file containing information for this phase. If not specified, an empty phase will be created. |
id | The name of this phase. This is used to look up the phase in the input file. |
Definition at line 22 of file BinarySolutionTabulatedThermo.cpp.
|
inlineoverridevirtual |
String indicating the thermodynamic model implemented.
Usually corresponds to the name of the derived class, less any suffixes such as "Phase", TP", "VPSS", etc.
Reimplemented from Phase.
Definition at line 176 of file BinarySolutionTabulatedThermo.h.
|
overridevirtual |
Returns true
if the species was successfully added, or false
if the species was ignored.
Derived classes which need to size arrays according to the number of species should overload this method. The derived class implementation should call the base class method, and, if this returns true
(indicating that the species has been added), adjust their array sizes accordingly.
Reimplemented from Phase.
Definition at line 70 of file BinarySolutionTabulatedThermo.cpp.
|
overridevirtual |
Initialize the ThermoPhase object after all species have been set up.
This method is provided to allow subclasses to perform any initialization required after all species have been added. For example, it might be used to resize internal work arrays that must have an entry for each species. The base class implementation does nothing, and subclasses that do not require initialization do not need to overload this method. Derived classes which do override this function should call their parent class's implementation of this function as their last action.
When importing from an AnyMap phase description (or from a YAML file), setupPhase() adds all the species, stores the input data in m_input, and then calls this method to set model parameters from the data stored in m_input.
Reimplemented from ThermoPhase.
Definition at line 80 of file BinarySolutionTabulatedThermo.cpp.
|
overridevirtual |
Returns a bool indicating whether the object is ready for use.
Reimplemented from Phase.
Definition at line 142 of file BinarySolutionTabulatedThermo.cpp.
|
overridevirtual |
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using the newThermo(AnyMap&) function.
This does not include user-defined fields available in input().
Reimplemented from ThermoPhase.
Definition at line 147 of file BinarySolutionTabulatedThermo.cpp.
|
overridevirtual |
returns an array of partial molar volumes of the species in the solution.
Units: m^3 kmol-1.
The partial molar volumes are derived as shown in the equations in the detailed description section.
vbar | Output vector of partial molar volumes. Length: m_kk. |
Reimplemented from ThermoPhase.
Definition at line 199 of file BinarySolutionTabulatedThermo.cpp.
|
overridevirtual |
Overloads the calcDensity() method of IdealSolidSoln to also consider non-ideal behavior.
The formula for this is
\[ \rho = \frac{\sum_k{X_k W_k}}{V_\mathrm{m}} \]
where \( X_k \) are the mole fractions, \( W_k \) are the molecular weights, and \( V_\mathrm{m} \) is the molar volume interpolated from \( V_{\mathrm{m,tab}} \).
Reimplemented from IdealSolidSolnPhase.
Definition at line 204 of file BinarySolutionTabulatedThermo.cpp.
|
overrideprotectedvirtual |
If the compositions have changed, update the tabulated thermo lookup.
Reimplemented from Phase.
Definition at line 28 of file BinarySolutionTabulatedThermo.cpp.
|
protected |
Species thermodynamics linear interpolation function.
Tabulated values are only interpolated within the limits of the provided mole fraction. If these limits are exceeded, the values are capped at the lower or the upper limit.
x | Current mole fraction at which to interpolate. |
inputData | Input vector of the data to be interpolated. |
Definition at line 159 of file BinarySolutionTabulatedThermo.cpp.
|
protected |
Numerical derivative of the molar volume table.
Tabulated values are only interpolated within the limits of the provided mole fraction. If these limits are exceeded, the values are capped at the lower or the upper limit.
inputData | Input vector of tabulated data to be derived. |
derivedData | Output vector of tabulated data that is numerically derived with respect to the mole fraction. |
Definition at line 179 of file BinarySolutionTabulatedThermo.cpp.
|
overrideprivatevirtual |
This function gets called for every call to functions in this class.
It checks to see whether the temperature has changed and thus the reference thermodynamics functions for all of the species must be recalculated. If the temperature has changed, the species thermo manager is called to recalculate G, Cp, H, and S at the current temperature.
Reimplemented from IdealSolidSolnPhase.
Definition at line 34 of file BinarySolutionTabulatedThermo.cpp.
|
protected |
Current tabulated species index.
Definition at line 241 of file BinarySolutionTabulatedThermo.h.
|
mutableprotected |
Tabulated contribution to h0[m_kk_tab] at the current composition.
Definition at line 244 of file BinarySolutionTabulatedThermo.h.
|
mutableprotected |
Tabulated contribution to s0[m_kk_tab] at the current composition.
Definition at line 247 of file BinarySolutionTabulatedThermo.h.
|
protected |
Vector for storing tabulated thermo.
Definition at line 250 of file BinarySolutionTabulatedThermo.h.
|
protected |
Definition at line 251 of file BinarySolutionTabulatedThermo.h.
|
protected |
Definition at line 252 of file BinarySolutionTabulatedThermo.h.
|
protected |
Definition at line 253 of file BinarySolutionTabulatedThermo.h.
|
protected |
Definition at line 254 of file BinarySolutionTabulatedThermo.h.