apace.classes

Module Contents

Classes

Base

Abstract base for all element and lattice classes.

Element

Abstract base for all element classes.

Drift

A drift space element.

Dipole

A dipole element.

Quadrupole

A quadrupole element.

Sextupole

A sextupole element.

Octupole

An octupole element.

Lattice

Defines the order of elements in the accelerator.

class apace.classes.Base(name, length, info='')

Abstract base for all element and lattice classes.

Parameters
  • name (str) – The name of the object.

  • info (str, optional) – Additional information about the object.

Attributes

name :str

The name of the object.

info :str

Additional information about the object

parent_lattices :Set[Lattice]

All lattices which contain the object.

length

Length of the object (m).

Return type

float

Methods

__repr__()

Return repr(self).

__str__()

Return str(self).

class apace.classes.Element(name, length, info='')

Inherits: Base

Abstract base for all element classes.

Parameters
  • name (str) – The name of the element.

  • length (float) – The length of the element (m).

  • info (str, optional) – Additional information about the element.

Attributes

attribute_changed :apace.utils.Signal

Gets emitted when one of the attributes changes.

length

Length of the element (m).

Return type

float

Methods

_on_attribute_changed(element, attribute)
__repr__()

Return repr(self).

__str__()

Return str(self).

class apace.classes.Drift(name, length, info='')

Inherits: Element

A drift space element.

Parameters
  • name (str) – The name of the element.

  • length (float) – The length of the element (m).

  • info (str, optional) – Additional information about the element.

Attributes

attribute_changed :apace.utils.Signal

Gets emitted when one of the attributes changes.

length

Length of the element (m).

Return type

float

Methods

_on_attribute_changed(element, attribute)
__repr__()

Return repr(self).

__str__()

Return str(self).

class apace.classes.Dipole(name, length, angle, e1=0, e2=0, info='')

Inherits: Element

A dipole element.

Parameters
  • name (str) – Name of the element.

  • length (float) – Length of the element (m).

  • angle (float) – Deflection angle in rad.

  • e1 (float, optional) – Entrance angle in rad.

  • e2 (float, optional) – Exit angle in rad.

  • info (str, optional) – Additional information about the element.

Attributes

angle

Deflection angle (rad).

Return type

float

e1

Entrance angle (rad).

Return type

float

e2

Exit angle (rad).

Return type

float

radius

Radius of curvature (m).

Return type

float

k0

Geometric dipole strength or curvature of radius (m).

Return type

float

length

Length of the element (m).

Return type

float

Methods

_on_attribute_changed(element, attribute)
__repr__()

Return repr(self).

__str__()

Return str(self).

class apace.classes.Quadrupole(name, length, k1, info='')

Inherits: Element

A quadrupole element.

Parameters
  • name (str) – Name of the element.

  • length (float) – Length of the element (m).

  • k1 (float) – Geometric quadrupole strength (m^-2).

  • info (str, optional) – Additional information about the element.

Attributes

k1

Geometric quadrupole strength (m^-2).

Return type

float

length

Length of the element (m).

Return type

float

Methods

_on_attribute_changed(element, attribute)
__repr__()

Return repr(self).

__str__()

Return str(self).

class apace.classes.Sextupole(name, length, k2, info='')

Inherits: Element

A sextupole element.

Parameters
  • name (str) – Name of the element.

  • length (float) – Length of the element (m).

  • k1 (float) – Geometric quadrupole strength (m^-3).

  • info (str, optional) – Additional information about the element.

Attributes

k2

Geometric sextupole strength (m^-3).

Return type

float

length

Length of the element (m).

Return type

float

Methods

_on_attribute_changed(element, attribute)
__repr__()

Return repr(self).

__str__()

Return str(self).

class apace.classes.Octupole(name, length, k3, info='')

Inherits: Element

An octupole element.

Parameters
  • name (str) – Name of the element.

  • length (float) – Length of the element (m).

  • k3 (float) – Geometric quadrupole strength (m^-4).

  • info (str, optional) – Additional information about the element.

Attributes

k3

Geometric sextupole strength (m^-1).

Return type

float

length

Length of the element (m).

Return type

float

Methods

_on_attribute_changed(element, attribute)
__repr__()

Return repr(self).

__str__()

Return str(self).

class apace.classes.Lattice(name, children, info='')

Inherits: Base

Defines the order of elements in the accelerator.

Parameters
  • name (str) – Name of the lattice.

  • children (List[Union[Element, Lattice]]) – List of elements and sub-lattices.

  • info (str) – Additional information about the lattice.

Attributes

length_changed :apace.utils.Signal

Gets emitted when the length of lattice changes.

element_changed :apace.utils.Signal

Gets emitted when an attribute of an element within this lattice changes.

n_elements

The number of elements within this lattice.

length

Length of the lattice.

Return type

float

children

List of direct children (elements or sub-lattices) in physical order.

Return type

List[Base]

sequence

List of elements in physical order. (Flattend children)

Return type

List[Element]

indices

A dict which contains the a List of indices for each element. Can be thought of as inverse of sequence. Sub-lattices are associated with the list of indices of their first element.

Return type

Dict[Element, List[float]]

objects

A Mapping from names to the given Element or Lattice object.

Return type

Dict[str, Union[Element, Lattice]]

elements

Unordered set of all elements within this lattice.

Return type

Set[Element]

sub_lattices

Unordered set of all sub-lattices within this lattice.

Return type

Set[Lattice]

Methods

traverse_children() :staticmethod:

Returns iterator which traverses all children of a lattice.

_init_properties()

A recursive helper function to initialize the properties.

__getitem__(key)
__del__()
update_length()

Manually update the Length of the lattice (m).

_on_length_changed()
_on_element_changed(element, attribute)
print_tree()

Print the lattice as tree of objects. (Similar to unix tree command)

_print_tree( prefix='') :staticmethod:
from_file( location, file_format=None) :classmethod:

Creates a new Lattice from file at location (path or url). :param location: path-like or url-like string which locates the lattice file :type location: Union[AnyStr, Path] :param file_format str: File format of the lattice file :type file_format: str, optional (use file extension) :rtype Lattice

from_dict( data) :classmethod:

Creates a new Lattice object from a latticeJSON compliant dictionary.

as_file(path, file_format=None)
as_dict()

Serializes the Lattice object into a latticeJSON compliant dictionary.

__repr__()

Return repr(self).

__str__()

Return str(self).