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

More accurate QuickPlots with Hermite interpolation #4483

Merged
merged 8 commits into from
Oct 10, 2024

Conversation

MarcBerliner
Copy link
Member

Description

The QuickPlot class plots the results using the raw data points. With the new Hermite interpolation changes in the IDAKLUSolver, we can improve the visual appearance of plots by interpolating the data. This PR adds 100 evenly spaced interpolation time points for all sub-solutions.

For example,

import pybamm

model = pybamm.lithium_ion.SPM()
solver = pybamm.IDAKLUSolver()
sim = pybamm.Simulation(model, solver=solver)
sol = sim.solve([0, 3600])

sol.plot(output_variables=["Voltage [V]"])

Hermite interpolation (new)

image

Raw data (old)

image

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)

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

accurate quickplots
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.42%. Comparing base (e4eb82a) to head (bb737aa).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4483      +/-   ##
===========================================
- Coverage    99.42%   99.42%   -0.01%     
===========================================
  Files          299      299              
  Lines        22739    22691      -48     
===========================================
- Hits         22608    22560      -48     
  Misses         131      131              

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

Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

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

This won't work well if there are multiple cycles (e.g. 5 times CCCV charge/discharge). Could it be done for each step in sol or would that be too slow?

@MarcBerliner
Copy link
Member Author

This won't work well if there are multiple cycles (e.g. 5 times CCCV charge/discharge). Could it be done for each step in sol or would that be too slow?

@valentinsulzer good point – I actually meant to do this, but I misunderstood solutions to be the sub-solutions and not different simulations. I just pushed this change.

Copy link
Member

@valentinsulzer valentinsulzer 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 other than style

src/pybamm/plotting/quick_plot.py Outdated Show resolved Hide resolved
@MarcBerliner MarcBerliner requested a review from kratman October 10, 2024 16:25
Copy link
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

Should be good after tests pass

@kratman kratman merged commit ab0020a into pybamm-team:develop Oct 10, 2024
23 checks passed
@MarcBerliner MarcBerliner deleted the quickplot-interp branch October 10, 2024 17:58
@arjxn-py
Copy link
Member

arjxn-py commented Oct 11, 2024

Hey @all-contributors please add @MarcBerliner for code, documentation, infrastructure and maintainance

Copy link
Contributor

@arjxn-py

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

@brosaplanella
Copy link
Member

Hahah you beat me to it @arjxn-py

@pybamm-team pybamm-team deleted a comment from allcontributors bot Oct 11, 2024
@arjxn-py
Copy link
Member

Hahah you beat me to it @arjxn-py

Haha, I made a small mistake 😅

@all-contributors please add @MarcBerliner for Maintenance

Copy link
Contributor

@arjxn-py

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

pkalbhor pushed a commit to pkalbhor/PyBaMM that referenced this pull request Nov 15, 2024
* Update CHANGELOG.md

accurate quickplots

* evenly sample sub-solutions

* lowercase variable

* move `_solver_args` inside class

---------

Co-authored-by: Eric G. Kratz <[email protected]>
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.

5 participants