phaser-server  0.0.7
Introduction

This document describes using the server software that calculates, and optionally corrects, RF Cavity phase errors. The document is intended for administrators who may need to install and operate the server. Additionally, there is information about the phase error calculation algorithm for scientists and engineers who want insight into how the phasing error estimates are achieved.

The client/server protocol is described in a separate document; which describes the communication format that is used between various clients and the server.

Installation

The server release package is currently installed in the Certified Software Repository. It can be found at /cs/certified/apps/rfPhaser. The package includes a configuration file which contains various settings to alter the behavior of the software. The only administrative configuration assignments are the target host computer and TCP port number. Other configuration assignments would be modified by a software expert that was very familiar with the details of the server code. The following is the layout of the installation directory.

|-- bin
| |-- rhel-6-ia32
| | |-- command
| | |-- listen
| | `-- rfPhaser
| |-- rhel-6-x86_64
| | |-- command
| | `-- listen
| `-- rhel-7-x86_64
| |-- command
| |-- listen
| `-- rfPhaser
|-- cfg
| `-- rfPhaser.cfg
|-- log
`-- log.txt

Note that the server connects to the phasing results database using the credentials saved in its configuration file. The server inserts information about each phasing job executed including individual cavity results. Phasing results can be viewed from the GUI application associated with this server. Additionally the server may write to the EPICS control system, and therefore must be executed as user Alarms.

Managing the server

The server code must be executed on the target host computer named in the configuration file. The server will refuse to execute otherwise. The bundled administrative tools may be executed on any host, as they connect to the server via TCP/IP. The server requires no command line arguments to start; enter “…/rfPhaser” to the shell prompt. When executed, it immediately becomes a daemon process and the command prompt is returned to the user. While operational, it maintains a log in the installation’s directory tree. The log is designed not to exceed a certain size. When it has grown to its maximum size, older entries are discarded to make room for new ones. There are two administrative applications bundled with the release, both are simple command line tools. The ‘command’ utility is used to issue administrative commands to the server. Most notably, the “…/command –c exit” is used to halt the server, “…/command –c bye” is used to verify the server is operating, and “…/command –c version” gets the version identification. Refer to the protocol document for the set of administrative commands. There is also a server notification listening application. Use “…/listen” to receive a stream of server notifications that are sent to all clients.

Live and Test modes

Normally the server runs in live mode; which is invasive to accelerator operations. It will modify the cavity phases in the control system as well as manage the Energy Locks. In test mode, no invasive actions are taken. This mode is useful for developing client applications. The mode of operation is determined by the configuration file keyword LiveMode. You can query a running server for the mode with the “…/command –c mode” command.

Calculation data logging

The measurement data gathered to make the phase error estimate can be optionally saved for analysis. Use the DataLogging keyword in the server’s configuration file to control the option. When enabled, a set of measurments made for an RF Cavity will be written to a file in the log folder of the deployed 3 server. The file name will be job<id>; where id is the job identification number assigned by the Phaser GUI and stored in the database of results.

Phase calculation algorithm

Calibration of RF cavity gradient settings and proper phasing is achieved by kicking a cavity’s phase and measuring the change in energy in the nearest downstream dispersive region. Once a sufficient number of samples are obtained, the following algorithm is applied to compute the amplitude and phase error of the cavity.

$$𝛿𝐸 = 𝐴 × cos(𝜃 + 𝜑) − 𝐴 × cos 𝜃$$

E: Total energy measured in the nearest BEM region.
A: The amplitude (MeV) of the cavity energy sine function to be measured.
θ: Cavity Phase angle error to be measured.
Φ: Cavity phase angle kick

The equation above can be written as follows, lending itself to the linear regression solution by choosing a number of kick angles and measuring the energy change.

$$𝛿𝐸 = (cos𝜑 − 1) × 𝑋₁ − sin 𝜑× 𝑋₂$$

Where: 𝑿₁ = 𝑨 × 𝐜𝐨𝐬 𝜽 and 𝑿₂ = 𝑨 × 𝐬𝐢𝐧 𝜽


$$ \begin{bmatrix}𝑋₁ \\ X₂\end{bmatrix} = \begin{bmatrix} cos 𝜑₁ − 1 & − sin 𝜑₁ \\ cos 𝜑₂ − 1 & − sin 𝜑₂ \\ ⋮ & ⋮ \end{bmatrix}^{−1} × \begin{bmatrix} 𝛿𝐸₁ \\ 𝛿𝐸₂ \\ ⋮ \end{bmatrix} $$

Note the inverse notation on the matrix above. Once the matrix equation is solved, the phase error and amplitude may be solved as follows.

$$𝜃 = tan^{−1}(𝑋₂ ÷ 𝑋₁)$$

$$𝐴 = 𝑋₁ ÷ cos 𝜃$$

Kick calculation algorithm

Larger phase kicks, up to a certain point, produce more accurate phase error estimates. Larger kicks also produce greater energy error in a region. The strategy then is to choose the largest kick that can be made that does not exceed the region’s energy change tolerance. There are two tolerance scenarios for 4 a region. One is the energy change that causes the beam to scrape and shutdown, thereby making it impossible to make phase error measurements. The other tolerance scenario is perturbing the beam to a point that it adversely impacts physics experiments; thereby invalidating ongoing experiments. The energy change tolerance used in this study is actually the normalized momentum error referred to as “dp/p”. The beam scraping and invasive to physics limits used was 1e-3 and 2e-4 respectively.

The calculation of phase kick is predicated on region energy error tolerance, the energy being produced by the Cavity being measured, and the current phase error of the Cavity. The first two of these factors are known, but the phase error is the quantity being measured. You have to estimate phase error; which can be done conservatively to assure the region energy error tolerance is not exceeded. A conservative phase error estimate is simply an angle larger in magnitude than the actual phase error.

The following derivation assumes that the actual phase error plus the kick will overshoot 90 degrees by less than half the kick. That means that the larger energy error is realized on the kick that moves further away from being on phase. For real-life scenarios, the 90 degree assumption is absolutely valid.

Definitions:

Ec = Cavity energy (MeV)

Ed = the energy delta introduced by a phase kick (MeV)
Er = Ed / Ec
Φe = Cavity phase error (degrees)
Φk = Phase kick to use (degrees)

Derivation:

Ed = Ec×cos(Φe) – Ec×cos(Φe+ Φk)

Er = Ed/Ec = cos(Φe) - cos(Φe+ Φk)
cos(Φe+ Φk) = cos(Φe) – Er
Φe+ Φk = cos-1(cos(Φe) – Er)
Φk = cos-1(cos(𝚽e) – Er) - 𝚽e

Notes:

  • The energy of the Cavity is the gradient setting multiplied by its length.
  • Set Ed to the dp/p tolerance multiplied by the region’s energy.
  • Set Φe to the maximum expected phase error.