If the beam files are not located in the path specified in line #2 of the macro, this line should be modified accordingly.

Line #11 of the macro computes the POP beam at surface 3 and saves the file in the BEAMFILES folder as ZBFSUM_demo1.zbf.

This is how the ZBFSUM_demo1.zbf files looks after line #11.



After line #17, there will be two beam files created by the macro in the BEAMFILE folder. The phase of the ZBFSUM_demo1.zbf beam will be tilted by some small amount with respect to the phase of the ZBFSUM_demo2.zbf beam.

Lines #23 and #25 introduces the initial Y decenter to the each of the beams so that when the two beams are coherently added for the first time they are completely separated. The Y decenter is achieved by specifying the decenter amount when re-sampling.

 
ZBFSUM_demo1.zbf

 
ZBFSUM_demo2.zbf



Inside the FOR loop, the beam files are coherently (line #36 ZBFSUM flag 1) added after they are shifted incrementally toward opposite directions. The result is saved in the ZBFSUM_demo_results.zbf file.

The line #38 updates the opened Beam File Viewer window (window #1) showing the ZBFSUM_demo_result.zbf file.

Here is how the ZBFSUM_demo_results.zbf file looks like after the 20th iteration, out of the total 41, of the FOR loop.



The line#42 and #43 implements a pause before executing the next iteration in the FOR loop, because the macro executes so quickly that a delay is necessary to let the window update.