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

Allow manual activation of log during simulation for debugging #13

Open
bgroenks96 opened this issue May 6, 2021 · 5 comments
Open

Comments

@bgroenks96
Copy link

I think it would be useful to allow the user to choose to manually activate the global log before calling solve in order to collect the logged values at every solver time step.

Of course this adds the performance overhead of logging, but for debugging purposes, that's totally fine.

It would also provide a workaround for use cases (like one of mine) when the model slightly violates temporal continuity by implicitly relying on "logged" values from the previous time step.

@bgroenks96
Copy link
Author

Looking at the code, it seems that we just need to add a version of get_log that allows for the global log to be already active. activate! and deactivate! should be fine as-is. I can take a crack at it.

@jonniedie
Copy link
Owner

Yeah, you can totally activate! or deactivate! a log manually. The only thing is it's going to log every time your function was called. That includes time points where the solver throws away the solution. And maybe even Jacobian calls too, if your solver is doing that. Maybe you could make use of that, but it might get pretty tough to figure out which were the "real" timesteps it took.

@bgroenks96
Copy link
Author

Ah. Well, at least with a simple forward integration scheme it should work. Do you think maybe SavingCallback is more appropriate for this case, in general?

@jonniedie
Copy link
Owner

I think really only Euler's method will work this way (and you definitely don't want that). Most other methods will make multiple function calls per time increment. SavingCallback I think will run into the same problem because it is only called after all of the function calls per update, not every one.

@bgroenks96
Copy link
Author

I think really only Euler's method will work this way

I actually often have to use Euler's method.... phase change sucks :(

It's surprisingly often faster in my application domain than most other solvers!

I think will run into the same problem because it is only called after all of the function calls per update, not every one.

Isn't that usually what we want?

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

No branches or pull requests

2 participants