def readLattice(file_name, lattice_name): lattice = TEAPOT_Lattice("lattice") print "Generate Lattice using MADX (new) parser from .SEQ file" lattice.readMADX(file_name, lattice_name) lattice.setUseRealCharge(1) # change to + 1 for proton return lattice
def load_lattice(file_name, lattice_name, new_parser=False): lattice = TEAPOT_Lattice("lattice") if new_parser: print "Generate Lattice using MADX (new) parser from .SEQ file" lattice.readMADX(file_name, lattice_name) else: print "Generate Lattice using MAD parser from .LAT file" lattice.readMAD(file_name, lattice_name) lattice.setUseRealCharge(useCharge=1) return lattice
trackDict = {} trackDict["lostbunch"] = lostbunch trackDict["bunch"] = b lostbunch.addPartAttr("LostParticleAttributes") energy = 1 syncPart = b.getSyncParticle() 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(
Qx, Qy = 18.84, 18.73 #Qx,Qy = 18.88,18.8 #---------------------------------------------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")
#---------------------------------------------Bunch init--------------------------------------------- b = Bunch() total_macroSize = 4e+10 b.macroSize(total_macroSize) energy = 2 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.setUseRealCharge(useCharge=1) #----------------------------------------------- matrix_lattice = TEAPOT_MATRIX_Lattice(lattice, b) (muX0, arrPosAlphaX0, arrPosBetaX0) = matrix_lattice.getRingTwissDataX() (muY0, arrPosAlphaY0, arrPosBetaY0) = matrix_lattice.getRingTwissDataY() beamline0 = Optics().readtwiss_teapot(lattice, b) solve = EnvelopeSolver(beamline0) twiss0 = solve.match_twiss_matrix(12.5e-6, 12.5e-6, 0.0, 0.0) #----------------------------------------------- #---------------------------------------------Make a Teapot Lattice---------------------------------- print "INTRODUCE MISALIGNEMENT IN THE QUADRUPOLES"
total_macroSize = 1e+11 b.macroSize(total_macroSize) energy = 50 * 10**(-6) 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