31 for (
size_t k = 0; k <
m_kk; k++) {
46 for (
size_t k = 0; k <
m_kk; k++) {
56 vector<double> hbar(kk);
58 for (
size_t i = 0; i < kk; i++) {
68 vector<double> sbar(kk);
70 for (
size_t i = 0; i < kk; i++) {
80 vector<double> cpbar(kk);
82 for (
size_t i = 0; i < kk; i++) {
99 for (
size_t k = 0; k <
m_kk; k++) {
107 for (
size_t k = 0; k <
m_kk; k++) {
123 for (
size_t k = 0; k <
m_kk; k++) {
127 for (
size_t k = 0; k <
m_kk; k++) {
143 for (
size_t k = 0; k <
m_kk; k++) {
149 for (
size_t k = 0; k <
m_kk; k++) {
168 const double temp1 = g0 + g1 * XB;
169 const double all = -1.0*XA*XB*temp1 - XA*XB*XB*g1;
171 for (
size_t iK = 0; iK <
m_kk; iK++) {
174 vbar[iA] += XB * temp1;
175 vbar[iB] += XA * temp1 + XA*XB*g1;
183 for (
auto& item :
m_input[
"interactions"].asVector<AnyMap>()) {
184 auto&
species = item[
"species"].asVector<
string>(2);
185 vector<double> h(2), s(2), vh(2), vs(2);
186 if (item.hasKey(
"excess-enthalpy")) {
187 h = item.convertVector(
"excess-enthalpy",
"J/kmol", 2);
189 if (item.hasKey(
"excess-entropy")) {
190 s = item.convertVector(
"excess-entropy",
"J/kmol/K", 2);
192 if (item.hasKey(
"excess-volume-enthalpy")) {
193 vh = item.convertVector(
"excess-volume-enthalpy",
"m^3/kmol", 2);
195 if (item.hasKey(
"excess-volume-entropy")) {
196 vs = item.convertVector(
"excess-volume-entropy",
"m^3/kmol/K", 2);
199 h[0], h[1], s[0], s[1], vh[0], vh[1], vs[0], vs[1]);
208 vector<AnyMap> interactions;
211 interaction[
"species"] = vector<string>{
214 interaction[
"excess-enthalpy"].setQuantity(
218 interaction[
"excess-entropy"].setQuantity(
222 interaction[
"excess-volume-enthalpy"].setQuantity(
226 interaction[
"excess-volume-entropy"].setQuantity(
229 interactions.push_back(std::move(interaction));
231 phaseNode[
"interactions"] = std::move(interactions);
240 const string& speciesB,
double h0,
double h1,
double s0,
double s1,
241 double vh0,
double vh1,
double vs0,
double vs1)
276 const double XAXB = XA * XB;
277 const double g0g1XB = (g0 + g1 * XB);
278 const double all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
279 for (
size_t iK = 0; iK <
m_kk; iK++) {
300 const double XAXB = XA * XB;
301 const double g0g1XB = (g0 + g1 * XB);
302 const double all = -1.0 * XAXB * g0g1XB - XAXB * XB * g1;
303 const double mult = 2.0 * invT;
304 const double dT2all = mult * all;
305 for (
size_t iK = 0; iK <
m_kk; iK++) {
319 for (
size_t k = 0; k <
m_kk; k++) {
327 for (
size_t k = 0; k <
m_kk; k++) {
333 double* dlnActCoeffds)
const
337 for (
size_t iK = 0; iK <
m_kk; iK++) {
338 dlnActCoeffds[iK] = 0.0;
346 double dXA = dXds[iA];
347 double dXB = dXds[iB];
350 const double g02g1XB = g0 + 2*g1*XB;
351 const double g2XAdXB = 2*g1*XA*dXB;
352 const double all = (-XB * dXA - XA *dXB) * g02g1XB - XB *g2XAdXB;
353 for (
size_t iK = 0; iK <
m_kk; iK++) {
356 dlnActCoeffds[iA] += dXB * g02g1XB;
357 dlnActCoeffds[iB] += dXA * g02g1XB + g2XAdXB;
366 for (
size_t iK = 0; iK <
m_kk; iK++) {
399 for (
size_t iK = 0; iK <
m_kk; iK++) {
400 for (
size_t iM = 0; iM <
m_kk; iM++) {
424 dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
425 dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
455 for (
size_t k = 0; k <
m_kk; k++) {
463 for (
size_t k = 0; k <
m_kk; k++) {
472 for (
size_t k = 0; k <
m_kk; k++) {
473 for (
size_t m = 0; m <
m_kk; m++) {
474 dlnActCoeffdlnN[ld * k + m] = data[
m_kk * k + m];
(see Thermodynamic Properties and class MargulesVPSSTP).
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 string &key) const
Returns true if the map contains an item named key.
void zero()
Set all of the entries to zero.
virtual void resize(size_t n, size_t m, double v=0.0)
Resize the array, and fill the new entries with 'v'.
vector< double > d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
vector< double > lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
vector< double > dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
vector< double > moleFractions_
Storage for the current values of the mole fractions of the species.
vector< double > dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
vector< double > dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
void getdlnActCoeffds(const double dTds, const double *const dXds, double *dlnActCoeffds) const override
Get the change in activity coefficients wrt changes in state (temp, mole fraction,...
double enthalpy_mole() const override
Molar enthalpy. Units: J/kmol.
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
vector< double > m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
vector< double > m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
size_t numBinaryInteractions_
number of binary interaction expressions
vector< double > m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only.
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
Return an array of partial molar volumes for the species in the mixture.
vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
double cv_mole() const override
Molar heat capacity at constant volume. Units: J/kmol/K.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector< double > m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
double entropy_mole() const override
Molar entropy. Units: J/kmol/K.
vector< double > m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
void getdlnActCoeffdT(double *dlnActCoeffdT) const override
Get the array of temperature derivatives of the log activity coefficients.
vector< double > m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
double cp_mole() const override
Molar heat capacity at constant pressure. Units: J/kmol/K.
void getPartialMolarCp(double *cpbar) const override
Returns an array of partial molar entropies for the species in the mixture.
void initLengths()
Initialize lengths of local variables after all species have been identified.
void getLnActivityCoefficients(double *lnac) const override
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction)
void s_update_lnActCoeff() const
Update the activity coefficients.
void getdlnActCoeffdlnX_diag(double *dlnActCoeffdlnX_diag) const override
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
vector< double > m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
void addBinaryInteraction(const string &speciesA, const string &speciesB, double h0, double h1, double s0, double s1, double vh0, double vh1, double vs0, double vs1)
Add a binary species interaction with the specified parameters.
MargulesVPSSTP(const string &inputFile="", const string &id="")
Construct a MargulesVPSSTP object from an input file.
vector< double > m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
void getdlnActCoeffdlnN_diag(double *dlnActCoeffdlnN_diag) const override
Get the array of log species mole number derivatives of the log activity coefficients.
void getd2lnActCoeffdT2(double *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients.
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies for the species in the mixture.
void getdlnActCoeffdlnN(const size_t ld, double *const dlnActCoeffdlnN) override
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
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).
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.
shared_ptr< Species > species(const string &name) const
Return the Species object for the named 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.
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void getStandardChemPotentials(double *mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void getCp_R(double *cpr) const override
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
void getEnthalpy_RT(double *hrt) const override
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
void getStandardVolumes(double *vol) const override
Get the molar volumes of the species standard states at the current T and P of the solution.
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 SmallNumber
smallest number to compare to zero.
Contains declarations for string manipulation functions within Cantera.