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 max_step arg in basesolver #3106

Closed
wants to merge 17 commits into from

Conversation

arjxn-py
Copy link
Member

@arjxn-py arjxn-py commented Jul 4, 2023

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #2253

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 (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
  • The documentation builds: $ python run-tests.py --doctest

You can run unit and doctests together 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

@arjxn-py arjxn-py marked this pull request as draft July 4, 2023 22:54
@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.60%. Comparing base (4df6a87) to head (9e9bc12).
Report is 747 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3106   +/-   ##
========================================
  Coverage    99.60%   99.60%           
========================================
  Files          259      259           
  Lines        21287    21309   +22     
========================================
+ Hits         21203    21225   +22     
  Misses          84       84           

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

@rtimms
Copy link
Contributor

rtimms commented Feb 15, 2024

@arjxn-py are you still working on this?

@arjxn-py
Copy link
Member Author

Yes, i'll try to finish this up asap.
Apologies as this one went down in the stack, thanks for pinging.

@agriyakhetarpal
Copy link
Member

It looks like Chocolatey community repositories are under maintenance, which explains the Windows job failures.

@arjxn-py
Copy link
Member Author

@rtimms can you give me some input about setting max_step for drive cycle simulations to the step size in the data. Do I have to do something about that?

@arjxn-py arjxn-py requested a review from a team as a code owner February 21, 2024 06:51
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@arjxn-py
Copy link
Member Author

Should also do changelog for this, right?

@brosaplanella
Copy link
Member

Should also do changelog for this, right?

Yup

@arjxn-py
Copy link
Member Author

arjxn-py commented Apr 8, 2024

@rtimms I'd be happy to have your review & input on this. Thanks.

Copy link
Contributor

@rtimms rtimms left a comment

Choose a reason for hiding this comment

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

In all of the solver classes you need to pass max_step to the actual call to solve in the appropriate way inside the _integrate method. Right now passing max_step doesn't do anything. E.g. in ScipySolver you need to pass max_step as a keyword argument to solve_ivp

@@ -24,14 +25,18 @@ class AlgebraicSolver(pybamm.BaseSolver):
specified in the form "lsq_methodname"
tol : float, optional
The tolerance for the solver (default is 1e-6).
max_step : float, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

the algebraic solver doesn't step in time so it doesn't make sense for it to be an argument here

@@ -4,6 +4,7 @@
import casadi
import pybamm
import numpy as np
from .base_solver import validate_max_step


class CasadiAlgebraicSolver(pybamm.BaseSolver):
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

@@ -16,6 +16,13 @@
from pybamm.expression_tree.binary_operators import _Heaviside


def validate_max_step(max_step):
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't validate other arguments such as tolerances. my guess is that all the solvers will have their own check to make sure max step makes sense, so maybe we should remove this?

max_step_decrease_count : float, optional
The maximum number of times step size can be decreased before an error is
raised. Default is 5.
dt_max : float, optional
dt_event : float, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree dt_event is a better name for this. Can you make it so that the solver also still accepts dt_max and raises a DeprecationWarning?

@arjxn-py arjxn-py marked this pull request as draft June 10, 2024 15:18
@agriyakhetarpal
Copy link
Member

Closing since this is superseded by #4673.

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.

Max step size option
4 participants