7.32 insert_elements
- type: action command.
- function: Insert elements into a beamline at specified locations. This is a convenient way to
add elements to a beamline without modifying the lattice file.
- sequence: must follow run_setup.
- notes: The modified beamline can be saved through save_lattice command. Be sure to use
“output_seq = 1” option in that command.
- Command syntax, including use of equations and subcommands, is discussed in 7.2.
&insert_elements
STRING name = NULL;
STRING type = NULL;
STRING exclude = NULL;
double s_start = -1;
double s_end = -1;
STRING start_at_element = NULL;
STRING end_at_element = NULL;
long skip = 1;
long disable = 0;
long insert_before = 0;
long add_at_end = 0;
long add_at_start = 0;
STRING element_def = NULL;
long total_occurrences = 0;
long occurrence[100]={0};
long allow_no_insertions = 0;
long allow_no_matches = 0;
&end
- name — Possibly wild-card containing string specifying the names of the elements after which
the new element is inserted. A list of comma- or space-separated names may be given.
- type — Possibly wild-card containing string specifying the type of the elements after which
the new element is inserted.
- exclude — Possibly wild-card containing string specifying the names of elements to be
excluded from the specification.
- skip — New elements are inserted at every nth specified location.
- s_start, s_end — If positive, these give the starting and ending s locations for insertion of
new elements. Note that the s locations are not updated as elements are inserted, but only
after completion of all insertions covered by a single command.
- start_at_element, end_at_element — If given, these are used to define (and override)
values for s_start and s_end based on the locations of named elements. s_start is taken
as the end of the first element with the name given by start_at_element, while s_end is
taken as the end of the last element with the name given by end_at_element. No wildcards
are accepted.
- disable — If nonzero, the command is ignored.
- insert_before — If nonzero, the insertions are before the selected elements. By default,
insertion is after the selected elements.
- add_at_end — If nonzero, the element is also inserted to the end of the beamline.
- add_at_start — If nonzero, the element is also inserted to the start of the beamline, ahead
of all other elements.
- element_def — The definition of the new element should be just as it would be entered in
the lattice file. To insert an existing element, simply give the name of the element and define
it to be a MARK element; elegant will recognize that the element already exists and use the
previous definition.
- total_occurrences, occurrence — These parameters are used to insert the new elements
after specified occurrences of the element name. total_occurrences specifies how many new
elements to add, up to a maximum of 100, while the entries in the array occurrence specify
the occurrences after which to add the new elements. If total_occurrences is non-zero, then
skip must be set to zero and the name must be the exact name (no wild-card matching).
- allow_no_matches — If nothing is inserted because there are no matches found to the name
and element type, it is normally considered an error. If this parameter is non-zero, a warning
is issued but the run continues.
- allow_no_insertions — If nothing is inserted, it is normally considered an error. If this
parameter is non-zero, a warning is issued but the run continues.
- insertion_count_variable — If given, the name of an rpn variable into which the number
of inserted elements will be written. Can be used, for example, with the field_final_value
parameter of optimization_term.