Hi, I think this API has some problems (ocelot.cpbd.optics.twiss:
def twiss(lattice, tws0=None, nPoints=None, return_df=False, attach2elem=False):
Implicitly it will try to find a periodic solution, unless tws0 is provided in which case it will propagate the Twiss parameters to the end of the lattice. If there is no stable solution, it prints a warning and returns None. This is kind of opaque and strange in Python terms. It really ought to instead print nothing and raise a custom exception, like, say UnstableLatticeError.
There is actually also a problem with attach2elem in that if the element instance is reused, only the final instance of the Twiss is attached to the element (previous ones are overwritten). I have already had one person get in contact with me expressing frustration that their optics didn't match, in the end actually it was just this issue with reused elements... So this also needs to be made much clearer.
I think it should really be just twiss and periodic_twiss, really... and none of this kwarg stuff where behaviour changes.
Hi, I think this API has some problems (ocelot.cpbd.optics.twiss:
def twiss(lattice, tws0=None, nPoints=None, return_df=False, attach2elem=False):Implicitly it will try to find a periodic solution, unless tws0 is provided in which case it will propagate the Twiss parameters to the end of the lattice. If there is no stable solution, it prints a warning and returns None. This is kind of opaque and strange in Python terms. It really ought to instead print nothing and raise a custom exception, like, say UnstableLatticeError.
There is actually also a problem with
attach2elemin that if the element instance is reused, only the final instance of the Twiss is attached to the element (previous ones are overwritten). I have already had one person get in contact with me expressing frustration that their optics didn't match, in the end actually it was just this issue with reused elements... So this also needs to be made much clearer.I think it should really be just twiss and periodic_twiss, really... and none of this kwarg stuff where behaviour changes.