-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add maximum number of iteration steps in Propagator::AdvanceParticle
#338
Conversation
…agation if we have a discrepancy of above 1cm, otherwise log and continue. Introduce resampling of random numbers in "backscattering" case.
Do I understand it correctly, that the introduced maximum number of iteration steps is the limit for all advancing steps in the propagation, regardless if the particle actually gets advanced or not? I suggest introducing an iteration counter for steps, where there is no progress. If e.g. the algorithm to find the correct multiple scattering does not converge (which is I think the only case where there is no progress), the number of iterations should be limited to 20, not 200. However, I think introducing such a general iteration limit for the steps where the particle gets advanced does make sense, whether there is a bug or not. However, I would increase the default value to at least 1000, or better 10000. |
The |
ah, so I did understand it wrong; the But 200 iterations for a single step is still inefficient. Are the differences between the iterations steps, let's say after 10 iterations still greater than the Maybe, if the algorithm doesn't converge, PROPOSAL should raise a warning instead of an Exception, or did we already discuss this concluding with this behaviour? |
Yes, I agree that 200 iterations is inefficient. In this PR, if the algorithm does not converge, we check the remaining difference: If it is smaller than |
I think when reaching the 200 iterations, PROPOSAL should always give a warning with the remaining uncertainty but should continue to propagate. |
Ok. I think a valid idea would be to just continue propagating (and giving a warning) no matter the remaining uncertainty. But in addition, if we have reached the iteration limit, we will recalculate energy and grammage with the current (and therefore accepted) actual distance_to_border. This way, the only "bias" that we may introduce is in the multiple scattering direction (which might be under/overestimated), but everything else will be fine. |
…cle to the border with current scattering angles.
Issue #332 shows that the propagation can stall if the
PARTICLE_POSITION_RESOLUTION
can not be reached due to numerical uncertainties (for very large propagation steps, complicated medium intersections, non-dense media, with multiple scattering enabled). I've been trying to find a "good" way to solve this problem, but was not successful to find a solution that made me happy.As a "quick fix", this PR adds an (adjustable) number of maximum iteration steps in
Propagator::AdvanceParticle
.After we reached the maximum number of propagation steps, we check the deviation from
PARTICLE_POSITION_RESOLUTION
is. If it is "still acceptable" (which is currently defined as "1 cm"), we still continue propagation. This avoids that the propagation always stops if we have the problem in issue #332. If the deviation is "not acceptable", we throw an error/exception.Furthermore, I found a small issue with the "backscattering" (issue #267), which is solved by resampling random numbers if we run into this case twice.
I have to admit that I am still not happy with the solution, but I believe this PR provides a quickfix that doesn't complicate the algorithm even further, and it should avoid that the algorithm stalls in case someone runs into this problem. For now, I don't think that many users will run into issue #332, but if they do, they will now get a reasonable error message that we can help to debug.
At some point in the future, it is going to be necessary to revise the whole
Propagator::AdvanceParticle
algorithm again.