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

Events for Casadi solver when stepping #789

Closed
TomTranter opened this issue Jan 21, 2020 · 3 comments · Fixed by #800
Closed

Events for Casadi solver when stepping #789

TomTranter opened this issue Jan 21, 2020 · 3 comments · Fixed by #800
Assignees

Comments

@TomTranter
Copy link
Contributor

Summary
Hi, can anyone explain why events are not implemented in the casadi solver compute_solution method and is this something that will never work or something we haven't got round to doing? There is a line saying events not implemented in this method and termination is always set to "final time". However, in the solve method when mode is safe there does seem to be some event handling. I was wondering whether this could be refactored a little so that the simulation step method could also use it as it currently just calls compute_solution.

Motivation
When stepping solution it's good to know why it finished

@valentinsulzer
Copy link
Member

Casadi solvers don't handle events and don't plan to (see #664). We get around this by doing a step-and-check during solve, but haven't implemented this for step. Happy to refactor step so that it calls step-and-check when using safe mode, as I am refactoring a lot of the solver code anyway in #784

@valentinsulzer
Copy link
Member

I have this working but one problem is that it continues to step over the event after hitting it. Say on the nth iteration you hit the event, then it stops and solver.termination = "event", but it can just keep going on the (n+1)th iteration because it's already gone past the event.

One option is to say "you can't step if the previous solution has hit an event". But this might cause problems with things like CCCV where you want to hit a voltage event and then keep stepping at constant voltage. Either way one can be the default and the other can be an option, the question is do we want the default to be "no stepping after events" (has to be manually disabled) or "allow stepping after events" (check for event termination has to be manually enabled)

@TomTranter
Copy link
Contributor Author

I think default should be stop when an event is met. We can string together a series of events like instructions to a potentiostat and append solutions but reset solvers

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 a pull request may close this issue.

2 participants