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

What would it take to support adaptive time step integration? #518

Open
sg-s opened this issue Apr 20, 2020 · 4 comments
Open

What would it take to support adaptive time step integration? #518

sg-s opened this issue Apr 20, 2020 · 4 comments
Assignees
Labels
C++ architectural change to the C++ code enhancement

Comments

@sg-s
Copy link
Owner

sg-s commented Apr 20, 2020

Why?

It can massively increase performance, possibly ~100X of what it is now

How?

There are various complex means of solving ODEs using adaptive time steps, but a simple one could work as follows:

  • define some maximum delta V that is acceptable over a time step
  • integrate with some test step size h
  • if delta V is smaller than acceptable limit, accept integration, increase h, and carry on
  • if it is bigger than the limit, rewind to previous state, decrease h, and repeat.
@sg-s sg-s self-assigned this Apr 20, 2020
@sg-s sg-s added the C++ architectural change to the C++ code label Apr 20, 2020
@alec-hoyland
Copy link
Collaborator

alec-hoyland commented Apr 20, 2020 via email

@sg-s
Copy link
Owner Author

sg-s commented Apr 20, 2020

Yes. and every single component has to be modified because it has to keep track of two states...

or, since the ODEs are time-reversible, i wonder what happens if you set dt to a negative value? Don't you go backwards in time?

@alec-hoyland
Copy link
Collaborator

alec-hoyland commented Apr 20, 2020 via email

@alec-hoyland
Copy link
Collaborator

alec-hoyland commented Apr 20, 2020

But I think you're correct; the best way to do this is to have new variables for each state variable that keep track of the state variable at the last integrated time point.

So for instance, a conductance would have m and m_prev and so on. Then before integration, m_prev = m, then integrate, check error, if error is below tolerance, proceed, else, adapt time step, and repeat until error is below tolerance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ architectural change to the C++ code enhancement
Projects
None yet
Development

No branches or pull requests

2 participants