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

Repeatibility issue: Torque solver not cleaning properly #260

Closed
DeSanz opened this issue May 20, 2020 · 2 comments
Closed

Repeatibility issue: Torque solver not cleaning properly #260

DeSanz opened this issue May 20, 2020 · 2 comments
Assignees

Comments

@DeSanz
Copy link

DeSanz commented May 20, 2020

Hello, I have been doing some repeatability tests and just found that there seems to be an issue with the RK45 solver (and probably other ones) not flushing its memory when, for example, a new m is defined.

What I see is that if you run the same simulation in a loop like this one:

for p:=0; p<12; p++{
    t = 0
    m = Uniform(-1,0.2,0)
    run(1e-9)
}

different results are obtained for each loop.

It seems to be an issue of the solver not flushing the torques in the memory because I can do this to force a flush:

for p:=0; p<12; p++{
    m = Uniform(-1,0.2,0)
    SetSolver(1)
    steps(10)
    SetSolver(5)
    t = 0
    m = Uniform(-1,0.2,0)
    run(1e-9)
}

and then (almost) fully reproducible results are obtained.

This looks to me like a serious bug, because intuitively one should not have to manually flush the torque buffer when changing m and this can lead to non-reproducibility of results when people do e.g. parameter scans using a loop.

I attach an example file with a complete script showing the issue.
Fix_solver_buffer.txt

@JeroenMulkers
Copy link
Collaborator

Nice catch!

In most cases, the error would be negligible because only the first timestep of the run would have a small error. Nevertheless, the cache buffers should indeed be flushed when starting a new run.

Pull request #261 fixes this issue. With these changes, the "flush cycle" and "no flush cycle" in "Fix_solver_buffer.txt" yield similar results. Note that there are still some small fluctuations in the results because the initial step size is slightly different for each run.

@DeSanz
Copy link
Author

DeSanz commented May 20, 2020

Great! Thanks so much for the fast response

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