예제 #1
0
def set_bunch(off,lattice,bunch):
	bunch.deleteAllParticles()
	x_offset = off[0]
	xp_offset = off[1]
	y_offset = off[2]
	yp_offset = off[3]

	matrix_lattice = TEAPOT_MATRIX_Lattice(lattice,bunch)
	(muX, arrPosAlphaX, arrPosBetaX) = matrix_lattice.getRingTwissDataX()
	(muY, arrPosAlphaY, arrPosBetaY) = matrix_lattice.getRingTwissDataY()
	(arrDispX,arrDispPrimeX) = matrix_lattice.getRingDispersionDataX()
	(arrDispY,arrDispPrimeY) = matrix_lattice.getRingDispersionDataY()

	alpax= arrPosAlphaX[0][1]
	betax = arrPosBetaX[0][1]

	alpay= arrPosAlphaY[0][1]
	betay = arrPosBetaY[0][1]

	# ini. 2D match distribution
	twissX = TwissContainer(alpha = alpax, beta = betax, emittance = emittance_x/2)
	twissY = TwissContainer(alpha = alpay, beta = betay, emittance = emittance_y/2)
	dist = KVDist2D(twissX,twissY)


	for i in range(NPIC):
		(x,xp,y,yp) = dist.getCoordinates()
		bunch.addParticle(x+x_offset,xp+xp_offset,y+y_offset,yp+yp_offset,0.0,0.0)
예제 #2
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()
        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:
                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()
            beamline[j].data['keyword'] = node.getName()
            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
        return beamline
예제 #3
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()
		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:
				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()
			beamline[j].data['keyword']=node.getName()
			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
		return beamline
예제 #4
0
lattice.readMAD("./lattice/sis18_inj.lat","SIS18_MID")
offset = 0.#70e-3

#============Set BPMs into lattice===============
length = round(lattice.getLength()/12,4)
for i in range(12):
	name = TeapotBPMSignalNode("BPM")
	addTeapotDiagnosticsNode(lattice, i*length, name)
#============Set BPMs into lattice===============


matrix_lattice = TEAPOT_MATRIX_Lattice(lattice,bunch)
(muX, arrPosAlphaX, arrPosBetaX) = matrix_lattice.getRingTwissDataX()
(muY, arrPosAlphaY, arrPosBetaY) = matrix_lattice.getRingTwissDataY()
(arrDispX,arrDispPrimeX) = matrix_lattice.getRingDispersionDataX()
(arrDispY,arrDispPrimeY) = matrix_lattice.getRingDispersionDataY()

alpax= arrPosAlphaX[0][1]
betax = arrPosBetaX[0][1]

alpay= arrPosAlphaY[0][1]
betay = arrPosBetaY[0][1]

#============add particles to beam===============
# ini. 2D match distribution
twissX = TwissContainer(alpha = alpax, beta = betax, emittance = emittance_x/2)
twissY = TwissContainer(alpha = alpay, beta = betay, emittance = emittance_y/2)
dist = KVDist2D(twissX,twissY)


for i in range(NPIC):
예제 #5
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