print("tracking") x_space0 = [(b.x(i), b.px(i)) for i in range(n_particles)] bunchtwissanalysis = BunchTwissAnalysis() bunchtwissanalysis.analyzeBunch(b) Ex = bunchtwissanalysis.getEmittance(0) Ey = bunchtwissanalysis.getEmittance(1) x = bunchtwissanalysis.getCorrelation(0, 0) y = bunchtwissanalysis.getCorrelation(2, 2) emitX, emitY, xMean, yMean, turn = [Ex], [Ey], [x], [y], [0] n_turns = 250 for i in range(n_turns): lattice.trackBunch(b, trackDict) # if (i+1)%10==0 or i<9: bunchtwissanalysis.analyzeBunch(b) Ex = bunchtwissanalysis.getEmittance(0) Ey = bunchtwissanalysis.getEmittance(1) x = bunchtwissanalysis.getCorrelation(0, 0) y = bunchtwissanalysis.getCorrelation(2, 2) emitX.append(Ex) emitY.append(Ey) xMean.append(x) yMean.append(y) turn.append(i + 1) strIn = "_{}_{}_{}_{:.0e}".format(distType, n_particles, emitx, total_macroSize) #lostbunch.dumpBunch("lostbunch{}.dat".format(strIn))
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.")
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))), print "" printM(transp_matrix) print "Stop."
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') ax1.set_ylim(-100,100) ax2.set_ylim(-100,100)
x_space0 = [(b.x(i), b.px(i)) for i in range(n_particles)] print "Bunch Generated." b.dumpBunch("bunch_2p5D_turn0.dat") #----------------------------------- # Tracking #----------------------------------- paramsDict = {} paramsDict["bunch"] = b n_turns = 2 for i in range(n_turns): lattice.trackBunch(b, paramsDict) b.dumpBunch("bunch_turn" + str(n_turns) + ".dat") #----------------------------------- # Add Tune Analysis node #----------------------------------- #tunes = TeapotTuneAnalysisNode("tune_analysis") #tunes.assignTwiss(10.207, 0.0469, -0.05, 0.0061, 10.639, 0.056) #addTeapotDiagnosticsNode(lattice, 0, tunes) #----------------------------------- # Add Space Charge nodes #-----------------------------------