Replies: 1 comment
-
Hello @elafmusa, it like looks like you are adding pointers to the same object in your list ring = [Q1.deeepcopy(), drift.deepcopy(), etc... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to insert errors to quadrupoles strengths in a lattice. I am showing here a very simple example for explanation:
Q1 = elements.Quadrupole('Q1', 0.7028, 0.2)
Q2 = elements.Quadrupole('Q2', 0.7028, -0.1)
DRIFT_0 = elements.Drift('DRIFT_0', 7.157399999999999)
ring = [Q1,DRIFT_0, Q2,DRIFT_0,Q1,DRIFT_0,Q2,DRIFT_0,Q1,DRIFT_0, Q2,DRIFT_0,Q1,DRIFT_0,Q2,DRIFT_0,Q1,DRIFT_0, Q2,DRIFT_0,Q1,DRIFT_0,Q2,DRIFT_0]
ring=at.Lattice(ring,energy=1)
errorQ = 1.e-4
tiltQ = 0
shiftQx =0
shiftQy =0
quad_indexes = get_refpts(ring, elements.Quadrupole)
for i in quad_indexes:
print('before err', ring[i].K)
ring[quad_indexes[i]].K += 0.1
print('after err', ring[i].K)
The result of the prints out gives the following:
before err 0.2
after err 0.30000000000000004
before err -0.1
after err -0.1
before err 0.4
after err 0.5
before err -0.1
after err -0.1
before err 0.6
after err 0.7
Whish is not what i want to do, i want to deal with every quadrupole in the lattice individually as in realty i will apply random errors.
So i got for example:
before err 0.2
after err 0.3
before err -0.1
after err 0
before err 0.2
after err 0.3
and so on.
@lfarv
Beta Was this translation helpful? Give feedback.
All reactions