-
Notifications
You must be signed in to change notification settings - Fork 4
Lattice
Sajid Ali edited this page Oct 19, 2022
·
1 revision
Lattice
describes the structure of the accelerator complex that we are simulating.
A Lattice
object can be created by reading in a Mad8/MadX file or a string as shown
in the above example. E.g.,
# construct a MadX reader object
reader = synergia.lattice.MadX_reader()
# read in the madx from a string
reader.parse(madx_string)
# or can read in from a madx file
reader.parse_file(madx_file)
# finally, extract the lattice from the named sequence or line
lattice = reader.get_lattice(sequence_name)
# (experimental) you may also extract a dynamic lattice from the reader
# a dynamic lattice keeps all the variables and expressions in the lattice
# element attributes, making it easy to adjust the lattice by tuning the
# variables
lattice = reader.get_dynamic_lattice(sequence_name)
Alternatively, a lattice object can also be created programmatically by appending
Lattice_element
objects to the lattice manually,
# lattice object needs a reference particle
ref_part = synergia.foundation.Reference_particle(charge, mass, energy)
# create a lattice object
lattice = synergia.lattice.Lattice(name, ref_part)
# create lattice elements
f = synergia.lattice.Lattice_element(type='quadrupole', name='f')
f.set_double_attribute('k1', 0.01)
o = synergia.lattice.Lattice_element(type='drift', name='o')
o.set_double_attribute('l', 1.0)
# (experimental) dynamic element attributes
d = synergia.lattice.Lattice_element(type='quadrupole', name='d')
d.set_double_attribute('k1', 'strength * 0.12')
# and append elements to the lattice
lattice.append(f)
lattice.append(o)
lattice.append(d)
lattice.append(o)
# (experimental) dynamic lattice
lattice.set_variable('strength', -0.01)