Overview
This page summarizes the design & implementation of the inference between the live FACET-II controls system and the FACET2E Bmad model.
Code is still WIP. Design details here are subject to change.
BmadLiveModel
The BmadLiveModel python class loads the FACET2E lattice and runs a local copy of Tao. The object connects to the production controls system via EPICS Channel Access and instantiates 4 daemon threads, three of which will monitor the controls system for live magnet/RF data and set devices in Tao accordingly, and a fourth which writes new model data to python data structures.
Modes of use
The BmadLiveModel can be used in three distinct modes, depending on the input flags at construction
Mode | kw arg | Code snippet | Notes |
---|---|---|---|
design model only | design_only | f2m = BmadLiveModel(design_only=True) | totally static, contents of BmadLiveModel.live will be identical to .design |
live model data with manual updates | instanced |
| This mode is designed for making lattice tweaks in Tao relative to extant machine settings, might be an edge-case use... |
live model data with real-time streaming |
| Use of the context manager is the "most pythonic" practice, but manual start() and stop() functions are also defined |
Daemon process design
Controls system communication is asynchronous to maximize update frequency. Responsibility of each thread should be designed for load balancing, to maximize the live model response time.
Name | responsibility | notes |
---|---|---|
rf-watcher |
| |
mag1-watcher |
| |
mag2-watcher |
| other stuff: solenoid, sextupoles, skew devices? |
model-update |
|
F2 Live Model Server
The live model server runs its own BmadLiveModel, and periodically writes live model data for NTTables accessible on the controls system via EPICS PVAccess. The table PVs are as follows
PV name | table columns |
---|---|
BMAD:SYS0:1:FACET2E:DESIGN:TWISS | element, device_name, s, z, length, p0c, alpha_x, beta_x, eta_x, etap_x, psi_x, alpha_x ..., psi_x |
BMAD:SYS0:1:FACET2E:DESIGN:RMAT | element, device_name, s, z, length, r11, r12, r13, r14, r15, r16, r21, r22, ..., r65, r66 |
BMAD:SYS0:1:FACET2E:DESIGN:TWISS | element, device_name, s, z, length, p0c, alpha_x, beta_x, eta_x, etap_x, psi_x, alpha_x ..., psi_x |
BMAD:SYS0:1:FACET2E:DESIGN:RMAT | element, device_name, s, z, length, r11, r12, r13, r14, r15, r16, r21, r22, ..., r65, r66 |
BMAD:SYS0:1:FACET2E:LEM_DATA | element, device_name, EREF, EACT, BREF, BACT, BERR |
Implementation details
Source: F2_live_model/ | Details |
---|---|
~/structs.py | auxiliary data structures for holding beamline data |
~/bmad.py | implements the BmadLiveModel class |
~/server.py | live model PVA service |
~/receiver.py | contains functions for getting data from the live model PVA server (analogous to F2_ModelReceiver.m ) |