# Presentation: 244974

## Online Modeling of the Fermilab Accelerators

**Elliott McCrory**
**Leo Michelotti**
**Jean-Francois Ostiguy**
**Beam Physics Department**
***Fermilab***

## Outline

- I. Beam Physics Computation Environment
- II. Physics Analysis Client Applications
*Online Database*
*Online Models*
*Open Access Models (Redirection)*
*Standalone Applications*
- III. Limitations
- IV. Possible Directions
- V. Summary

## I. Beam Physics Computation Environment

*MXYZPTLK* Library
*Lie Algebra and Automatic Differentiation*
*Valid to any desired order*
*Beamline* Library
*Lattice construction, hierarchy and analysis classes*
- Object-Oriented C++
*Modular and distinct*
*One person can learn a small piece of the system and improve it.*

**Notes:**
Leo will expand on 3 slides from now

TCL/TK: 
Have an app, used by Holt at FFTB, for designing and changing lattices/beamlines and viewing results.
RasterMonitors

## Slide 4

**Notes:**
Many other UML diagrams possible.  

“31” bmlnElmnt’s: easy to extend that
OO: adding bmlnElmnt’s or Machine’s have no effect on the other; Polymorphism.

Leo: 2 slides from now.

## Online Model Architecture

## II A. Online Database of Physics Parameters

- Commercial Sybase Database Server
- We generate static database tables for
*Lattice Elements*
- names, positions, alignment
*Lattice Values*
- orbit, twiss, R-matrix, covariance matrix
- C-callable functions to access these tables
*For Controls application programmers*

**Notes:**
The database is a commercial one.
Open Protocol
Leverages this very potent tool! 
Anybody, anywhere can, in principle, access these databases. It is on the net.
No ACNET-specific garbage!

The static DB info is derived from exactly the same lattice as all the other on-line models

## Static Database Example

- sql> select * from lattice_twiss where lattice_name = "MI_20"
- 2> go
-  lattice_name         slot_number alphax               betax               	psix                 dispx                dprimex
- 	alphay               betay                psiy                	dispy                dprimey
-  -------------------- ----------- -------------------- --------------------	-------------------- -------------------- --------------------
- 	-------------------- -------------------- --------------------	-------------------- --------------------
-  MI_20                          0             0.935708            15.306615	            0.000000            -0.035001             0.003318
- 	           -2.046558            43.169907             0.000000	            0.000000             0.000000
-  MI_20                          1             0.609946            11.197358	            0.204496            -0.026179             0.003318
- 	           -2.366082            54.901296             0.054637	            0.000000             0.000000
-  MI_20                          2             0.572599            10.836919	            0.232169            -0.025168             0.003318
- 	           -2.402715            56.354825             0.060117	            0.000000             0.000000
-  MI_20                          3             0.538435            10.527148	            0.258276            -0.024243             0.003318
- 	           -2.436224            57.703984             0.065006	            0.000000             0.000000
-  MI_20                          4             0.538435            10.527148	            0.258276            -0.024243             0.003318
- 	           -2.436224            57.703984             0.065006	            0.000000             0.000000
- [...]

**Notes:**
Boring!

How I access the DB when debugging

## II B. Online Models

- Beam physics computations for existing machines at Fermilab
*The user may change beam line devices and have the model predict  the effect*
- Controls Applications on VMS
*The Client*
- Computation on Unix
*The Server*
*Solaris/SPARC & Linux/Pentium*

**Notes:**
A summary slide

Client: Operations GUI, access to readings/settings

Server: Same lattice as elsewhere; canned, specific calculations

Next: Architecture for the OLM.

## OLM: BPM’s & Model of 8GeV Line

## II C. Open Access Models

- Console Redirection
*Virtual Machine for testing normal Controls Applications*
- Proof-of-principle for FMI & RR
- Problems remain
*Development is tedious: the exact behavior of all front ends must be duplicated.*

**Notes:**
Be careful: This is the one area that is not really done at all.

Dropped because the priority went to the OLM’s

But!!

A. Underlying lattice is exactly the same as for other manifestations of these models
B. The process is defined and has been proven to work (slowly).

## II D. General-Purpose Fitting & Tuning

- Offline Program
- Variables & constraints defined dynamically by user
- Fit can be dynamically monitored (& stopped)
- See Ostiguy’s Talk in 30 minutes
*Recycler Trombone*

**Notes:**
Francois’ slides are next.
Generality is costly!!
Uses an existing toolkit, first offline to prove it can be done.

Trombone:
Read a file; 
get initial condition lattice at both ends (constraints on each side); 
define variables (quads that are tuned in the trombone); 
specify the desired phase advance
This can/should be hardwired

## III. Limitations

- Legacy environment
*VAX/VMS; C subroutine calls*
*Changes dominated by:*
- Compile time
- Complexity of the Controls API
- Model-based redirection is too low
*Requires specific knowledge of the hardware*
*Changes in hardware (common) must be transferred to the simulation*

## IV. Possible Directions

- Build model ideas into controls database
*E.g., all beam line classes in control system have hooks to return the design twiss values at that point.*
- Create an abstraction layer that is satisfactory to Controls and to Models
*For example:*
- Abstract class BeamPosition
*All real BPMs support this abstraction*
*Most functionality of any BPM is in this abstraction*
*Could be an “interface”*
- Abstract class Orbit, uses BeamPosition

## V. Summary

- Beam Physics Computation Classes
*Extremely accurate, arbitrary-order beam physics calculations*
- Integrated into Fermilab Control System
*Static Database lookup via C*
*On-Line Models (OLM)*
*Console redirection proof-of-principle (OAM)*
- Standalone Applications
- Need Abstraction layer in control system

**Notes:**
Animated

Last point:

We need affirmation from the management that (a) the product is important and 
(b) that the process we have chosen is correct.

Furthermore, management needs to give us the go-ahead to get more people involved.  They have already nixed our request, made in December, for another staff.