Skip to content
Snippets Groups Projects
Commit 1105a60b authored by Claudio Scafuri's avatar Claudio Scafuri :speech_balloon:
Browse files

added

parent 53ab1dd5
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python3
import os
import at
import matplotlib.pylab as mp
import numpy as np
lattfile = "~/src/gitlab/dt/machine/lattice/elettra2/srElettra2_9_4_beta.mat"
#lattfile = "~/src/gitlab/dt/machine/lattice/elettra2/srElettra2_9_4_beta_test_digital_twins.mat"
#lattfile = "~/esrf_visit/last.mat"
lattfile = os.path.expanduser(lattfile)
ring=at.load_lattice(lattfile, energy=2.4e9)
refpts = range(len(ring) + 1)
ring.radiation_off()
elemdata0, ringdata,elemdata=at.linopt6(ring,refpts,0.00)
[chromH,chromV]=ring.get_chrom()
[tuneH,tuneV] = ring.get_tune()
s_pos = elemdata['s_pos']
#--- lionop needs radiation off
ring.radiation_on()
ring.rf_voltage=2e6
#elemdata0, tune, chrom, elemdata=at.linopt(ring,refpts)
incoord = np.array([0.0001,0.00, 0.0002, 0.0, 0.0,0.0])
mrefpts=[3]
nt = 10000
coord = at.lattice_pass(ring,incoord,nt,mrefpts)
h_traj=coord[0, 0, :, :] # get X
v_traj=coord[3, 0, :, :] # get Y
plotbase = (np.array([np.arange(0,nt)]))
mp.figure()
mp.plot(plotbase,h_traj,'.')
mp.xlabel('n')
mp.ylabel('x')
mp.title('traj_x' )
mp.figure()
mp.plot(plotbase,v_traj,'.')
mp.xlabel('n')
mp.ylabel('y')
mp.title('traj_y' )
mp.xlabel('s [m]')
mp.ylabel('m')
mp.title('traj_x' )
mp.show()
#!/usr/bin/python3
import at
import math
#--------- test shift ---------------
#function for extracting shift elemnts that is alignemnt errors
def get_elem_shift(elem):
#if thre is no T1 and T2????
dx2=elem.T2[0]
dy2=elem.T2[2]
dx1=elem.T1[0]
dy1=elem.T1[2]
#check coherency
if dx1+dx2 != 0.0 or dy1+dy2 !=0.0:
print(elem.FamName,"incoherent T1 and T2 vectors")
return dx2,dy2
QF = at.Quadrupole('QF:', 1.0, 0.2) #create a Quadrupole
dx=0.1 # horizontal shift [m] positive to the left
dy=0.2 # vertical shift [m] positive up
at.shift_elem(QF,dx,dy,relative=False) #use absolute shift
# now check T1 and T2 matrices
t1=QF.T1
t2=QF.T2
print ("T1", t1)
print("T2", t2)
print(t1[0],t1[2])
print(t2[0],t2[2])
a,b=get_elem_shift(QF)
print("dx",a,"dy",b)
QF.T1[2]*=0.00001
a2,b2=get_elem_shift(QF)
print("dx",a2,"dy",b2)
at.shift_elem(QF,0.0,0.0,relative=False)
a3,b3=get_elem_shift(QF)
#----------- test rotations -------------------------
print("rotations")
SD = at.Sextupole('SD', 1.0, 0.2) #create a Quadrupole
at.shift_elem(SD,0,0)
a,b=get_elem_shift(SD)
#print("dx",a,"dy",b)
tilt = math.asin(0.01) # rotation around s-axis
pitch = math.asin(0.02) # rotation around x-axis
yaw = math.asin(0.03) # rotation around y-axis
at.rotate_elem(SD,tilt,pitch,yaw,relative=False)
a2,b2=get_elem_shift(SD)
print("dx",a2,"dy",b2)
# ALAERT: rotations modify also T1 and T2 that is shift! Where is the rotation centre???? NOT CLEAR
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment