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

Issue 4224 duration bug #4239

Merged
merged 14 commits into from
Jul 11, 2024
Merged

Issue 4224 duration bug #4239

merged 14 commits into from
Jul 11, 2024

Conversation

valentinsulzer
Copy link
Member

@valentinsulzer valentinsulzer commented Jul 3, 2024

Description

Fixes #4224

  • longer default duration (1000 hours)
  • default duration is 2 / C-rate hours for C-rate steps
  • warning if step finishes due to hitting the default duration

Currently working on adding a warning if maximum duration is reached

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.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

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 tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

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

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@ejfdickinson
Copy link

ejfdickinson commented Jul 4, 2024

@valentinsulzer You need to take abs(value) in CRate.default_duration(), because value comes through negative for charge steps.

Alternatively you might think about CRate storing its direction and magnitude in a more descriptive way.

Copy link
Sponsor Member

@brosaplanella brosaplanella left a comment

Choose a reason for hiding this comment

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

Looks good to me, let's just add a line to CHANGELOG before merging.

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.55%. Comparing base (b4eaa3f) to head (8381ba2).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4239      +/-   ##
===========================================
+ Coverage    99.54%   99.55%   +0.01%     
===========================================
  Files          288      288              
  Lines        21886    21897      +11     
===========================================
+ Hits         21786    21800      +14     
+ Misses         100       97       -3     

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

@ejfdickinson
Copy link

@brosaplanella @valentinsulzer To confirm, this is working as expected for the use cases on which I was testing.

@valentinsulzer
Copy link
Member Author

Changing default duration to 1000 hours caused a severe performance degradation, investigating further

@aabills
Copy link
Contributor

aabills commented Jul 10, 2024

Thanks! I just tried it and though I'd prefer a longer duration barring a substantial performance hit, in my opinion, the bug is fixed by the warning alone.

I wonder if 100 + ε hours might be a happy medium?

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@valentinsulzer
Copy link
Member Author

This PR adds the warning and also fixes the C/100 case which I assume is more common than specifying a small current (backed up by a n=2 sample size from @aabills and @ejfdickinson ). The default duration is 24h and we can reconsider once @MarcBerliner is done with updates to solvers, which will make solve times much less sensitive to things like duration, period, etc

@valentinsulzer valentinsulzer marked this pull request as ready for review July 10, 2024 22:02
@valentinsulzer valentinsulzer requested review from Saransh-cpp and a team as code owners July 10, 2024 22:02
pybamm/simulation.py Outdated Show resolved Hide resolved
pybamm/simulation.py Outdated Show resolved Hide resolved
pybamm/experiment/step/base_step.py Show resolved Hide resolved
pybamm/experiment/step/base_step.py Show resolved Hide resolved
@kratman kratman merged commit ab7348f into develop Jul 11, 2024
26 checks passed
@kratman kratman deleted the issue-4224-duration-bug branch July 11, 2024 13:50
kratman pushed a commit that referenced this pull request Jul 11, 2024
* make longer default duration and calculate it for C-rate

* add tests

* typo

* #4224 add warning for time termination and add abs

* fix tests

* #4224 keep non-C-rate default at 24h for performance reasons

* trying to fix experiment

* fix example

* #4224 eric comments

* fix bug
kratman pushed a commit that referenced this pull request Jul 12, 2024
* make longer default duration and calculate it for C-rate

* add tests

* typo

* #4224 add warning for time termination and add abs

* fix tests

* #4224 keep non-C-rate default at 24h for performance reasons

* trying to fix experiment

* fix example

* #4224 eric comments

* fix bug
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
* make longer default duration and calculate it for C-rate

* add tests

* typo

* pybamm-team#4224 add warning for time termination and add abs

* fix tests

* pybamm-team#4224 keep non-C-rate default at 24h for performance reasons

* trying to fix experiment

* fix example

* pybamm-team#4224 eric comments

* fix bug
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.

[Bug]: [24.5rc0] Simulations with pybamm.Experiment terminate after 24 h
5 participants