A diffractive optical element (DOE) illuminated by a coherent beam can project almost any intensity pattern in the far field. This article shows how to model such an element in OpticStudio by describing the complex field leaving the DOE in a Zemax Beam File (ZBF) and using that file as the source beam for a Physical Optics Propagation (POP) analysis.
A worked example is attached. A Python script designs a phase map from a PNG image and writes it to a ZBF file, and an OpticStudio file propagates that beam through a plano-convex singlet to reproduce the pattern at the focal plane.
Background
A phase-only DOE, also called a kinoform or a computer-generated hologram (CGH), imprints a fixed phase map onto an incident wavefront. When the element is placed in the front focal plane of a lens, the field in the back focal plane is the Fourier transform of the field leaving the element. A suitable phase map therefore produces a chosen intensity distribution at the focal plane.
There are two ways to represent this in OpticStudio:
- Represent the phase map with a Grid Phase or Grid Sag surface and illuminate it with a POP beam.
- Describe the field that leaves the DOE directly, as a complex amplitude array stored in a ZBF file, and use that file as the POP source beam. While this first option works OK with simple phase profiles, some issues may arise when more complex phase distributions are used, especially if significant phase curvature is added and/or if the chief rays is deviated, some unexpected results may show.
This article covers the second approach, which proves to be more robust. The phase map is computed outside OpticStudio on exactly the grid that POP will use, and OpticStudio is responsible only for propagating that field through the optical system. The same method applies to a spatial light modulator or any other device whose output field is known.
Please note that, some other workflows we have can present some similarities with the one we introduce here:
- The small-scale metalens workflow has a similar approach in terms of embedding the phase information into the .zbf file, the difference being the way the phase profile is generated, and the actual method to manufacture the surface with meta-atoms is considered, including exact nano structure geometry and diffraction efficiency
- The volume hologram workflow also considers diffraction efficiency, but need some assumptions to be used, especially in terms of phase profile continuity
The use case here is focused on phase only DOE, like computer-generated holograms. While diffraction efficiency is not computed, an example of script is provided to turn an image into a phase profile.
If you already have a complex phase profile, you may then look at the 2nd part of the script, that then adds this phase information into a .zbf file.
Example System
The attached doe_pop_singlet.zmx places the DOE plane 50 mm in front of a plano-convex N-BK7 singlet with a focal length of 50 mm, mounted with the curved side toward the DOE. The display plane is at the back focal plane, set by a marginal ray height solve. The wavelength is 0.633 µm and the entrance pupil diameter is 8.192 mm, matching the size of the beam file.
The DOE is sampled on an N by N grid of pitch Δ. Three relationships fix the design. The largest angle the element can diffract into is set by the sample pitch:
θmax = λ / (2Δ)
The sample size and the full width of the array at the display plane follow from the focal length:
δ = λ f / (NΔ) W = λ f / Δ
The pitch therefore sets the size of the projected pattern, and the number of samples sets its resolution. The values used in the example are:
| Quantity | Expression | Value |
| Wavelength | λ | 633 nm |
| Samples across the DOE | N | 512 |
| Sample pitch | Δ | 16 µm |
| DOE clear aperture | NΔ | 8.192 mm |
| Lens focal length | f | 50 mm |
| Largest diffraction angle | λ / (2Δ) | 19.8 mrad |
| Sample size at the display plane | λ f / (NΔ) | 3.86 µm |
| Full width of the display array | λ f / Δ | 1.978 mm |
The target pattern is placed inside the central half of the display array. The remaining area is a guard band that keeps residual diffraction orders from folding back onto the pattern.
Designing the Phase Map
The phase map is computed with the Gerchberg-Saxton iterative Fourier transform algorithm [1]-[3]. Starting from a random phase, each iteration performs four operations:
- Fourier transform the field leaving the DOE to the display plane.
- Replace the amplitude there with the square root of the target irradiance, keeping the phase.
- Inverse transform back to the DOE plane.
- Replace the amplitude there with the illumination profile, keeping the phase.
The target is read from a PNG image in which white means light and black means none. The example uses the attached doe_input.png:
After 60 iterations the example converges to 87.7 % of the power inside the pattern with 38.9 % RMS non-uniformity. The resulting phase map is a fine, quasi-random structure. The central 128 by 128 samples are shown below:
Note: Line art, text and silhouettes reproduce well. Continuous-tone photographs do not, because a phase-only element designed this way carries a speckle pattern that swamps smooth gray levels.
Using the Python Script
The attached doe_design.py performs the design and writes the beam file. It requires Python 3 with NumPy, Matplotlib and Pillow.
The parameters at the top of the script control the design. The ones most likely to be changed are:
| Parameter | Meaning | Example value |
| IMAGE_FILE | Input image, relative to the script folder | doe_input.png |
| IMAGE_INVERT | Set to True for dark artwork on a light background | False |
| N | Samples across the DOE, must match the POP sampling | 512 |
| DX | Sample pitch in mm | 0.016 |
| LAM | Wavelength in mm, must match the system wavelength | 633e-6 |
| F_LENS | Focal length of the lens in mm | 50.0 |
| PREVIEW_ONLY | Set to True to check the target without running the design | False |
The script writes doe_pattern.zbf and preview images to an output folder next to the script. It also reads the beam file back and prints its header, so the file can be checked before it is loaded in OpticStudio.
The Beam File Format
The ZBF file is binary. Its layout is given in the Help File under The Analyze Tab (sequential ui mode) > Laser and Fibers Group > About Physical Optics Propagation > Defining the Initial Beam > File, and is summarized below:
| Block | Contents |
| 5 integers | Version (1), nx, ny, is-polarized flag, units flag |
| 4 integers | Unused |
| 12 doubles | dx, dy, then the Z position, Rayleigh distance and waist for X and Y, then wavelength, index, receiver efficiency, system efficiency |
| 8 doubles | Unused |
| 2 nx ny doubles | Ex real and imaginary values, interleaved, X index varying fastest |
Note:
- Every length in the header, including the wavelength, is expressed in the units set by the units flag. For a file written in millimeters, a 633 nm wavelength is stored as 6.33e-4.
- The six pilot beam entries do not contribute to the field itself, which is held entirely in the Ex array, but they are not inert. POP uses the pilot beam as its reference to choose between the near-field and far-field propagation algorithms and to re-sample the array, so incorrect values give a file that loads without complaint but propagates incorrectly. For a beam at its waist, the Z position is zero, the waist is the illumination waist radius, and the Rayleigh distance is π w₀² / λ. The same values are reported in the Beam File Viewer text tab.
Running the POP Analysis
- Copy doe_pattern.zbf into the POP beam file folder, {Zemax}\POP\BEAMFILES. Only files in that folder appear in the POP beam file list.
- Open doe_pop_singlet.zmx.
- Optionally, open Analyze > Laser and Fibers > Beam File Viewer and select the file. The irradiance shows a clean Gaussian and the phase shows the quasi-random phase map filling the illuminated area.
- Open Analyze > Laser and Fibers > Physical Optics Propagation and apply the settings below.
| Tab | Setting | Value |
| General | Start Surface | 1 |
| General | End Surface | 4 |
| General | Use Polarization | Off |
| Beam Definition | X-Sampling, Y-Sampling | 512 x 512 |
| Beam Definition | X-Width, Y-Width | 8.192 |
| Beam Definition | Use Total Power | 1.0 |
| Beam Definition | Beam Type | File |
| Beam Definition | Beam File | doe_pattern.zbf |
| Display | Data | Irradiance |
Note: The sampling and width must match the grid on which the beam file was written. If the grid is changed in the script, update X-Sampling, Y-Sampling, X-Width and Y-Width to N and NΔ. If they differ, OpticStudio interpolates the file onto the POP grid, which blurs the phase map and degrades the result without an obvious error message.
Results
The pattern appears at the display plane, superimposed on the speckle that is characteristic of an iteratively designed phase-only element.
The Text tab of the analysis window reports the array width at the display plane. For this example it is 1.978 mm, which matches λ f / Δ. Checking this value is the quickest way to confirm that the beam file and the POP settings agree.
At this aperture the singlet carries approximately one wave of spherical aberration, which softens the edges of the pattern and raises the background. Replacing the singlet with a Paraxial surface of the same focal length shows the ideal result, and isolates what the real lens contributes. This is the practical reason for running the propagation in OpticStudio rather than relying on the Fourier transform used in the design.
Practical Considerations
- Wavelength and focus. The system wavelength must match the wavelength used in the design, and the display plane must sit at the waist of the pilot beam. The Rayleigh range of the pilot beam at focus scales with the square of the focal length and is only about 0.13 mm in this example[CW1] [F(2] . If the display plane falls outside it, POP chooses a different propagation algorithm, the array shrinks to a small fraction of the pattern and only speckle is visible. Use a marginal ray height solve for the image distance rather than a fixed value.
- Sampling. The sample pitch sets the largest diffraction angle. Any content the design requires beyond that angle is aliased back into the pattern.
- Zero order. The beam file describes an ideal element. A fabricated element leaves some undiffracted light on axis. If this matters, design the pattern off axis by adding a linear phase ramp so that it is separated from the undiffracted spot.
- Efficiency and uniformity. A phase-only element cannot reproduce an arbitrary pattern exactly. Efficiency and uniformity trade against each other, and both depend on how much of the display array the pattern occupies.
- Orientation. [CW3] [F(4] The sign convention of the discrete Fourier transform used in the design is mirrored in X relative to the OpticStudio display. The script corrects this by flipping the target array once before the design runs, so the projected pattern appears the right way round. The line is marked in section 5.1 of the script and can be changed if a different convention is needed.
- Illumination aberrations. Aberrations of the beam that illuminates the DOE are not included unless they are written into the beam file. If they are significant, the Grid Phase approach is the better choice.
Attachments
| File | Description |
| doe_design.py | Designs the phase map from an image and writes the beam file. |
| doe_input.png | Example input image used as the target pattern. |
| doe_pattern.zbf | The beam file used in this article. |
| doe_pop_singlet.zar | OpticStudio system with the plano-convex singlet. |
References
- J. W. Goodman, Introduction to Fourier Optics, 4th ed. New York, NY, USA: W. H. Freeman, 2017.
- R. W. Gerchberg and W. O. Saxton, "A practical algorithm for the determination of phase from image and diffraction plane pictures," Optik, vol. 35, no. 2, pp. 237-246, 1972.
- F. Wyrowski and O. Bryngdahl, "Iterative Fourier-transform algorithm applied to computer holography," J. Opt. Soc. Am. A, vol. 5, no. 7, pp. 1058-1065, 1988.