pybamm-team / PyBaMM

Fast and flexible physics-based battery models in Python
https://www.pybamm.org/
BSD 3-Clause "New" or "Revised" License
876 stars 492 forks source link

Add functions of time in experiment step #4222

Closed MarcBerliner closed 1 week ago

MarcBerliner commented 1 week ago

Description

Adds functionality to pass in arbitrary functions of time as the argument for a pybamm.step

Fixes https://github.com/pybamm-team/PyBaMM/issues/4187

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

Key checklist:

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.55%. Comparing base (e22d10c) to head (e6decee). Report is 1 commits behind head on develop.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #4222 +/- ## ======================================== Coverage 99.55% 99.55% ======================================== Files 288 288 Lines 21856 21871 +15 ======================================== + Hits 21759 21774 +15 Misses 97 97 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

MarcBerliner commented 1 week ago

For steps that compute their charge/discharge direction (Current, CRate, Power, Resistance), there were a few redundancies in the BaseStep initialization. I moved the value_based_charge_or_discharge inside the BaseStep class and evaluate it after sanitizing the step value. This should fix the codecov (I believe)