def getLattice(lattice_length, n_parts): elem = teapot.DriftTEAPOT("a drift") elem.setLength(lattice_length) elem.setnParts(n_parts) teapot_lattice = teapot.TEAPOT_Lattice("teapot_lattice") teapot_lattice.addNode(elem) teapot_lattice.initialize() return teapot_lattice
def getLattice(lattice_length,n_parts,spaceChargeCalculator2p5D): elem = teapot.DriftTEAPOT("my_drift") elem.setLength(lattice_length) elem.setnParts(n_parts) teapot_lattice = teapot.TEAPOT_Lattice("teapot_lattice") teapot_lattice.addNode(elem) teapot_lattice.initialize() # we will put SC nodes as frequently as possible. # In this case one for each part of the Drift node sc_path_length_min = 0.00000001 scNodes_arr = scLatticeModifications.setSC2p5DAccNodes(teapot_lattice, sc_path_length_min,spaceChargeCalculator2p5D) return (teapot_lattice,scNodes_arr)
import sys from orbit.teapot import teapot from orbit.teapot import TEAPOT_Lattice from orbit.teapot import DriftTEAPOT from orbit.lattice import AccLattice, AccNode, AccActionsContainer from bunch import Bunch from orbit.utils.orbit_mpi_utils import bunch_orbit_to_pyorbit, bunch_pyorbit_to_orbit from orbit.injection import TeapotInjectionNode from orbit.injection import addTeapotInjectionNode from injection import InjectParts from injection import JohoTransverse, JohoLongitudinal, UniformLongDist print "Start." teapot_latt = teapot.TEAPOT_Lattice() print "Read MAD." teapot_latt.readMAD("MAD_Lattice/LATTICE", "RING") print "Lattice=", teapot_latt.getName( ), " length [m] =", teapot_latt.getLength(), " nodes=", len( teapot_latt.getNodes()) #====Injection aperature============ xmin = -0.050 xmax = 0.050 ymin = -0.050 ymax = 0.050 injectparams = (xmin, xmax, ymin, ymax) #=====set up bunch stuff============
from orbit.lattice import AccLattice, AccNode, AccActionsContainer from orbit.utils.orbit_mpi_utils import bunch_orbit_to_pyorbit, bunch_pyorbit_to_orbit from spacecharge import Boundary2D from orbit.space_charge.sc2p5d import scAccNodes, scLatticeModifications from spacecharge import SpaceChargeCalc2p5D from orbit.diagnostics import TeapotTuneAnalysisNode from orbit.diagnostics import addTeapotDiagnosticsNode from orbit.bunch_generators import TwissContainer, TwissAnalysis from orbit.bunch_generators import GaussDist3D print "Start." #=====Make a Teapot style lattice====== lattice = teapot.TEAPOT_Lattice() print "Read MAD." lattice.readMAD("SNSring_pyOrbitBenchmark.LAT", "RING") print "Lattice=", lattice.getName(), " length [m] =", lattice.getLength( ), " nodes=", len(lattice.getNodes()) #------------------------------ # Main Bunch init #------------------------------ n_particles = 100000 twissX = TwissContainer(alpha=0.0046902, beta=10.207, emittance=3.e-5) twissY = TwissContainer(alpha=0.056823, beta=10.639, emittance=3.e-5) twissZ = TwissContainer(alpha=0., beta=100000., emittance=0.008) dist = GaussDist3D(twissX, twissY, twissZ)
b = Bunch() b.mass(mass) b.macroSize(intensity / nParticles) b.getSyncParticle().kinEnergy(KE) for i in range(nParticles): (x, xp, y, yp) = distro.getCoordinates() z = (2 * random.random() - 1) * Lattice_Length zp = 0.0 b.addParticle(x, xp, y, yp, z, zp) #----------------------------------------------------------------------------- # Create Lattice #----------------------------------------------------------------------------- EnvLat = teapot.TEAPOT_Lattice("Envelope Solition Lattice") if RunParticleBunch: BLat = teapot.TEAPOT_Lattice("Bunch Test Lattice") def MakeUniformNodes(TLattice, elemNum, ElemLength, LenOfTune, x_tune, y_tune, LatType): """ This Function will make a Uniform lattice node and add the created node to the lattice """ if (elemNum < 10): index = "00" + str(elemNum) elif (elemNum < 100): index = "0" + str(elemNum)
zp = 0. b.addParticle(x,xp,y,yp,z,zp) #Print bunch data to file b.dumpBunch("initial.dat") paramsDict = {} paramsDict["bunch"] = b # lostbunch = Bunch() # lostbunch.addPartAttr("LostParticleAttributes") # paramsDict["lostbunch"] = lostbunch #----------------------------------------------------------------------------- # Create Lattice and Nodes #----------------------------------------------------------------------------- Lattice = teapot.TEAPOT_Lattice("Uniform Lattice Test") def MakeUniformNodes(TLattice, elemNum, ElemLength, LenOfTune, x_tune, y_tune, LatType): """ This Function will make a Uniform lattice node and add the created node to the lattice """ if(elemNum < 10): index = "00" + str(elemNum) elif(elemNum < 100): index = "0" + str(elemNum) else: index = str(elemNum) elem = teapot.UniLatTEAPOT("UniTest" + "_Elem_" + index) TLattice.addNode(elem)
LType = 1 elif (LatticeType == "RING"): Dispersion = betaX**2 * 2 * pi / Lattice_Length LType = 0 # LatList = [] # for i in range(Count): # if(i < 100 and i < 10): # tag = "00"+str(i) # elif(i < 100): # tag = "0"+str(i) # else: # tag = str(i) lat = teapot.TEAPOT_Lattice("Lattice_") # + tag) # LatList.append(lat) i = 1 # for i,lat in enumerate(LatList): for j in range(NodeCount): AddUniformNode(lat, j, Lattice_Length / NodeCount, LenOfTune, xTune, yTune, LType) # for i in range(LatCount): if EnvSolverNodes: ChildNode = BasicSolverNode() ChildNode.setDispersion(Dispersion) ChildNode.setDLength(0.0001) for node in lat.getNodes():