Exemplo 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
Exemplo n.º 2
0
#lattice.addNode(elem1)
lattice.addNode(elem2)
#lattice.addNode(elem3)

#-----------------------------
# Set TEAPOT nodes parameters
#-----------------------------
elem1.setLength(1.0)
elem2.setLength(1.0)
elem3.setLength(1.0)

elem2.setnParts(5)
elem2.addParam("kq", -0.5)

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

transp_matrix = Matrix(6, 6)

matrixGenerator = MatrixGenerator()

matrixGenerator.initBunch(b)
lattice.trackBunch(b)
matrixGenerator.calculateMatrix(b, transp_matrix)


def printM(m):
    print "----matrix--- size=", m.size()
    for i in xrange(m.size()[0]):
        for j in xrange(m.size()[1]):
#lattice.addNode(elem1)
lattice.addNode(elem2)
#lattice.addNode(elem3)

#-----------------------------
# Set TEAPOT nodes parameters
#-----------------------------
elem1.setLength(1.0)
elem2.setLength(1.0)
elem3.setLength(1.0)

elem2.setnParts(5)
elem2.addParam("kq",-0.5)

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

transp_matrix = Matrix(6,6)

matrixGenerator = MatrixGenerator()

matrixGenerator.initBunch(b)
lattice.trackBunch(b)
matrixGenerator.calculateMatrix(b,transp_matrix)


def printM(m):
	print "----matrix--- size=",m.size()
	for i in xrange(m.size()[0]):
		for j in xrange(m.size()[1]):