Closed SchroederSa closed 6 months ago
Hi,
Thanks for reporting this bug. The problem is that line 108 is leftover after major refactoring, and since I did not have unit tests that cover this case (drift length as a variable), I did not catch this bug. You can simply comment out this line or wait a bit until I commit the bug fix and a unit test to prevent this problem from occurring again.
Sergey
Hi Sergey,
There is another little piece missing in this function. After matching, when updating the twiss parameters via tws_matched = twiss(lat, tws, nPoints=10000)
the code crashes with the error message:
ocelot/cpbd/optics.py:113), in trace_z(lattice, obj0, z_array)
IndexError: list index out of range
I figured out that this is due to the total lattice length not being updated.
Adding the following lines to the end of the match.py function solve the issue:
'''
Update total lattice length
'''
lat.totalLen = 0
for i, el in enumerate(lat.sequence):
lat.totalLen += el.l
Best Sarah
Hi Sarah,
thanks for reporting this issue. Indeed we had a problem here. I made a bug fix in dev branch https://github.com/ocelot-collab/ocelot/commit/99dbbaf737383c8328fea22dceaf55477ad6ca3f
Cheers, Sergey.
Hi, I'd like to use the match function to get specific twiss parameters at the end of a focusing section. To achieve this, I'd like to vary quadrupole strengths but also drift lengths. The match function seems to facilitate this functionality, however, it crashes with the error message:
AttributeError: Drift object has no attribute create_tm
What is line 108 (vars[i].create_tm()) in match.py supposed to do and is it actually needed?
Thank you for your help! Best Sarah
For reference my code looks like this: