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

Add electrode balancing example #472

Merged

Conversation

brosaplanella
Copy link
Contributor

@brosaplanella brosaplanella commented Aug 22, 2024

Description

Added an example for electrode balancing. The main issue was defining the model, for now I have hacked it via an ECM but this means we can only balance half cells. In the future it would be interesting to define specific models for electrode balancing, which could support full cells too.

Issue reference

Fixes #222

Review

Before you mark your PR as ready for review, please ensure that you've considered the following:

  • Updated the CHANGELOG.md in reverse chronological order (newest at the top) with a concise description of the changes, including the PR number.
  • Noted any breaking changes, including details on how it might impact existing functionality.

Type of change

  • New Feature: A non-breaking change that adds new functionality.
  • Optimization: A code change that improves performance.
  • Examples: A change to existing or additional examples.
  • Bug Fix: A non-breaking change that addresses an issue.
  • Documentation: Updates to documentation or new documentation for new features.
  • Refactoring: Non-functional changes that improve the codebase.
  • Style: Non-functional changes related to code style (formatting, naming, etc).
  • Testing: Additional tests to improve coverage or confirm functionality.
  • Other: (Insert description of change)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All unit tests pass: $ nox -s tests
  • The documentation builds: $ nox -s doctest

You can run integration tests, unit tests, and doctests together at once, using $ nox -s quick.

Further checks:

  • Code is well-commented, especially in complex or unclear areas.
  • Added tests that prove my fix is effective or that my feature works.
  • Checked that coverage remains or improves, and added tests if necessary to maintain or increase coverage.

Thank you for contributing to our project! Your efforts help us to deliver great software.

@NicolaCourtier
Copy link
Member

Thanks @brosaplanella, I like your use of the Thevenin model in this example, but unfortunately it doesn't seem to work on the develop branch - probably due to my changes to set_initial_state. Let me know if you'd like me to look into this.

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.76%. Comparing base (42a5f93) to head (b2ed501).
Report is 355 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #472      +/-   ##
===========================================
+ Coverage    98.70%   98.76%   +0.05%     
===========================================
  Files           48       48              
  Lines         3172     3153      -19     
===========================================
- Hits          3131     3114      -17     
+ Misses          41       39       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@brosaplanella
Copy link
Contributor Author

I just merged develop and the tests are passing. The only one that breaks it the Lychee one, as for some reason it picks up a string I define in the notebook that is not complete (I append the extra bit later on). Not sure if there is a way to tell Lychee to ignore that (@agriyakhetarpal might know). Otherwise, I will hardcode each of the URLs which should make the test pass.

@NicolaCourtier
Copy link
Member

It passes when pip installing from main. To see what I mean, set up the environment with:
%pip install git+https://github.com/pybop-team/PyBOP@develop --force-reinstall -q

@BradyPlanden
Copy link
Member

Not sure if there is a way to tell Lychee to ignore that

Yes, you can add an exclusion for the broken link to the Lychee workflow file:

--exclude "https://tiles.stadiamaps.com/*|https://b.tile.openstreetmap.org/*"

It would look like this:
--exclude "https://raw.githubusercontent.com/paramm-team/pybamm-param/develop/pbparam/input/data/"

@brosaplanella
Copy link
Contributor Author

I have now made Lychee ignore the incomplete URL so it passes. About the issue with develop branch, I tried creating a new virtual environment and installing the develop branch and the example still runs as expected. I also double checked and the GitHub actions should install the version in the tested branch, which I have now made sure is up-to-date with develop. If someone else try to reproduce Nicola's that would be great!

@NicolaCourtier
Copy link
Member

Thanks for the update! I tested again and now think the issue may not be due to the branch, just some initial values. Please could you try an initial soc >= 0.5 and capacity >= 50? In my case, SciPyMinimize terminates before locating the minimum, so it may be worth amending the parameter bounds for robustness.

Other than that, just two things, please:

  • fix typo on the first line
  • add fig.show() at the end, to include the plot in the preview

Copy link
Member

@NicolaCourtier NicolaCourtier left a comment

Choose a reason for hiding this comment

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

Nice work, thanks @brosaplanella !

Copy link
Member

@BradyPlanden BradyPlanden left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @brosaplanella! The bottom figure will be correctly rendered when #410 lands with nbviewer, so that should be sorted soon.

@BradyPlanden
Copy link
Member

@all-contributors please add @brosaplanella for examples

Copy link
Contributor

@BradyPlanden

I've put up a pull request to add @brosaplanella! 🎉

@BradyPlanden BradyPlanden linked an issue Aug 27, 2024 that may be closed by this pull request
@BradyPlanden BradyPlanden merged commit ae4404a into pybop-team:develop Aug 27, 2024
31 checks passed
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.

August 2024 Examples Workshop Add electrode balancing example
3 participants