pyaml.common.element#

Base classes for configured accelerator and lattice elements.

Functions

set_repr_options([max_items, max_depth, ...])

Configure the limits used by PyAML object representations.

Classes

Element(name[, lattice_names, description])

Base class for an element in a physical or simulated lattice.

ElementConfigModel(*, name[, description, ...])

Base class for element configuration.

ReprOptions([max_items, max_depth, max_length])

Limits applied to PyAML object representations.

class pyaml.common.element.Element(name, lattice_names=None, description=None)#

Bases: object

Base class for an element in a physical or simulated lattice.

Parameters:
  • name (str) – Unique element name.

  • lattice_names (str or None, optional) –

    Lattice element selector associated with this element. Defaults to name when omitted. A pyAML element can be associated to several lattice elements.

    Supported syntax of lattice_names:
    list(name,[name]) : Lattice element names
    [name]@idx[,idx] : Lattice element indices in the subset formed by name.
    [name]#start_idx..end_idx : Lattice element range in the subset formed by name.

    In the above syntax, if the name is not specficied, the whole set of lattice element is used for indexing. name refers to the FamName of the lattice elements, or to the attribute configured in the simulator linker when one is used.

  • description (str or None, optional) – Human-readable element description.

Attributes

name

Return the element name.

lattice_names

Return the lattice selector associated with the element.

description

Return the element description, if one is configured.

peer

Return the simulator or control system attached to the element.

Methods

get_name()

Return the element name.

get_lattice_names()

Return the lattice selector associated with the element.

get_description()

Return the element description, if available.

set_energy()

Set the beam energy used by this element, if supported.

set_mcf()

Set the momentum compaction factor, if supported.

set_harmonic()

Set the RF harmonic number, if supported.

check_peer()

Raise an error if the element is not attached to a peer.

attached_to()

Return a human-readable description of the attached peer.

post_init()

Perform post-construction initialization after attachment.

attached_to()#

Return a human-readable description of the attached peer.

Returns:

str – Peer type and name, or "None" when unattached.

Return type:

str

check_peer()#

Raise an error if the element is not attached to a peer.

Raises:

PyAMLException – If the element is not attached to a simulator or control system.

get_description()#

Return the element description, if available.

get_lattice_names()#

Return the lattice selector associated with the element.

get_name()#

Return the element name.

post_init()#

Perform post-construction initialization after attachment.

Base elements do not require additional initialization.

set_energy(E)#

Set the beam energy used by this element, if supported.

Parameters:

E (float) – Beam energy.

set_harmonic(h)#

Set the RF harmonic number, if supported.

Parameters:

h (int) – Number of RF buckets per revolution.

set_mcf(alphac)#

Set the momentum compaction factor, if supported.

Parameters:

alphac (float) – Momentum compaction factor.

property description: str | None#

Return the element description, if one is configured.

property lattice_names: str#

Return the lattice selector associated with the element.

property name: str#

Return the element name.

property peer: ElementHolder#

Return the simulator or control system attached to the element.

class pyaml.common.element.ElementConfigModel(*, name, description=None, lattice_names=None)#

Bases: BaseModel

Base class for element configuration.

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

  • description (str, optional) – Human-readable description of the element.

  • lattice_names (str or None, optional) – The name(s) of the associated element(s) in the lattice. By default, the PyAML element name is used. lattice_name accept the following syntax: - list(name,[name]) : Element names - [name]@idx[,idx] : Element indices in the subset formed by name. - [name]#start_idx..end_idx : Element range in the subset formed by name. In the above syntax, if the name is not specficied, the whole set of lattice element is used for indexing. name refers to the FamName of the lattice elements, or to the attribute configured in the simulator linker when one is used.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class pyaml.common.element.ReprOptions(max_items=3, max_depth=2, max_length=800)#

Bases: object

Limits applied to PyAML object representations.

pyaml.common.element.set_repr_options(max_items=None, max_depth=None, max_length=None)#

Configure the limits used by PyAML object representations.

Passing no arguments returns the current options. Every supplied value must be a positive integer.