Exemplo n.º 1
0
def one_turn_map(coord_in, flag_ebe=False):

	# coord = np.array([x, px, y, py, sigma, delta])

	coord = coord_in
	
	npart = 1
	
	bunch=sixtracklib.CParticles(npart=npart, 
			p0c=p0c_eV,
			beta0 = beta0,
			gamma0 = gamma0)
	bunch.x+=coord[0]
	bunch.px+=coord[1]
	bunch.y+=coord[2]
	bunch.py+=coord[3]
	bunch.sigma+=coord[4]
	bunch.set_delta(coord[5])

	particles,ebe,tbt = machine.track_cl(bunch,nturns=1,elembyelem={True:True, False:None}[flag_ebe], turnbyturn=True)

	coord =  np.array([tbt.x[1][0], tbt.px[1][0], tbt.y[1][0], tbt.py[1][0], 
					tbt.sigma[1][0], tbt.delta[1][0]])

	if flag_ebe:
		return coord, ebe
	else:
		return coord
Exemplo n.º 2
0
def test_particle():
    bunch = sixtracklib.CParticles(npart=4)
    bunch.x[1] = 0.3
    bunch.y[2] = 0.2
    bunch.sigma[3] = 0.1
    assert len(bunch.partid) == 4
    assert bunch.sigma[3] == 0.1
Exemplo n.º 3
0
def test_track():
    fodo = sixtracklib.CBlock()
    fodo.add_Drift(length=1.5)
    fodo.add_Multipole(knl=[0.0, 0.001])
    fodo.add_Drift(length=1.3)
    fodo.add_Multipole(name='qd', knl=[0.0, -0.001])

    bunch = sixtracklib.CParticles(npart=2)
    bunch.x[0] = 0.3
    bunch.y[1] = 0.2

    particles, ebe, tbt = fodo.track_cl(bunch,
                                        nturns=1,
                                        elembyelem=True,
                                        turnbyturn=True)
    return fodo, particles, ebe, tbt
Exemplo n.º 4
0
                     phi=phi,
                     alpha=alpha,
                     Sig_11_0=Sig_11_0,
                     Sig_12_0=Sig_12_0,
                     Sig_13_0=Sig_13_0,
                     Sig_14_0=Sig_14_0,
                     Sig_22_0=Sig_22_0,
                     Sig_23_0=Sig_23_0,
                     Sig_24_0=Sig_24_0,
                     Sig_33_0=Sig_33_0,
                     Sig_34_0=Sig_34_0,
                     Sig_44_0=Sig_44_0)

bb = machine.bb_data_list[0]

bunch = sixtracklib.CParticles(npart=2, p0c=6.5e12)

x = 1e-3
px = 50e-3
y = 2e-3
py = 27e-3
sigma = 3.
delta = 2e-4

bunch.x = bunch.x * 0. + x
bunch.y = bunch.x * 0. + y
bunch.px = bunch.x * 0. + px
bunch.py = bunch.x * 0. + py
bunch.sigma = bunch.x * 0. + sigma
bunch.delta = bunch.x * 0. + delta
Exemplo n.º 5
0



npart = 10

# delta = np.linspace(0, 8e-4, npart)
# rpp = 1./(delta+1)
# pc_eV = p0c_eV/rpp
# gamma = np.sqrt(1. + (pc_eV/pmass_eV)**2)
# beta = np.sqrt(1.-1./gamma**2)
# rvv=beta/beta0
# psigma = pmass_eV*(gamma-gamma0)/(beta0*p0c_eV)

bunch=sixtracklib.CParticles(npart=npart, 
		p0c=p0c_eV,
		beta0 = beta0,
		gamma0 = gamma0)
bunch.x+=0.001
bunch.y+=0.002

bunch.set_delta(np.linspace(0, 8e-4, npart))

particles,ebe,tbt=machine.track_cl(bunch,nturns=512,elembyelem=None,turnbyturn=True)


import matplotlib.pyplot as pl
pl.close('all')
fig1 = pl.figure(1, figsize=(8*2,6))
fig1.set_facecolor('w')
spx = pl.subplot(2,2,1)
spy = pl.subplot(2,2,3, sharex=spx)
Exemplo n.º 6
0
import sys; sys.path.append('../')

import sixtracklib
machine = sixtracklib.CBlock()
machine.add_Drift(length=1.)

print('This works')
bunch=sixtracklib.CParticles(npart=1)
particles,ebe,tbt=machine.track_cl(bunch,nturns=1,elembyelem=True,turnbyturn=True)
bunch=sixtracklib.CParticles(npart=1)
particles,ebe,tbt=machine.track_cl(bunch,nturns=1,elembyelem=True,turnbyturn=True)
print('Done')

print('This gives segfault:')
bunch=sixtracklib.CParticles(npart=1)
particles,ebe,tbt=machine.track_cl(bunch,nturns=1,elembyelem=True,turnbyturn=True)
particles,ebe,tbt=machine.track_cl(bunch,nturns=1,elembyelem=True,turnbyturn=True)

print('This also gives segfault:')
bunch=sixtracklib.CParticles(npart=1)
particles,ebe,tbt=machine.track_cl(bunch,nturns=1,elembyelem=True,turnbyturn=True)
particles2,ebe,tbt=machine.track_cl(particles,nturns=1,elembyelem=True,turnbyturn=True)
Exemplo n.º 7
0
machine.add_Multipole(name='test_dip', knl=[1e-3], length=1., hxl=1e-3)

#from scipy.constants import c as c_light
pmass_eV = 938.272046e6
p0c_eV = 6500e9
gamma0 = np.sqrt(p0c_eV**2 + pmass_eV**2) / pmass_eV
beta0 = p0c_eV / np.sqrt(p0c_eV**2 + pmass_eV**2)

delta = 0.  #1e-3
rpp = 1. / (delta + 1)
pc_eV = p0c_eV / rpp
gamma = np.sqrt(1. + (pc_eV / pmass_eV)**2)
beta = np.sqrt(1. - 1. / gamma**2)
rvv = beta / beta0
psigma = pmass_eV * (gamma - gamma0) / (beta0 * p0c_eV)

bunch = sixtracklib.CParticles(npart=1,
                               p0c=p0c_eV,
                               beta0=beta0,
                               gamma0=gamma0,
                               delta=delta,
                               rvv=rvv,
                               rpp=rpp,
                               psigma=psigma)
bunch.x[0] = 0.3
bunch.y[0] = 0.2

particles, ebe, tbt = machine.track_cl(bunch,
                                       nturns=1,
                                       elembyelem=None,
                                       turnbyturn=True)