29 const std::string& id_)
38 const std::string& id_)
54 bool x_changed = (
m_xlast != xnow);
60 }
else if (xnow == 1) {
71 if (x_changed ||
m_tlast != tnow) {
74 double rrt = 1.0 /
RT();
77 for (
size_t k = 0; k <
m_kk; k++) {
78 double deltaE = rrt *
m_pe[k];
93 "Species '{}' is not in phase '{}'",
97 vector_fp x = table[
"mole-fractions"].asVector<
double>();
103 std::vector<std::pair<double,double>> x_h(N), x_s(N);
104 for(
size_t i = 0; i < N; i++){
105 x_h[i] = {x[i], h[i]};
106 x_s[i] = {x[i], s[i]};
108 std::sort(x_h.begin(), x_h.end());
109 std::sort(x_s.begin(), x_s.end());
113 m_enthalpy_tab.resize(N);
114 m_entropy_tab.resize(N);
115 for (
size_t i = 0; i < N; i++) {
117 m_enthalpy_tab[i] = x_h[i].second;
118 m_entropy_tab[i] = x_s[i].second;
127 std::vector<std::pair<double,double>> x_h_temp, x_s_temp;
129 if (id_.size() > 0) {
130 if (phaseNode.
id() != id_) {
131 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
132 "phasenode and Id are incompatible");
136 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
137 "No. of species should be equal to 2!");
141 std::string mString = thermoNode[
"model"];
143 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
144 "Unknown thermo model: " + mString);
146 if (thermoNode.
hasChild(
"tabulatedSpecies")) {
147 XML_Node& speciesNode = thermoNode.
child(
"tabulatedSpecies");
148 std::string tabulated_species_name = speciesNode[
"name"];
151 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
152 "Species " + tabulated_species_name +
" not found.");
155 if (thermoNode.
hasChild(
"tabulatedThermo")) {
162 if ((x.size() != h.size()) || (x.size() != s.size()) || (h.size() != s.size())) {
163 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
164 "Species tabulated thermo data has different lengths.");
167 for(
size_t i = 0; i < x.size(); i++){
168 x_h_temp.push_back(std::make_pair(x[i],h[i]));
169 x_s_temp.push_back(std::make_pair(x[i],s[i]));
171 std::sort(x_h_temp.begin(), x_h_temp.end());
172 std::sort(x_s_temp.begin(), x_s_temp.end());
176 m_enthalpy_tab.resize(x_h_temp.size());
177 m_entropy_tab.resize(x_h_temp.size());
178 for (
size_t i = 0; i < x_h_temp.size(); i++) {
180 m_enthalpy_tab[i] = x_h_temp[i].second;
181 m_entropy_tab[i] = x_s_temp[i].second;
184 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
185 "Unspecified tabulated species or thermo");
188 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
189 "Unspecified thermo model");
199 if (phaseNode.
hasChild(
"standardConc")) {
203 throw CanteraError(
"BinarySolutionTabulatedThermo::initThermoXML",
204 "Unspecified standardConc model");
213 std::pair<double, double> c;
216 c.first = m_enthalpy_tab.back();
217 c.second = m_entropy_tab.back();
221 c.first = m_enthalpy_tab[0];
222 c.second = m_entropy_tab[0];
227 c.first = m_enthalpy_tab[i-1] + (m_enthalpy_tab[i] - m_enthalpy_tab[i-1])
229 c.second = m_entropy_tab[i-1] + (m_entropy_tab[i] - m_entropy_tab[i-1])
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...
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.
vector_fp convertVector(const std::string &key, const std::string &units, size_t nMin=npos, size_t nMax=npos) const
Convert a vector of dimensional values.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
double m_xlast
Current tabulated species mole fraction.
BinarySolutionTabulatedThermo()
Default constructor for BinarySolutionTabulatedThermo.
double m_s0_tab
Tabulated contribution to s0[m_kk_tab] at the current composition.
vector_fp m_molefrac_tab
Vector for storing tabulated thermo.
size_t m_kk_tab
Current tabulated species index.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
std::pair< double, double > interpolate(double x) const
Species thermodynamics interpolation functions.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id_)
Import and initialize a ThermoPhase object using an XML tree.
double m_h0_tab
Tabulated contribution to h0[m_kk_tab] at the current composition.
virtual void compositionChanged()
If the compositions have changed, update the tabulated thermo lookup.
virtual void _updateThermo() const
This function gets called for every call to functions in this class.
Base class for exceptions thrown by Cantera classes.
vector_fp m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast.
vector_fp m_cp0_R
Vector containing the species reference constant pressure heat capacities at T = m_tlast.
vector_fp m_h0_RT
Vector containing the species reference enthalpies at T = m_tlast.
vector_fp m_s0_R
Vector containing the species reference entropies at T = m_tlast.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
virtual doublereal standardConcentration(size_t k) const
The standard concentration used to normalize the generalized concentration.
vector_fp m_pe
Vector of potential energies for the species.
virtual void compositionChanged()
Apply changes to the state which are needed after the composition changes.
void setStandardConcentrationModel(const std::string &model)
Set the form for the standard and generalized concentrations.
virtual void update(doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state properties for all species.
std::string name() const
Return the name of the phase.
size_t nSpecies() const
Returns the number of species in the phase.
size_t m_kk
Number of species in the phase.
double moleFraction(size_t k) const
Return the mole fraction of a single species.
doublereal temperature() const
Temperature (K).
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
doublereal m_tlast
last value of the temperature processed by reference state
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.
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
AnyMap m_input
Data supplied via setParameters.
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 size_t npos
index returned by functions to indicate "no position"
const double Faraday
Faraday constant [C/kmol].
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
const double BigNumber
largest number to compare to inf.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
Namespace for the Cantera kernel.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name,...
Contains declarations for string manipulation functions within Cantera.