- type: setup/action command.
- function: set up rf cavity frequency, phase, and voltage for a storage ring
- sequence: must follow run_setup. In action mode, must follow action-mode instance of twiss_output.
- Command syntax, including use of equations and subcommands, is discussed in 7.2.

&rf_setup

STRING filename = NULL;

STRING name = NULL;

long start_occurence = -1;

long end_occurence = -1;

double s_start = -1;

double s_end = -1;

long set_for_each_step = 0;

double near_frequency = 0;

long harmonic = -1;

double bucket_half_height = 0;

double over_voltage = 0;

double total_voltage = 0;

long disable = 0;

long output_only = 0;

long track_for_frequency = 0;

&end

STRING filename = NULL;

STRING name = NULL;

long start_occurence = -1;

long end_occurence = -1;

double s_start = -1;

double s_end = -1;

long set_for_each_step = 0;

double near_frequency = 0;

long harmonic = -1;

double bucket_half_height = 0;

double over_voltage = 0;

double total_voltage = 0;

long disable = 0;

long output_only = 0;

long track_for_frequency = 0;

&end

This command must follow a twiss_output command that includes radiation integral computation, since the energy loss per turn is needed to set up the rf cavities. Note that the command includes features to allow selecting a subset of the RFCA elements in the beamline. The selected subset is assumed to include all of the cavities that will impart net energy to the beam.

This command stores values for bunch length in symbols Sz0 and St0, and also stores the fractional energy spread in Sdelta0, where they can be used in rpn expressions in subsequent commands, e.g.,

&bunched_beam

sigma_dp = "(Sdelta0)",

sigma_s = "(Sz0)",

...

&end

sigma_dp = "(Sdelta0)",

sigma_s = "(Sz0)",

...

&end

- filename — Name of a file to which data related to the rf settings will be written.
- name — A possibly-wildcard-containing string giving the names of the elements to set. If not given, all RFCA elements are selected.
- start_occurence, end_occurence — If nonzero, these give the starting and ending occurrence numbers of elements that will be set.
- s_start, s_end — If non-negative, these give the gaving and ending position limits for the end-of-element locations of elements to be set.
- set_for_each_step — If nonzero, then the setup is repeated at each simulation step. In this case, one must also give output_at_each_step=1 for twiss_output.
- near_frequency – If nonzero, then the rf frequency is chosen to be the closest harmonic to the given frequency.
- harmonic — If nonzero, then the rf frequency is set to the given harmonic of the revolution frequency.
- bucket_half_height — If nonzero, the voltage is computed so as to give the specified bucket half
height.
(11) where U

_{0}is the energy loss per turn, α is the momentum compaction factor, h is the harmonic, E is the beam energy,(12) and q is the overvoltage factor, related to the rf voltage by q = V∕U

_{0}. (See Wiedemann, Vol. 1, 8.2.2.) - over_voltage — If nonzero, the voltage is set to the given factor relative to the energy loss per turn.
- total_voltage — If nonzero, the total rf voltage is set to the given value. The frequency and phase are computed for this voltage.
- disable — If nonzero, command does nothing.
- output_only — If nonzero, command generates output file but does not change rf cavity settings.
- track_for_frequency — If nonzero, particle tracking is used to determine the rf frequency. If zero, the ideal length of the lattice is used.

replace_elements