Currently an instance of the Twiss class is linked a given Lattice object. If the Lattice object changes so will the Twiss object.
This can be counter-intuitive if one wants to save some reference values before optimizing a given lattice and can lead to mistakes:
twiss = ap.Twiss(lattice)
ref_beta_x = twiss.beta_x
# do the opitmization
beta_x = twiss.beta_x
Now ref_beta_x is bound to the same underlying numpy.ndarray as beta_x. This might be error prone.
One solution to that would be to always allocate a new numpy.ndarray when calculating th twiss parameter instead of reusing the old one. Test how large the overhead would be!
Currently an instance of the
Twiss
class is linked a givenLattice
object. If theLattice
object changes so will theTwiss
object.This can be counter-intuitive if one wants to save some reference values before optimizing a given lattice and can lead to mistakes:
Now
ref_beta_x
is bound to the same underlyingnumpy.ndarray
asbeta_x
. This might be error prone.One solution to that would be to always allocate a new
numpy.ndarray
when calculating th twiss parameter instead of reusing the old one. Test how large the overhead would be!