Example #1
0
def plot_info(lattice):
	xAvg = []
	yAvg = []
	s = []
	#============Set BPMs into lattice===============
	length = round(lattice.getLength()/12,4)
	for i in range(12):
		name = TeapotBPMSignalNode("BPM")
		addTeapotDiagnosticsNode(lattice, i*length, name)

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

	lattice.trackBunch(bunch)
	lattice.trackBunch(bunch)

	#============Get the BPM signal===============
	nodes = lattice.getNodes()
	for i in range(1):
		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))
					#print node.getSignal()[0]*1e3, node.getSignal()[1]*1e3
					
	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(-20,20)

	ax1.set_ylabel('x [mm]')
	ax2.set_ylabel('xp [mm]')
	ax2.set_xlabel('s [m]')
Example #2
0
phase_space = []
for i in range(n_particles):
    particle = dist.getCoordinates()
    phase_space.append(particle)
    b.addParticle(*particle)

nParticlesGlobal = b.getSizeGlobal()
b.macroSize(total_macroSize / nParticlesGlobal)
print "Bunch Generated"

#----------------------------Add Tune Diagnostics -----------------------------------------------------

tunes = TeapotTuneAnalysisNode("tune_analysis")
tunes.assignTwiss(TwissDataX0[2][0][1], TwissDataX0[1][0][1], 0.0, 0.0,
                  TwissDataY0[2][0][1], TwissDataY0[1][0][1])
addTeapotDiagnosticsNode(lattice, 0, tunes)

print("Tune analysis node added")

#----------------------------Add Space Charge nodes----------------------------------------------------

sc_path_length_min = 0.000001
sizeX = 32  #number of grid points in horizontal direction
sizeY = 32  #number of grid points in vertical direction
sizeZ = 16  #number of longitudinal slices

calc2p5d = SpaceChargeForceCalc2p5D(sizeX, sizeY, sizeZ)
scLatticeModifications.setSC2p5DAccNodes(lattice, sc_path_length_min, calc2p5d)

print "SC nodes appied to the lattice"
total_macroSize=1.e+14
b.mass(0.93827231)
energy = 1.0 #Gev
#b.readBunch(distribution_file, n_particles)
print "Bunch Generated."
b.getSyncParticle().kinEnergy(energy)
nParticlesGlobal = b.getSizeGlobal()
b.macroSize(total_macroSize/nParticlesGlobal)

#-----------------------------------
# Add Tune Analysis node
#-----------------------------------

tunes = TeapotTuneAnalysisNode("tune_analysis")
tunes.assignTwiss(10.207, 0.0469, -0.05, 0.0061, 10.639, 0.056)
addTeapotDiagnosticsNode(lattice, 0, tunes)

#-----------------------------------
# Add Space Charge nodes
#-----------------------------------

nMacrosMin = 1
sc_path_length_min = 0.00000001
sizeX = 32   #number of grid points in horizontal direction
sizeY = 32   #number of grid points in vertical direction
sizeZ = 16   #number of longitudinal slices

# Make a boundary
bpoints = 128
bmodes = 10
xdim = 0.073
Example #4
0
emittance_x = 50e-6
emittance_y = 50e-6
		
bunch.mass(0.93827231)
bunch.getSyncParticle().kinEnergy(energy)
	
print "Generate Lattice."
lattice = TEAPOT_Lattice("no_sc_lattice")
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]
b = Bunch()
b.mass(0.93827231)
b.macroSize(macrosize)
energy = 1.0 #Gev
b.getSyncParticle().kinEnergy(energy)
b.readBunch("Bunches/controlbunch_600.dat", 1000)
bunch_pyorbit_to_orbit(teapot_latt.getLength(), b, "Bunches/controlbunch_600_ORBIT.dat")
#bunch_orbit_to_pyorbit(teapot_latt.getLength(), energy, "Bunches/Bm_KV_Uniform_1000",b)

tunes = TeapotTuneAnalysisNode("tune_analysis")
#tunes.assignTwiss(3.25011, 0.811013, 1.45074, -0.636723, 10.6922, -2.13656)
#addTeapotDiagnosticsNode(teapot_latt, 38.788, tunes)

tunes.assignTwiss(9.335, -1.826, -0.065, -0.03, 8.089, 0.497)
addTeapotDiagnosticsNode(teapot_latt, 51.035, tunes)


addTeapotMomentsNodeSet(teapot_latt, "moments", 3) 
addTeapotStatLatsNodeSet(teapot_latt, "statlats")

print "===========Lattice modified ======================================="
print "New Lattice=",teapot_latt.getName()," length [m] =",teapot_latt.getLength()," nodes=",len(teapot_latt.getNodes())

#print "============= nodes inside the region ==========="
#print all nodes around the specified position
	#for node in teapot_latt.getNodes():
#print "node=",node.getName()," type=",node.getType()," L=",node.getLength()

#=====track bunch ============
Example #6
0
collimator = TeapotCollimatorNode(colllength, ma, density_fac, shape, radius, 0., 0., 0., 0., "Collimator 1")
addTeapotCollimatorNode(teapot_latt, 0.5, collimator)

#-------------------------------
#  Lattice is ready
#-------------------------------

nodes = teapot_latt.getNodes()
i = 0
for node in nodes:
	print i, " node=", node.getName()," s start,stop = %4.3f %4.3f "%teapot_latt.getNodePositionsDict()[node]
	print "There are ", node.getNumberOfBodyChildren()," child nodes."
	i=i+1

tunes = TeapotTuneAnalysisNode("tune_analysis")
addTeapotDiagnosticsNode(teapot_latt, 36.066, tunes)


#================Do some turns===========================================

teapot_latt.trackBunch(b, paramsDict)
teapot_latt.trackBunch(b, paramsDict)

for i in xrange(39):
	teapot_latt.trackBunch(b, paramsDict)
addTeapotStatLatsNodeSet(teapot_latt, "statlats")
addTeapotMomentsNodeSet(teapot_latt, "moments", 3)
print 'last turn'
teapot_latt.trackBunch(b, paramsDict)
b.dumpBunch("bunch_36.dat")