Esempio n. 1
0
    del lattice.turns[-1]
    for i in range(n_particles):
        x = b.x[i]
        xp = b.xp[i]
        y = b.y[i]
        yp = b.yp[i]
        phi_x = 0.31 * 6.28
        b.x[i] = x * np.cos(phi_x) + lattice.BETX * xp * np.sin(phi_x)
        b.xp[i] = -x * np.sin(phi_x) / lattice.BETX + xp * np.cos(phi_x)
        phi_y = 0.32 * 6.28
        b.y[i] = y * np.cos(phi_y) + lattice.BETY * yp * np.sin(phi_y)
        b.yp[i] = -y * np.sin(phi_y) / lattice.BETY + yp * np.cos(phi_y)

############################ NAFF  ##################################

tunes_x = naff(lattice.turns[0:10], vec_HostBunch.x, vec_HostBunch.xp)
tunes_y = naff(lattice.turns[0:10], vec_HostBunch.y, vec_HostBunch.yp)
fig, ax = create_plot(tunes_x,
                      tunes_y,
                      grid,
                      0,
                      colorbar=False,
                      resonance_diagram=False,
                      order=0)
#plt.show()

############################ FMA  ##################################

#tunes_x1, tunes_y1, tunes_x2, tunes_y2, tune_diffusion = FMA(lattice.turns[1:500], lattice.turns[500:1000])
#fig,ax=create_plot(tunes_x2,tunes_y2, grid, tune_diffusion, colorbar=True, resonance_diagram=True, order=4)
#plt.show()
  #lattice.write_ptx("LHC/lhc_no_bb")
  lattice.write_ptx("LHC/lhc_no_bb")
else:
  #lattice.read_ptx("LHC/lhc_no_bb")
  lattice.read_ptx("LHC/lhc_no_bb")

lattice.n_turns = 1000
lattice.norm_emit_x = 2e-6
#lattice.bunch_length=1e-3
lattice.norm_emit_y = 2e-6

n_particles=50
b=lattice.make_matched_bunch(n_particles)

lattice.collect_tbt_data = 1 # every 1 turn

lattice.bunch_energy_spread = 1e-4

lattice.track(b)

############################ DELTA-Z  ##################################

for i in range (n_particles):
  print 'Particle: ',i
  plt.plot(lattice.turns[:].z(i), lattice.turns[:].d(i))
plt.show()

############################ NAFF  ##################################

tunes = naff(lattice.turns[0:1000], vec_HostBunch.z, vec_HostBunch.d)
Esempio n. 3
0
n_particles = b.size()

lattice.track(b)

filename = 'tbt.dat'
tbt = [(b.x[0], b.xp[0], b.y[0], b.yp[0], b.z[0], b.d[0])
       for b in lattice.turns]
with open(filename, 'w') as outfile:
    for t in tbt:
        outfile.write("{} {} {} {} {} {}\n".format(t[0], t[1], t[2], t[3],
                                                   t[4], t[5]))

############################ NAFF  ##################################

tunes_x = naff(lattice.turns[0:lattice.n_turns],
               vec_HostBunch.x,
               vec_HostBunch.xp,
               second_half=True)
tunes_y = naff(lattice.turns[0:lattice.n_turns], vec_HostBunch.y,
               vec_HostBunch.yp)
fig, ax = create_plot(tunes_x, tunes_y, grid, resonance_diagram=False)
plt.show()

############################ FMA  ##################################

tunes_x1, tunes_y1, tunes_x2, tunes_y2, tune_diffusion = FMA(
    lattice.turns[0:3000], lattice.turns[7000:10000], second_half_x=True)
fig, ax = create_plot(tunes_x2,
                      tunes_y2,
                      diff_tunes=tune_diffusion,
                      colorbar=True,
                      resonance_diagram=True,
Esempio n. 4
0
#print lattice.sigma_x(), lattice.sigma_y()
#b,grid = cmp_grid (lattice.sigma_x(), lattice.sigma_x()*4, lattice.sigma_y(), lattice.sigma_y()*4,0.3,lattice)
#n_particles=b.size()
n_particles = 10
#b=HostBunch(n_particles)
b = lattice.make_matched_bunch(n_particles)
#for i in range (n_particles):
#    b.y[i]=0
#    b.yp[i]=0
#    b.d[i]=10e-5
lattice.track(b)

############################ FMA  ##################################
tunes_x = naff(lattice.turns[0:1000],
               vec_HostBunch.x,
               vec_HostBunch.xp,
               second_half=False)
tunes_y = naff(lattice.turns[0:1000],
               vec_HostBunch.y,
               vec_HostBunch.yp,
               second_half=False)
fig, ax = create_plot(tunes_x, tunes_y, 0)
plt.show()

#tunes_x1, tunes_y1, tunes_x2, tunes_y2, tune_diffusion = FMA(lattice.turns[0:500], lattice.turns[500:1000])
#fig,ax=create_plot(tunes_x2,tunes_y2, 0, tune_diffusion, colorbar=True, resonance_diagram=False, order=4)
#plt.show()

#particle_x=[lattice.turns[0].x[i] for i in range (n_particles)]
#particle_y=[lattice.turns[0].y[i] for i in range (n_particles)]
#fig,ax = create_plot (particle_x,particle_y,0,tune_diffusion,colorbar=True,resonance_diagram=False,order=4)