SixTrack / sixtracklib

Library for single charged particle simulations in accelerators
GNU Lesser General Public License v2.1
12 stars 16 forks source link

Hotfix/issue128 fix track line #129

Closed martinschwinzerl closed 4 years ago

martinschwinzerl commented 4 years ago

Attempts to fix the problems encountered in isseu #128 by changing the behavior of the global aperture check and the track_line method:

Feedback & tests would be appreciated

aoeftiger commented 4 years ago

Thanks so much for the quick fix! It surely solves the https://github.com/SixTrack/sixtracklib/pull/128 MWE already!

$ python reproducing.py 

[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
Indeed, half of the particles have been lost in the aperture. They are all marked `state==0`.

Let's track the first drift again after having finished the previous turn:
[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
aoeftiger commented 4 years ago

Yes!! I can confirm it works perfectly fine also in the full SIS100 tracking setup for SixTrackLib+PyHEADTAIL with losses in both, this bug was the source for the issue I had discussed with you earlier! Thanks a million times @martinschwinzerl ! :+1:

martinschwinzerl commented 4 years ago

Adds tests ensuring the expected behavior based on the minimal reproducible example for issue #128. Adds also missing API to NS(MultiPole) and sixtrack::MultiPole required for the tests to actually work.