Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New getDeltaRefGibbs and getDeltaRefEntropy methods added to Kinetics.h and InterfaceKinetics.h and .cpp #1

Merged
merged 10 commits into from
Oct 18, 2021

Conversation

skasiraj
Copy link

@skasiraj skasiraj commented Aug 13, 2021

Checklist

  • There is a clear use-case for this code change
  • The commit message has a short title & references relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • The pull request is ready for review

If applicable, fill in the issue number this pull request is fixing

Fixes VlachosGroup/openmkm#42, VlachosGroup/openmkm#50

Changes proposed in this pull request

Report reaction deltas (of entropy and Gibbs free energy) at Ref Pressure of 1 bar. Changes present in Kinetics.h InterfaceKinetics.h and .cpp
@mbkumar
Copy link
Owner

mbkumar commented Oct 13, 2021

@skasiraj,

Could you please write a detailed summary for the (pull request) PR at the top and why this PR is needed and describe the changes you introduced. Otherwise the PR would be hard to understand the PR.

Copy link
Owner

@mbkumar mbkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Shashank,

Thanks for the additions to the code. For consistency, could you please add the methods introduced in InterfaceKientics to GasKinetics as well. The relevant GasKinetics files are GasKinetics.h and GasKinetics.cpp.

I am asking for few minor edits before I merge the code. Please find them in the review.

virtual void getDeltaRefEntropy(doublereal* deltaS) {
throw NotImplementedError("Kinetics::getDeltaRefEntropy");
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain the functionality of getDeltaRefGibss and getDeltaRefEntropy with comments on top of the methods.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

virtual void getDeltaRefGibbs(doublereal* deltaG) {
throw NotImplementedError("Kinetics::getDeltaRefGibbs");
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency add getDeltaRefEnthalpy as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -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);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency add getDeltaRefEnthalpy as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -499,12 +499,33 @@ void InterfaceKinetics::getDeltaSSGibbs(doublereal* deltaGSS)
// of the solution.
for (size_t n = 0; n < nPhases(); n++) {
thermo(n).getStandardChemPotentials(m_mu0.data() + m_start[n]);
//thermo(n).getGibbs_RT_ref(m_grt.data() + m_start[n]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the commented line added to this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the newly added commented line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

getReactionDelta(m_mu0.data(), deltaGSS);
}

void InterfaceKinetics::getDeltaRefGibbs(doublereal * deltaGSS)
{
// Get the standard state chemical potentials of the species. This is the
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change standard state to reference state in the comment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// Get the standard 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 the solution.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State the numerical value of the reference pressure as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -538,6 +559,22 @@ void InterfaceKinetics::getDeltaSSEntropy(doublereal* deltaS)
getReactionDelta(m_grt.data(), deltaS);
}

void InterfaceKinetics::getDeltaRefEntropy(doublereal* deltaS)
{
// Get the standard state entropy of the species. We define these here as
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

As per PR mbkumar#1 review, adding the getDeltaRefEnthalpy method definition in the InterfaceKinetics.h file for consistency sake.
Update Kinetics.h based on PR#1. Added comments to the methods getDeltaRefEntropy and getDeltaRefGibbs. Added a new method for getDeltaRefEnthalpy for consistency sake
Deleted commented code. And fix comments to "Reference" state as opposed to "standard" state. Also mentioned reference P of 1 bar.
Formatting change.
@skasiraj
Copy link
Author

Hello Shashank,

Thanks for the additions to the code. For consistency, could you please add the methods introduced in InterfaceKientics to GasKinetics as well. The relevant GasKinetics files are GasKinetics.h and GasKinetics.cpp.

I am asking for few minor edits before I merge the code. Please find them in the review.

I did not update GasKinetics.cpp or GasKinetics.h methods with the new "ref' state methods because, they don't have any of the Delta methods defined (be it at actual state, standard state or reference state). All of the Delta Methods are only re-implemented in the InterfaceKinetics. GasKinetics will use the Base Class BulkKinetics class methods

class GasKinetics : public BulkKinetics

Do I now edit the BulkKinetics methods or override the GasKinetics ones? Do I add all of the the Delta, DeltaSS and DeltaRef methods to the GasKinetics modules (.h and .cpp)?

I took care of all of the other minor edits.

@skasiraj skasiraj requested a review from mbkumar October 15, 2021 19:14
@mbkumar
Copy link
Owner

mbkumar commented Oct 18, 2021

I did not update GasKinetics.cpp or GasKinetics.h methods with the new "ref' state methods because, they don't have any of the Delta methods defined (be it at actual state, standard state or reference state). All of the Delta Methods are only re-implemented in the InterfaceKinetics. GasKinetics will use the Base Class BulkKinetics class methods

class GasKinetics : public BulkKinetics

Do I now edit the BulkKinetics methods or override the GasKinetics ones? Do I add all of the the Delta, DeltaSS and DeltaRef methods to the GasKinetics modules (.h and .cpp)?

You need to add only DeltaRef methods to the GasKinetics code. The rest (Delta and DeltaSS) will be taken from BulkKinetics.

Added the DeltaRef methods to the GasKinetics.h file as suggested in the review for mbkumar#1.
Implemented the DeltaRef methods in the GasKinetics.cpp file as suggested in the review for mbkumar#1
Updated the DeltaRef method for enthalpy to avoid compilation errors.
@skasiraj
Copy link
Author

skasiraj commented Oct 18, 2021

You need to add only DeltaRef methods to the GasKinetics code. The rest (Delta and DeltaSS) will be taken from BulkKinetics.

I finished doing this just now. I added a "Not Implemented" method for getDeltaRefEnthalpy method as it is giving me an error during the linking process (shown below). We don't need this method so we don't have to define this at this point. It compiles and runs okay with these edits. Please review and close this PR request and the related issue: VlachosGroup/openmkm#50

Error for reference:
GasKinetics.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl Cantera::GasKinetics::getDeltaRefEnthalpy(double *)" (?getDeltaRefEnthalpy@GasKinetics@Cantera@@UEAAXPEAN@Z) InterfaceKinetics.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl Cantera::InterfaceKinetics::getDeltaRefEnthalpy(double *)" (?getDeltaRefEnthalpy@InterfaceKinetics@Cantera@@UEAAXPEAN@Z) KineticsFactory.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl Cantera::InterfaceKinetics::getDeltaRefEnthalpy(double *)" (?getDeltaRefEnthalpy@InterfaceKinetics@Cantera@@UEAAXPEAN@Z)

Copy link
Owner

@mbkumar mbkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDeltaEnthalpy virtual method defined in Kinetics.h is enough if you are not going to implement it for Interface and GasKinetics.

Deleted redundant implementation of virtual methods in the GasKinetics.h and InterfaceKinetics.h header files. Based on mbkumar#1 review feedback.
@skasiraj
Copy link
Author

getDeltaEnthalpy virtual method defined in Kinetics.h is enough if you are not going to implement it for Interface and GasKinetics.

Okay. Makes sense. Took care of this. It compiles okay now. All yours to review and close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants