10.9 BRANCH—Conditional branch instruction to jump to another part of the beamline

Conditional branch instruction to jump to another part of the beamline
Parallel capable? : yes
GPU capable? : no
Back-tracking capable? : no






Parameter Name UnitsType Default

Description






COUNTER long 0

Counter, which is decremented by 1 for each pass. Set to negative value for unconditional branch.






INTERVAL long 0

Interval between branching. If non-positive, use COUNTER-based method instead.






OFFSET long 0

If INTERVAL method used, offset of branch passes.






VERBOSITY long 0

Larger values result in more output during running.






DEFAULT_TO_ELSE long 0

If non-zero, defaults to ELSE_TO when performing tracking for closed orbit, twiss_output, etc.






BRANCH_TO STRINGNULL

Optional name of element to which to jump when counter is non-positive.






ELSE_TO STRINGNULL

Optional name of element to which to jump when counter is positive.






GROUP string NULL

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






This element is experimental and should be used with care. It may not work well with other features, e.g., orbit correction or twiss parameter output. It should work well with tracking.

Use of the BRANCH element to change the starting point in the lattice is not ideal. It is better to use the change_start command.

The element permits switching tracking between two segments of a beamline. This can be done once per run or periodically. For the former, the COUNTER parameter should be used to specify the pass number (which is zero on the first pass) on which to branch. For the latter, the INTERVAL i and (optionally) OFFSET o parameters should be used; the branch will occur when (p - o)%i == 0.

The application that inspired creation of this element is to switch from tracking using lumped elements to tracking using element-by-element methods. More specifically, imagine we want to track for 10,000 turns to reach an equilibrium, then perform a beam abort. The equilibrium state can be accurately and rapidly modeled using lumped elements, such as ILMATRIX and SREFFECTS, but the beam abort needs to be modeled using comparatively slow element-by-element tracking.

RING1: ILMATRIX,...  
SR1: SREFFECTS,...  
...  
RINGFULL: line=(SECTOR1, SECTOR2, ..., SECTOR40)  
M1: MARK  
M2: MARK  
RF: RFCA,...  
BR1: BRANCH,COUNTER=10000,BRANCH_TO="M1"  
BR2: BRANCH,COUNTER=-1,BRANCH_TO="M2"  
BL: line=(BR1,RING1,SR1,M1,RINGFULL,M2,RF)

Another application is to model a periodic bypass, e.g.,

RINGA: line=(...)  
RINGB: line=(...)  
RINGC: line=(...)  
BYPASS: line=(...)  
M1: MARK  
M2: MARK  
BR1: BRANCH,INTERVAL=100,BRANCH_TO="M1",ELSE_TO="M2"  
BR2: BRANCH,COUNTER=-1,BRANCH_TO="M3"  
BL: line=(RINGA,BR1,M1,BYPASS,BR2,M2,RINGB,M3,RINGC)

In this example, the full ring is composed of three sections, RINGA, RINGB, and RINGC. Every 100 passes, the RINGB portion is bypassed in favor of BYPASS.

BRAT