Пример #1
0
	def offset(self):
		matrix_lattice = TEAPOT_MATRIX_Lattice(self.lattice,self.bunch)

		OTM = np.zeros((6, 6))
		kickOTM = np.zeros((6))
		mt = matrix_lattice.getOneTurnMatrix()
		for i in range(6):
			for j in range(6):
				OTM[i][j] = mt.get(i,j)
			for i in range(6):
				kickOTM[i] = mt.get(i,6)

		#z0 fulfill: z0 = Mz0 with M as one turn matrix
		# Mz + k = z => z = (I-M)^-1 k
		z0, _, _, _ = np.linalg.lstsq(np.eye(6, dtype=int) - OTM,kickOTM)
		return z0
Пример #2
0
	def offset(self):
		matrix_lattice = TEAPOT_MATRIX_Lattice(self.lattice,self.bunch)

		OTM = np.zeros((6, 6))
		kickOTM = np.zeros((6))
		mt = matrix_lattice.getOneTurnMatrix()
		for i in range(6):
			for j in range(6):
				OTM[i][j] = mt.get(i,j)
			for i in range(6):
				kickOTM[i] = mt.get(i,6)

		#z0 fulfill: z0 = Mz0 with M as one turn matrix
		# Mz + k = z => z = (I-M)^-1 k
		z0, _, _, _ = np.linalg.lstsq(np.eye(6, dtype=int) - OTM,kickOTM)
		return z0
Пример #3
0
bunch = Bunch()
bunch.getSyncParticle().kinEnergy(Tkin)

matrix_lattice = TEAPOT_MATRIX_Lattice(teapot_latt, bunch)
print "Lattice=", matrix_lattice.getName(
), " matrix lattice length [m] =", matrix_lattice.getLength()

nodes = matrix_lattice.getNodes()
for node in nodes:
    if (isinstance(node, BaseMATRIX)):
        print "node =", node.getName(), " dict=", node.getParamsDict(
        )["matrix_parent_node"].getParamsDict()
    else:
        print "node =", node.getName(), " dict=", node.getParamsDict()

one_turn_matrix = matrix_lattice.getOneTurnMatrix()
print "=============one turn pyORBIT matrix for MATRIX lattice===="
printM(one_turn_matrix)

print "=== ring parameters ==="
ring_par_dict = matrix_lattice.getRingParametersDict()
Tkin = ring_par_dict["Ekin [GeV]"]
T = ring_par_dict["period [sec]"]
freq = ring_par_dict["frequency [Hz]"]
eta = ring_par_dict["eta"]
gamma_trans = ring_par_dict["gamma transition"]
Tkin_trans = ring_par_dict["transition energy [GeV]"]
alpha_p = ring_par_dict["momentum compaction"]
f_tune_x = ring_par_dict["fractional tune x"]
f_tune_y = ring_par_dict["fractional tune x"]
Tkin = 1.0
bunch = Bunch()
bunch.getSyncParticle().kinEnergy(Tkin)

matrix_lattice = TEAPOT_MATRIX_Lattice(teapot_latt,bunch)
print "Lattice=",matrix_lattice.getName()," matrix lattice length [m] =",matrix_lattice.getLength()

nodes = matrix_lattice.getNodes()
for node in nodes:
	if(isinstance(node, BaseMATRIX)):
		print "node =",node.getName()," dict=",node.getParamsDict()["matrix_parent_node"].getParamsDict()
	else:
		print "node =",node.getName()," dict=",node.getParamsDict()
	

one_turn_matrix = matrix_lattice.getOneTurnMatrix()
print "=============one turn pyORBIT matrix for MATRIX lattice===="
printM(one_turn_matrix)

print "=== ring parameters ==="
ring_par_dict = matrix_lattice.getRingParametersDict()
Tkin = ring_par_dict["Ekin [GeV]"]
T = ring_par_dict["period [sec]"]
freq = ring_par_dict["frequency [Hz]"]
eta = ring_par_dict["eta"]
gamma_trans = ring_par_dict["gamma transition"]
Tkin_trans = ring_par_dict["transition energy [GeV]"]
alpha_p = ring_par_dict["momentum compaction"] 
f_tune_x = ring_par_dict["fractional tune x"]
f_tune_y = ring_par_dict["fractional tune x"]
Пример #5
0
        loc = L + node.getLength() / 2
        #print("loc = {} period loc = {}".format(loc, loc-LL*period/12))
        period += 1
    L += node.getLength()
print(LL)
#-----------------------------------------------
matrix_lattice = TEAPOT_MATRIX_Lattice(lattice, b)

for matrixNode in matrix_lattice.getNodes():
    mt = matrixNode.getMatrix()
    if "mh" in matrixNode.getName():
        print("{}\n[{} {}]\n[{} {}]\n".format(matrixNode.getName(),
                                              mt.get(0, 0), mt.get(0, 1),
                                              mt.get(1, 0), mt.get(1, 1)))

mt = matrix_lattice.getOneTurnMatrix()
cos_phi_x = (mt.get(0, 0) + mt.get(1, 1)) / 2.0
cos_phi_y = (mt.get(2, 2) + mt.get(3, 3)) / 2.0
print("COS[MUX] ={}".format(cos_phi_x))
print("COS[MUY] ={}".format(cos_phi_y))

(muX0, arrPosAlphaX0, arrPosBetaX0) = matrix_lattice.getRingTwissDataX()
(muY0, arrPosAlphaY0, arrPosBetaY0) = matrix_lattice.getRingTwissDataY()

#print("tunes:\nQx={}\nQy".format(muX0[-1]/2/np.pi,muY0,[-1]/2/np.pi))
print("tunes:\nQx={}\nQy={}".format(muX0[-1][1], muY0[-1][1]))

svar, betax = np.transpose(arrPosBetaX0)
s_inter = np.linspace(svar[0], svar[-1], len(svar) * 2)
betax_inter = np.interp(s_inter, svar, betax, period=lattice.getLength() / 2)