Wir schaffen Wissen heute fr morgen Paul Scherrer

  • Slides: 10
Download presentation
Wir schaffen Wissen – heute für morgen Paul Scherrer Institut Sven Reiche & Masamitsu

Wir schaffen Wissen – heute für morgen Paul Scherrer Institut Sven Reiche & Masamitsu Aiba Online Model – Part I PSI, 03 03 Januar 2022

Client-Server Approach Server Clients (e. g. Matlab) Basic Ideas: • Can be called from

Client-Server Approach Server Clients (e. g. Matlab) Basic Ideas: • Can be called from clients on various platform (e. g. Matlab). • Interface standardized by using CAFÉ or EPICS 4 PVAccess • Server can be used for online (does the execution of the codes) or offline (generates input decks for the codes such as ELEGANT) calculations • Server should be accessible in controls network as well as office network (to be discussed with controls) • Writing clients should be straight forward and nearly independent on the server network (though knowledge of the codes is needed, e. g. to match with MADX) • The server side is written in Python, which is strongly supported at PSI and does not PSI, require 03. 01. 2022 Seite 2 licenses

Server Components Layout Manager: • This module contains the layout of the machine and

Server Components Layout Manager: • This module contains the layout of the machine and will be the reference for Swiss. FEL and SITF. The Heilige Liste is derived from it but the online model does not require the Heilige Liste (aka access to the CITY Database). Right now the module is written in Python but a more general way to define the layout and the layout manager is forseen in the future. The Layout cannot be changed as part of the service of the clients Type Manager: • Module to define the types in the lattice, e. g. quadrupoles. Each type is a class in Python and has access functions to define the element for each code considered. There is also a line/sequence container type which combines a set of basic types and other containers. Swiss. FEL will be on top level a container type (as enforced by the layout manager). Code Manager: • Mostly a set of shared libraries which can linked to the server dynamically and executed directly within the code. So far MADX has been converted to work that way and others are forseen. Otherwise the approach (A. write lattice and input deck, B. excute the code as a system command, C. parse output) can be used Control Interface Manager: • All the stuff to interface with the control environment, in particular the protocol to the PSI, 03. 01. 2022 Seite 3 client side.

Virtual Accelerator (Program Flow) Machine Controls Environment 2. Clones Epics Channels Server 1. Request

Virtual Accelerator (Program Flow) Machine Controls Environment 2. Clones Epics Channels Server 1. Request Service Client 8. Release Instance of Online Model Con. Env. 3. Configuration 4. Instantiation 7. Retrieval For each service an individual instance of virtual EPICS channels and lattice are generated. Multiple Lattice instances can be run at the same time. • Step 3 -7 can be repeated as long as the client wants (virtual accelerator sand box) 5. Execution • The client must retrieve all required information before releasing the instance of the accelerator Code • Branching is done by PV setvalues of dipoles (e. g. if 6. Evaluationthe Injector spectrometer dipole has current the lattice ends at the injector dump) • Results are stores as PV channels. PSI, 03. 01. 2022 • Seite 4

Offline Modeling • Instead of running an accelerator sand box the online model should

Offline Modeling • Instead of running an accelerator sand box the online model should also be able to generate input decks to run offline. • It is not decided yet where the execution of “time-consuming” codes are required to be offline or whethere is an access to the merlin cluster (low priority). • The server will have also its own PV channels to control the configurations, e. g. name of the lattice file when writing to a file. • Also not defined yet, whether the input decks are piped to the client or whether they are saved in a well defined AFS location. PSI, 03. 01. 2022 Seite 5

Restriction and Conventions • The element names follow the naming conventions (However we have

Restriction and Conventions • The element names follow the naming conventions (However we have the right to define the names in our lattice) • There are three levels of contains: • “S” – Swiss. FEL • “IN”, “ 10”, … - Domains • “BC 01”, ”CB 02” – Sections • The names of the containers are merged when accessing elements • Branching occurs for a non-zero deflection angle of some specific magnets. Others such as the BC magnets are not part of the branching • EPICS channels are given by the device name. No existing channels are created on the fly so that the online model works without the connection to the controls network. • There might be a time out for an instance and the total number of instances might be limited (defined by the controls) to prevent unknowingly “Denial of Service Attacks” PSI, 03. 01. 2022 Seite 6

Example Code I - Python CI=OMControl. Interface. Control. Interfa ce() Generate Sandbox Instance of.

Example Code I - Python CI=OMControl. Interface. Control. Interfa ce() Generate Sandbox Instance of. Control Interface Alter a value (here: turn on the injector dump) CI. set. Value('S 10 DI 01. MBND 100', 'an gle', -20) Generate Instance of the Lattice (Branching) Swiss. FEL=OMLayout. Swiss. FEL(). bui ld(CI) Select Starting Point for Lattice Swiss. FEL. set. Range('SINLH 01') Generate Interface with MAD madx=OMCode. Mad. X() Pipe ASCII lattice to madx. open() Note that the container Swiss. FEL has a method to pipe out the lattice in ASCII format Swiss. FEL. write. Mad. X(madx) to madx. So far I use a simple write to file and run madx in shell (not shown here). In madx. close() the official version, Masamitsu will write this module to link MADX as a shared library. PSI, 03. 01. 2022 Seite 7

Example Code II – Layout Manager indict={'Type': 'Quadrupole', 'Length': 0. 15, 'Length. Res': 0.

Example Code II – Layout Manager indict={'Type': 'Quadrupole', 'Length': 0. 15, 'Length. Res': 0. 25, 'corx': 0, 'cory': 0, 'Baug ruppe': 'QFD'} Define Template Elements (here QFD magnet) TM. define('QFD', indict) … Instantiate a container Swiss. FEL=OMType. Line. Container('S’) Injector=OMType. Line. Container('IN') … DI 02=OMType. Line. Container('DI 02', 5. 456) Add element to container DI 02. append(TM. generate('DBPM-C 16', 10), 0. 356, 'relative') Instantiate element from templa DI 02. append(TM. generate('QFD', 20), 0. 1, 'relative') DI 02. append(TM. generate('QFD', 30), 0. 9, 'relative') DI 02. append(TM. generate('DBPM-C 16', 40), 0. 7, 'relative') DI 02. append(TM. generate('QFD', 50), 0. 1, 'relative') DI 02. append(TM. generate('QFD', 60), 0. 9, 'relative') DI 02. append(TM. generate('QFBS', 70), 0. 6, 'relative') DI 02. append(TM. generate('DBPM-C 16', 80), 0. 0, 'relative') DI 02. append(TM. generate('QFD', 90), 0. 1, 'relative') Injector. append(DI 02, 0, 'relative') Swiss. FEL. append(Injector, 0, 'relative') PSI, 03. 01. 2022 Seite 8

Example Code III – Type Manager Sextupole as a child class of magnet class

Example Code III – Type Manager Sextupole as a child class of magnet class Sextupole(Magnet): def __init__(self, prop): Magnet. __init__(self, prop) Constructor: make sure that it has all essential field if not(prop. has_key('k 2')): self. __dict__. update({'k 2': 0}) if not(prop. has_key('Tag')): self. __dict__. update({'Tag': 'MSEX'}) The way it is written in a MAD lattice def write. Mad. X(self, madx): madx. write("%s. k 2 : = %f; " % (self. Name, self. k 2)) madx. write("%s: SEXTUPOLE, L=%f, k 2: =%s. k 1, tilt=%f; n" % (self. Name, self. Length, self. Name, self. Tilt)) return self. Name Fill with set values from control def initiate(self, CI, name="", p 0=250): sandbox p 0=Simple. Container. initiate(self, CI, name, p 0) (right now if channel does not self. k 2=CI. get. Value(self. Name, 'k 2') exists, one is created) return p 0 PSI, 03. 01. 2022 Seite 9

Outlook Code Support: • Right now only MADX is supported. The minimum set would

Outlook Code Support: • Right now only MADX is supported. The minimum set would be to support ELEGANT and the Lie. Track-Derivative (Marc) • Test with Masamitsu’s work Control: • Promised support from controls to give us the sand box EPICS channels. • Interface of the online server, following EPICS standards, to be developed • Interface between lattice values and controls values ( I k 1 for quads) Client: • At least one basic client with GUI needed. Plotting optics function etc • Need Linac-Energy-Management (LEM) system (can be part of the server but is not required) Other: • Access from the outside? • Running codes on the cluster? • Which codes to include? • Automated start-to-end simulations? PSI, 03. 01. 2022 Seite 10