Ejemplo n.º 1
0
 def fodo(k1, k2):
     """Create FODO lattice. k1 and k2 are the focusing strengths of the
     focusing (1st) and defocusing (2nd) quads, respectively.
     """
     # Instantiate elements
     lattice = TEAPOT_Lattice()
     drift1 = teapot.DriftTEAPOT('drift1')
     drift2 = teapot.DriftTEAPOT('drift2')
     drift_half1 = teapot.DriftTEAPOT('drift_half1')
     drift_half2 = teapot.DriftTEAPOT('drift_half2')
     qf = teapot.QuadTEAPOT('qf')
     qd = teapot.QuadTEAPOT('qd')
     qf_half1 = teapot.QuadTEAPOT('qf_half1')
     qf_half2 = teapot.QuadTEAPOT('qf_half2')
     qd_half1 = teapot.QuadTEAPOT('qd_half1')
     qd_half2 = teapot.QuadTEAPOT('qd_half2')
     # Set lengths
     half_nodes = (drift_half1, drift_half2, qf_half1, qf_half2, qd_half1,
                   qd_half2)
     full_nodes = (drift1, drift2, qf, qd)
     for node in half_nodes:
         node.setLength(L * fill_fac / 4)
     for node in full_nodes:
         node.setLength(L * fill_fac / 2)
     # Set quad focusing strengths
     for node in (qf, qf_half1, qf_half2):
         node.addParam('kq', +k1)
     for node in (qd, qd_half1, qd_half2):
         node.addParam('kq', -k2)
     # Create lattice
     if start == 'drift':
         lattice.addNode(drift_half1)
         lattice.addNode(qf)
         lattice.addNode(drift2)
         lattice.addNode(qd)
         lattice.addNode(drift_half2)
     elif start == 'quad':
         lattice.addNode(qf_half1)
         lattice.addNode(drift1)
         lattice.addNode(qd)
         lattice.addNode(drift2)
         lattice.addNode(qf_half2)
     # Other
     if reverse:
         lattice.reverseOrder()
     lattice.set_fringe(fringe)
     lattice.initialize()
     for node in lattice.getNodes():
         name = node.getName()
         if 'qf' in name:
             node.setTiltAngle(+angle)
         elif 'qd' in name:
             node.setTiltAngle(-angle)
     return lattice
Ejemplo n.º 2
0
syncPart.kinEnergy(energy)
EE = syncPart.kinEnergy()
print(EE)
#---------------------------------------------Make a Teapot Lattice----------------------------------
print "Generate Lattice."

lattice = TEAPOT_Lattice("lattice")
#lattice.readMADX("fodo_thin.seq","fodo")
lattice.readMADX("FODO_x6.seq", "fodo")
#lattice.readMADX("cryring.madx","cryring")
#lattice.readMADX("sis100_full_thin_fix.seq","sis100ring")
lattice.setUseRealCharge(useCharge=1)

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

for node in lattice.getNodes():
    if node.getLength() > 1.0:
        node.setnParts(int(node.getLength() // 1 + 1))

#------------------------------------------------------------------------------------------------------

matrix_lattice = TEAPOT_MATRIX_Lattice(lattice, b)

TwissDataX0, TwissDataY0 = matrix_lattice.getRingTwissDataX(
), matrix_lattice.getRingTwissDataY()

beta_x0 = np.transpose(TwissDataX0[-1])
beta_y0 = np.transpose(TwissDataY0[-1])

#---------------------------------------------------- ERRORS-------------------------------------------
# WE INTRODUCE MISALIGNEMENT IN THE QUADRUPOLES; dx, dy = HOR AND VER DISPLACEMENT OF QUADRUPOLES
Ejemplo n.º 3
0
paramsDict["errtype"] = "RotationError"
paramsDict["elementtype"] = "straight"
paramsDict["subtype"] = "YS"
paramsDict["sample"] = "Fixed"
paramsDict["angle"] = 0.1

setDict["elementtype"] = "quad"
setDict["ringline"] = "ring"

ESet = AddErrorSet(lattice, positioni, positionf, setDict, paramsDict)

z = 0.0
print "Start lattice, z = ", z

# set the number of sections in quads to the same as for ORBIT_MPI
for acc_elem in lattice.getNodes():
    z += acc_elem.getLength()
    print "Node = ", acc_elem.getName()," type = ", acc_elem.getType(),\
        " L = ", acc_elem.getLength(), " N child nodes = ",\
        acc_elem.getNumberOfChildren(), " z = ", z
    if (acc_elem.getType() == "quad teapot"):
        acc_elem.setnParts(5)

print "lattice length=", lattice.getLength()

# dump initial bunch for ORBIT_MPI input
bunch_pyorbit_to_orbit(lattice.getLength(), b, "bunch_input.dat")

#=====track bunch ============
ACC_TURNS = 1
print("Tracking.")
Ejemplo n.º 4
0
dist = KVDist2D(twissX,twissY)


for i in range(NPIC):
	(x,xp,y,yp) = dist.getCoordinates()
	bunch.addParticle(x+offset,xp,y,yp,0.0,0.0)
#============add particles to beam===============


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')
Ejemplo n.º 5
0
#---------------------------------------------Bunch init---------------------------------------------
print "Start."

b = Bunch()
energy = 1
syncPart = b.getSyncParticle()
syncPart.kinEnergy(energy)

#---------------------------------------------Make a Teapot COLD Lattice ---------------

print "Generate ideal cold Lattice."
lattice = TEAPOT_Lattice("lattice")
lattice.readMADX("sis100cold.seq", "sis100ring")
lattice.setUseRealCharge(useCharge=1)
[
    node.setnParts(10) for node in lattice.getNodes()
    if node.getType() in ["drift teapot", "quad teapot"]
]

# match cold lattice
bc = betaCorrection(lattice, b)
bc.matchTunes(qx0=Qx, qy0=Qy, quadsDict=qDict, A=0.01)

#---------------------------------------------Make a Teapot WARM Lattice--------------

print "Generate Lattice with warm quads."
latt = TEAPOT_Lattice("lattice")
latt.readMADX("sis100.madx", "sis100ring")
latt.setUseRealCharge(useCharge=1)
[
    node.setnParts(10) for node in latt.getNodes()
Ejemplo n.º 6
0
paramsDict["errtype"]     = "RotationError"
paramsDict["elementtype"] = "straight"
paramsDict["subtype"]     = "YS"
paramsDict["sample"]      = "Fixed"
paramsDict["angle"]       = 0.1

setDict["elementtype"] = "quad"
setDict["ringline"] = "ring"

ESet  = AddErrorSet(lattice, positioni, positionf, setDict, paramsDict)

z = 0.0
print "Start lattice, z = ", z

# set the number of sections in quads to the same as for ORBIT_MPI
for acc_elem in lattice.getNodes():
	z += acc_elem.getLength()
	print "Node = ", acc_elem.getName()," type = ", acc_elem.getType(),\
	    " L = ", acc_elem.getLength(), " N child nodes = ",\
	    acc_elem.getNumberOfChildren(), " z = ", z
	if(acc_elem.getType() == "quad teapot"):
		acc_elem.setnParts(5)

print "lattice length=",lattice.getLength()

# dump initial bunch for ORBIT_MPI input
bunch_pyorbit_to_orbit(lattice.getLength(), b, "bunch_input.dat")

#=====track bunch ============
ACC_TURNS = 1
print("Tracking.")
Ejemplo n.º 7
0
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



#------------------------------------------------------------------------------------------------------
'''
dict1 =lattice.getNodePositionsDict()
dict2 =latt.getNodePositionsDict()