A subject of frequent confusion for elegant users is the
distinction between setup and action commands. An ``action'' command
causes elegant to immediately perform a specific computation or
set of computations. In contrast, a ``setup'' command tells elegant
how to perform computations when it later encounters a ``major'' action
command (one of analyze_map, find_aperture, frequency_map, momentum_aperture, optimize,
or track).
Several commands are switchable between action and setup modes. These
include the coupled_ twiss_output,
correction_matrix_output, twiss_output,
find_aperture, matrix_output, and sasefel
commands. Except for find_aperture, all of the commands that
can run in both modes have the output_at_each_step parameter,
which is used to switch between the modes. In the case of
find_aperture, the switch is accomplished using the
optimization_mode parameter. Regardless of which parameter is
present, unless the parameter is given a value of 1, the command
operates in action mode. Further, if the command is used in setup mode
and no relevant action command is present later in the file, then the requested
will not be performed.
Typically one wants to use these switchable commands in setup mode whenever one is simulating random errors, performing a parameter scan, or performing optimization. When in setup mode, the indicated computations will be performed repeatedly, e.g., for each set of errors, for each step in the parameter scan, or for use in each evaluation of the optimization penalty function.