- type: setup command.
- function: set up for correction of the tunes.
- sequence: should follow twiss_output.
- Command syntax, including use of equations and subcommands, is discussed in 7.2.

&correct_tunes

STRING quadrupoles = NULL;

STRING exclude = NULL;

double tune_x = 0;

double tune_y = 0;

long n_iterations = 5;

double correction_fraction = 0.9;

double tolerance = 0;

long step_up_interval = 0;

double max_correction_fraction = 0.9;

double delta_correction_fraction = 0.1;

long update_orbit = 0;

STRING strength_log = NULL;

long change_defined_values = 0;

long use_perturbed_matrix = 0;

double dK1_weight = 1;

&end

- quadrupoles — List of names of quadrupoles to be used. Several names may be given and the names may include wildcards. If so, then quadrupoles in each group are changed by the same amount for each iteration. This would typically be used when the quadrupoles are nominally identical (though perhaps differing in strength because of introduced errors). If that’s not the case, the iteration may fail to converge
- exclude — List of names of elements to exclude. This may be used to exclude some quadrupoles that are matched by wildcards in the quadrupoles list.
- dK1_weight — Weighting factor that is used to minimize the mean-square changes in K
_{1}values in the event that there are more than two families. - tune_x, tune_y — Desired x and y tune values. If not given, the desired values are assumed to be the unperturbed tunes.
- n_iterations — The number of iterations of the correction to perform.
- correction_fraction — The fraction of the correction to apply at each iteration.
- tolerance — When both tunes are within this value of the desired tunes, the iteration is stopped.
- step_up_interval — Interval between increases in the correction fraction.
- max_correction_fraction — Maximum correction fraction to allow.
- delta_correction_fraction — Change in correction fraction after each step_up_interval steps.
- update_orbit — If non-zero, the orbit calculation is updated after each n
^{th}adjustment of the quadupoles. - strength_log — The (incomplete) name of a SDDS file to which the quadrupole strengths will be written as correction proceeds. Recommended value: “%s.qst”.
- change_defined_values — Changes the defined values of the quadrupole strengths. This means that when the lattice is saved (using save_lattice), the quadrupoles will have the corrected values. This would be used for correcting the tunes of a design lattice, for example, but not for correcting tunes of a perturbed lattice.
- use_perturbed_matrix — If nonzero, requests use of the perturbed correction matrix in performing correction. For difficult lattices with large errors, this may be necessary to obtain correction. In general, it is not necessary and only slows the simulation.

coupled_twiss_output