from PyHEADTAIL.particles.slicing import UniformBinSlicer
slicer = UniformBinSlicer(n_slices=64, n_sigma_z=2.)
ecloud = PyEC4PyHT.Ecloud(L_ecloud=machine.circumference / n_segments,
                          slicer=slicer,
                          Dt_ref=25e-12,
                          pyecl_input_folder='./drift_sim',
                          x_aper=x_aper,
                          y_aper=y_aper,
                          Dh_sc=Dh_sc,
                          init_unif_edens_flag=init_unif_edens_flag,
                          init_unif_edens=init_unif_edens,
                          N_mp_max=N_mp_max,
                          nel_mp_ref_0=nel_mp_ref_0)

# install ecloud in the machine
machine.install_after_each_transverse_segment(ecloud)

# setup transverse losses (to "protect" the ecloud)
import PyHEADTAIL.aperture.aperture as aperture
apt_xy = aperture.EllipticalApertureXY(x_aper=ecloud.cloudsim.chamb.x_aper,
                                       y_aper=ecloud.cloudsim.chamb.y_aper)
machine.one_turn_map.append(apt_xy)

# generate a bunch
bunch = machine.generate_6D_Gaussian_bunch(n_macroparticles=300000,
                                           intensity=1.5e11,
                                           epsn_x=epsn_x,
                                           epsn_y=epsn_y,
                                           sigma_z=.11)

# simulate
示例#2
0
                          accQ_y=20.)

ecloud = PyEC4PyHT.Ecloud(L_ecloud=machine.circumference / N_kicks,
                          slicer=slicer,
                          Dt_ref=25e-12,
                          pyecl_input_folder='./drift_sim',
                          x_aper=x_aper,
                          y_aper=y_aper,
                          Dh_sc=Dh_sc,
                          init_unif_edens_flag=init_unif_edens_flag,
                          init_unif_edens=init_unif_edens,
                          N_MP_ele_init=N_MP_ele_init,
                          N_mp_max=N_mp_max,
                          nel_mp_ref_0=nel_mp_ref_0,
                          B_multip=B_multip,
                          slice_by_slice_mode=False)

machine_whole_bunch.install_after_each_transverse_segment(ecloud)

t_start_bunch = time.mktime(time.localtime())
for ii in xrange(N_turns):
    print 'Turn', ii
    machine_whole_bunch.track(bunch)
t_end_bunch = time.mktime(time.localtime())

print '\n\n'
print 'Sliced %.2e s per turn' % (
    (t_end_slice - t_start_slice) / float(N_turns))
print 'Full bunch %.2e s per turn' % (
    (t_end_bunch - t_start_bunch) / float(N_turns))
init_unif_edens=2e11
N_MP_ele_init = 100000
N_mp_max = N_MP_ele_init*4.

nel_mp_ref_0 = init_unif_edens*4*x_aper*y_aper/N_MP_ele_init


ecloud = PyEC4PyHT.Ecloud(L_ecloud=machine.circumference/N_kicks, slicer=slicer, 
				Dt_ref=25e-12, pyecl_input_folder='../../PyECLOUD/testing/tests_PyEC4PyHT/drift_sim/',
				x_aper=x_aper, y_aper=y_aper, Dh_sc=Dh_sc,
				init_unif_edens_flag=init_unif_edens_flag,
				init_unif_edens=init_unif_edens, 
				N_mp_max=N_mp_max,
				nel_mp_ref_0=nel_mp_ref_0,
				B_multip=B_multip)
machine.install_after_each_transverse_segment(ecloud)

if show_movie:
	ecloud.save_ele_distributions_last_track = True
	ecloud.save_ele_potential_and_field = True
				
# generate a bunch 
bunch = machine.generate_6D_Gaussian_bunch(n_macroparticles=300000, intensity=1.15e11, epsn_x=epsn_x, epsn_y=epsn_y, sigma_z=0.2)


# replace first particles with HEADTAIL ones
bunch.x[:n_part_per_turn] = x[0,:]
bunch.xp[:n_part_per_turn] = xp[0,:]
bunch.y[:n_part_per_turn] = y[0,:]
bunch.yp[:n_part_per_turn] = yp[0,:]
bunch.z[:n_part_per_turn] = z[0,:]