pybamm-team / PyBaMM

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

Max step size option #2253

Open rtimms opened 2 years ago

rtimms commented 2 years ago

Add a max_step parameter to BaseSolver and pass it to the solvers in the appropriate way. Then for drive cycle simulations we should set max_step to the step size in the data.

rtimms commented 2 years ago

Or at least do that in our drive cycle examples

jaskiratsingh2000 commented 1 year ago

Hey @rtimms What are you excatly expecting out of this? Where can I find this? Thanks!

rtimms commented 1 year ago

I wanted to add a max_step parameter to BaseSolver which controls the maximum step size the solver can take. You'll need to look at the docs for the each of the solvers we use as they may all have different interfaces. E.g. for scipy integrate you can directly pass max_step as an extra option. We should probably follow their syntax so that the default is inf, i.e., the step size is not bounded and determined solely by the solver.

Note this is different from dt_max used in the CasadiSolver to set the step size for event checking. I propose we rename dt_max to dt_event.

This might be more like medium rather than easy.

jaskiratsingh2000 commented 1 year ago

I see. Can you provide a basic example for the same because I'm not getting where other parameters are gettiing called in https://github.com/pybamm-team/PyBaMM/blob/develop/pybamm/models/submodels/base_submodel.py

Saransh-cpp commented 1 year ago

I think you are looking at the wrong class (based on the link you attached). BaseSolver -

https://github.com/pybamm-team/PyBaMM/blob/6ab6c15979ad1b11fcebea37e43723179d201ea6/pybamm/solvers/base_solver.py#L19

jaskiratsingh2000 commented 1 year ago

@rtimms Any update on this?

rtimms commented 1 year ago

What do you need an update on? I think you were looking at the wrong class, as suggested by @Saransh-cpp .

jaskiratsingh2000 commented 1 year ago

@rtimms I was expecting the example on above. That would be helpful if you can provide it.

arjxn-py commented 1 year ago

Hi there @rtimms I had gone through the scipy integrate to try to understand what exacty could be done, but I don't find any parameter like max_step there. Would you like to suggest me anything in regards?

rtimms commented 1 year ago

max_step is in the **options part of the scipy docs