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 1477 sensitivities for solvers #1552

Merged
merged 93 commits into from
Aug 19, 2021
Merged

Conversation

martinjrobins
Copy link
Contributor

@martinjrobins martinjrobins commented Jul 16, 2021

Description

Adds functionality to calculate sensitivities. Specifically:

  • pybamm.base_solver.solve function can take a list of input parameters to calculate the sensitivities of the solution with respect to. Or it can be True to calculate the sensitivities for all input parameters. If this arg changes between different calls to solve, then the model is re-setup.
  • If model.convert_to_format = 'casadi', then sensitivities will be calculated by solving the explicit forward sensitivity equations. Any solver can be used, except for the IDKLU solver which uses CVODES forward sensitivity methods, see next item
  • For model.convert_to_format = 'casadi' or model.convert_to_format = 'jax', the IDKLU solver can use the CVODES package to calculate sensitivities.

Fixes #1477

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: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

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

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.

THanks for taking this on @martinjrobins ! Just a few comments

CHANGELOG.md Outdated Show resolved Hide resolved
sens-test-pybamm.py Outdated Show resolved Hide resolved
sens-test.py Outdated Show resolved Hide resolved
test-sensitivities.ipynb Outdated Show resolved Hide resolved
tests/unit/test_solvers/test_casadi_algebraic_solver.py Outdated Show resolved Hide resolved
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! Will just need to merge develop after #1596 to fix the github actions

@martinjrobins martinjrobins merged commit 404fa2e into develop Aug 19, 2021
@martinjrobins martinjrobins deleted the issue-1477-idaklu-send branch August 19, 2021 08:14
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.

IDAKLU solver sensitivities using IDAS
2 participants