Exemple #1
0
    distType = "kv"
    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)
Exemple #2
0
        sizeX = 32
        sizeY = 4
        sizeZ = 4  # Number of longitudinal slices in the 2.5D solver
        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')
	b.addParticle(x, xp, y, yp, z, zp)

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
    ), " end=", node_pos_start + node.getLength()
    myaperturenode = TeapotApertureNode(1, 10, 18, position)
    node.addChildNode(myaperturenode, node.ENTRANCE)
    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
Exemple #5
0
    b.addParticle(x, xp, y, yp, z, zp)

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
teapot_latt = teapot.TEAPOT_Ring()
print "Read MAD."
teapot_latt.readMAD("MAD_Lattice/RealInjection/SNSring_pyOrbitBenchmark.LAT","RING")
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
Exemple #7
0
collimator = TeapotCollimatorNode(colllength, ma, density_fac, shape, radius, 0., 0., 0., 0., "Collimator 1")
addTeapotCollimatorNode(teapot_latt, 0.5, collimator)

#-------------------------------
#  Lattice is ready
#-------------------------------

nodes = teapot_latt.getNodes()
i = 0
for node in nodes:
	print i, " node=", node.getName()," s start,stop = %4.3f %4.3f "%teapot_latt.getNodePositionsDict()[node]
	print "There are ", node.getNumberOfBodyChildren()," child nodes."
	i=i+1

tunes = TeapotTuneAnalysisNode("tune_analysis")
addTeapotDiagnosticsNode(teapot_latt, 36.066, tunes)


#================Do some turns===========================================

teapot_latt.trackBunch(b, paramsDict)
teapot_latt.trackBunch(b, paramsDict)

for i in xrange(39):
	teapot_latt.trackBunch(b, paramsDict)
addTeapotStatLatsNodeSet(teapot_latt, "statlats")
addTeapotMomentsNodeSet(teapot_latt, "moments", 3)
print 'last turn'
teapot_latt.trackBunch(b, paramsDict)
b.dumpBunch("bunch_36.dat")