Exemplo n.º 1
0
    def getBunch(self, nParticles, twissX, twissY, twissZ, cut_off=-1.):
        """
		Returns the pyORBIT bunch with particular number of particles.
		"""
        (x0, xp0, y0, yp0, z0, dE0) = self.init_coords
        bunch = Bunch()
        self.bunch.copyEmptyBunchTo(bunch)
        macrosize = (self.beam_current * 1.0e-3 / self.bunch_frequency)
        macrosize /= (math.fabs(bunch.charge()) * self.si_e_charge)
        distributor = GaussDist3D(twissX, twissY, twissZ, cut_off)
        bunch.getSyncParticle().time(0.)
        for i in range(nParticles):
            (x, xp, y, yp, z, dE) = distributor.getCoordinates()
            bunch.addParticle(x + x0, xp + xp0, y + y0, yp + yp0, z + z0,
                              dE + dE0)
        nParticlesGlobal = bunch.getSizeGlobal()
        bunch.macroSize(macrosize / nParticlesGlobal)
        return bunch
Exemplo n.º 2
0
	def getBunch(self, nParticles, twissX, twissY, twissZ, cut_off = -1.):
		"""
		Returns the pyORBIT bunch with particular number of particles.
		"""
		(x0,xp0,y0,yp0,z0,dE0) = self.init_coords
		comm = orbit_mpi.mpi_comm.MPI_COMM_WORLD
		rank = orbit_mpi.MPI_Comm_rank(comm)
		size = orbit_mpi.MPI_Comm_size(comm)		
		data_type = mpi_datatype.MPI_DOUBLE		
		main_rank = 0		
		bunch = Bunch()
		self.bunch.copyEmptyBunchTo(bunch)		
		macrosize = (self.beam_current*1.0e-3/self.bunch_frequency)
		macrosize /= (math.fabs(bunch.charge())*self.si_e_charge)
		distributor = GaussDist3D(twissX,twissY,twissZ, cut_off)
		bunch.getSyncParticle().time(0.)	
		for i in range(nParticles):
			(x,xp,y,yp,z,dE) = distributor.getCoordinates()
			(x,xp,y,yp,z,dE) = orbit_mpi.MPI_Bcast((x,xp,y,yp,z,dE),data_type,main_rank,comm)
			if(i%size == rank):
				bunch.addParticle(x+x0,xp+xp0,y+y0,yp+yp0,z+z0,dE+dE0)
		nParticlesGlobal = bunch.getSizeGlobal()
		bunch.macroSize(macrosize/nParticlesGlobal)
		return bunch
Exemplo n.º 3
0
                        beta=TwissDataY0[2][0][1],
                        emittance=emity)
'''
if solve.success== True:
	twissX = TwissContainer(alpha = twiss_sc[0,1], beta = twiss_sc[0,0], emittance = emitx)
	twissY = TwissContainer(alpha = twiss_sc[0,3], beta = twiss_sc[0,2], emittance = emity)
else:
	twissX = TwissContainer(alpha = TwissDataX0[1][0][1], beta = TwissDataX0[2][0][1], emittance = emitx)
	twissY = TwissContainer(alpha = TwissDataY0[1][0][1], beta = TwissDataY0[2][0][1], emittance = emity)
	print("!!! WARNING, DISTRIBUTION ISNT MATCHED")

'''
twissZ = TwissContainer(alpha=0., beta=100000000., emittance=sigma_p)
distType = "gauss"
if distType == "gauss":
    dist = GaussDist3D(twissX, twissY, twissZ)
else:
    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 -----------------------------------------------------
Exemplo n.º 4
0
betaY = 2.0
betaZ = 3.0

emittX = 4. * 1.0e-6
emittY = 5. * 1.0e-6
emittZ = 6. * 1.0e-6

print " aplha beta emitt X=", alphaX, betaX, emittX
print " aplha beta emitt Y=", alphaY, betaY, emittY
print " aplha beta emitt Z=", alphaZ, betaZ, emittZ

twissX = TwissContainer(alphaX, betaX, emittX)
twissY = TwissContainer(alphaY, betaY, emittY)
twissZ = TwissContainer(alphaZ, betaZ, emittZ)

distGen = GaussDist3D(twissX, twissY, twissZ)
distGen = WaterBagDist3D(twissX, twissY, twissZ)
distGen = KVDist3D(twissX, twissY, twissZ)
n_parts = 10000
for i in range(n_parts):
    (x, xp, y, yp, z, dE) = distGen.getCoordinates()
    b.addParticle(x, xp, y, yp, z, dE)

b.compress()
syncPart = b.getSyncParticle()
syncPart.kinEnergy(TK)

# copy the initial bunch to another to track through TEAPOT Quad
b1 = Bunch()
b.copyBunchTo(b1)