CESRV: The Virtual CESR Program

Created: 1/1/99 -- DCS
Last Revised: October 18, 2010


TOP

General Description

The "Virtual CESR" program CESRV is a general purpose program for simulating CESR. For example, With CESRV you can:

How to run

To run CESRV:
  1. If not yet done so, set the X-window (using "DO REMX" or whatever).
  2. To start the program type either:
     
       CESRV                             ! You will be prompted for input.
       CESRV READ <data_file_name>       ! Read in "nonstandard" data from a file.
       CESRV READ O: <orbit_file_number> ! Read in an orbit, 0 => latest orbit.
       CESRV READ P: <phase file number> ! Read a phase/coupling data file.
       CESRV READ E: <eta file number>   ! Read a Dispersion data file.
       CESRV READ B: <eta file number>   ! Read a Beta data file.
       CESRV CALL <file_name>            ! Use a CESRV command file (see note).
       CESRV READ CSR <num>          ! Use a CSR save set.
       CESRV L: <lattice_name>       ! Specify lattice to use.
       CESRV L: 0                    ! Use current lattice in the database.
       CESRV L:                      ! You will be give a list of lattice choices. 
       CESRV L: <n>                  ! Use nth lattice (from the lattice list)
       CESRV F: <lattice_name>       ! Specify BMAD input file to use.
       CESRV TAKE ETA                    ! Take a dispersion measurement.
       CESRV TAKE PHASE                  ! Take a phase measurement.
       CESRV TAKE ORBIT                  ! Takes an orbit and uses this for data.
    

Notes:

Examples:

    CESRV READ ABC          ! Read in the data file ABC.DAT.
    CESRV READ O:56930      ! Read in the orbit 56930.
    CESRV TAKE ORBIT        ! Take an orbit.
    CESRV READ P:0          ! Read in latest phase/coupling data.
    CESRV READ P:           ! Same as above, Blank is treated as a 0.
    CESRV TAKE PHASE        ! Take a phase/coupling measurement.
    CESRV L:                ! You will be given a list of lattices to choose from.
    CESRV L: 8              ! Use the 8th lattice in the lattice list
    CESRV L: N9A19B700.FD93S_5269_15KG  ! Use this lattice.
    CESRV F: BMAD_ABC.EFG               ! Use this bmad input file.
    CESRV -custom_calib my_calibs.dat L:0 ! Use custom calibrations, and use latest lattice

TOP

Definitions

Correctors
A corrector is anything that can be varied in the MODEL. Examples include quadrupole strengths, horizontal and vertical steerings, separators, etc. There are certain standard lists of correctors that CESRV knows about for use in flattening or fitting to data. Use the SHOW command to see what correctors are enabled. The VETO/RESTORE/USE commands are used to set what correctors are used in flattening or data fitting. The SHOW VAR command can be used to view the state of a standard variable. You can also create a custom set of correctors. See the OPT_VARS command for more details. The CHANGE command is used to vary correctors "by hand".

Model
CESRV has an internal model of the CESR Layout. Use the SHOW RING command to view a list of elements in a segment of the ring. Use the SHOW ELE command to get information on a particular element.

Data
Each data point (for example, the horizontal orbit at detector 15w) has a number of quantities associated with it. They are: DATA, REFERENCE, MODEL, BASE_MODEL, FIT, and DESIGN. Use the SHOW DATA command to view the state of these quantities. See the PLOT and BASELINE commands for additional details in terms of plotting these quantities.
DATA
DATA is the measured data read in by the latest READ command. A list of data types is given in the Data Types section. If you start up CESRV by just reading in a lattice then DATA is initially set to what is calculated from the design lattice. Alternatively, if you use the TRANSFER MODEL DATA command then the DATA is set to what is calculated from the current state of the MODEL.
REFERENCE
REFERENCE is the measured reference data read in by the latest READ REF command. Alternatively, if you use the TRANSFER MODEL REF command then the REFERENCE is set to what is calculated from the current state of the MODEL.
MODEL
The MODEL data is the data as calculated from the model lattice.
DESIGN
The DESIGN data is the data as calculated from the design lattice.
BASE_MODEL
BASE_MODEL data is data as calculated from some baseline model lattice. Use the command TRANSFER MODEL BASE_MODEL to set the baseline model equal to the current model.
FIT
Right now FIT is only set by the CALIBRATE command and is used to show the residual deviations of the fitting done by CALIBRATE.

Merit Function
The Merit Function is the quantity which CESRV tries to minimize when the RUN or FLATTEN command is used. See the sections below on Twiss or Orbit correction for the exact form of the Merit Function. Use the SHOW TOP10 command to see what the value of the Merit Function is and what terms of the merit function are the greatest contributors to its value and to see which correctors have the greatest dMerit/dCorrector values. Use the SHOW command to see the weights that go into the Merit Function calculation. Use the SET command to change the weights. Typically the data terms in the Merit Function look like:
  merit_term = weight * (data - model)^2 
So that the minimum in the merit function comes when model = data. There are 3 other forms that the terms in the Merit Function can take depending upon what the setting for the baseline is for the top plot (cf. the BASELINE command):

TOP

The Plot Regions of the Plot Window

The normal plot window that is created when CesrV is run is divided into two plot regions called TOP and BOTTOM:
  ----------
  |        |
  |  TOP   |
  |        |
  ----------
  |        |
  | BOTTOM |
  |        |
  ----------
ALL refers to both of them. For example, BASELINE REF ALL will set the baseline of both regions.

The PLOT WIDE command creates four plots:

  --------------------
  |        |         |
  |  TOP   |  2TOP   |
  |        |         |
  --------------------
  |        |         |
  | BOTTOM | 2BOTTOM |
  |        |         |
  --------------------
The following names refer to multiple regions:
  ALL     ! TOP and BOTTOM
  2ALL    ! 2TOP and 2BOTTOM
  ENTIRE  ! All four regions.

Note: Use the command PLOT MAG <num> to scale the screen size.


TOP

Data Types

The types of data that CesrV knows about:
  2QX               ! 2Qx sextupole resonance data 
  2QY               ! 2Qy sextupole resonance data
  AC_ETA            ! AC dispersion data
  CBAR              ! Coupling data.
  ETA               ! Dispersion data
  BETA              ! Beta data
  ORBIT             ! Orbit data
  PHASE             ! Betatron phase data
  QX+QY             ! Qx+Qy sextupole resonance data.
  QX-QY             ! Qx-Qy sextupole resonance data.
  SPLINE_BETA       ! Beta calculation using a spline fit of the phase data. 

Sometimes it is convenient to refer to multiple data types simultaneously. Names for the combinations that CesrV knows about are:

  _CBAR_AND_ETA     ! Cbar and Eta data
  2Q                ! 2Qx and 2Qy data
  QX                ! Qx+Qy and Qx-Qy data.
  Q_RES             ! 2Qx, 2Qy, Qx+Qy, Qx-Qy data
  TWISS             ! Phase and Cbar coupling data. 
So, for example, BASELINE REF TWISS will set the baselines of the PHASE and CBAR plotted data. When plotting data, individual graphs are referred to using the syntax
  <data_type> <plane> 
The appropriate <plane> names for the sextupole resonance data are: 
  IN
  OUT  
For everything else except CBAR data, the appropriate <plane> names are:
  X
  Y 
For CBAR data a different syntax is used and the three graphs are referred to using the names
CBAR11 CBAR12 CBAR22

TOP

Variable Types

The types of variables that CesrV knows about:
  BPM_TILT                ! Angular Tilt of a BPM in the transverse plane
  CUSTOM_VAR              ! Custom variable 
  GROUP <name>            ! Cesr Data Base group knob
  H_SEPARATOR             ! Horizontal separator
  HORIZONTAL              ! Horizontal steering
  OCTUPOLE                ! Octupole strength (K3} 
  QUAD (k1)               ! Quadrupole strength (K1)
  SEXTUPOLE               ! Sextupole strength (K2)
  SKEW_QUAD               ! Skew quadrupole strength (K1)
  _SKEW_SEX               ! Skew sextupole strength (K2)
  VERTICAL                ! Vertical steering.  

For <name> strip off the "CSR" prefix. For example GROUP HBUMP


TOP

Twiss (Phase, Coupling and Beta) Analysis and Correction

Here is a short checklist for taking a phase/coupling measurement.

By the term "CORRECTORS" it is meant the quadrupole strengths (k1's), and/or skew quad strengths and/or sextupole strengths (k2's).

By the term "DATA" it is meant the Betatron Phase data and/or the coupling Cbar12 data and/or Beta data. [For instrumental reasons the Cbar11 and Cbar22 data is generally of poorer quality and is not used in the analysis].

Given the measured DATA the task is to figure out what corrector values are needed to reproduce the measurements. That is, We thus seek a set of "MODEL" corrector values such that the MODEL data (calculated from the MODEL corrector values) most nearly equals the measured DATA.

The "DESIGN" corrector values are what are given from the DESIGN lattice. The "DESIGN" data are what is calculated using the DESIGN correctors. In CESRV there is no relationship between the DESIGN and MODEL corrector values other than they both use the same lattice layout (placement of elements). Note that initially, for lack of anything better to do, MODEL is set equal to DESIGN. The point at which differences between the two matter is when the corrections are actually put into CESR (see below).

The "SAVED" corrector values are the corrector values at some point in time. [For the present discussion that time will be when a phase/coupling measurement is made.] At the time of making a measurement, the CU (Computer Unit) values for the correctors are written to the phase/coupling measurement data file. When phase/coupling data is read into CESRV, the corrector CU values are also read in and these values are converted into corrector strengths using the appropriate calibration constants.

The "MERIT" function is a figure-of-merit for how close the MODEL data is to the measured DATA. The idea is to minimize the merit function.

   merit = 
      phase_x_wgt * [sum: (phase_x_model - phase_x_data)^2] +
      phase_y_wgt * [sum: (phase_y_model - phase_y_data)^2] +
      cbar12_wgt  * [sum: (cbar_12_model - cbar_12_data)^2] +  
      tune_x_wgt  * (tune_x_model - tune_x_data)**2 +
      tune_y_wgt  * (tune_y_model - tune_y_data)**2 +
      beta_x_wgt  * (beta_x_model - beta_x_data)**2 +
      beta_y_wgt  * (beta_y_model - beta_y_data)**2 +
      k1_wgt    * [sum: (k_model - k_saved)**2] +
      k2_wgt    * [sum: (k2_model - k2_saved)**2]

After the MODEL is adjusted to minimize the MERIT function so that (hopefully) the MODEL data = the measured DATA. then the "TARGET" corrector values are what the correctors should be set to so that (presumably) the actual lattice will be identical to the DESIGN lattice. The formula for the target is:

                TARGET = SAVED + DESIGN - MODEL 

Notes:

Examples of commands used in the analysis:

$ CESRV P:                   ! Start program using the latest phase data.
CESRV> VETO PHASE 3:5     ! Don't use these data points
CESRV> SHOW TOP10         ! Show largest contributors to merit function
CESRV> SHOW               ! Show some parameters
CESRV> TW = 0             ! Set the tune_weight = 0
CESRV> RUN                ! Run the optimizer
CESRV> WRITE              ! Save the results to a file
CESRV> LOAD               ! Load the corrections
CESRV> TAKE               ! Take another phase measurement
   ... etc ...


TOP

Special Custom Corrector Sets

A custom corrector set is specified by an input file. After making the file use the OPT_VARS command to read it in (and use the MERIT_DATA command to set what data use use). The file input format uses Fortran90 namelist input as follows:
&A VAR = <element> <attribute> <units> <low_lim> <high_lim> <step_size> <weight>
where:
    <element>    -- Element name
    <attribute>  -- Element attribute to vary. For an overlay_lord to
                            control the coefficient of the Nth slave use 
                            "SLAVE N"
    <unit>       -- How <low_lim>, <high_lim>, and <step_size>
                            are interpreted. Possibilities are:
                            "ABS"  -> real_low_lim = input_low_lim, etc.
                            "REL"  -> real_low_lim = current_value_of_var +
                                                                  input_low_lim
                            "%REL" -> real_low_lim = (1+input_low_lim) *
                                                          current_value_of_var
    <low_lim>    -- Input Lower limit for variable
    <high_lim>   -- Input Upper limit for variable
    <step_size>  -- Input "Typical" small increment to be used when varying
                            variable
    <weight>     -- Weight in merit function. The total weight in the 
                            merit function is <weight> * VAR_WGT

Example:

!------------------------------------------------------------------
!         Name    Attribute            Low   High    Step  Weight
&A VAR = "q10w"      "tilt"    "abs"   0.0   0.25  0.0001    1.0 /  
&A VAR = "h_sep_45w" "hkick"   "%rel" -0.01  0.01   0.001    1.0 /  
&A VAR = "h20w"      "slave 1" "abs"   0.0   0.002  0.001    1.0 /  

TOP

Notes on the Optimizers

Common Features

Note:

FLETCHER-REEVES

FLETCHER-REEVES optimization is essentially FRPRMN from Numerical Recipes. FLETCHER-REEVES takes the correctors and moves along a line in n-dimensional corrector space to a minimum in the merit function. This is a "CYCLE". FLETCHER-REEVES then chooses a new direction and does another cycle. etc., etc. A "CALL" is a single step along the line in corrector space and the "calls/cycle" number printed is a measure of the efficiency with which FLETCHER-REEVES can find a minimum along the line.

FLETCHER-REEVES takes OPT_CYCLES cycles Prints the results, and repeats this process OPT_LOOPS times. Thus the total number of cycles is OPT_LOOPS*OPT_CYCLES (except when FLETCHER-REEVES is near a min. see below.)

Parameters used by FLETCHER-REEVES:

CHANGE_MIN
If the optimizer in 1 cycle does not change the merit function by CHANGE_MIN (in %) then the optimizer will assume it is at a minimum and abort the current loop.

OPT_TOLERANCE
Tolerance used for finding a minimum in a cycle (in %). A smaller number will make things more accurate at the cost of more time.

Note:

LEVENBERG-MARQUARDT

LEVENBERG-MARQUARDT uses the data verses variable derivative matrix (cf. the DMERIT command) plus the form of the merit function (which is a sum of quadratics) to calculate where the minimum merit should be. An OPT_LOOP consists of: 1) MARQUARDT makes a prediction where the minimum should be. 2) The variables are adjusted to correspond to this supposed minimum. 3) If the merit function has actually decreased by making this step then the step is accepted. If the merit function increases then the variables are reset to their values at the beginning of the loop and the variable A_LAMBDA is increased by a factor of 10. For a step that resulted in the merit function decreasing A_LAMBDA is decreased by a factor of 10. Roughly: A_LAMBDA is a measure of how linear the problem is. See the Numerical Recipes writeup for more details. If the step MARQUARDT makes takes a variable out of bounds (cf. the LIMIT command) then the actual step used is scaled so that the variable is just inside the limit and the variable is VETOed from the list of variables to use.


TOP

Wave Analysis

The "Wave" analysis is a way of analyzing data to find exactly where a "kick" is coming. This analysis can be used to find steering errors with orbit data, quadrupole errors with phase data and skew quadrupole errors with coupling data. The write-up for the wave analysis is given by: CBN 97-01

Example analysis:

$ CESRV P:                 ! Start program using the latest phase data.
CESRV> VETO PHASE 4 23E    ! Don't use these data points
CESRV> WAVE PHASE X        ! Use the horizontal phase for the analysis
CESRV> IX_A = 40 53        ! Define edges of A region (see SET command)
CESRV> IX_B1 = 60          ! Define left edge of B region
CESRV> IX_B2 = 72          ! Define right edge of region B
CESRV> VETO PHASE 43:44    ! I don't want to use these data points either
CESRV> PLOT WAVE           ! Do the wave analysis
CESRV> OUTPUT HARD         ! Get hardcopy output
CESRV> SHOW QUAD           ! Get phase, etc. info on the quads
CESRV> SHOW RING 42E       ! Get phase, etc. info on ring elements near 42E

Notes:

  1. What is used for "data" is what is plotted. E.g. if the difference DATA - REF is plotted then DATA - REF will be used in the wave analysis
  2. The WAVE_SET command shows a wave analysis using a sliding window: At every data point the data within the range +/- N_WAVE_WINDOW is used to fit to the equation of a freely propagating wave and the fit coefficients are plotted:
     Data   Kicker     Fit            Equation of Freely propagating
     Type   Element    Coefficients   wave at i_th detector
     ----   -------    ------------   ------------------------------
    
     Orbit  Steering   A, phi_0       orbit_i  = A * sin(phi_i + phi_0)
     Phase  Quad       A, phi_0, C    phase_i  = A * sin(phi_i + phi_0) + C
     Cbar12 Skew Quad  A_r, phi_r0,   cbar12_i = A_r * sin(phi_r_i + phi_r0) + 
                         A_s, phi_s0                    A_s * sin(phi_s_i + phi_s0)
    
    Where: 
        phi_r =  phi_x - phi_y
        phi_s = -phi_x - phi_y            
    

TOP

Mapping between the CESRV arrays and the CESR Data Base Nodes

To simplify the things, CESRV defines arrays of variables where each array corresponds to a particular type of element in the CESR ring. For example, the elements of the HORIZONTAL array of CESRV correspond to horizontal kickers in the CESR ring. In this case there are 2 CESR Data Base nodes that are mapped to horizontal kickers. these nodes are: CSR HORZ CUR and CSR HBND CUR. The mapping between the HORIZONTAL array on the one hand and CSR HORZ CUR and CSR HBND on the other is:
 
    i^th element of CSR HORZ CUR  <-->  i^th     element of HORIZONTAL
    j^th element of CSR HBND CUR  <-->  100+j^th element of HORIZONTAL
The table below lists the correspondence between the CESRV arrays and the CESR Data Base nodes:
    CESR Data Base             CESRV                         Attribute
    --------------------       ------------------------      ---------
    CSR HORZ CUR  1 - 98       Horizontal       1 -  98      Hkick
    CSR HBND CUR  1 -  6       Horizontal     101 - 106      Hkick
    UND CNTG CUR  1 -  1       Horizontal     111 - 111      Hkick
    UND CNTGTRIM  1 -  1       Horizontal     112 - 112      Hkick

    CSR VERT CUR  1 - 98       Vertical         1 -  98      Vkick
    UND VERT CUR  1 -  4       Vertical       101 - 103      Vkick
                           
    CSR HSP VOLT  1 -  6       H_Separator      1 -   6      Hkick
                           
    CSR VSP VOLT  1 -  6       V_Separator      1 -   6      Vkick
                           
    Not in the Data Base       Quadrupole         0, 99      K1  [REC Quads]
    CSR QUAD CUR  1 - 98       Quadrupole       1 -  98      K1
    CSR QADD CUR  1 -  7       Quadrupole     101 - 107      K1
    SCIR QUADCUR  1 -  4       Quadrupole     111 - 114      K1
                           
    CSR SQEWQUAD  1 - 98       Skew_Quad        1 -  98      K1
    SCIR SKQUCUR  1 -  4       Skew_Quad      111 - 114      K1
                           
    CSR SEXT CUR  1 - 98       Sextupole        1 -  98      K2
                           
    CSR SQEWSEXT  1 -  4       _Skew_Sex        1 -   4      K2
    SCIR SKSXCUR  1 -  1       _Skew_Sex       11 -  11      K2
                           
    CSR OCTU CUR  1 -  4       Octupole         1 -   4      K3

TOP

Flattening the Orbit

The merit function for minimization is
    merit = [sum: (orbit_x_model - orbit_x_data)^2] +
            [sum: (orbit_y_model - orbit_y_data)^2] +
            steering_wgt * [sum: (horz_cu_db - horz_cu_model)^2] +
            steering_wgt * [sum: (vert_cu_db - vert_cu_model)^2] +
            cam_wgt  * [sum: (cam_model - cam_saved)**2] +
            energy_wgt * (dE/E)^2

After the MODEL is adjusted to minimize the MERIT function so that (hopefully) the MODEL data = the measured DATA. then the "TARGET" corrector values are what the correctors should be set to so that (presumably) the orbit will be flat. The formula for the target is:

                TARGET = SAVED - MODEL 

Notes:

Notes:

Example commands:

CESRV> TAKE                ! Take an orbit
CESRV> VETO HOR 2E:2W      ! Veto IR horiz steerings. See also USE, RESTORE
CESRV> USE VERT 11w 23w    ! Use only these 2 vertical steerings.
CESRV> SHOW                ! Show parameters
CESRV> SHOW SINGLE         ! Show how well you do varying only a single
                              !       corrector at a time
CESRV> SHOW STEERINGS      ! Show steering info
CESRV> PLOT HORIZONTAL     ! Plot horizontal steering strengths except the
                              !   HBND's
CESRV> PLOT HBND           ! Plot horizontal HBND steering strengths.
CESRV> PLOT VERTICAL       ! Plot vertical steering strengths
CESRV> PLOT ORBIT          ! Plot the orbit
CESRV> READ REF 45678      ! Read in a reference orbit
CESRV> SCALE X             ! Scale X_ORBIT plot
CESRV> SET STEERING_WGT = 1.0e-6 ! Set the merit function steering weight
CESRV> SW = 1.0e-6         ! Abbreviation for SET STEERING_WGT = 1.0e-6
CESRV> TRANSFER ZERO HOR   ! Zeros the model horizontal steering strengths
CESRV> FLATTEN             ! Run the optimizer to fit the model to the data.
                              ! This is the same as the RUN command
CESRV> LOAD  0.5           ! Load 1/2 the steering corrections
CESRV> LOAD -0.5           ! Undoes previous load
CESRV> EXIT                ! That's all folks

TOP

Orbit Data

There are three ways that orbit "data" can be read into and/or manipulated in CESRV:
! Example of an orbit file

 &DATA_PARAMETERS                          ! Fortran90 namelist.
  file_type = 'ORBIT DATA'                 ! Identifies file as an orbit file.
  lattice   = 'N9A18A000.FD93S_5269_15KG'  ! This is optional.
  data_date = '1998-JAN-06 18:05:36'       ! This is optional.
  save_set  =  51220                       ! This is optional.
  comment   = 'This optional comment is used for a title when plotting'
 /END

! det  X_orbit     Y_orbit

  0     0.4738      0.7273   ! orbit in mm
  1     3.9285      0.7567   ! orbit in mm
  2     2.6885      1.5943   ! orbit in mm
         ... etc ...
 99     0.1874      1.9483   ! orbit in mm

Note:


TOP

Phase/Cbar Data

There are three ways that phase/cbar "data" can be read into and/or manipulated in CESRV:
! Example of a phase/cbar file

 &DATA_PARAMETERS                          ! Fortran90 namelist.
  file_type = 'PHASE DATA'                 ! Identifies file as an phase/cbar file.
  horiz_freq = 9.5106                      ! Horizontal freq (1 => 2pi radians).
  vert_freq = 10.6056                      ! Vertical freq (1 => 2pi radians).
  lattice   = 'N9A18A000.FD93S_5269_15KG'  ! This is optional.
  data_date = '1998-JAN-06 18:05:36'       ! This is optional.
  save_set  =  51220                       ! This is optional.
  comment   = 'This optional comment is used for a title when plotting'
 /END

! det    phase_a   phase_b  cbar_11  cbar_12, cbar_22
        (radians) (radians)

  0      0.056    0.065     0.00344  0.0012   0.0006
  1      0.144    0.209     0.00023  0.0103   0.0098
         ... etc ...
 99     37.456   43.783     0.00583  0.0034   0.0046

Note:


TOP

All Data Files

General data files can be read in by CESRV.
! Example of a General data file

 &DATA_PARAMETERS                          ! Fortran90 namelist format.
  file_type = 'ALL DATA'                   ! Identifies this type of file.
  lattice   = 'N9A18A000.FD93S_5269_15KG'  ! Optional.
  data_date = '1998-JAN-06 18:05:36'       ! Optional.
  save_set  =  51220                       ! Optional.
  comment   = 'This optional comment is used for a title when plotting'
 /

 &PHASE_PARAMETERS           ! Namelist must be present even if parameters are not.
  species    =  1            ! Optional: +1 = positrons, -1 = electrons.
  horiz_freq =  9.5106       ! Optional: Horizontal freq (1 => 2pi radians).
  vert_freq  = 10.6056       ! Optional: Vertical freq (1 => 2pi radians).
 /

&ALL_DATA
  !    det      X      Y    Valid?
  orbit(0) = 0.0034  0.0005  T     ! In meters
  orbit(1) = ...

  phase(0) = 0.056    0.065  T     ! In radians
  phase(1) = ...

  beta(0)   = ...

  eta(0)    = ...
  ac_eta(0) = ...

  ! Cbar, unlike everything else, does not not have X, Y components.

  cbar11(0) = 0.00023 T            ! Dimensionless
  cbar11(1) = 0.00023 T

  cbar12(0) = 0.00453 T
  cbar12(1) = ...

  cbar21(0) = ...

  cbar22(0) = ...

/


TOP

Reloading Corrections or Restoring Save Set or Data Set Conditions

Say you have made a phase/coupling correction in the past and now, after changes have been made to CESR, you want to go back to the state that you had after you had put in the correction. If you had taken a CSR save set after the correction you could restore this. Alternatively, if you had saved the state of the CESRV MODEL (using the WRITE command) when you made the correction then you can reload the state from the MODEL. Example:
CESRV> READ MODEL 137          ! Reload the correct model. 
CESRV> READ DATA P:1405        ! Reload the data that the model was fit to. 
CESRV> OPT_VARS QUADRUPOLE     ! This only needed if OPT_VARS is presently 
                               !   set to something else. 
CESRV> LOAD                    ! Start the load sequence.
Notice that CESRV will always end up after a load at the exact same ending place irregardless of what the present conditions in CESR are. The same procedure will work with steerings or sextupoles except here if you have a save set then you could just as well restore the save set.

Using a variant of the above you can also restore the conditions that existed when you had taken a save set or had taken phase or orbit data. In this case you read in the save set or data set and set the MODEL = DESIGN. Example:

CESRV> READ DATA P:1405       ! Reload some data.
CESRV> READ CSR 54321         ! *Or* Read in a CSR Save Set.
CESRV> TRANSFER DESIGN MODEL  ! Make MODEL = DESIGN (not needed if you 
                              !   haven't varied the MODEL with FLATTEN, etc.).
CESRV> OPT_VARS QUADRUPOLE    ! This only needed if OPT_VARS is presently 
                              !   set to something else. 
CESRV> LOAD                   ! Start the load sequence.

TOP

Fitting using Multiple Data Sets

Normally when you fit the MODEL to the DATA (e.g. in Twiss corrections or orbit flattening) you are dealing with just one data set (a "data set" can include reference data). CESRV also has the capability of simultaneous fitting to multiple data sets. To do this you need to understand the concept of the "universe". The universe is a single MODEL + a single DATA set. Using the CREATE_UNIVERSES command you can create multiple universes. Each universe has its own MODEL and its own DATA. The variables in the MODEL of each universe can be varied separately using, for example, the CHANGE command. However, when you use the RUN command to fit the model to the data, the optimizer will couple the variables that it varies so that they will be the same across all universes. Thus, for example, with flattening using steerings, the steering strength of H10W (if it is used) will be the same in all universes after the flattening.

Note that since the optimizer varies variables across all universes, it does not matter which universe you are in when you VETO, USE, or, RESTORE variables. The data in separate universes, however, is separate. Thus, for example, VETO PHASE 52 will veto phase data only in the current VIEWed universe.

Example: Suppose you had two phase data sets. One set being taken with one particular pretzeled orbit and the other set with a different pretzeled orbit. If you then want to fit to the sextupoles your CESRV session might look like this:

  CESRV> create_uni 2   ! Create 2 universes
  CESRV> read P:405     ! Read data into universe #1
  CESRV> pretzel saved  ! Set the pretzel for universe #1 MODEL to the
                        !   save set values from the p:405 data
  CESRV> view_uni 2     ! work on universe #2
  CESRV> read P:406     ! Read in the 2nd data set into universe #2
  CESRV> pretzel saved  ! Set the pretzel for universe #2 MODEL to the
                        !   save set values from the p:406 data
  CESRV> opt sex        ! Fit with the sextupoles
  CESRV> run            ! Vary the sextupoles of both universes to fit 
                        !   the 2 data sets. After the fit, the strengths 
                        !   of the sextupoles will be the same
                        !   for both universes.

TOP

Specifying Elements for Veto, Restore, and Use Commands

Notes:


TOP

Calibrating BPMs with Respect to Quadrupole Centers

See detailed instructions.


TOP

Explanation of Commands



TOP
BASELINE <what> {<where>}

Where:
• <what> = [MODEL, DESIGN, FIT, NONE, REFERENCE, RM, RF, or RMB]
• <where> = [<Region Name>, or <Data Name>]
          (Note: HELP REGION and HELP DATA commands gives more info)

BASELINE determines the baseline for the plotting of data. That is, what is plotted is:
          <Something> - <Baseline>
Use the PLOT command to set <Something>. The BASELINE command sets <Baseline>. Note:

Examples: 
   BASE REF         ! Makes the reference data the baseline for both the
                    !  top and bottom plots.
   BASE MODEL PHASE ! Makes the model values the baseline for the 
                    !  phase plot(s).
   BASE DESIGN      ! Makes the design values the baseline.
   BASE NONE TOP    ! No baseline for the top plot. 
   BASE RM          ! Use reference and model for the baseline.
   BASE RMB         ! Use reference, model and base_model for the baseline.


TOP
BETA_RENORMALIZE

This command renormalizes the beta data my a multiplicative factor so that the median measured beta value is equal to the median MODEL beta value. The multiplicative factor is based on data used for the optimization.


TOP
CALIBRATE <magnet_name> <CU1> <CU2>
CALIBRATE BPM <bpm_index> <CU1> <CU2>

Where:
• <magnet_name> = Name of the steering or quadrupole magnet.
• <CU1>, <CU2> = CU Settings used for the difference measurement. If not given then CESRV will will choose <CU1> and <CU2>.

CALIBRATE measures the CU to kick calibration of a steering or quadrupole. CALIBRATE also measures the bpm centers with respect to the nearest quadrupole. CESRV will take a difference orbit or phase measurement using <CU1> and <CU2> and then fit the data to find the calibration. Note: To minimize errors, consider making a phase measurement or even correcting the lattice first. Note: CESRV only reads in the calibrations from the calibration files once at the beginning of the program. If you change a calibration you need to stop and restart CESRV.

If you are taking many measurements then to automate the process SET LOGIC%AUTO_MEASUREMENT = T so CESRV will not ask before taking a measurement. Note: If the analysis is off because of bad data points then veto the bad data and reissue a RECALIBRATE command. See also the SHOW CALIBRATION command to get an idea of what CU difference is needed to get a given orbit ripple. Also, for BPM calibrations, SET LOGIC%CALIB_BPM_CALC_ORBIT_BUMP = F will suppress the orbit bump calculation.

For steerings, the default CU1 and CU2 is calculated to give approximately a 4 mm maximum orbit change between CU1 and CU2 at beta = 20 m (the calculation ignores the resonance denominator in the formula so the actual change will be somewhat larger). For quadrupoles, CU2 - CU1 is set to 2000 CU.

If <CU!> Ends in "%" then the actual measurement range will be that percentage of the nominal range.

The calibration calculation uses the same derivative matrix of the MODEL that is used for fitting the MODEL to the DATA when the RUN command is issued. Initially on startup the MODEL is set equal to the DESIGN. If the actual optics are far from the DESIGN optics, this will introduce errors into the calibration calculation. If a phase/coupling measurement has been made then these errors can be eliminated by fitting the MODEL to one of the data sets and then using the DMERIT command to recompute the MODEL derivatives. This is important when calibrating skew quadrupoles since the Cbar wave created by varying the skew quadrupole strength is directly related to the tune split.

The calibration results for steerings are put in a file named "steering_calibration.dat" and for quadrupoles the data file is called "quadrupole_calibration.dat". If this file already exists then the results are appended to the file.

  
Examples:
  CALIB V11E        ! Calibrate steering V10E and let CESRV pick the limits.
  CALIB BPM 10 50%  ! Measure BPM 10W center using 50% of the nominal quad variation.
  CALIB SK_Q02W     ! Calibrate skew quad SK_Q02W 
  CALIB SEX_08E     ! Calibrate sextupole 8E
  CALIB H10W 0 500  ! Calibrate steering H10W between 0 CU and 500 CU.
  CALIB H_SEP_08W   ! Calibrate Horizontal Separator at 8W
  CALIB H_SEP_45E   ! Calibrate Horizontal Separator at 45E

TOP
BURN

BURN takes data generated by the SYNRAD command and makes a contour plot of the power hitting a crotch exit (window) or projected target.

The command will ask for which crotch to project from (4E 5E 6E 4W 5W 6W 11W WEST EAST or ALL) where:

 4E is F-line
 5E is E-line
 6E is D-line
 4W is C-line
 5W is B-line
 6W is A-line
11W is G-line

TOP
CALL <filename> <arg_list>

CALL opens a command file and executes the commands in it. Up to 9 arguments may be passed to the command file. The i^th argument is substituted in place of a string of the form "[i]".

Note: Command files may not be nested. That is, you may not use a CALL in a command file. To temporarily halt reading in of command input put a PAUSE command in the command file.

Note: CESRV will search the default directory for the command file. If not present, CESRV will then search the $CESR_ONLINE/acc_control/program_info/cesrv/command_files directory. Use the command SHOW COMMAND_FILES to see a list of command files.

Note: The file "cesrv.in", if present, will be read in automatically at startup.

Example:
  CALL my_cmd_file     ! Reads in commands from my_cmd_file
  CALL a_file ABC DEF  ! The argument string  "ABC" is substituted for any 
                       !   "[1]" appearing in a_file and "DEF" is 
                       !   substituted for any "[2]". 

TOP
CHANGE <what> <index> <change>
CHANGE ELEMENT <name> <attribute> <change>
CHANGE ELEMENT <name> IS_ON {<state>}
CHANGE ELEMENT <name> SLAVE <num> NAME <slave_name>
CHANGE ELEMENT <name> SLAVE <num> ATTRIBUTE <attribute>
CHANGE ELEMENT <name> SLAVE <num> COEFFICIENT <change>
CHANGE TWISS <plane> <which_twiss> <change>
CHANGE TWISS C_MAT <ij> <change>

Where:
• <what> = [<Variable Name> (See HELP VARIABLE)]
• <index> = Location of element to change
• <change> = Change in strength.
• <state> = [True, or False]
• <attribute> = Name of attribute whose value is to be changed.
• <plane> = [X, or Y]
• <which_twiss> = [ALPHA, BETA, ETA, or ETAP]
• <ij> = [11, 12, 21, or 22]

CHANGE allows you to change the value of almost anything that can be varied. For overlay_lord elements you can change which slave elements are controlled, what attributes are varied, and what the coefficients. For more information on overlay_lords see the BMAD documentation. The CHANGE command can also be used to vary an element's longitudinal position using the "S_OFFSET" attribute (see the example below).

Note: If you are dealing with multiple universes, CHANGE will only change the variable of the currrently VIEWed universe. To set the corresponding variables of all the universes, replace "CHANGE" with "*CHANGE".

The CHANGE TWISS command is used with the &CUT_RING command. Note:

Examples: 
  CHAN SEX 59 0.4T        ! Change 40E sextupole to 0.4+Design
  CHAN CAM 1 35 UM        ! Change cam_rho #1 by 3.5e-6 meters.
  CHAN QU QADD_47E -.02   ! Change QADD_47E quadrupole strength by -.02 
  CHAN QUAD 34 2.3%       ! Change quad 34 K1 by 2.3%
  CHAN HORI 90 0.05       ! Change horizontal steering 9E by 0.05 radians
  CHAN CUSTOM 20 1.2      ! Change custom variable #20 by 1.2
  * CHAN VER 23 200CU     ! Change vertical steering 23W by 200CU and then
                          !   set vert 23W of all other universes to the
                          !   value of this one.
  CHAN QU 34 CU 145       ! Change Quad 34 by 145 CU
  CHAN OCT 1 @100CU       ! Set OCT_45W to 100 CU
  CHAN _SKEW 1 0.03       ! Change SK_SEX_23W k2 value by 0.03
  CHAN GR PRETZING 1 100  ! Change CSR PRETZING 1 by 100 CU
  CHA ELE Q10W TILT D15   ! Change Tilt of element Q10W by 15 degrees.
  CHA ELE Q10W S_OFFSET 1 ! Move Q10W longitudinally by 1 m.
  CHA ELE MB05W IS_ON     ! Toggle on/off state of MB05W 
  CHA ELE MB05W IS_ON F   ! Toggle state of MB05W to off (looks like a drift)
  CHA ELE MB05W IS_ON T   ! Toggle state of MB05W to on  (normal state)
  CHA ELE H20W SLAVE 1 NAME B34W   ! Change the 1st slave of H20W to B34W
  CHA ELE H20W SLAVE 1 ATTRIBUTE VKICK  ! Change the 1st slave attribute
  CHA ELE H20W SLAVE 1 COEF 0.23        ! Change the 1st slave coefficient

TOP
CHROM_TUNE <dQ'x> <dQ'y>

Where:
• <dQ'x>, <dQ'y> = Change in MODEL chromaticities.
Use "@" symbol before <dQ'x> for absolute value Default is to change the MODEL chromaticities to match DESIGN.

CHROM_TUNE Changes the model sextupole k2's so that the chromaticities change by <dQx> and <dQy>. One use for CHROM_TUNE is to change the model to matched the design chromaticities. This is useful when you are doing a sextupole correction at a chromaticity that is not the same as the design and you do not want the chromaticity to change when you put in the correction.

Examples:
     CHROM 1 1    ! Change the model x and y chromaticities by 1 unit.
     CHROM        ! Change the model x and y chromaticities to match design.

TOP
CLIP {<plane>} <where> {<level>}

Where:
• <plane> = [X, or Y]
• <where> = [<Region Name>, or <Data Name>]
          (Note: HELP REGION and HELP DATA commands gives more info)
• <level> = value over which data is clipped. Default is plot maximum.

CLIP vetoes displayed data locations where the absolute value of what is plotted is over <level>. <where> can only be omitted with a wave plot. If <plane> is omitted then both X and Y plots are clipped.

Examples:                                
     CLIP TOP 5    ! For the top plot: Veto all locations where 
                   !          |Plotted phase data| > 5
     CLIP X PHASE  ! For the phase plot: Veto all locations where 
                   !          |plotted x data| > X_PLOT_MAX
     CLIP          ! With a wave plot: Veto all locations where 
                   !          |plotted data| > PLOT_MAX

TOP
CLOSE_BUMP <bump_name> <delta_cu>
CLOSE_BUMP V_SEP_BUMP

Where:
• <bump_name> = The 5 letters of the node name (without the beginning "CSR" and the ending "ING") along with the element number.
• <delta_cu> = Change in bump for the measurement. CESRV will will choose the start and stop CU based upon this number, the software limits and the present value of the bump. if <delta_cu> is 0 then a default 1000 CU will be used. If no measurement is done then this number is ignored

CLOSE_BUMP closes orbit bumps. For everything but the vertical separator bump CESRV closes a bump using 2 steerings in the bump (you will be prompted for what steerings to use). CESRV will take a difference orbit with <delta_cu> change in the knob (<delta_cu> may be negative) and then fit the data to close the bump. If you veto taking a measurement then CESRV will use the present DATA and REF orbits for the measurement. In this case CESRV will figure out what <delta_cu> is from the data sets. After CESRV calculates the new coefficients you will be prompted if you want the new calibrations put in the Data Base. Note: To minimize errors, consider correcting the lattice before you do this. Note: If the analysis is off because of some bad data points, veto the bad data and reissue the CLOSE_BUMP command. This time, however, do not take a new measurement. Note: For 4 element bumps the FIX_GROUP command is recommended.

For closing the vertical separator bump CESRV will use CSR VCROSING 4 and 7. In this case if CESRV sets the bump then CESRV will use the OLD voltage settings in the CESR Data Base.

For fixing group knobs use the FIX_GROUP command. Essentially the difference between FIX_GROUP and CLOSE_BUMP is that CLOSE_BUMP only works for bump group knobs but is more automated than FIX_GROUP.

Examples:
   CLOSE HBUMP 12 500   ! Close CSR HBUMPING #12 with Delta CU = 500 CU.
   CLOSE VBSAV 1        ! Close CSR VBSAVING #1 with Delta CU = 1000 CU.
   CLOSE V_SEP_BUMP     ! Close the vertical separator bump.

TOP
CONTINUE

CONTINUE is used to continue reading from a command file after the command file has been PAUSEed.


TOP
CREATE_UNIVERSES <num>

CREATE_UNIVERSES creates multiple universes (see the section above on "Fitting using Multiple Data Sets"). The viewed universe is set by CREATE_UNIVERSES to universe #1. See also the VIEW_UNIVERSE command. Note: The universes are all initialized so you will lose any changes you have made to any variables.

Example:
    CREATE 2    ! Creates 2 universes

TOP


CUT_RING <element>

CUT_RING is for 1-turn tracking analysis. CUT_RING makes the lattice non-circular and the MODEL tracking is done starting at <element> and going for 1-turn. To make the lattice circular again use "-" as the element.

The initial coordinates are controlled using the INIT_ORB variables. The INIT_ORB variables act like any other variables and may be CHANGED or used to fit the MODEL to the DATA using the RUN command. Use the SHOW command to see which INIT_ORB variables are enabled for fitting. Use the SHOW CUT_RING command to view the INIT_ORB values.

Using a "&" before the CUT_RING command causes the Twiss parameters as well to be calculated assuming a cut ring starting from the cut element. Use the CHANGE TWISS command to vary the initial Twiss parameters in this case.

Examples:
  CUT  Q34W   ! Cut at the end of Q34W and do tracking from this point.
 &CUT  Q34W   ! Same as above but the Twiss parameter are now calculated
              !   taking the cut into account.
  CUT  345    ! Cut at the end of element number 345.
  CUT  -      ! Undo the cut.

TOP
DELETE_FILE <type>

Where:
• <type> = [MODEL, PHASE, or ETA]

DELETE_FILE deletes the last data file taken.

Examples:
     DELETE MODEL    ! Delete latest model file created with WRITE MODEL.
     DELETE PHASE    ! Delete latest phase/coupling data file.

TOP
DMERIT

DMERIT forces recomputation of the derivative matrix which is used by the optimizer when you RUN. You want to recalculate when the nonlinearities in the problem are such that the current true derivatives are different from what was last calculated due to the change in the model variables since the last calculation.

  
Example:
   DMERIT          ! Does a recalculation of the derivative matrix.
   DMERIT DIGEST   ! This calculates and writes out a new digested file 
                   !   for the dmerit matrix.

TOP
END_FILE

Marks the end of a command file. Lines after an END_FILE will not be processed. See the CALL command.


TOP
ENERGY_USER_CTRL {<toggle>} <number>
ENERGY_USER_CTRL RING <GeV>

Where:
• <toggle> = [ON, or OFF]
• <number> = Value for energy error dE/E
• <GeV> = Energy in GeV

ENERGY_USER_CTRL is used to set either: 1) the energy error of the beam in the model relative to the design energy or 2) the ring design energy itself.

With ENERGY_USER_CTRL OFF, the model beam energy error is calculated by CESRV using as input the steering strengths. In this mode one can see how much the beam energy will change with flattening.

With ENERGY_USER_CTRL ON, the user is allowed to set the model beam energy error. This means that the energy shift due to kicks will not be calculated.

With ENERGY_USER_CTRL RING, the user can set the design energy of the lattice itself. With this, the DESIGN values for quadrupole strengths, etc. will be kept constant but the calibrations between strength and CU will be scaled appropriately. Note: The CLEO solenoid, Q00W, Q00E and the wigglers will have their strengths scaled as if their magnetic fields are constant.

Note: If you are dealing with multiple universes, ENERGY_USER_CTRL will only change the energy the currrently VIEWed universe. To set the energy of all the universes, replace "ENERGY_USER_CTRL" with "*ENERGY_USER_CTRL".

Examples:
   ENERGY           ! Type status of ENERGY_USER_CTRL
   ENERGY ON        ! Fix the model beam energy error at dE/E = 0.0
   ENERGY ON 0.001  ! Fix dE/E at 0.001
   * ENERGY ON 0.01 ! Fix dE/E at 0.01 in all universes.
   ENERGY OFF       ! dE/E is variable dependent upon steering strengths.
   ENERGY RING 5.3  ! Set the ring design energy to 5.3

TOP
ENGINE {<engine>}

Where:
• <engine> = [FLETCHER, or MARQUARDT]

ENGINE selects what optimizing algorithm to use. MARQUARDT is the default. For more information on how the optimizers work see the optimizer section.

Examples:
     ENGINE        ! Show which algorithm is being used.
     ENGINE MARQ   ! Use Levenberg-Marquardt (cf. MRQMIN in Num. Rec.)
     ENGINE FLET   ! Use Fletcher-Reeves (cf. FRPRMN in Numerical Recipes)

TOP
EXIT

Exits the program.


TOP
F: <file_name>

F: Reinitializes the model with a new lattice using the specified bmad input file. This is the same command as the one you can use to start up CESRV.

 
Example:
  CESRV F: BMAD_ABC.EFG               ! Use this bmad input file.

TOP
FIX_GROUP <group_name> <delta_cu>

Where:
• <group_name> = The 5 letters of the node name (without the beginning "CSR" and the ending "ING") along with the element number.
• <delta_cu> = Change in the bump (Data - Ref) used in the the measurements.

FIX_GROUP fixes group knob coefficients based upon measurement. The process is as follows:

  1. If it doesn't exist, create a BIGGRP set with the correct theoretical group coefficients. For bumps this means running the program CREATE_CESR_BUMPS, loading coefficients into the data base, and then (at the VMS level) SAVE BIGGRP. [You might want to reload the current BIGGRP after this. It depends upon whether you want to start from the theoretical coefficients or the current coefficients.]
  2. After you start CESRV, read in the BIGGRP set with the theoretical coefficients using the command READ BIGGRP.
  3. read or take a baseline measurement. Put this into DATA.
  4. Fit the MODEL to the DATA. Use any variables you want.
  5. TRANSFER MODEL BASE_MODEL to set BASE_MODEL = MODEL
  6. Read or take data with the group knob changed by <delta_cu>. Put this into DATA and the original measurement into REF (use READ or TRANSFER commands).
  7. PLOT DATA - RMB to plot: (Data - Ref) - (Model - Base_Model).
  8. CHANGE GROUP <group_name> <delta_cu> to set the MODEL to correspond to the change in the group knob. Note: This last step is only needed to properly set unvaried variables if you do not use all of the variables of the group when you run the optimizer.
  9. Setup to run the Optimizer:
  10. RUN the optimizer. If you are having problems consider:
  11. Repeat the last two steps until you have a good optimization (a flat graph).
  12. use the FIX_GROUP command to calculate new group coefficients. FIX_GROUP will ask you if you want to load the new coefficients into the CESR data base. FIX_GROUP will never change the coefficients in CESRV since these must always remain the theoretical coefficients for FIX_GROUP to work.

Note: For fixing 3 element bump knobs use the CLOSE_BUMP command instead which is faster and more painless.

Examples:
   FIX SCMAT 5 200    ! Fix CSR SCMATING #5 with Delta CU = 200 CU.

TOP
FLATTEN

FLATTEN is exactly the same as RUN. See the RUN command or more details.


TOP
HELP COMMANDS
HELP <command>
HELP <section>

Where:
• <command> = Any CESRV command.
• <section> = [TOPIC:WAVE, or TOPIC:FLATTENING]

HELP gives general help on various aspects of CESRV. NOTE: to get help on a particular command an alternative syntax is:

<command> ?
Examples:
   HELP COMMANDS       ! Gives a list of the commands CESRV knows about.
   HELP PLOT           ! Gives help on the PLOT command.
   HELP SET            ! Gives help on the SET command.
   PLOT ?              ! Same as HELP PLOT.
   HELP TOPIC:WAVE     ! Gives help on wave analysis.
   HELP TOPIC:FLATTEN  ! Gives help on flattening the orbit.
   HELP                ! Gives this message.

TOP
HISTORY
HISTORY <number>
HISTORY <string>

CESRV stores the last 100 commands in a command line buffer. You can recall and modify any particular command in the buffer by pressing the Up_ARROW repeatedly.

The commands in the buffer are numbered starting from 1. When recalling a command "0" denotes the last command and a negative number is relative to the last command. A "command" is what you type at the CESRV> prompt. Other stuff that you type will not be recorded. Remember: All commands are recorded that get past the first round of error checking. Thus "bad" commands can get into the history list. Use the REMEMBER command if you want to record the commands in the history buffer (along with all future commands) in a file.

Examples
   HIST        ! Prints last 50 commands.
   HIST 23     ! Execute command numbered 23.
   HIST -1     ! Execute the command before the last command.
   HIST RE     ! Execute the last command that started with "RE"

TOP
INSERT <what>

Where:
• <what> = [BBI, FILE <name>, or LRBBI <name>]

INSERT inserts various elements into the ring structure. Note: For the LRBBI elements to change the number of particles in the bunches use the "SET N_PART = <value>" command. to control individually the number of particles use the command "CHANGE ELE LRBBI_nnn CHARGE <value>"

Examples:                                        
  INSERT BBI     ! Insert a Beam-Beam interaction element at the IP
                 !   (Actually at element #1)
  INS FILE ABC   ! Read the BMAD file ABC.BMAD.
                 !   The default file name suffix is ".BMAD"
  INS LRBBI ABC  ! Inserts long range BBI elements from the file ABC.BMAD.
                 !   The LRBBI elements must have names beginning with
                 !   "LRBBI_". CESRV will offset the elements = -pretzel.


TOP
L: <lattice>

L: Reinitializes the model with a new lattice. This is the same command as the one you can use to start up CESRV.

 Examples:
   L:                ! You will be given a list of lattices to choose from.
   L: 8              ! Use the 8th lattice in the lattice list
   L: N9A19B700.FD93S_5269_15KG  ! Use this lattice.

TOP
LIMIT {<toggle>}
LIMIT ZERO <who> <number>

Where:
• <toggle> = [ON, or OFF]
• <who> = [HORIZONTAL, or VERTICAL]

There are software limits in the CESR data base that limit the range of orbit steering strengths, quad k, and sextupole k2 values. When RUNning the optimizer, these limits are checked, and if a variable TARGET value is outside of the permissible range, CESRV will set the variable MODEL value so that the TARGET value is at the limit. Additionally, CESRV will and will VETO the variable so the it will not be further used by the optimizer.

LIMIT ZERO is used to set a band around zero off limits to avoid power supply regulation problems. If the magnitude of a target value is less than <number> then the model value will be changed to make the target value equal to <number> and the corrector will be vetoed from the optimizer list. <number> is in CU. To disable LIMIT ZERO use a value of 0 for the limit number.

Examples:
  LIMIT OFF        ! Ignore any limits with RUN command.
  LIMIT ON         ! Check limits. Limits will be checked with RUN and
                   !   write commands.
  LIMIT            ! Same as LIMIT ON.
  LIMIT Z VERT 100 ! Make all vertical corrector strengths > 100 CU        

TOP
LOAD <fraction>
LOAD <who> <fraction>

Where:
• <who> = [QUADRUPOLES, SEXTUPOLES, STEERINGS, _SKEW_SEX, or SKEW_QUAD]
• <fraction> = fraction of the correction to load (default = 1.0)

LOAD loads steering, quadrupole or sextupole corrections to the database. If <who> is not specified then what gets loaded depends upon the setting of OPT_VARS.

If the MODEL is not touched, or new data taken, repeated loads can be done. The cumulative effect is the sum of all the loads. For example, two sequential loads with fraction = 0.5 is equivalent to a single load with fraction = 1. Similarly, a load with fraction = 1 followed by a load with fraction = -1 will restore the magnets to their original state before the first load.

Examples:        
    LOAD _SKEW_SEX 0.5   ! Load half the skew sextupole correction

TOP
MERIT_DATA <type>
MERIT_DATA <cbar_type> {<true_false>}

Where:
• <type> = [TWISS, ORBIT, or ALL_DATA]
• <cbar_type> = [CBAR11, or CBAR22]
• <true_false> = [TRUE, or FALSE]

MERIT_DATA sets what data is put in the merit function. To select what variables are used in the optimization use the command OPT_VARS.

Examples:
    MERIT TWISS       ! Use Phase and Cbar data in the merit function.
    MERIT ORBIT       ! Use Orbit data in the merit function.
    MERIT ALL         ! Use both Phase, Cbar and Orbit data.
    MERIT CBAR11 TRUE ! Use Cbar11 data as well as Cbar12 data.
    MERIT CBAR11      ! Use Cbar11 data as well as Cbar12 data.


TOP
MULTIPOLE {<which>}

Where:
• <which> = [ON, or OFF]

MULTIPOLE turns on or off any multipole elements in the MODEL.

Examples:
     MULTI          ! Types whether the multipoles are on or off.
     MULTI ON       ! Turns on any multipoles.
     MULTI OFF      ! Turns off any multipoles.

TOP
OPT_VARS <what>
OPT_VARS <lock_state>

Where:
• <what> = [QUADRUPOLES, SEXTUPOLES, STEERINGS, ALL_VARS {<file_name>}, or CUSTOM {<file_name>}]
• <lock_state> = [LOCKED, or UNLOCKED]

OPT_VARS sets what correctors are to be varied for the optimization. The initial setting of OPT_VARS depends upon what type of data been read in. To see what OPT_VARS is use the SHOW command.

<what> = CUSTOM is used to select a custom set of correctors. The custom set is specified by an input file. The default name of the input file is special_vars.in. See below for details on the file format.

<what> = ALL_VARS is for using all the variables. If you give a file name then this will be used to read in the CUSTOM variables.

Normally CESRV changes the opt_vars state automatically to fit the data that is read in. For example, if the current opt state is QUADRUPOLES and orbit data is read in then CESRV will change OPT_VARS to STEERINGS. to prevent automatic changing use the LOCKED toggle.

To select the type of data being optimized use the command MERIT_DATA.

Examples:        
  OPT QUAD        ! Optimize twiss parameters using quad 
                  !   strengths and skew quad strengths.
  OPT SEX         ! Optimize twiss parameters using sextupole strengths.
  OPT STEER       ! Optimize the orbit using the steerings.
  OPT ALL         ! Use all the variables.
  OPT ALL FOO     ! Same as above and the file FOO.IN is read to get
                  !   the custom variables.
  OPT CUSTOM      ! Optimize with custom set from SPECIAL_VARS.IN
  OPT CUSTOM FOO  ! Optimize with custom set from FOO.IN
  OPT LOCKED      ! Prevent CESRV from automatic changing of the
                  !      OPT_VARS state.
  OPT UNLOCKED    ! Allow automatic change of OPT_VARS state.

TOP
OUTPUT <out_type>
OUTPUT -NO_CLOSE <out_type>

Where:
• <out_type> = [HARDCOPY, GIF, or PS]

OUTPUT outputs the plot.

The -NO_CLOSE optional switch can be used to generate files with multiple pages of graphics. When using this switch, a final OUTPUT command without the switch will write the current plot and close the plot file.

Examples:
     OUT HARD       ! Create a hardcopy of the plot on a printer
     OUT GIF        ! Create a GIF file of the plot
     OUT PS         ! Create a PostScript file of the plot. No printing.

TOP
PAUSE <value>

PAUSE pauses CESRV. This is useful in a command file (see the CALL command) when you want to make sure a plot stays around long enough for you to see it. If <value> is negative, CESRV will wait until you press a CR or type STOP. The STOP will disable reading from the command file until a CONTINUE command is issued.

Examples:
     PAUSE      ! Default Pause time is 3 seconds.
     PAUSE 1.2  ! Pause 1.2 seconds.
     PAUSE -1   ! Pause until CR is pressed or type STOP.

TOP
PLOT
PLOT <data_name> {<where>}
PLOT <something> {<where>}
PLOT <something> - <baseline> {<where>}
PLOT <mode>
PLOT <variable>

Where:
• <data_name> = [<Data Name>, ENERGY, FFT, NONE or SYMMETRIC]
          (Note: HELP DATA command gives more info)
• <something> = [DATA, DESIGN, BASE_MODEL, FIT, MODEL, or REFERENCE]
• <baseline> = [MODEL, DESIGN, FIT, NONE, REFERENCE, RM, RF, or RD]
• <mode> = [IP_AT_CENTER, MAGNIFICATION , NORMALIZE_BETA, OFF, ON, or STANDARD]
• <variable> = [QUAD_K1, SKEW_QUAD_K1, RAW, SEX_K2, HBND HORIZONTAL, VERTICAL, or WAVE]
• <where> = [BOTTOM, TOP, or ALL]

the PLOT command sets what is plotted. When plotting data what is plotted is:

<something> - <Baseline>
Use the PLOT command to set <something> and optionally <Baseline>. Use the BASELINE command to set <Baseline> by itself. See the BASELINE command for more information on <Baseline>.

Examples:
  PLOT            ! Replots last request.
  PLOT BASE_MODEL ! Plot BASE_MODEL - <Baseline>.
  PLOT DATA       ! Plots DATA - <Baseline> in top and bottom plots.
  PLOT DATA TOP   ! Plots DATA - <Baseline> in the top plot.
  PLOT DATA-REF   ! Plots DATA - REF in both plots.
  PLOT DESIGN     ! Plots DESIGN - <Baseline>. If <Baseline> = DESIGN and
                  ! the pretzel is on then the plot will be: 
                  !     DESIGN(W/PRETZ) -  DESIGN(W/O PRETZ)
  PLOT ENERGY     ! Plot beam energy around the ring.
                  !   To show energy variations due to radiation damping use:
                  !     SET LOGIC%RADIATION_ON = T
  PLOT FFT        ! Plot FFT of TBT data. Use SET LOGIC%IX_BPM_FFT to set which BPM is used.
  PLOT IP_AT_CENTER  
                  ! Toggle whether the IP is at the start and end of the plot
                  !  (the default) or at the center of the plot.
  PLOT MAG 0.5    ! X11 plot window will be half as large as the standard size.
  PLOT MODEL      ! Plots MODEL - <Baseline>  in top and bottom plots.
  PLOT NONE BOT   ! Suppress the bottom plot.
  PLOT NORMALIZE_BETA
                  ! Toggles whether dBeta/Beta or dBeta is plotted with beta plots.
  PLOT OFF        ! Turns off plotting. Used with command files to speed
                      things up.
  PLOT ON         ! Turns on plotting. Used with PLOT OFF.
  PLOT ORBIT      ! Plot orbit data in bottom plot.
  PLOT PHASE      ! Plot phase in the top plot and cbar data in the bottom.
  PLOT PHASE BOT  ! Plot phase data in the bottom plot.
  PLOT RAW        ! Plot raw button signals for orbit or phase data.
  PLOT REF BOT    ! Plots REF - <Baseline> in the bottom plot.
  PLOT STANDARD   ! Display the standard plot (ie, not the wave plot).
  PLOT TWISS      ! Top Plot: Phase data, Bottom Plot: Cbar data.
  PLOT WAVE       ! Plots the results of the wave analysis.

TOP
PRETZEL <which> <factor>

Where:
• <which> = [OFF, DESIGN, or SAVED]

PRETZEL sets the MODEL kicks given by the horizontal separators. If <factor> is present then the values of the kicks will be multiplied by <factor>. Use the transfer command for changing the MODEL vertical separators.

Examples:
   PRETZ OFF       ! Turns off the separators
   PRETZ SAVED     ! Uses the actual kicks as recorded in the data file.
   PRETZ DESIGN    ! Uses the theoretical kicks scaled so that the
   PRETZ DES -1.0  ! Uses the negative of the theoretical kicks.

TOP
PROJECT

PROJECT takes data generated by the SYNRAD command and projects synchrotron radiation that hits crotch exits further by a specified amount.

The command will ask for which crotch(es) to project from, (4E 5E 6E 4W 5W 6W 11W WEST EAST or ALL) where:

 4E is F-line
 5E is E-line
 6E is D-line
 4W is C-line
 5W is B-line
 6W is A-line
11W is G-line

TOP
Q_TUNE <dQx> <dQy>

Where:
• <dQx>, <dQy> = Change in MODEL tunes in kHz.
Use "@" symbol before <dQx> for absolute value Use "DATA" or "DESIGN" to qtune to the Measured or Design values.

Q_TUNE Changes the model k1's in the arcs so that the tunes change by <dQx> and <dQy>. One use for Q_TUNE is to change the model to match the design tunes. This is useful when you are doing quad corrections at a different actual tune from the design and you do not want the tune to walk when you put in the corrections.

Normally Q_TUNE uses all the quads associated with the CSR_QUAD_CUR data base node. If you put a "&" before "Q_TUNE", an additional restriction is imposed that only quadrupoles that are currently being used in the optimization will be used.

Examples:
  Q_TUNE 0 -1        ! Q_tune model Q_y down 1 kHz.
  Q_T @ 210 231      ! Q_tune model to Qx = 210 kHz, Qy = 231 kHz.
  Q_T DATA           ! Q_tune model to match the measured data.
  Q_T DESIGN         ! Q_tune model to match the design values.
  &Q_T DESIGN        ! Same as above except do not use any vetoed quad.

TOP
RAYOUTPUT

RAYOUTPUT takes data generated by the SYNRAD command and lists information about each ray hitting either a crotch exit (window) or projected target.

The command will ask for which crotch(es) to list rays for, (4E 5E 6E 4W 5W 6W 11W WEST EAST or ALL), where:

 4E is F-line
 5E is E-line
 6E is D-line
 4W is C-line
 5W is B-line
 6W is A-line
11W is G-line

TOP
RAYPLOT

RAYPLOT takes data generated by the SYNRAD command and plots the center of each ray hitting either a crotch exit (window) or projected target.

The command will ask for which crotch to plot (4E 5E 6E 4W 5W 6W 11W WEST EAST or ALL), where:

 4E is F-line
 5E is E-line
 6E is D-line
 4W is C-line
 5W is B-line
 6W is A-line
11W is G-line

TOP
READ <type> <file_number>
READ CSR *
READ {<data_or_ref>} <data_type> <file_number>
READ {<data_or_ref>} FAKE <file_name>
READ <DESIGN_DIGESTED> <file_name>
READ <MODEL_DIGESTED> <file_name>

Where:
• <type> = [CONDX, CSR, BIGGRP, or MODEL]
• <data_or_ref> = [DATA, or REFERENCE]
• <data_type> = [ETA, AC_ETA, ORBIT, PHASE, or TBT]

READ reads in a data file. Additionally READ can read in a model or digested bmad file generated with the WRITE command. When using a file_number, "0" denotes the latest model or measurement and a negative number is relative to the latest measurement. See also the INSERT command for modifying the lattice layout.

Note: When using READ to read in save set values from CSR or CONDX save sets, the values read in are put into the "SAVED" corrector values. Use the SAVE CSR command to save a CSR save set.

"READ CSR *" is like READ CSR except the values are read from the current Cesr database settings.

Note: Reading in an orbit means reading in a "buttons" file and converting the detector button readings to x-y orbit data. By default LOGIC%NONLINEAR_CALC = T so that nonlinearities in the detector button signals are taken into account in the conversion to x-y orbit data. Set this to False to disable the nonlinearity calculation. This will not affect data that has already been read in. By default, button calibration info is not used, but it can be enabled by toggling the NONLIN_BPM_USE_COEFF variable.

From the turn by turn (TBT) data, the beta function, beta betatron phase, coupling (CBAR), and DC orbits can be computed. The beta data is always loaded into CesrV but the other data is only loaded if the logical LOGIC%READ_TWISS_WITH_TBT is set to TRUE (using the SET command). The default for this logical is FALSE.

Examples:
  READ BIG 62333       ! Read the BIGGRP_SET.62333 save set.
  READ CONDX 64539     ! Import the values from condx_set.64539.
  READ CSR *           ! Use the current values in the CESR Data Base
  READ DATA FAKE PHA_1 ! Reads the data file PHA_1.DAT.
  READ DATA 55100      ! Loads the data from L_BUT:BUTNS.55100 or
                       !   L_PHASE:PHASE.55100 depending upon the
                       !   OPT_VARS setting
  READ DAT E 5         ! read the dispersion data from L_ETA:ETA.00005
  READ 0               ! Same as above if the latest data number is 55100.
  READ REF P 0         ! Read latest phase/coupling data.
  READ REF P           ! Same as P 0.
  READ MODEL  0        ! Reads in the latest model values from
                       !   L_MODEL:MODEL.nnnnn
  &READ P:1234         ! Reanalyze existing data. Do not use. For debug only.
  READ TBT:-5          ! Read turn-by-turn data. SET LOGIC%READ_TWISS_WITH_TBT to
                       ! enable reading of phase, coupling and orbit data.
  READ DESIGN_DIGEST RING.DAT ! Read in a new design lattice from the 
                              !   digested BMAD file RING.DAT.
  READ MODEL_DIGEST RING.DAT  ! Read in a model lattice from the 
                              !   digested BMAD file RING.DAT.

TOP
RECALIBRATE
RECALIBRATE <who>
RECALIBRATE <who> <data_file1> <data_file2>
RECALIBRATE <data_file1> <data_file2>

Where:
• <who> = [QUADRUPOLE, BPM, or BPM <index>]
• <data_file1>, <data_file2> = Data file names to use for the calibration. If not given then CESRV will use the current files that have been read in.

RECALIBRATE calculates the CU to kick calibration constant for a steering or a quadrupole magnet. RECALIBRATE is similar to the CALIBRATE command except RECALIBRATE uses existing data. RECALIBRATE will figure out which steering or quadrupole has been changed and by how much. See the CALIBRATE command for more details.

Examples:
   RECAL                 ! Recalibrate using current data.
   RECAL O:65933 O:65934 ! Recalculate calibration using BUTNS.65933 and 
                         !   BUTNS.65934

TOP
REMEMBER
REMEMBER <file_name>

REMEMBER records all the commands that are in the command history buffer to a file and then turns on the automatic recording of all future commands you type until you exit CESRV. See the HISTORY command for some important details. Use the REMEMBER command only once in a session. The default file name is: "cesrv_cmds.in".

Examples:
  REMEM          ! Record commands using the default file: cesrv_cmds.in
  REMEM ABC      ! Record commands using the file: abc.in

TOP
RESTORE <what> <list>
RESTORE ALL_DATA
RESTORE ALL_VARS

Where:
• <what> = [2QX, 2QY, BPM_TILT, BETA, CBAR, CUSTOM, ETA, GROUP, HORIZONTAL, H_SEPARATOR,ORBIT, PHASE, QUAD, QX+QY, QX-QY, SEXTUPOLE, SKEW_QUAD, SLAVES, SYM_K1, VERTICAL, or _SKEW_SEX]
• <list> = [List of locations, or ALL]

RESTORE adds to the list of: 1) Correctors to be used by the optimizer, or 2) Data to be used in the merit function. See also USE and VETO. The difference between RESTORE and USE is that USE vetoes everything first.

See also the MERIT_DATA and OPT_VARS commands for setting what data and/or variables are included in the optimization.

 Examples:
   RESTORE ALL_DATA         ! Restore all data.
   RESTORE ALL_VARS         ! Restore all variables
   RESTORE PHASE 2E:2W      ! Restore IR phase measurements.
   RESTORE VERT 10E:4E      ! Restore vertical steerings.
   RESTORE GROUP PRETZ 1    ! Restore CSR PRETZING 1 group knob.
   RESTORE SLAVES PRETZ 1   ! Restore CSR PRETZING 1 slave elements.

TOP
REVERSE_TRACKING

REVERSE_TRACKING reverses the direction that particles are tracked. The direction of tracking is only important when radiation damping is turned on (using the SET command).

Note: The reverse tracking is accomplished by reversing the order of the elements in the lattice. Thus the SHOW RING command will show the elements in the reverse order of what they normally are. However, the various plots that use the detector index along the x-axis will still plot this index from 0 on the left to 99 on the right.


TOP
RF <which>

Where:
• <which> = [ON, or OFF]

RF turns on or off the RF fields in the RF cavities. The startup default is to have the RF off.

Examples:
     RF ON       ! Turns on the RF
     RF OFF      ! Turns off the RF

TOP
RUN

RUN runs the optimizer which varies the correctors to minimize the merit function. Use the ENGINE command to set what optimizer to use. See also: SET, VETO, RESTORE, and USE.


TOP
SAVE <what>

Where:
• <what> = [BPM_CALIBRATION, CONDX, CSR, or GOLDEN]

SAVE BPM_CALIBRATION saves the last BPM calibration calculated using CALIBRATE BPM.

SAVE CONDX creates a condx save set from the present Cesr database conditions.

SAVE CSR creates a csr save set from the present Cesr database conditions.

SAVE GOLDEN saves the cu_saved variable values to be used with the LOAD GOLDEN command.


TOP
SCALE {<plane>} {<where>} <level>
SCALE {<plane>} {<where>} MIN <min_num> MAX <max_num>

Where:
• <plane> = [X, or Y]
•<where> = [TOP, BOTTOM, ALL, 2QX, 2QY, ORBIT, PHASE, CBAR, CBAR_ALL, BETA, ETA, QX+QY, QX-QY, or SPLINE_BETA]
• <level> = Value to set plot maximum. minimum is set to -maximum. If <level> is not present maximum is chosen so that all the data fits on the plot.
• <max_num> = Value to set the plot maximum.
• <min_num> = Value to set the plot minimum.

SCALE scales the plot maximum and minimum. If <where> is omitted then both TOP and BOTTOM plots will be scaled. If <plane> is omitted then both X and Y plots are scaled. Normally the plot is symmetric about zero so that minimum = -maximum. There is an exception here for some beta and spline beta plots where the minimum is set to 0. To specify the maximum and minimum separately put "MAX" or "MIN" in front of the number. Note: SCALE CBAR will scale the cbar12 plot and set the cbar11 and cbar22 plots to this scale. SCALE CBAR_ALL, like SCALE CBAR, will scale all three plots to the same scale. However, in this case, the data points of all three plots will be on scale.

Example:
  SCALE PHASE 10         ! Set phase plots max = 10, min = -10.
  SCALE TOP              ! Set top plots max and min to make the data fit 
                         !   the plot.
  SCALE X TOP 0.8        ! Set X top plot max = 0.8, min = -0.8
  SCALE BOTTOM MIN -4    ! Set bottom plots min = -4.
  SCA TOP MAX 10 MIN -2  ! Set top plots max = 10, min = -2.

TOP
SET <parameter> = <value>
SET <parameter> *= <value>
SET <parameter> /= <value>

Where:
• <parameter> = Parameter name.
• <value> = Value to set to.

SET sets various parameters. To examine the parameters use the SHOW command. the word "SET" may be omitted. The "*=" and "/=" forms of the set command multiply and divide the present value of the parameter by <value>.

Note: If you are dealing with multiple universes then using a "*" before the SET command set the corresponding variables of all the universes.

The following abbreviations are recognized:

The following vectors can be used to manipulate data and weights:

If an orbit vector is being set, <value> may refer to a corresponding orbit vector. See below for an example

Note: If electrons are to be simulated (using the SPECIES command) and radiation damping is turned on (see below), then the REVERSE_TRACKING command should be used to get valid results.

Note: If REF_ORBIT_X or REF_ORBIT_Y is set, the SAVED REFERENCE values for the steerings will be set to zero. This will affect the calculation of the steering's contribution to the merit function and hence will affect orbit corrections.

Note: For LOGIC%AC_ETA_TYPE, possibilities are 'XY','C12','SINCOS'

Examples: 
  TUNE_X_WGT *= 10               ! Increase the weight for tune_x by a factor of 10.
  TW = 1000                      ! Set tune_x_wgt and tune_y_wgt = 1000.
  *SET TW = 1000                 ! Set the tune weight in all universes. 
  N_PART = 1E11                  ! Set the number of particles in a bunch (For BBI).
                                 !   Use SHOW PARAMETERS to see the value.
  SYM_K1_WGT(2) = 1e6            ! Set sym_k1_wgt for Quad 2 E/W.
  REF_ORBIT_X(6:28) = 1.4        ! Set reference orbit_x 6 through 28 = 1.4 mm.
  REF_ORBIT_X(6:28) = ORBIT_X    ! Set ref orbit_x 6 through 28 to corresponding 
                                 !   values in orbit_x array. 
  LOGIC%RADIATION_ON = T         ! Set synchrotron radiation damping toggle.
  LOGIC%AUTO_MEASUREMENT = T     ! Used for the CALIBRATE command.
  LOGIC%DQ_MAX_QUAD_CALIB = 0.02 ! Used for CALIBRATE BPM command.
  LOGIC%RESTRICTED_CBAR_PLOT = T ! Used to not plot Cbar11 and Cbar22.
  LOGIC%NONLINEAR_CALC = T       ! See the READ command for more details.
  LOGIC%PRETZ1_CALC_ON = T       ! Turn on the pretzel calculation.
  LOGIC%USE_NORMAL_MODE_ETAS = T ! Use normal mode dispersion values for the model dispersion.
  LOGIC%VCROS5_CALC = T          ! Turn on the cvros5 calculation.
  LOGIC%AC_ETA_FREQ_RANGE = 1    ! 1 -> 12.5 - 100 KHZ,  2 -> 6.25 - 50 kHz.

TOP
SHOW {<what>}
SHOW <magnet> {<how>}
SHOW COMMENTS {<filter>} <file_type> mmmmm:nnnnn
SHOW DATA <data_name> <number>
SHOW DMERIT <ix1> <ix2>
SHOW LIGHTSOURCES
SHOW RAD_INT <int_id>
SHOW RING <location>
SHOW TRANSFER_MATRIX <element_name_or_number>
SHOW VARIABLE <var_name> <number>
SHOW WEIGHT <who>

Where:
• <data_name> = [ORBIT X/Y, PHASE X/Y, BETA X/Y, ETA X/Y, SPLINE_BETA X/Y, TUNE X/Y, CBAR (=CBAR12), CBAR11, CBAR12, CBAR22, CHROM X/Y, CHROM X/Y, D_ENERGY, 2QX IN/OUT, 2QY IN/OUT, QX+QY IN/OUT, QX-QY IN/OUT]
• <file_type> = [ETA, MODEL, ORBIT, or PHASE]
• <filter> = [/LATTICE = <name>, /ROUTE = <name>]
• <how> = [ASYMMETRY, CU, K, KL, LIMIT, or REF_DIFFERENCE]
• <magnet> = [HORIZONTAL, OCTUPOLE, QUADRUPOLE, SEXTUPOLE, SKEW_QUAD, _SKEW_SEX, STEERINGS, or VERTICAL]
• <int_id> = [I0, I1, I2, I3, I4A, I4B, I5A, I5B, or I6]
• <var_name> = [QUADRUPOLE, SEXTUPOLE, CUSTOM_VAR, HORIZONTAL, VERTICAL, SKEW_QUAD, H_SEPARATOR, _SKEW_SEX, OCTUPOLE, INIT_ORB, D_ENERGY]
• <what> = [ALL_TWISS <file_name>, BPM_TILT, CALIBRATION, 2QX, 2QY, QX+QY, QX-QY, CBAR, CBAR11, CBAR12, CBAR22, COMMAND_FILES, CUSTOM, CUT_RING, DETECTORS, ELEMENT <Name/#>, ETA, FLOOR, GEOMETRY <#>, GLOBAL, IP, LOGICALS, LUMINOSITY, ORBIT, PARAMETERS, SETS, SEPARATORS, CHROMATICITY, SINGLE_CORRECTION, TBT <REF>, TOP10, TUNE, TWISS <s>, WAVE]
• <who> = [TWISS, ORBIT_AND_DISPERSION, VARIABLES]

SHOW Types listings of parameters, data, etc. If you put a "&" before "SHOW" then CESRV will also create an output file with the results. In this case CESRV will query you for the file name. If you give a blank file name then CESRV will append to the last file used by SHOW. If there has been no previous file then the default name CESRV.DAT will be used. If you type "*REM" then CESRV will append to the file used with the REMEMBER command.

Examples:
  SHOW                  ! Types a list of parameters and their values  
                        !   relevant for the setting of OPT_VARS.
  SHOW ALL_TWISS S.LIST ! Shows the Twiss parameters at a set of s locations
                        ! given in the file S.LIST. This file needs to have
                        ! one s location value per line.
  SHOW BPM_GAINS        ! Show BPM gain calibration info.
  SHOW BPM_TILT         ! Show BPM Tilt calibration info.
  SHOW CBAR             ! Same as SHOW CBAR12.
  &SHOW CALIB           ! Show steering calibration info. The output will also
                        !   be written to a file.
  SHOW COMMAND_FILES    ! Shows a list of the command files in the current directory 
                        !   and in the 
			!   $CESR_ONLINE/acc_control/program_info/cesrv/command_files
			!   dir. 
                        !   Files must have a .in suffix to be shown.
  SHOW COMMENT M 1:0    ! Show the comments from all the model files.
  SHOW COMMENT O -10:0  ! Show the comments from the last 10 orbit files.
  SHOW COMMENT P 45:67  ! Show the comments from the phase/coupling data files.
                        !  data files 00045 through 00067.
  SHOW COMMENT/LAT=2S PHASE -100:0
                        ! Same as above but only show comments for data files
                        !  taken with the 2S lattice.
  SHOW COMMENT/ROUTE = 2S_ON_STANDARD -100:0
                        ! Same as above but only show comments for data files
                        !  taken under the 2S_ON_STANDARD route.
  SHOW CHROM            ! Show chromaticity values.
  SHOW CUSTOM           ! Show the custom variables (See OPT CUSTOM).
  SHOW CUT_RING         ! Show the init_orb variables. 
                        !   Used with the CUT_RING command.
  SHOW DAT ORB X 3      ! Show information on datum: x_orbit #3
  SHOW DET              ! Show Twiss parameters, etc. at the detectors.
  SHOW DMERIT 34 0      ! Show row 34 of the dmerit matrix.
  SHOW ELE Q02W         ! Show information on Q02W ring element.
  SHOW ELE -ALL Q02W    ! Shows full information on Q02W ring element.
  SHOW ELE Q*           ! Lists all elements whose name starts with "Q"
  SHOW ELE 156          ! Show information on ring element #156. 
                        !   Use SHOW RING to find the number for an element.
  SHOW ETA              ! Show dispersion data.
  SHOW FLOOR 34E        ! Show ring geometry (floor coords) for elements near 34E.
  SHOW FLOOR 80:150     ! Show ring geometry (floor coords) for elements 80 through 150.
  SHOW GEOM 80:150      ! Same as SHOW FLOOR 80:150
  SHOW GLOBAL           ! Show various global parameters, tune, emittance, etc.
  SHOW IP               ! Show Twiss parameters at the IP.
  SHOW LIGHTSOURCES     ! Show information at the x-ray source points for CHESS and VBSMs
  SHOW LOGICALS         ! Show state of various global logicals.
  SHOW LUMINOSITY       ! Show the expected luminosity. CESRV will read certain
                        !   parameters (emittances] from CESRV_LUMINOSITY.IN. 
                        !   If this file is not found in the current directory
                        !   then the default file will be read from [CESR.CESRV].
                        !   See this file for more information.
  SHOW OCT CU           ! Show Octupole k3 values and CU settings
  SHOW ORBIT            ! Show orbit data.
  SHOW PARAM            ! Show various parameter settings.
  SHOW QUAD             ! Show K values and Twiss parameters of all the quads.
  SHOW QUAD ASYM        ! Show quad differences between West and East.
  SHOW QUAD REF_DI      ! Show quad settings from the reference data measurement.
  SHOW QUAD CU          ! Show CU settings of all the quads.
  SHOW QUAD LIMIT       ! Show how close to a limit quad target values are.
  SHOW RAD_INT I4A      ! Show element-by-element values for the I4a radiation integral.
  SHOW RING 45E         ! Show Twiss, Orbit, etc. info at the center of
                        !   those elements near 45E.
  SHOW RING ENDS 45E    ! Same as above except Twiss/orbit values are 
                        !   evaluated at the ends of the elements.
  SHOW RING 80:150      ! Show Twiss, Orbit, etc. info for ring elements 
                        !   80 through 150.
  SHOW RING NO_ETA 45E  ! This does not show eta but shows more decimal
                        ! places for the Orbit.
  SHOW SETS             ! Show Save set and Data set numbers.
  SHOW SKEW K           ! Show K values (design, model, etc.) for the skew quads.
  SHOW SKEW KL          ! Same as SHOW SKEW K except values are multiplied by 
                        !   the element length
  SHOW SEP              ! Show separator info.
  SHOW SEX              ! Show sextupole k2 values, etc.
  SHOW _SKEW CU         ! Show skew sextupole k2 values and CU settings.
  SHOW SINGLE           ! Show which correctors when varied individually.
                        !    would give the largest corrections.
  SHOW STEER            ! Show steering info.
  SHOW STEER CU         ! Show steering info.
  SHOW STEER LIMIT      ! Show how close to a limit steering target values are.
  SHOW TBT              ! Show information on turn-by-turn data.
  SHOW TBT REF          ! Show information of turn-by-turn refrence data.
  SHOW TOP10            ! Show lists of:
                        !   * Largest contributors to the merit function.
                        !   * Largest derivatives: dMerit/dVar.
                        !   * Largest deviations of Variable values from design.
  SHOW TRANSFER Q10W    ! Show one-turn transfer matrix, along with the zeroth
                              part of the transfer map, from exit end of q10w.
  SHOW TUNE             ! Show model, theory and measured tunes. 
                        !   Use UNITS TUNE to set the display units.
                        !   Use SHOW GLOBAL to get the integer part of the tune
  SHOW TWISS 4.3        ! Show Twiss and Orbit at s = 4.3 m.
  SHOW VAR QUAD 3       ! Show parameters associated with the variable Q03W.
  SHOW VAR GROUP VCROS 7  ! Show parameters associated with CSR_VCROSING #7
  SHOW WAVE             ! Show parameters from the wave analysis.
  SHOW WEIGHT TWISS     ! Show weights for beta, eta, phi and cbar

TOP
SPAWN <dcl_command>

Spawn runs a dcl command.

Example:
  SPAWN RUN MY_PROGRAM  ! run an external program.

TOP
SPECIAL <name>

Where:
• <name> = Special procedure name.

SPECIAL is for special custom procedures that are programmed in for individual users.


TOP
SPECIES <which>

Where:
• <which> = [POSITRON, ELECTRON]

SPECIES sets what the species of particle the beam is made of. This affects the orbit if the separators are on. This is equivalent to the "SET LOGIC%BEAM_SPECIES" command.

Note: If electrons are to be simulated and radiation damping is turned on, then the REVERSE_TRACKING command should be used to get valid results.


TOP
SYNRAD

SYNRAD uses the current cesrv model to initiate and track synchrotron radiation. Quads, bends and wigglers are sliced into sections.

The number of sections per element can be changed like: SET logic%synrad_params%n_slice = 5

The default number of sections is 20.

Synch. radiation rays are launched from the end of each section and tracked until they hit a wall. Any rays that hit the "wall" section that delineates the exit of a chess crotch are stored for examination with RAYPLOT, RAYOUT and BURN. The rays can be projected past the crotch exits with the PROJECT command.

The command will ask for the current per beam and vertical emittance for power and power density calculations. The default vertical emittance is 2% of the horizontal emittance or the measured vertical emittance (from coupling) if it is available.


TOP
TAKE {<kind>} {<what>} <args>

Where:
• <kind> = [DATA, REFERENCE] [Default = DATA]
• <what> = [AC_ETA, CHROMATICITY, ETA, ORBIT, PHASE]
• <args> = [AUTO GATE [POS/ELE] [TmBn]]

TAKE makes an orbit measurement, phase/coupling or dispersion measurement. if <what> is not specified then what is taken depends upon what data was taken last. Note: The dispersion and phase/coupling measurements also give you an orbit measurement as well.

AUTO directs CESRV to not use species, train, and gate from DETEC. Usually this means GATE should also be entered.
eg: TAKE ORBIT AUTO GATE POS T1B1
entering just TAKE ORBIT
works as before, using Detec settings.

Note: Taking an orbit involves converting converting the detector button readings to x-y orbit data. By default LOGIC%NONLINEAR_CALC = T so that nonlinearities in the detector button signals are taken into account in the conversion to x-y orbit data. Set this to False to disable the nonlinearity calculation. This will not affect data that has already been taken.

The species and train number for orbit and phase taking is set by:

  LOGIC%BEAM_SPECIES   ! May be 0 or +/- 1.
  LOGIC%BEAM_BUNCH
If LOGIC%BEAM_SPECIES is 0, the species used will be determined by which beam has current in it. In this case, if both beams have current, data taking will be aborted and the user must set LOGIC%BEAM_SPECIES to either +1 or -1.
Examples:
   TAKE CHROM                     ! Take chromaticity
   TAKE DATA PHASE                ! Take phase data.
   TAKE PHASE                     ! Same as above.
   TAKE REF ORBIT                 ! Take reference orbit.
   TAKE ORBIT AUTO GATE POS T1B1  ! GATED ORBIT E+
   TAKE ORBIT AUTO GATE ELE T7B1  ! GATED ORBIT E-

TOP
TRANSFER <from_what> <to_what_var> <factor>
TRANSFER <from_where1> <to_where1>
TRANSFER MODEL BASE_MODEL

Where:
• <from_what> = [BASE_MODEL, DESIGN, SAVED, ZERO, REFERENCE, S-R (Saved - Ref)]
• <to_what_var> = [QUADRUPOLE, SEXTUPOLE, SKEW_QUAD, HORIZONTAL, VERTICAL, H_SEPARATOR, or MODEL]
• <factor> = [(optional) fraction to load. 1.0 = full load]
• <from_where> = [BASE_MODEL, DATA, DESIGN, MODEL, ZERO, or REFERENCE]
• <to_where> = [DATA, REFERENCE, XQUNEING]

TRANSFER copies data or corrector settings from one place to another. The optional <factor> argument is used for partial transfers. Thus

  TRANSFER DESIGN MODEL 0.4 
produces
  MODEL_AFTER = MODEL_BEFORE + 0.4 * (DESIGN - MODEL_BEFORE) 
 Examples:
    TRANS DESI QUAD   ! Loads design values to quad k MODEL values.
    TRANS DESI MODEL  ! Transfers design values to the MODEL variable values.
                      !   the model variables are determined by what is being
                      !   optimized. For example if the quads are being
                      !   optimized then vars = [Quad_k's]
    TRANS MODEL DATA  ! Loads beta, phase, orbit, etc. data with 
                      !   values obtained from the model calculation.
    TRANS DATA REF    ! Transfer data to reference
    TRANS DATA XQUNE  ! Transfer 100*data values to CSR_XQUNEING data base node.

TOP
UNITS <who> {<what>}

Where:
• <who> = [PHASE, TUNE]
• <what> = [RADIANS, DEGREES, CYCLES, KHZ]

UNITS sets what units are used for the display of phase and tune values. Default is RADIANS.

Examples:
   UNITS PHA RADIANS   ! Default
   UNITS TUNE CYCLES   ! 1 Cycle = 360 degrees
   UNITS PHA KHZ       ! 390.1 kHz = 360 degrees
   UNITS               ! Show current units

TOP
USE <what> <list>
USE ALL_DATA
USE ALL_VARS

Where:
• <what> = [BPM_TILT, BETA, CBAR, CUSTOM, ETA, GROUP, HORIZONTAL, H_SEPARATOR,ORBIT, PHASE, QUAD, SEXTUPOLE, SKEW_QUAD, SLAVES, SYM_K1, VERTICAL, _SKEW_SEX]
• <list> = [List of locations, or ALL]

USE sets: 1) The correctors to be used by the optimizer, or 2) The data to be used in the merit function. See also RESTORE or VETO. The difference between RESTORE and USE is that USE is equivalent to to first VETOing all and then using RESTORE.

See also the MERIT_DATA and OPT_VARS commands for setting what data and/or variables are included in the optimization.

Examples:
   USE ALL_DATA             ! Use all data
   USE ALL_VARS             ! Use all variables
   USE PHASE 0:90 -3E -44W  ! Phase data to use
   USE QUAD Q00W            ! Special: turn on use of Q00W
   USE CBAR ALL             ! Use all cbar data
   USE HORZ 10E             ! Horizontal steering to use
   USE GROUP PRETZ 1        ! Use CSR PRETZING 1 group knob.
   USE SLAVES PRETZ 1       ! Use CSR PRETZING 1 slave elements.

TOP
VETO <what> <list>
VETO ALL_DATA
VETO ALL_VARS

Where:
• <what> = [BPM_TILT, BETA, CBAR, CUSTOM, ETA, GROUP, HORIZONTAL, H_SEPARATOR,ORBIT, PHASE, QUAD, SEXTUPOLE, SKEW_QUAD, SLAVES, SYM_K1, VERTICAL, _SKEW_SEX]
• <list> = [List of locations, or ALL]

VETO vetoes: A) from the current list of correctors to be used by the optimizer or B) data to be used in the merit function. See also RESTORE or USE.

See also the MERIT_DATA and OPT_VARS commands for setting what data and/or variables are included in the optimization.

Examples:
  VETO ALL_DATA             ! Vetoes everything.
  VETO ALL_VARS             ! Vetoes everything.
  VETO QUAD 47W:47E -49 67  ! Veto quad k1 correctors
  VETO QUAD Q47AW           ! Veto a qadd 47AW
  VETO CUSTOM 4:5           ! Veto custom variables  
  VETO GROUP PRETZ 1        ! Veto CSR PRETZING 1 group knob.
  VETO SLAVES PRETZ 1       ! Veto CSR PRETZING 1 slave elements.

TOP
VIEW_UNIVERSE <universe_num>

VIEW_UNIVERSE sets which universe (created using the CREATE_UNIVERSES command) is plotted.

Example:
    VIEW 2           ! View universe #2

TOP
WAVE_SET <what> {<plane>}

Where:
• <what> = [PHASE, ORBIT, ETA, CBAR]
• <plane> = [X, Y]

WAVE_SET sets what to use for the wave analysis.

Using a "&" before the WAVE_SET command causes the kick point information to be written to a file named "wave.raw".

    Examples:
         WAVE ORBIT Y        ! Use Y orbit data for the analysis 
         WAVE CBAR           ! Use the Cbar12 data for the analysis
        &WAVE CBAR           ! Same as above and write kick point information.


TOP
WIGGLER {<which>}

Where:
• <which> = [ON, OFF]

WIGGLER turns on or off the quadrupole focusing component of the wigglers. The wiggler strength is defined by the lattice. The startup default is to have the wigglers on.

Examples:
     WIGGLER          ! Types whether the wigglers are on or off.
     WIGGLER ON       ! Turns on any wigglers.
     WIGGLER OFF      ! Turns off any wigglers.

TOP
WRITE <what>

Where:
• <what> = [BMAD <File_Name>, DIGESTED <File_Name>, MODEL, ORBIT <File_Name>, PHASE <File_Name>]

WRITE creates model and bmad digested files. Use the READ command to read these back into CESRV.

WRITE MODEL creates a CESRV model file. This is an ASCII file that gives the model settings for the standard CESRV variables (steerings, quadrupoles, etc.) What is missing is any non-standard changes that possibly have been made. For example, if you have shifted the locations of any elements then this is not saved.

WRITE DIGESTED creates a bmad digested file from the MODEL lattice. A digested file is a binary file (not readable by humans) that saves the exact state of the model lattice. This file can be read in by other Bmad based programs so a Bmad digested file provides a good way for porting the state of the lattice from one program to another.

WRITE BMAD creates a Bmad lattice file from the MODEL lattice.

WRITE ORBIT creates an ASCII orbit file that gives the model orbit data in conformance with the orbit data file format described above.

Examples:
   WRITE MODEL  ! Create a file containing the current model settings.
                !  The file name is L_MODEL:MODEL.nnnnn .
   WRITE DIG DIGESTED_RING.DAT 
                ! Create the file RING.DAT containing 
                ! the model ring structure. The file is in BMAD digested 
                ! form which means that it is not readable by a human.
   WRITE ORBIT ORBIT.DAT 
                ! Create the file ORBIT.DAT containing 
                ! the model orbit data. 
   WRITE PHASE PHASE.DAT 
                ! Create the file PHASE.DAT containing 
                ! the model phase, cbar and orbit data. 
   WRITE BMAD BMAD.LAT
                ! Create a Bmad lattice file called BMAD.LAT.                

TOP
XBSM <what>

Where:
• <what> = [DATA, MODEL, or ZERO (default)]

XBSM csets what is used for the x-coordinate in plotting.

Examples:
  XBSM DATA   ! Calculates the beam trajectory through the source point bend 
              !   interpolating from the neigherest neighbor orbit data points. 
              !   This neglects the kick due to the quadrupole in between the
              !   detectors but serves as a quick check.
  XBSM MODEL  ! Uses the model orbit for the beam trajectory through the bend.
  XBSM ZERO   ! Uses the zero orbit for the beam trajectory through the bend.

TOP
X_AXIS <what>

Where:
• <what> = [INDEX, PHASE, TUNE, S]

X_AXIS sets what is used for the x-coordinate in plotting.

Examples:
   X_AXIS INDEX ! Use the detector or quad index (default).
   X_AXIS PHASE ! Use the phase (horizontal or vertical as appropriate)
                ! in radians.
   X_AXIS TUNE  ! Same as phase except use "tune" units (1 == 2pi).
   X_AXIS S     ! Use the longitudinal position.
            

TOP
ZERO <what>

Where:
• <what> = ['CHROM']

ZERO DCHROM sets the Data and Reference chromaticities (in all universes) for the so that the contribution to the Merit function is zero.