Пример #1
0
def make6DEllipticalBeam(lattice_file,lattice_name):
    
    '''Constructs a coasting elliptic beam with Gaussian longitduinal distribution and stores it in a Synergia bunch.
    
    A lattice file is required, as Synergia constructs the bunch relative to the reference particle as specified in mad-x.
    
    Arguments:
        lattice_file - A .madx file which stores the lattice
        lattice_name - The sequence name within the madx file

     '''
    
    #import lattice and construct options object
    #load lattice
    lattice = synergia.lattice.MadX_reader().get_lattice(lattice_name,lattice_file)
    length = lattice.get_length()
    ref = lattice.get_reference_particle() #reference particle
    ds = 0.01
    #nsteps = int(length/ds) +1 #calculate # of steps to take per turn
    #nsteps_per_element = nsteps/len(lattice.get_elements()) #not this isn't using future division, so returns int
    nsteps_per_element = 10 #hardcoded for IOTA nl elements
    nsteps = len(lattice.get_elements())*nsteps_per_element


    name = 'lattice_1IO_NL_Center'
    order = 1
    outputdir = 'order_'+str(order)+'_'+name

    opts = workflow.make_opts(name, order, outputdir, nsteps, nsteps_per_element)
    opts.macro_particles=1000
    opts.emitx = 7.0e-6
    workflow.make_path(outputdir)

    #make lattice chef propagating
    latticework.make_chef(lattice)

    stepper = synergia.simulation.Independent_stepper_elements(lattice, opts.map_order, opts.steps_per_element)
    lattice_simulator = stepper.get_lattice_simulator()
    #lattice_simulator = synergia.simulation.Lattice_simulator(lattice,opts.map_order)


    #construct bunch array and write it to a textfile
    EllipticalBeam6D(opts)

    #read in the file and construct a synergia bunch
    particles_file = 'myBunch.txt'
    comm = synergia.utils.Commxx(True)
    bucket_length = lattice_simulator.get_bucket_length()
    bucket_length = 0.05 #potential workaround
    myBunch = read_bunch.read_bunch(particles_file, ref, opts.real_particles, bucket_length, comm, verbose=False)
    
    return opts, lattice, lattice_simulator, stepper, myBunch
    
Пример #2
0

#import lattice and construct options object
#load lattice
lattice = synergia.lattice.MadX_reader().get_lattice("iota", "/Users/ncook/Synergia_Tests/lattices/Iota6-6/lattice_2IO_nll.madx")
length = lattice.get_length()
ref = lattice.get_reference_particle() #reference particle
ds = 0.01
nsteps = int(length/ds) +1 #calculate # of steps to take per turn
nsteps_per_element = nsteps/len(lattice.get_elements()) #not this isn't using future division, so returns int

name = 'lattice_2IO_NL'
order = 1
outputdir = 'order_'+str(order)+'_'+name

opts = workflow.make_opts(name, order, outputdir, nsteps, nsteps_per_element)
opts.macro_particles=1000
opts.emitx = 1.0e-5
#workflow.make_path(outputdir)

lattice_simulator = synergia.simulation.Lattice_simulator(lattice,opts.map_order)

#construct bunch array and write it to a textfile
EllipticBeam6D.EllipticalBeam6D(opts)

#read in the file and construct a synergia bunch
particles_file = 'myBunch.txt'
comm = synergia.utils.Commxx(True)
bucket_length = lattice_simulator.get_bucket_length()
myBunch = read_bunch.read_bunch(particles_file, ref, opts.real_particles, bucket_length, comm, verbose=False)