How to sum POP beams coherently

Physical Optics Propagation (POP) is a powerful tool in OpticStudio for analyzing coherent wavefront and beam propogation. This article describes how the capabilites of POP can be extended by using the ZBFSUM macro keyword to coherently sum the results of multiple POP calculations.

Authored By Nam-Hyong Kim


Article Attachments


OpticStudio has a powerful Physical Optics Propagation (POP) tool for use when your analysis calls for analysis of the wavefront that ray tracing cannot sufficiently describe. The POP analysis can save the result at any surface in the as a *.ZBF beam file within the {Zemax}/POP/BEAMFILES directory. This analysis may be extended to coherently or incoherently sum any two beam fields via the use of the ZPL macro keyword, ZBFSUM. 

This article will work through using ZBFSUM and similar keywords to sum two beams.

ZBFSUM example

Open the attached ZIP archive and place the ZBFSUM DEMO.ZPL file in the {Zemax}\MACROS directory. Open the 'ZBFSUM demo.ZAR' file and execute the macro. The Beam File Viewer should cycle through position changes of the two beams, as shown in the animation below:

The Beam File Viewer shows the coherent sum of two identical Gaussian beams with some phase tilt between the two. The macro file can be opened and edited in OpticStudio by navigating to the Programming Tab...Edit/Run.

Useful ZPL keywords

In addition to ZBFSUM, there are other ZBF related keywords. These are:

  • ZBFCLR: Clears the complex amplitude data in a ZBF file.
  • ZBFMULT: Multiplies the complex amplitude data in a ZBF file by a complex factor.
  • ZBFPROPERTIES: Opens the specified ZBF file and places various data about the beam in a vector variable.
  • ZBFRESAMPLE: Resamples a ZBF file to a new width and point spacing.
  • ZBFSHOW: Displays a ZBF file in a viewer window.
  • ZBFSUM: Sums either coherently or incoherently the data in two ZBF files and places the resulting data in a third ZBF file.
  • ZBFTILT: Multiplies the data in a ZBF file by a complex phase factor to introduce phase tilt to the beam.

The usage of several of these keywords will be discussed in the followign 

Using ZBF related keywords

The following code is from the provided macro ZBFSUM DEMO.ZPL and is reproduced here to enable some key point to be explained. The code may be amended as necessary to meet your specific requirements. There is a built-in ZPL editor in OpticStudio, but any ASCII file editor (like Notepad) can be used to write a macro.





file1_full_path$=path$ + file1$

file2_full_path$=path$ + file2$


! Run POP and save the beam file at surface 3 as ZBFSUM_demo1.zbf
POP file1$, 3

! Create a copy of ZBFSUM_demo1.zbf file named ZBFSUM_demo2.zbf
COPYFILE file1_full_path$, file2_full_path$

! Tilt the phase of the ZBFSUM_demo1.zbf
ZBFTILT file1$, 0,0, 0, 30

! Decenter the beams so that they are completly separated initially

! Decenter the ZBFSUM_demo2.zbf beam in -Y direction
ZBFRESAMPLE file2$, 128,128, 1.5040, 1.5040, 0, -0.36

! Decenter the ZBFSUM_demo1.zbf beam in +Y direction
ZBFRESAMPLE file1$, 128,128, 1.5040, 1.5040, 0, 0.36


FOR i, 0, 41, 1

! Incrementally move the ZBFSUM_demo2.zbf beam towards +Y direction
ZBFRESAMPLE file2$, 128,128, 1.5040, 1.5040, 0, 0.018

! Incrementally move the ZBFSUM_demo1.zbf beam towards -Y direction
ZBFRESAMPLE file1$, 128,128, 1.5040, 1.5040, 0, -0.018 

! Coherently sum the two beam and save the result as ZBFSUM_demo_result.zbf
ZBFSUM 1 file1$ file2$ file3$

! Update the Beam File Viewer window
UPDATE 1      

! WAIT some time before decentering again



PRINT "done"


If the beam files are not located in the path specified in line #1 of the macro (the default location for .ZBF files), this line should be modified accordingly.

Line #10 of the macro computes the POP beam at surface 3 (using the POP keyword) and saves the file in the BEAMFILES folder as ZBFSUM_demo1.zbf.

The following image shows how the ZBFSUM_demo1.zbf file looks after line #10:

beam file viewer

After line #23, 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 (using the ZBFTILT keyword).

Lines #21 and #23 introduce the initial Y decenter to 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 (using the ZBFRESAMPLE keyword). On the left is 'ZBFSUM_demo1.zbf' and 'ZBFSUM_demo2.zbf' is on the right:

ZBFSUM demo 1ZBFSUM demo 2

Inside the FOR loop, the beam files are coherently (line #33: 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 #35 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.

total irradiance 2nd image

The line #44 implements a pause (using the PAUSE keyword) 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.


Was this article helpful?
1 out of 1 found this helpful



Please sign in to leave a comment.