Skip to content

Commit

Permalink
Merge pull request #1 from skasiraj/zeroP
Browse files Browse the repository at this point in the history
New getDeltaRefGibbs and getDeltaRefEntropy methods added to Kinetics.h and InterfaceKinetics.h and .cpp
  • Loading branch information
mbkumar committed Oct 18, 2021
2 parents a1d295a + 93febeb commit 1b164e8
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/cantera/kinetics/GasKinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class GasKinetics : public BulkKinetics
virtual void getEquilibriumConstants(doublereal* kc);
virtual void getFwdRateConstants(doublereal* kfwd);

// Utility methods to get reaction Deltas
virtual void getDeltaRefGibbs(doublereal* deltaG);
virtual void getDeltaRefEntropy(doublereal* deltaS);

//! @}
//! @name Reaction Mechanism Setup Routines
//! @{
Expand Down
3 changes: 3 additions & 0 deletions include/cantera/kinetics/InterfaceKinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class InterfaceKinetics : public Kinetics
virtual void getDeltaSSEnthalpy(doublereal* deltaH);
virtual void getDeltaSSEntropy(doublereal* deltaS);

virtual void getDeltaRefGibbs(doublereal* deltaG);
virtual void getDeltaRefEntropy(doublereal* deltaS);

//! @}
//! @name Reaction Mechanism Informational Query Routines
//! @{
Expand Down
42 changes: 42 additions & 0 deletions include/cantera/kinetics/Kinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,48 @@ class Kinetics
throw NotImplementedError("Kinetics::getDeltaSSEntropy");
}

/**
* Return the vector of values for the change in the standard state
* entropies for each reaction at reference pressure of 1 bar. These values
* don't depend upon the concentration of the solution.
*
* units = J kmol-1 Kelvin-1
*
* @param deltaS Output vector of ss deltaS's for reactions Length:
* nReactions().
*/
virtual void getDeltaRefEntropy(doublereal* deltaS) {
throw NotImplementedError("Kinetics::getDeltaRefEntropy");
}

/**
* Return the vector of values for the reaction standard state Gibbs free
* energy change at reference pressure of 1 bar. These values don't
* depend upon the concentration of the solution.
*
* units = J kmol-1
*
* @param deltaG Output vector of ss deltaG's for reactions Length:
* nReactions().
*/
virtual void getDeltaRefGibbs(doublereal* deltaG) {
throw NotImplementedError("Kinetics::getDeltaRefGibbs");
}

/**
* Return the vector of values for the change in the standard state
* enthalpies of each reaction at reference pressure of 1 bar. These values don't
* depend upon the concentration of the solution.
*
* units = J kmol-1
*
* @param deltaH Output vector of ss deltaH's for reactions Length:
* nReactions().
*/
virtual void getDeltaRefEnthalpy(doublereal* deltaH) {
throw NotImplementedError("Kinetics::getDeltaRefEnthalpy");
}

//! @}
//! @name Species Production Rates
//! @{
Expand Down
35 changes: 35 additions & 0 deletions src/kinetics/GasKinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,41 @@ void GasKinetics::getFwdRateConstants(doublereal* kfwd)
}
}

void GasKinetics::getDeltaRefGibbs(doublereal* deltaGSS)
{
// Get the reference state chemical potentials of the species. This is the
// array of chemical potentials at unit activity We define these here as the
// chemical potentials of the pure species at the temperature and reference
// pressure of 1 bar of the solution.
for (size_t n = 0; n < nPhases(); n++) {
thermo(n).getGibbs_RT_ref(m_grt.data() + m_start[n]);
}

for (size_t k = 0; k < m_kk; k++) {
m_grt[k] *= thermo(reactionPhaseIndex()).RT();
}

// Use the stoichiometric manager to find deltaG for each reaction.
//getReactionDelta(m_mu0.data(), deltaGSS);
getReactionDelta(m_grt.data(), deltaGSS);
}

void GasKinetics::getDeltaRefEntropy(doublereal* deltaS)
{
// Get the reference state entropy of the species. We define these here as
// the entropies of the pure species at the temperature and at reference
// pressure of 1 bar of the solution.
for (size_t n = 0; n < nPhases(); n++) {
thermo(n).getEntropy_R_ref(m_grt.data() + m_start[n]);
}
for (size_t k = 0; k < m_kk; k++) {
m_grt[k] *= GasConstant;
}

// Use the stoichiometric manager to find deltaS for each reaction.
getReactionDelta(m_grt.data(), deltaS);
}

bool GasKinetics::addReaction(shared_ptr<Reaction> r)
{
// operations common to all reaction types
Expand Down
35 changes: 35 additions & 0 deletions src/kinetics/InterfaceKinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,25 @@ void InterfaceKinetics::getDeltaSSGibbs(doublereal* deltaGSS)
getReactionDelta(m_mu0.data(), deltaGSS);
}

void InterfaceKinetics::getDeltaRefGibbs(doublereal * deltaGSS)
{
// Get the reference state chemical potentials of the species. This is the
// array of chemical potentials at unit activity We define these here as the
// chemical potentials of the pure species at the temperature and reference
// pressure of 1 bar of the solution.
for (size_t n = 0; n < nPhases(); n++) {
thermo(n).getGibbs_RT_ref(m_grt.data() + m_start[n]);
}

for (size_t k = 0; k < m_kk; k++) {
m_grt[k] *= thermo(reactionPhaseIndex()).RT();
}

// Use the stoichiometric manager to find deltaG for each reaction.
//getReactionDelta(m_mu0.data(), deltaGSS);
getReactionDelta(m_grt.data(), deltaGSS);
}

void InterfaceKinetics::getDeltaSSEnthalpy(doublereal* deltaH)
{
// Get the standard state enthalpies of the species. This is the array of
Expand Down Expand Up @@ -538,6 +557,22 @@ void InterfaceKinetics::getDeltaSSEntropy(doublereal* deltaS)
getReactionDelta(m_grt.data(), deltaS);
}

void InterfaceKinetics::getDeltaRefEntropy(doublereal* deltaS)
{
// Get the reference state entropy of the species. We define these here as
// the entropies of the pure species at the temperature and at reference
// pressure of 1 bar of the solution.
for (size_t n = 0; n < nPhases(); n++) {
thermo(n).getEntropy_R_ref(m_grt.data() + m_start[n]);
}
for (size_t k = 0; k < m_kk; k++) {
m_grt[k] *= GasConstant;
}

// Use the stoichiometric manager to find deltaS for each reaction.
getReactionDelta(m_grt.data(), deltaS);
}

bool InterfaceKinetics::addReaction(shared_ptr<Reaction> r_base)
{
if (!m_surf) {
Expand Down

0 comments on commit 1b164e8

Please sign in to comment.