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

Fix bug with electrochemical-legacy #1256

Merged
merged 2 commits into from
Apr 29, 2022

Conversation

dschmider-HSOG
Copy link
Contributor

Changes proposed in this pull request

  • Change alias in ReactionFactory.cpp to enable correct legacy behavior for electrochemical reactions
  • Fix problem described in Cantera Users' Group

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #1256 (a955dfd) into main (a394423) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1256      +/-   ##
==========================================
+ Coverage   65.50%   65.54%   +0.04%     
==========================================
  Files         329      329              
  Lines       46666    46668       +2     
  Branches    19855    19855              
==========================================
+ Hits        30568    30590      +22     
+ Misses      13538    13516      -22     
- Partials     2560     2562       +2     
Impacted Files Coverage Δ
src/kinetics/ReactionFactory.cpp 96.03% <100.00%> (+2.38%) ⬆️
src/kinetics/InterfaceKinetics.cpp 72.46% <0.00%> (+0.22%) ⬆️
src/kinetics/Reaction.cpp 81.72% <0.00%> (+0.55%) ⬆️
src/thermo/SurfPhase.cpp 80.36% <0.00%> (+1.92%) ⬆️
src/kinetics/importKinetics.cpp 79.36% <0.00%> (+4.76%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@speth
Copy link
Member

speth commented Apr 28, 2022

I think this change makes sense, but I'm a little concerned about what it says about how we're testing this reaction type to verify that the "legacy" and new implementations corresponding to CTI and YAML input are actually the same. If the test suite didn't catch this error, I think we need to take another look at those tests.

@ischoegl
Copy link
Member

ischoegl commented Apr 29, 2022

Thanks, @dschmider-HSOG for tracking that bug down! This was a clear oversight that happened to fall through the cracks of the test suite.

@speth Regarding unit test coverage, both electrochemical and electrochemical-legacy were already covered from the YAML side. I didn't realize that we still had a version for sofc.cti in data/inputs, which I am now also checking against. The pre-existing test is thorough, so I didn't feel it to be necessary to add things to test_reaction.py.

To facilitate a resolution here, I pushed an update to include testing of CTI input to this PR.

@ischoegl ischoegl requested a review from speth April 29, 2022 13:16
@ischoegl ischoegl added the Input Input parsing and conversion (for example, ck2yaml) label Apr 29, 2022
@speth
Copy link
Member

speth commented Apr 29, 2022

Thanks for adding this test, @ischoegl. The thing that I'm still surprised to see is that if you revert the change that fixes the reaction type, this new test still passes.

One difference that I did notice between @dschmider-HSOG's example posted on the Users' Group and sofc.cti is the use of the exchangecurrentdensity option in the former case:

surface_reaction("Li+[electrolyte] + V[NCA] + electron <=> Li[NCA]",
                 [2.62895E+10, 0.0, (61.0098120252686, 'kJ/mol')],
                 rate_coeff_type = "exchangecurrentdensity",
                 beta = 0.5,
                 id="NCA_reaction")

I'm thinking we don't actually have a test that covers this case for the "legacy" reaction framework / CTI input, though the feature is used in data/inputs/lithium_ion_battery.cti.

@ischoegl
Copy link
Member

ischoegl commented Apr 29, 2022

I'm thinking we don't actually have a test that covers this case for the "legacy" reaction framework / CTI input, though the feature is used in data/inputs/lithium_ion_battery.cti.

Thanks, @speth. When refactoring, I relied on existing tests. From the implementation side, the exchangecurrentdensity is a relatively small portion where I actually was able to avoid major refactoring, as most of what is required is to set InterfaceRateBase::m_exchangeCurrentDensityFormulation (none of the implementation changed even if the 'plumbing' was reshuffled).

If there wasn't a test covering this behavior from the get-go this is a different issue. It's outside of my wheel house and should probably be added by a separate issue? Tagging @decaluwe here ...

@ischoegl
Copy link
Member

ischoegl commented Apr 29, 2022

@speth ... I opened #1259 which should resolve a larger issue. I don't think this should be added to this PR as this goes well beyond the scope of what @dschmider-HSOG signed up for.

@ischoegl
Copy link
Member

Based on #1263, I'd suggest to merge here (fwiw, the new sofc.cti test does add coverage, while not covering the actual issue).

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

Thanks for identifying this fix and submitting the PR, @dschmider-HSOG.

@speth speth merged commit d2be7fc into Cantera:main Apr 29, 2022
@dschmider-HSOG dschmider-HSOG deleted the bug-electrochemical-legacy branch May 2, 2022 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Input Input parsing and conversion (for example, ck2yaml)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants