print "Start."

teapot_latt = teapot.TEAPOT_Lattice()
print "Read MAD."
teapot_latt.readMAD("../MAD/LATTICE","RING")
ring_length = teapot_latt.getLength()
print "Lattice=",teapot_latt.getName()," ring length [m] =",ring_length

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]"]
Esempio n. 2
0
print("check sbends")
L = 0
period = 0
for node in lattice.getNodes():
    if node.getType() == "bend teapot":
        print("parameters. theta {} length {}".format(node.getParam("theta"),
                                                      node.getLength()))
        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()
Esempio n. 3
0
teapot_latt = teapot.TEAPOT_Lattice()
print "Read MAD."
teapot_latt.readMAD("../MAD/LATTICE", "RING")
ring_length = teapot_latt.getLength()
print "Lattice=", teapot_latt.getName(), " ring length [m] =", ring_length

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]"]
Esempio n. 4
0
	def readtwiss_teapot(self,lattice, bunch):
		
		beamline=Optics()
		matrix_lattice = TEAPOT_MATRIX_Lattice(lattice,bunch)

		(arrmuX, arrPosAlphaX, arrPosBetaX) = matrix_lattice.getRingTwissDataX()
		(arrmuY, arrPosAlphaY, arrPosBetaY) = matrix_lattice.getRingTwissDataY()

		(DispersionX, DispersionXP) = matrix_lattice.getRingDispersionDataX()
		(DispersionY, DispersionYP) = matrix_lattice.getRingDispersionDataY()

		nodes = lattice.getNodes()

		matrixNodes = matrix_lattice.getNodes()	
		idx = 0
		Md = np.identity(6) # Matrix of downstream element

		for node in nodes:
			for j in range(len(arrPosBetaX)):
				if (round(lattice.getNodePositionsDict()[node][1],4)==round(arrPosBetaX[j][0],4)):
					muX = arrmuX[j][1]
					betaX = arrPosBetaX[j][1]
					alphaX =  arrPosAlphaX[j][1]
					dx = DispersionX[j][1]
					dmux = DispersionXP[j][1]
					muY = arrmuY[j][1]
					betaY = arrPosBetaY[j][1]
					alphaY = arrPosAlphaY[j][1]
					dmuy = DispersionYP[j][1]

			if node.getType() == "quad teapot":
				k1l = node.getParam("kq")*node.getLength()
			else:


		    		if node.getType()=="multipole teapot":
			    		k1l = node.getParam("kls")[1]
				else:
					k1l = 0.0
			if node.getType() == "bend teapot":
				angle = node.getParam("theta")
			else:
				angle = 0.0
			beamline.add(1)
			j=len(beamline)-1
			beamline[j]=Twiss()
			name = node.getName()
			beamline[j].data['keyword']=name
			beamline[j].data['marker']=node.getType()
			beamline[j].data['s']=round(lattice.getNodePositionsDict()[node][1],4)
			beamline[j].data['L']=node.getLength()
			beamline[j].data['alfx']=alphaX
			beamline[j].data['alfy']=alphaY
			beamline[j].data['betx']=betaX
			beamline[j].data['bety']=betaY
			beamline[j].data['Dx']=dx
			beamline[j].data['Dpx']=dmux
			beamline[j].data['mux']=muX
			beamline[j].data['muy']=muY
			beamline[j].data['angle']=angle
			beamline[j].data['k1']=k1l

			matName = matrixNodes[idx].getName()

			M = np.identity(6)

			while name in matName and idx < len(matrixNodes)-1:
				matNode = matrixNodes[idx]
				matName = matNode.getName()
				mt = matNode.getMatrix()
				idx+=1
				for index in range(36):
					Md[index//6,index%6] = mt.get(index//6,index%6)

				M = np.dot(M[:],Md)

			beamline[j].data['map'] = M

		return beamline