calcsbs = SpaceChargeCalcSliceBySlice2D(sizeX,sizeY,sizeZ) sc_path_length_min = 0.00000001 # Add the space charge solver to the lattice as child nodes sc_nodes = scLatticeModifications.setSC2p5DAccNodes(Lattice, sc_path_length_min, calcsbs) print ' Installed', len(sc_nodes), 'space charge nodes ...' #----------------------------------------------------- # Add tune analysis child node #----------------------------------------------------- parentnode_number = 97 parentnode = Lattice.getNodes()[parentnode_number] Twiss_at_parentnode_entrance = Lattice.getNodes()[parentnode_number-1].getParamsDict() tunes = TeapotTuneAnalysisNode("tune_analysis") if slicebyslice: tunes.assignTwiss(Twiss_at_parentnode_entrance['betax'], Twiss_at_parentnode_entrance['alphax'], Twiss_at_parentnode_entrance['etax'], Twiss_at_parentnode_entrance['etapx'], Twiss_at_parentnode_entrance['betay'], Twiss_at_parentnode_entrance['alphay']) addTeapotDiagnosticsNodeAsChild(Lattice, parentnode, tunes) if frozen: tunes.assignTwiss(*[Twiss_at_parentnode_entrance[k] for k in ['betax','alphax','etax','etapx','betay','alphay','etay','etapy']]) tunes.assignClosedOrbit(*[Twiss_at_parentnode_entrance[k] for k in ['orbitx','orbitpx','orbity','orbitpy']]) addTeapotDiagnosticsNodeAsChild(Lattice, parentnode, tunes) #---------------------------------------------------- # Prepare a bunch object to store particle coordinates #---------------------------------------------------- bunch_tmp = Bunch() bunch.copyEmptyBunchTo(bunch_tmp) bunch_tmp.addPartAttr('ParticlePhaseAttributes') #---------------------------------------------------- # Define twiss analysis and output dictionary
dist = KVDist3D(twissX, twissY, twissZ) phase_space = [] for i in range(n_particles): particle = dist.getCoordinates() phase_space.append(particle) b.addParticle(*particle) nParticlesGlobal = b.getSizeGlobal() b.macroSize(total_macroSize / nParticlesGlobal) print "Bunch Generated" #----------------------------Add Tune Diagnostics ----------------------------------------------------- tunes = TeapotTuneAnalysisNode("tune_analysis") tunes.assignTwiss(TwissDataX0[2][0][1], TwissDataX0[1][0][1], 0.0, 0.0, TwissDataY0[2][0][1], TwissDataY0[1][0][1]) addTeapotDiagnosticsNode(lattice, 0, tunes) print("Tune analysis node added") #----------------------------Add Space Charge nodes---------------------------------------------------- sc_path_length_min = 0.000001 sizeX = 32 #number of grid points in horizontal direction sizeY = 32 #number of grid points in vertical direction sizeZ = 16 #number of longitudinal slices calc2p5d = SpaceChargeForceCalc2p5D(sizeX, sizeY, sizeZ) scLatticeModifications.setSC2p5DAccNodes(lattice, sc_path_length_min, calc2p5d) print "SC nodes appied to the lattice"
total_macroSize=1.e+14 b.mass(0.93827231) energy = 1.0 #Gev #b.readBunch(distribution_file, n_particles) print "Bunch Generated." b.getSyncParticle().kinEnergy(energy) nParticlesGlobal = b.getSizeGlobal() b.macroSize(total_macroSize/nParticlesGlobal) #----------------------------------- # 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 #----------------------------------- nMacrosMin = 1 sc_path_length_min = 0.00000001 sizeX = 32 #number of grid points in horizontal direction sizeY = 32 #number of grid points in vertical direction sizeZ = 16 #number of longitudinal slices # Make a boundary bpoints = 128 bmodes = 10
node.addChildNode(myaperturenode, node.BODY) node.addChildNode(myaperturenode, node.EXIT) position += node.getLength() n += 1 #----------------------------------------------------- # Add tune analysis child node #----------------------------------------------------- parentnode_number = 0 parentnode = Lattice.getNodes()[parentnode_number] Twiss_at_parentnode_entrance = Lattice.getNodes()[parentnode_number - 1].getParamsDict() tunes = TeapotTuneAnalysisNode("tune_analysis") tunes.assignTwiss(Twiss_at_parentnode_entrance['betax'], Twiss_at_parentnode_entrance['alphax'], Twiss_at_parentnode_entrance['etax'], Twiss_at_parentnode_entrance['etapx'], Twiss_at_parentnode_entrance['betay'], Twiss_at_parentnode_entrance['alphay']) addTeapotDiagnosticsNodeAsChild(Lattice, parentnode, tunes) #---------------------------------------------- # Add the main bunch and lost particles bunch #---------------------------------------------- print '\nAdding main bunch ...' Intensity = 1.6e+13 m0 = mass_proton # protons ... mp_final = 500000 # total number of particles injected macrosize = Intensity / mp_final bunch = Bunch() setBunchParamsPTC(bunch)
total_macroSize = 1.e+14 b.mass(0.93827231) energy = 1.0 #Gev #b.readBunch(distribution_file, n_particles) print "Bunch Generated." b.getSyncParticle().kinEnergy(energy) nParticlesGlobal = b.getSizeGlobal() b.macroSize(total_macroSize / nParticlesGlobal) #----------------------------------- # 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 #----------------------------------- nMacrosMin = 1 sc_path_length_min = 0.00000001 sizeX = 32 #number of grid points in horizontal direction sizeY = 32 #number of grid points in vertical direction sizeZ = 16 #number of longitudinal slices # Make a boundary bpoints = 128 bmodes = 10
print "Lattice=",teapot_latt.getName()," length [m] =",teapot_latt.getLength()," nodes=",len(teapot_latt.getNodes()) b = Bunch() b.mass(0.93827231) b.macroSize(macrosize) energy = 1.0 #Gev b.getSyncParticle().kinEnergy(energy) b.readBunch("Bunches/controlbunch_600.dat", 1000) bunch_pyorbit_to_orbit(teapot_latt.getLength(), b, "Bunches/controlbunch_600_ORBIT.dat") #bunch_orbit_to_pyorbit(teapot_latt.getLength(), energy, "Bunches/Bm_KV_Uniform_1000",b) tunes = TeapotTuneAnalysisNode("tune_analysis") #tunes.assignTwiss(3.25011, 0.811013, 1.45074, -0.636723, 10.6922, -2.13656) #addTeapotDiagnosticsNode(teapot_latt, 38.788, tunes) tunes.assignTwiss(9.335, -1.826, -0.065, -0.03, 8.089, 0.497) addTeapotDiagnosticsNode(teapot_latt, 51.035, tunes) addTeapotMomentsNodeSet(teapot_latt, "moments", 3) addTeapotStatLatsNodeSet(teapot_latt, "statlats") print "===========Lattice modified =======================================" print "New Lattice=",teapot_latt.getName()," length [m] =",teapot_latt.getLength()," nodes=",len(teapot_latt.getNodes()) #print "============= nodes inside the region ===========" #print all nodes around the specified position #for node in teapot_latt.getNodes(): #print "node=",node.getName()," type=",node.getType()," L=",node.getLength() #=====track bunch ============