示例#1
0
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.")
for i in range(ACC_TURNS):
    lattice.trackBunch(b)
    print "Turn ", i

# dump ORBIT_MPI bunch to compare results
bunch_pyorbit_to_orbit(lattice.getLength(), b, "bunch_output.dat")

print("STOP.")
示例#2
0
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

setDict = {}
paramsDict = {}
positioni = 0.0
positionf = lattice.getLength()

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

paramsDict["errtype"] = "FieldError"
paramsDict["subtype"] = "QuadField"

paramsDict["sample"] = "Gaussian"
paramsDict["fracerr"] = 0.012
paramsDict["mean"] = 0.0
paramsDict["sigma"] = 1.0

ESet = AddErrorSet(lattice,
                   positioni,
                   positionf,
示例#3
0
energy = 11.4e-3 # Gev
		
		
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]
示例#4
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]):
            print("(%1d,%1d)= % 6.5e " % (i, j, m.get(i, j))),
示例#5
0
from orbit.teapot import TEAPOT_Lattice
from spacecharge import SpaceChargeCalc2p5D
from spacecharge import Boundary2D

from orbit.utils.orbit_mpi_utils import bunch_pyorbit_to_orbit, bunch_orbit_to_pyorbit
from orbit.space_charge.sc2p5d import scAccNodes, scLatticeModifications

print "Start."
#------------------------------
#Make a Teapot Lattice
#------------------------------
print "Generate Lattice."
lattice = TEAPOT_Lattice("sc_lattice")
lattice.readMAD("../LATTICES/Q_0p125.LAT", "FODO")

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

#------------------------------
#Bunch init
#------------------------------
b = Bunch()
print "Read Bunch."
runName = "KV_Ellipse_5e12_1"
energy = 1.0  #Gev
b.mass(0.93827231)
b.macroSize(5.0e+7)

# get initial bunch from ORBIT_MPI input
bunch_orbit_to_pyorbit(lattice.getLength(), energy,
                       "../DISTRIBUTIONS/Bm_KV_Ellipse", b)
#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]):
			print ("(%1d,%1d)= % 6.5e "%(i,j,m.get(i,j))),
示例#7
0
b.macroSize(macro_size)

energy = 1.0  #Gev
b.getSyncParticle().kinEnergy(energy)

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

print "Generate Lattice."
lattice = TEAPOT_Lattice("rcs_lattice")
lattice.readMAD(
    "./lattice_data/rcslat_6450.6420_woQMBMfringe_woMKC_wLeakFld.foiltofoil.lat",
    "RING")

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

quads = lattice.getNodesOfClass(QuadTEAPOT)
rfs = lattice.getNodesOfClass(RingRFTEAPOT)
bends = lattice.getNodesOfClass(BendTEAPOT)
print "debug N quads =", len(quads)
print "debug N RFs   =", len(rfs)
print "debug N bends =", len(bends)

#---- this is a printing of the quads' parameters
#---- User can change these parameters if he/she wants to
#---- by using setParam("name_of_param",value_of_param)
for quad in quads:
    print "debug quad=", quad.getName(), " kq=", quad.getParam("kq")
"""
#if user want to generagte the bunch by himself
#============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]')

show()
示例#9
0
syncPart = b.getSyncParticle()
syncPart.kinEnergy(energy)
EE = syncPart.kinEnergy()
print(EE)
#---------------------------------------------Bunch init---------------------------------------------

print "Generate Lattice."
#---------------------------------------------Make a Teapot 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)
#-----------------------------------------------
LL = lattice.getLength()
print("check the quads")
#L = 0
#for node in lattice.getNodes():
#	if node.getType() == "quad teapot":
#		print("parameters. kq {} length {}".format(node.getParam("kq"),node.getLength()))
#		print(L+node.getLength()/2)
#	L+=node.getLength()

print("check sbends")
L = 0
period = 0
for node in lattice.getNodes():
    if node.getType() == "bend teapot":
        print("parameters. theta {} length {}".format(node.getParam("theta"),
                                                      node.getLength()))
示例#10
0
b.macroSize(macro_size)

energy = 1.0 #Gev
b.getSyncParticle().kinEnergy(energy)

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

print "Generate Lattice."
lattice = TEAPOT_Lattice("sc_lattice")
lattice.readMAD("./LATTICES/Q_0p125.LAT","FODO")
#lattice.readMAD("./LATTICES/TEST_SC_LATTICE.LAT","FODO")

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


"""
#if user want to generagte the bunch by himself
r_bunch = 0.05
l_bunch = lattice.getLength()
x_offset = 0.04
y_offset = 0.00
count = 0
while(count < nMaxMacroParticles):
	x = r_bunch*2.0*(0.5-random.random())
	y = r_bunch*2.0*(0.5-random.random())
	z = l_bunch*2.0*(0.5-random.random())
	if(x**2+y**2 < r_bunch**2):
		b.addParticle(x+x_offset,0.,y+y_offset,0.,z,0.)
示例#11
0
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.")
for i in range(ACC_TURNS):
	lattice.trackBunch(b)
	print "Turn ",i

# dump ORBIT_MPI bunch to compare results
bunch_pyorbit_to_orbit(lattice.getLength(), b, "bunch_output.dat")

print("STOP.")
b.getSyncParticle().kinEnergy(energy)
#---------------------------------------------Bunch init---------------------------------------------

print "Generate Lattice."
#---------------------------------------------Make a Teapot Lattice----------------------------------
lattice = TEAPOT_Lattice("lattice")
lattice.readMAD("sis18.lat","SIS18")
#---------------------------------------------Make a Teapot Lattice----------------------------------

print "INTRODUCE MISALIGNEMENT IN THE QUADRUPOLES"
#---------------------------------------------ORBIT ERRORS-------------------------------------------
# WE INTRODUCE MISALIGNEMENT IN THE QUADRUPOLES; dx, dy = HOR AND VER DISPLACEMENT OF QUADRUPOLES
setDict = {}
paramsDict = {}
positioni = 0.0
positionf = lattice.getLength()
paramsDict["errtype"]  = "StraightError"
paramsDict["subtype"]  = "TransDisp"
paramsDict["sample"]      = "Uniform"
paramsDict["maximum"]        = 0.5
paramsDict["minimum"]       = 0.0
paramsDict["dx"]       = 0.005
paramsDict["dy"]       = 0.007

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

ESet  = AddErrorSet(lattice, positioni, positionf, setDict, paramsDict, seed_value=50)
# ESet  = AddErrorSet(lattice, positioni, positionf, setDict, paramsDict) # Random
#---------------------------------------------ORBIT ERRORS-------------------------------------------
示例#13
0
from orbit.teapot import TEAPOT_Lattice
from spacecharge import SpaceChargeCalc2p5D
from spacecharge import Boundary2D

from orbit.utils.orbit_mpi_utils import bunch_pyorbit_to_orbit, bunch_orbit_to_pyorbit
from orbit.space_charge.sc2p5d import scAccNodes, scLatticeModifications

print "Start."
#------------------------------
#Make a Teapot Lattice
#------------------------------
print "Generate Lattice."
lattice = TEAPOT_Lattice("sc_lattice")
lattice.readMAD("../LATTICES/Q_0p125.LAT","FODO")

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

#------------------------------
#Bunch init
#------------------------------
b = Bunch()
print "Read Bunch."
runName = "KV_Ellipse_5e12_1"
energy = 1.0 #Gev
b.mass(0.93827231)
b.macroSize(5.0e+7)

# get initial bunch from ORBIT_MPI input
bunch_orbit_to_pyorbit(lattice.getLength(), energy, "../DISTRIBUTIONS/Bm_KV_Ellipse",b)

#make 2.5D space charge calculator