accml_lib.custom.pyat_simulator package

Subpackages

Submodules

accml_lib.custom.pyat_simulator.accelerator_simulator module

class accml_lib.custom.pyat_simulator.accelerator_simulator.PyATAcceleratorSimulator(*, at_lattice)[source]

Bases: AcceleratorSimulatorInterface

Factory class for creating proxies for accelerator elements.

This class provides an interface for retrieving accelerator element proxies from a given lattice structure.

Warning

Currently, this implementation uses an at_lattice directly, which should be revised when a proper lattice model becomes available.

Todo

Revisit name: still a proxy? The element proxy currently not necessary`?

Leave addon element proxy e.g. for handling combined function magnets

get(element_id)[source]

Retrieve an element proxy based on the given element ID.

Parameters:

element_id (str) – The ID of the element to retrieve.

Returns:

The proxy object for the requested element.

Return type:

ElementProxy

Raises:

ValueError – If the element is not found in the lattice.

static get_element_id_of_host(element_id)[source]

Derives the host element ID from the provided element ID.

Parameters:

element_id (str) – The ID of the element.

Returns:

The ID of the host element.

Return type:

str

Raises:

ValueError – If the element ID cannot be processed.

get_tune()[source]
Return type:

Tune

Todo

review who else needs these data

instantiate_addon_proxy(sub_lattice, *, element_id, host_element_id)[source]

Instantiates the correct proxy for the given sub lattice and element ID.

Parameters:
  • sub_lattice – The AT sub lattice containing the element.

  • element_id – The ID of the element.

  • host_element_id – The ID of the host element.

Returns:

The proxy instance for the element.

Return type:

KickAngleCorrectorProxy

Raises:

ValueError – If the element ID type is unsupported.

accml_lib.custom.pyat_simulator.element_proxies module

class accml_lib.custom.pyat_simulator.element_proxies.AddOnElementProxy(obj, *, element_id, host_element_id)[source]

Bases: ElementProxy

Proxy for an element whose updates are relayed to another element.

host_element_id

ID of the host element.

update(property_id, value, element_data)[source]

Update element properties dynamically based on property_id.

Parameters:
  • property_id (str) – The property to update.

  • value – The value to set.

  • element_data – Element-specific data required for update.

Raises:

ValueError – If an unknown property is specified.

Todo: is that Liaison management?

the inverse way

class accml_lib.custom.pyat_simulator.element_proxies.ElementProxy(obj, *, element_id, name=None)[source]

Bases: ElementInterface

Proxy class for an accelerator element to handle interactions and updates.

Parameters:
_obj

The underlying accelerator element.

element_id

Identifier for the element.

on_update_finished

Event triggered upon update completion.

on_changed_value

Event triggered upon value change.

get_name()[source]
Return type:

str

peek(property_id)[source]
Return type:

float

Parameters:

property_id (str)

peek_frequency()[source]
peek_kick(property_id)[source]
Parameters:

property_id (str)

peek_main_strength(property_id)[source]
Parameters:

property_id (str)

async update(property_id, value)[source]

Update element properties dynamically based on property_id.

Parameters:
  • property_id (str) – The property to update.

  • value (object) – The value to set.

  • element_data – Element-specific data required for update.

Raises:

ValueError – If an unknown property is specified.

Todo: is that Liaison management?

the inverse way

update_roll(*, roll)[source]

Todo: implement setting roll Set the roll of the element

async update_shift(*, dx=None, dy=None)[source]

Update the element shift.

Parameters:
  • dx – Shift in x-direction.

  • dy – Shift in y-direction.

Raises:

AssertionError – If both dx and dy are None.

class accml_lib.custom.pyat_simulator.element_proxies.KickAngleCorrectorProxy(obj, *, correction_plane, **kwargs)[source]

Bases: AddOnElementProxy

Proxy for handling kick angle corrections in a specific plane.

correction_plane

Specifies whether correction is horizontal or vertical.

peek(property_id)[source]
Return type:

float

Parameters:

property_id (str)

async update(property_id, value, element_data)[source]

Handle updates for the corrector element.

Parameters:
  • property_id (str) – The property to update (should be ‘im’).

  • value – The value to set.

  • element_data – Element-specific conversion data.

Raises:

ValueError – If an unknown property is specified.

async update_kick(*, kick_x=None, kick_y=None, element_data)[source]

Update kick angles for the corrector element.

Parameters:
  • kick_x – Horizontal kick angle.

  • kick_y – Vertical kick angle.

  • element_data – Element-specific conversion data.

Todo: review if this code is still neede

accml_lib.custom.pyat_simulator.element_proxies.estimate_shift(element, eps=1e-08)[source]

Todo: get it upstreamed into pyat todo: currently this is very pyat specific element update Estimate the shift values for an element.

Parameters:
  • element – The element to estimate shift for.

  • eps – Tolerance value for consistency check.

Returns:

Computed shift values.

Return type:

np.ndarray

Raises:

AssertionError – If standard deviation exceeds the tolerance.

accml_lib.custom.pyat_simulator.element_proxies.manipulate_kick(kick_angles, kick_x=None, kick_y=None)[source]
Return type:

Tuple[float, float]

Parameters:

kick_angles (Tuple[float, float])

accml_lib.custom.pyat_simulator.simulator_backend module

class accml_lib.custom.pyat_simulator.simulator_backend.SimulationStateModel[source]

Bases: object

all methods added by class::transitions.Machine

transititions used as bluesky seems not to use superstate machine any more

class accml_lib.custom.pyat_simulator.simulator_backend.SimulatorBackend(*, acc, name, logger=<RootLogger root (WARNING)>)[source]

Bases: BackendRW

Simulation backend based on pyAT

I assume today that the calculation engine works the following way:

  1. set to a state

  2. then calculations are triggered

So the calculations shall only happen after the state was set (completely).This is not (and can not) directly observed here. Here the calculation is only conducted when its results are requested. Calculation, setting, and reading back calculation results are protected by a lock, so no more sets are made while calculation is running nor calculation results are delivered ahead of time.

Todo

where to break async / sync or threaded approach?

Parameters:
get_natural_view_name()[source]
get_tune()[source]
async read(dev_id, prop_id)[source]
Return type:

object

Parameters:

Todo

acquire lock for read too? So that no inconsistent state will be read?

async set(dev_id, prop_id, value)[source]
Parameters:
async trigger(dev_id, prop_id)[source]
Parameters:
class accml_lib.custom.pyat_simulator.simulator_backend.TuneElement(backend)[source]

Bases: ResultElement

get(prop_id)[source]
Return type:

Tune

Parameters:

prop_id (str)

Module contents

Accelerator backend based on pyat