47        } 
else if (x_other == 0) {
 
   57    if (x_changed || 
m_tlast != tnow) {
 
   60        double rrt = 1.0 / 
RT();
 
   63        for (
size_t k = 0; k < 
m_kk; k++) {
 
   73        throw CanteraError(
"BinarySolutionTabulatedThermo::addSpecies",
 
   74                           "No. of species should be equal to 2");
 
   87                "No. of species should be equal to 2 in phase '{}'!",
name());
 
   92                "Species '{}' is not in phase '{}'",
 
   96        vector<double> x = table[
"mole-fractions"].asVector<
double>();
 
   98        vector<double> h = table.
convertVector(
"enthalpy", 
"J/kmol", N);
 
   99        vector<double> s = table.
convertVector(
"entropy", 
"J/kmol/K", N);
 
  100        vector<double> vmol(N);
 
  103        if (table.
hasKey(
"molar-volume")) {
 
  106            for(
size_t i = 0; i < N; i++) {
 
  113        vector<pair<double,double>> x_h(N), x_s(N), x_vmol(N);
 
  114        for(
size_t i = 0; i < N; i++) {
 
  115            x_h[i] = {x[i], h[i]};
 
  116            x_s[i] = {x[i], s[i]};
 
  117            x_vmol[i] = {x[i], vmol[i]};
 
  119        std::sort(x_h.begin(), x_h.end());
 
  120        std::sort(x_s.begin(), x_s.end());
 
  121        std::sort(x_vmol.begin(), x_vmol.end());
 
  125        m_enthalpy_tab.resize(N);
 
  126        m_entropy_tab.resize(N);
 
  127        m_molar_volume_tab.resize(N);
 
  128        m_derived_molar_volume_tab.resize(N);
 
  130        for (
size_t i = 0; i < N; i++) {
 
  132            m_enthalpy_tab[i] = x_h[i].second;
 
  133            m_entropy_tab[i] = x_s[i].second;
 
  134            m_molar_volume_tab[i] = x_vmol[i].second;
 
  137        diff(m_molar_volume_tab, m_derived_molar_volume_tab);
 
  153    tabThermo[
"enthalpy"].setQuantity(m_enthalpy_tab, 
"J/kmol");
 
  154    tabThermo[
"entropy"].setQuantity(m_entropy_tab, 
"J/kmol/K");
 
  155    tabThermo[
"molar-volume"].setQuantity(m_molar_volume_tab, 
"m^3/kmol");
 
  156    phaseNode[
"tabulated-thermo"] = std::move(tabThermo);
 
  160                                                  const vector<double>& inputData)
 const 
  165        c = inputData.back();
 
  169        c = inputData.front();
 
  174    c = inputData[i-1] + (inputData[i] - inputData[i-1])
 
  180                                         vector<double>& derivedData)
 const 
  182    if (inputData.size() > 1) {
 
  183        derivedData[0] = (inputData[1] - inputData[0]) /
 
  185        derivedData.back() = (inputData.back() - inputData[inputData.size()-2]) /
 
  188        if (inputData.size() > 2) {
 
  189            for (
size_t i = 1; i < inputData.size()-1; i++) {
 
  190                derivedData[i] = (inputData[i+1] - inputData[i-1]) /
 
  195        derivedData.front() = 0;
 
  208    double dVdX_tab = 
interpolate(Xtab, m_derived_molar_volume_tab);
 
Header file for an binary solution model with tabulated standard state thermodynamic data (see Thermo...
 
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
 
Declarations for the virtual base class PDSS (pressure dependent standard state) which handles calcul...
 
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
 
Declaration for class Cantera::Species.
 
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.
 
vector< double > convertVector(const string &key, const string &units, size_t nMin=npos, size_t nMax=npos) const
Convert a vector of dimensional values.
 
vector< double > m_molefrac_tab
Vector for storing tabulated thermo.
 
double m_s0_tab
Tabulated contribution to s0[m_kk_tab] at the current composition.
 
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.
 
void getPartialMolarVolumes(double *vbar) const override
returns an array of partial molar volumes of the species in the solution.
 
double interpolate(const double x, const vector< double > &inputData) const
Species thermodynamics linear interpolation function.
 
size_t m_kk_tab
Current tabulated species index.
 
void diff(const vector< double > &inputData, vector< double > &derivedData) const
Numerical derivative of the molar volume table.
 
void calcDensity() override
Overloads the calcDensity() method of IdealSolidSoln to also consider non-ideal behavior.
 
BinarySolutionTabulatedThermo(const string &infile="", const string &id="")
Construct and initialize an BinarySolutionTabulatedThermo ThermoPhase object directly from an input f...
 
double m_h0_tab
Tabulated contribution to h0[m_kk_tab] at the current composition.
 
void compositionChanged() override
If the compositions have changed, update the tabulated thermo lookup.
 
bool ready() const override
Returns a bool indicating whether the object is ready for use.
 
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
 
void _updateThermo() const override
This function gets called for every call to functions in this class.
 
Base class for exceptions thrown by Cantera classes.
 
vector< double > m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast.
 
vector< double > m_h0_RT
Vector containing the species reference enthalpies at T = m_tlast.
 
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 standardConcentration(size_t k) const override
The standard concentration  used to normalize the generalized concentration.
 
vector< double > m_s0_R
Vector containing the species reference entropies at T = m_tlast.
 
vector< double > m_speciesMolarVolume
Vector of molar volumes for each species in the solution.
 
void compositionChanged() override
Apply changes to the state which are needed after the composition changes.
 
vector< double > m_cp0_R
Vector containing the species reference constant pressure heat capacities at T = m_tlast.
 
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
 
virtual void update(double T, double *cp_R, double *h_RT, double *s_R) const
Compute the reference-state properties for all species.
 
void assignDensity(const double density_)
Set the internally stored constant density (kg/m^3) of the phase.
 
ValueCache m_cache
Cached for saved calculations within each ThermoPhase.
 
size_t nSpecies() const
Returns the number of species in the phase.
 
size_t m_kk
Number of species in the phase.
 
double temperature() const
Temperature (K).
 
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
 
string speciesName(size_t k) const
Name of the species with index k.
 
size_t speciesIndex(const string &name) const
Returns the index of a species named 'name' within the Phase object.
 
double moleFraction(size_t k) const
Return the mole fraction of a single species.
 
int stateMFNumber() const
Return the State Mole Fraction Number.
 
string name() const
Return the name of the phase.
 
double RT() const
Return the Gas Constant multiplied by the current temperature.
 
double m_tlast
last value of the temperature processed by reference state
 
void initThermoFile(const string &inputFile, const string &id)
Initialize a ThermoPhase object using an input file.
 
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
 
AnyMap m_input
Data supplied via setParameters.
 
CachedScalar getScalar(int id)
Get a reference to a CachedValue object representing a scalar (double) with the given id.
 
int getId()
Get a unique id for a cached value.
 
const double Faraday
Faraday constant  [C/kmol].
 
const double GasConstant
Universal Gas Constant  [J/kmol/K].
 
Namespace for the Cantera kernel.
 
const size_t npos
index returned by functions to indicate "no position"
 
const double BigNumber
largest number to compare to inf.
 
Contains declarations for string manipulation functions within Cantera.
 
A cached property value and the state at which it was evaluated.
 
bool validate(double state1New)
Check whether the currently cached value is valid based on a single state variable.