lnls-fac / pyaccel

Python module for beam dynamics tracking and optics calculations
MIT License
7 stars 5 forks source link

OPT.BUG: calc_beamenvelope in transport lines #110

Open jquentino opened 2 years ago

jquentino commented 2 years ago

The optics.calc_beamenvelope function was always turning on the cavity and the radiation, even if a fixed point is passed. In this way, an exception occurs when propagating the envelope in a transport line, because its cavity is always False and an immutable property. I changed the method to only turn on the cavity and rad if the fixed point is not passed.

fernandohds564 commented 1 year ago

I'll check this on the next days.

fernandohds564 commented 1 month ago

guys, @xresende, @murilobalves, @vellosok75, and @Gabrielrezende-asc, I revived this PR with what I think is the correct fix for the bug.

The last fix was overloading the meaning of the fixed_point input, using it to decide whether the cavity and radiation states should be changed within the code. With this fix I've made, these properties will always be changed, except the cavity_on for transfer lines that do not have the harmonic_number set.

However, we could rethink this overall behavior of pyaccel, where functions change locally the radiation_on and cavity_on properties of the accelerator to make them compliant with what is expected. Maybe, a better approach would be to raise errors and warnings of non-compliant states and let the user change the properties accordingly.

xresende commented 3 weeks ago

@fernandohds564 , I agree that rasing exception with an informing message (to help the class user) is the best to do! Before merginf this PR I would add a comment line in the code to remind of this future implementation