PyORBIT-Collaboration / py-orbit

Core of Py-ORBIT code
MIT License
25 stars 38 forks source link

Collimator Issue #47

Closed urmila-star closed 3 years ago

urmila-star commented 3 years ago

I am designing a line in which I am using collimator in PyORBIT. But what I observed that when I am applying collimator with sufficiently large aperture such that beam does not hit the collimator, the phase space differ from the case when I am not applying any collimator. Also applying the multiple collimator successively such that the total length of collimator remains same in that cases again the results differs. Please guide me regarding this problem. PyORBIT File For Collimator.zip

khilde commented 3 years ago

Thank you for including your code. After looking into this the difference in the z coordinate (5th coordinate in beam dump) between the cases you described there was a problem with the collimator code that has been corrected.

The difference in (x,xp,y,yp) (the first 4 coordinates in beam dump) from running with a collimator or just with a drift same length of the collimator is very small and due to rounding errors. For your case removing the collimator results in have a drift of ~1.2 m. And PyOrbit tracks a particle through this drift in one step (drifts it 1.2 m). However, in the case of the collimator code, each particle is drifted through many steps across the collimator. The step size is about ~0.001 m. This is done so that after each step it can check if it has "hit" the collimator. So for a collimator of length about 1.2 m it is drifting each particle through over 1000 steps. Each step will introduce a rounding error, and with a huge number of steps this rounding error can add up. This is why you see the small difference in (x,xp,y,yp). From the rounding errors due to drifting using over 1000 steps vs drifting over 1 step.

azukov commented 3 years ago

@urmila-star The PR fixing the issue was merged. Please make sure that it actually fixes your issue.

urmila-star commented 3 years ago

Thanks a lot for helping. The changes fixed my issue.