bunch.addParticle(x + offset, xp, y, yp, 0.0, 0.0)
#============add particles to beam===============

xAvg = []
yAvg = []
s = []

#============Get BPMs signal===============
nodes = lattice.getNodes()
for i in range(1):
    lattice.trackBunch(bunch)
    for node in nodes:
        if node.getType() == "monitor":
            xAvg.append(node.getParam("xAvg"))
            yAvg.append(node.getParam("yAvg"))
            s.append(lattice.getNodePositionsDict()[node][0] +
                     lattice.getLength() * (i))

#======================plot===============
fig, (ax1, ax2) = plt.subplots(2, sharex='col')

ax1.plot(array(s), array(xAvg) * 1e3, '-rx')
ax2.plot(array(s), array(yAvg) * 1e3, '-bx')

ax1.set_ylim(-100, 100)
ax2.set_ylim(-100, 100)

ax1.set_ylabel('x [mm]')
ax2.set_ylabel('y [mm]')
ax2.set_xlabel('s [m]')
예제 #2
0

xAvg = []
yAvg = []
s = []


#============Get the BPM signal===============
nodes = lattice.getNodes()
for i in range(10):
	lattice.trackBunch(bunch)
	for node in nodes:
			if node.getType()=="BPMSignal":
				xAvg.append(node.getSignal()[0])
				yAvg.append(node.getSignal()[1])
				s.append(lattice.getNodePositionsDict()[node][0]+lattice.getLength()*(i))
#============Get the BPM signal===============

#======================plot====================
fig, (ax1, ax2) = plt.subplots(2, sharex='col')

ax1.plot(array(s),array(xAvg)*1e3, '-rx')
ax2.plot(array(s),array(yAvg)*1e3, '-bx')

ax1.set_ylim(-100,100)
ax2.set_ylim(-100,100)

ax1.set_ylabel('x [mm]')
ax2.set_ylabel('y [mm]')
ax2.set_xlabel('s [m]')
예제 #3
0
lattice = TEAPOT_Lattice("lattice")
lattice.readMAD("/home/laptop/Documents/Scripts/FODO_thick.lat","fodo")
lattice.setUseRealCharge(useCharge = 1)
'''
#---------------------------------------------Make a Teapot Lattice----------------------------------
print "Generate Lattice."

latt = TEAPOT_Lattice("lattice")
#latt.readMADX("/home/laptop/Documents/Scripts/FODO_thick.seq","fodo")
latt.readMADX("cryring.madx","cryring")
latt.setUseRealCharge(useCharge = 1)

#---------------------------------------------SPLIT LONG ELEMENTS--------------------------------------

d =latt.getNodePositionsDict()

for node in latt.getNodes():
	L =node.getLength()
	val = d[node]
	print node.getName(),val,L, val[0]/2+val[-1]/2, val[0]+L/2
	node.setnParts(10)

#for key,val in sorted(d.items(),reverse=False,key=lambda x: x[1][0]):
#	L =key.getLength()
#	print key.getName(),val, L, val[0]/2+val[-1]/2, val[0]+L/2



#------------------------------------------------------------------------------------------------------
'''