10.2 APCONTOUR—An aperture (or its inverse) defined by (x, y) points in an SDDS file.

An aperture (or its inverse) defined by (x, y) points in an SDDS file.
Parallel capable? : yes
GPU capable? : no
Back-tracking capable? : no

Parameter NameUnitsType Default


L M double 0.0


TILT RADdouble 0.0

rotation about longitudinal axis

DX M double 0.0


DY M double 0.0


DZ M double 0.0


RESOLUTION M double 0.0

z resolution of finding intersection

XFACTOR double 1

factor by which to multiply x contour values

YFACTOR double 1

factor by which to multiply y contour values

INVERT short 0

if non-zero, contour defines an obstruction rather than an aperture

STICKY short 0

if non-zero, effect persists in downstream elements until canceled or replaced

CANCEL short 0

if non-zero, sole effect is to cancel previous sticky APCONTOUR

HOLD_OFF short 0

if non-zero and STICKY=1, then effect only seen in the next element downstream


name of file containing contour data


name of column containing x data


name of containing y data


Optionally used to assign an element to a group, with a user-defined name. Group names will appear in the parameter output file in the column ElementGroup

The STICKY parameter results in the aperture contour being applied inside subsequent CCBEND, CSBEND, CSRCSBEND, KQUAD, KSEXT, KOCT, and KQUSE elements, as well as at the end of other downstream elements. This continues until another APCONTOUR element asserts a new contour, or uses CANCEL=1 to cancel the feature.

For versions 2022.1 and later, the input file may have multiple pages, each with (x,y) points specifying a closed contour. The combination of the effect of these contours is specified using the Logic parameter in the input file, utilizing the logical stack and logical operators of the rpn module. For each particle, the program loops over each contour. If the particle is inside (outside) the contour, a true (false) value is pushed onto the stack, followed by execution of the indicated logic. If the final value is true, the particle survives, otherwise it is lost. (The invert parameter on the element definition can be used to invert this.)

For example, if the aperture file is

&column name=x type=float units=m &end  
&column name=y type=float units=m &end  
&parameter name=Logic type=string &end  
&data mode=ascii no_row_counts=1 &end  
-0.01   -0.015  
-0.01   -0.0075  
-0.015   -0.0075  
-0.015   -0.015  
-0.01   -0.015  
0.01   -0.015  
0.01   -0.0075  
0.015   -0.0075  
0.015   -0.015  
0.01   -0.015

then particles survive only if inside one of the two rectangles.