brookhaven science associates high level applications and epics control guobao shen nsls-ii, control...

28
BROOKHAVEN SCIENCE ASSOCIATES High level applications and EPICS control GUOBAO SHEN NSLS-II, Control Group May 4 th , 2009

Upload: charla-heath

Post on 31-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

BROOKHAVEN SCIENCE ASSOCIATES

High level applications and EPICS control

GUOBAO SHEN

NSLS-II, Control Group

May 4th, 2009

2 BROOKHAVEN SCIENCE ASSOCIATES

Contents

From device control to beam control

HLA environments

MMLT

Python

Model server

3 BROOKHAVEN SCIENCE ASSOCIATES

From device control to beam control

Goal

Desired accelerator beam

Accelerator device control

Hardware subsystem control

Magnet power supply, beam diagnostics,…

Accelerator beam control

Realized through device control

4 BROOKHAVEN SCIENCE ASSOCIATES

Accelerator device control

Displayer

Controller

Device Model

Sensor Actuator

Device

From device control to beam control

5 BROOKHAVEN SCIENCE ASSOCIATES

From device control to beam control

Accelerator device control

Distributed and modular architectureEPICS based device control

Flexible, extensible, reusable, pluggable

Channel Access Client (CAC)Connection Data Transfers

Channel Access Protocol

Connection Server

Connection Data TransfersChannel Access Server (CAS)

DB Engine

Device Support

Driver SupportI/O Controller

Types

Connection Data TransfersChannel Access Server (CAS)

DB Engine

Device Support

Driver Support

I/O Controller

Types

6 BROOKHAVEN SCIENCE ASSOCIATES

Accelerator beam control

Operator Interface

High Level Applications

Model based Control

Beam Monitor

AcceleratorDevice

Beam

From device control to beam control

7 BROOKHAVEN SCIENCE ASSOCIATES

HLA environments

What is a HLA environment?

A software environment for beam commissioning & operation

Physics applications, model based control

Data archiving & analysis

Machine status save & restore

Machine real time status presentation

Database related applications

Available environments

MMLT, SDDS, XAL, …

8 BROOKHAVEN SCIENCE ASSOCIATES

HLA environments

Desired features

Scripting

Online simulator

Convenient low level access

Channel Access supporting

Plotting and Graphical User Interface

Numerical libraries (Optional)

9 BROOKHAVEN SCIENCE ASSOCIATES

HLA environments

A modular environment proposed at NSLS-IIClient-server modelLoose coupling, Pluggable, Reusable

EPICS based low level control system

Distributed IOC Process Databases

Channel Access

Application / Family

Middle Layer Client/Server

Name Mapping

Conversions

Dipole Quad Sext. Corr. BPM RF

Orbit Differences

Gradient Errs & Corrections

Beam R. M. Diff’s

Data Server

Optics Deviations

OpticsResp. Matrix (S)

Model Server

PhysicsApplications(Thin Client)

EPICS Client/Server

PhysicsApplications

(Thick Client)

Measured OrbitLattice

Installations

RDB

10 BROOKHAVEN SCIENCE ASSOCIATES

HLA environments

Communication protocol oriented architecture

Thick HLA Client Measured Orbit

Orbit Differences

Gradient Errs & Corrections

Beam R. M. Diff’sData Server

Optics Deviations

Thin HLA Client

Modularized HLA Srv

Model ServerTracy Elegant

API

Name MappingConversions

LatticeInstallations

RDB

EPICS based low level control system

Distributed IOC Process Databases

Dipole Quad Sext. Corr. BPM RF

EPICS Client/Server

Communication Protocol

11 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

Matlab based HLA environment

MMLT: Matlab Middle Layer Toolkit

High Level Matlab Applications(scripts and functions)

Matlab to EPICS(MCA, LabCA, SCAIII)

Matlab Middle Layer

Accelerator Toolbox (AT)(Model)

Accelerator Hardware

AT Server(Simulator)

Channel Access

HLA

12 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

MMLT is selected

Closer to our modular architecture

Rich available applications Used by many facilities for many years

13 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

MMLT Enhancement

Multi-simulators support

14 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

MMLT Enhancement

Directory structure

AT TracyTracy ElegantElegant NSLS2

MMLT ROOT

Applications EPICS CA Links MachineMML Tracy (*.so)Tracy (*.so) Elegant(*.so)Elegant(*.so)AT

S.R.S.R.S.R.

15 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

Command to select model

% use at simulator by defaultsetpathnsls2

% use tracy simulatorsetpathnsls2 tracy

% switch to onlineswitch2online

16 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

Display (plotfamily):

Beta plotting

(b) against AT

(a) against Tracy-3

17 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

Scripting Example: Orbit Correction Refer to Greg Portmann’s example: “EPICS Meeting April 27, 2005”

% Create an Orbit Errorvcm = .0005 * randn(180,1); % 180 vertical correctors at the NSLS-IIsetsp('VCM', vcm);

% Get the vertical orbitY = getam('BPMy');

%plot vertical orbitfigure;subplot(3,1,1);plot(Y);

% Get the Vertical response matrix from the modelRy = getrespmat('BPMy', 'VCM'); % 180x180 matrix

% Computes the SVD of the response matrixIvec = 1:24;[U, S, V] = svd(Ry, 0);

% Find the corrector changes use 48 singular valuesDeltaAmps = -V(:,Ivec) * S(Ivec,Ivec)^-1 * U(:,Ivec)' * Y;

% Changes the corrector strengths setsp('VCM', DeltaAmps);

%plot residual orbit after one orbit-correction iterationY2 = getam('BPMy');subplot(3,1,2);plot(Y2);

%plot different between residual orbit and originalsubplot(3,1,3); plot(Y-Y2,Y);

18 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

Chromaticity measurement

(a) against Tracy-3 (b) against AT

19 BROOKHAVEN SCIENCE ASSOCIATES

MMLT

Beam based alignment

against AT against Tracy-3

X Y

X Y

20 BROOKHAVEN SCIENCE ASSOCIATES

Model server

Online model server Based on a so-called “virtual accelerator”

Originally developed by SOLEIL and Diamond

Wrap into EPICS based Integrate with the narrow API interface Support Tracy-3 and Elegant Use CA-V3 for the communication protocol

Tracy/Elegant simulator (shared library)

Lattice configuration

Distributed IOC Process Databases

EPICS device support (API Interface)

EPICS Channel Access

LatticeLattice

21 BROOKHAVEN SCIENCE ASSOCIATES

Real Machine

Distributed IOC process databases

Dipole Quad Sext Corr BPM RF

VIOC

EPICS Client/Server

Tracy Simulation Engine

High level

Low level

MMLTMMLT XAL/TracyXAL/TracyPython/Tracy

Python/Tracy

EPICS Client/Server

Dipole Quad Sext Corr BPM rf

Elegant Simulation Engine

Dipole Quad Sext Corr BPM rf

Model API

VIOC

EPICS Client/ServerEPICS Client/Server

Model API

ATTracy

Elegant

EPICS Client/ServerEPICS Client/Server

Model server

HLA environments evaluated at NSLS-II

22 BROOKHAVEN SCIENCE ASSOCIATES

Model server

MMLT applications – orbit correction

Against VIOC (using Tracy-3 simulator)

Including whole bare lattice of NSLS-II

Errors for all elements: ±0.005%

Kick beam: 1e-5 for 1st H&VDuring correction (with 5 iterations)After correction

23 BROOKHAVEN SCIENCE ASSOCIATES

Python

Why python?

Good scripting language

Good interface with other language

Good math libraries

Good GUI libraries

Platform Independent

Open source, free license

24 BROOKHAVEN SCIENCE ASSOCIATES

Python

#!/usr/bin/python2.5# matplotlib is used for plotting

"Virtual Accelerator Orbit Test"

import sysfrom time import sleepfrom pylab import *

# Use ca library from Diamondsys.path.append("./ca/build/lib")from dca import *

Scripting Example: Access simulation server via CA

System library

Channel access library

25 BROOKHAVEN SCIENCE ASSOCIATES

Python

betax = caget("SR:C00-Glb:G00<BETA:00>RB:X").dbr.valuesubplot(2,1,1)plot(betax)

betay = caget("SR:C00-Glb:G00<BETA:00>RB:Y").dbr.valuesubplot(2,1,2)plot(betay)

show()

Scripting Example: Access simulation server via CA

Figure layout & plot

Figure layout & plot

Show on the displayer

Channel Accesscaget()

26 BROOKHAVEN SCIENCE ASSOCIATES

Python

caput("SR:C01-MG:G02A<HCM:H1>Fld:SP", 1e-4)caput("SR:C01-MG:G02A<VCM:H2>Fld:SP", 1e-4)sleep(1.0)

orbitx = caget("SR:C00-Glb:G00<ORBIT:00>RB:X").dbr.valuesubplot(2,1,1)plot(orbitx)

orbity = caget("SR:C00-Glb:G00<ORBIT:00>RB:Y").dbr.valuesubplot(2,1,2)plot(orbity)

caput("SR:C01-MG:G02A<HCM:H1>Fld:SP", 0)caput("SR:C01-MG:G02A<VCM:H2>Fld:SP", 0)

show()

Scripting Example: Access simulation server via CA

Figure layout & plot

Figure layout & plot

Show on the displayer

Channel Accesscaget()

Channel Access:caput()

27 BROOKHAVEN SCIENCE ASSOCIATES

Applications of IRMIS lattice database

Using IRMIS for lattice management

IRMISIRMIS

IRMIS Data IRMIS Data Service LayerService Layer

ModelModelDeck GeneratorDeck Generator

Tracy Elegant

Simulation Server(Tracy)

Simulation Server(Elegant)

IRMIS to Deck Object Mapping

Deck InputDeck Input

Deck to IRMISObject Mapping

Deck ParserTracy/Elegant

ElegantDeckTracyDeck

28 BROOKHAVEN SCIENCE ASSOCIATES

Applications of IRMIS lattice database

Lattice and other database

IRMIS Lattice DBIRMIS Lattice DB(Bare Lattice)(Bare Lattice)

IRMIS Saving DBIRMIS Saving DB(EPICS PV Snapshot)(EPICS PV Snapshot)

Mapping table

Lattice Generating

IRMIS Data IRMIS Data Service LayerService Layer

XML protocol

IRMIS Installation DBIRMIS Installation DB(Engineering Error)(Engineering Error)

Mapping table