The Sequence Selector is a powerful tool in non-sequential mode for tracking, filtering, and analyzing rays following specific optical paths. This article is intended to serve as an introduction to the capabilities of this tool and takes the reader through several use cases of this tool and its features through examples.
Note: The Sequence Selector feature is available in the Premium and Enterprise editions of Ansys Zemax OpticStudio.
Authored By Elham Sarbazi
Introduction
In complex non-sequential optical systems, the number of possible ray paths can increase rapidly, making it difficult to analyze those that cause performance issues such as stray light or ghost images. The Sequence Selector tool addresses this challenge by providing a structured and persistent way to identify and analyze ray paths. Here, a sequence is an ordered list of objects and object faces a ray interacts with as it propagates through the system.
The Sequence Selector provides capabilities for generating, modifying, visually inspecting, and grouping sequences, simplifying analyses such as component-level stray light evaluation and ghost identification. It also enables the isolation of intended ray paths, supporting faster and more straightforward imaging analysis in non-sequential mode
This article introduces the Sequence Selector tool using a cell phone camera lens system as an example. Camera lenses are well suited for this purpose because they contain multiple light sources, numerous optical surfaces, and a detector where both direct and stray light paths affect performance. This complexity creates a large number of possible ray paths, making it challenging to identify those responsible for stray light or ghost images. By using the Sequence Selector, ray sequences can be efficiently tracked, analyzed, and grouped, demonstrating how the tool simplifies analysis and provides insight into the behavior and performance of complex optical systems.
Example: cell phone camera system
Open the “710_reoptimized_MTF_materials_QType-NONSEQ.zar” file from the attachment.
Run a non-sequential ray trace, with "Use Polarization" and "Split NSC Rays" options checked. Save the ray data into a ZRD file. This ZRD file contains all ray interaction data needed for subsequent analysis.
After the ray trace is completed, visualize the rays in the Shaded Model, or NSC 3D Layout, by loading the saved ZRD file. At this stage, a dense and cluttered ray display is observed. To identify specific paths, Filter Strings should be used.
Assume that the goal is to inspect the flux contribution of rays originating from Source 2, including ghost reflections at lens 23, that reach the detector. These rays can be isolated using the filter string Q2 & G23 & H25, as shown in the screenshot below:
The rays captured by the filter string Q2 & G23 & H25 include at least one ghost reflection at lens 23. However, this collection is broad and diverse, it may include rays with ghost reflections at other lenses, multiple ghost orders, or additional interactions that are not relevant to a specific analysis. As a result, while this filter provides a general view of rays contributing to ghost events at lens 23, it is insufficient for investigating more specific ray paths.
For more targeted analysis, filter strings with greater complexity are required to isolate the exact sequences of interest. For example, the filter string below isolates rays that originate from Source 2, pass sequentially through all lenses while including two ghost reflections at lens 23:
X_SEQ(2, 6.1, 6.2, 10.1, 10.2, 13.1, 13.2, 16.1, 16.2, 19.1, 19.2, 22.1, 22.2, 23.1, 23.2, 23.1, 23.2, 25)
While this filter string allows precise tracking of rays following this specific path, constructing such detailed filter strings can be error-prone and difficult to manage, especially in complex optical systems with many interacting components. The Sequence Selector tool simplifies this task by systematically categorizing rays into meaningful sequences and groups, and by providing simple, persistent filter strings that make targeted analysis easier and more reliable.
Sequence Selector
The Sequence Selector tool is located in the Raytrace Analysis group within the Analyze tab.
As shown in the screenshot below, the left panel provides access to the Sequence Generator and Sequence Builder, which define how ray sequences are generated and modified. The bottom table lists all generated sequences, where each row corresponds to a unique optical path and includes key information such as the sequence definition, source, flux contribution, stop surface, and last object encountered. Enabling sequences in this table makes them immediately available for use across other non-sequential analysis tools, providing a unified and persistent workflow for ray path exploration. A shaded layout on the right offers a real-time visualization of representative rays for the selected sequence, helping to visually validate optical paths within the system geometry.
Sequence Generator
The Sequence Generator tab enables the generation of sequences using straight-through paths, imported path filters from Path Analysis, or ray data from ZRD or PAF files.
When the Sequence Selector tool is launched for the first time, a set of straight-through sequences are automatically generated. Each sequence represents a ray path that travels directly from a source to the detector without undergoing any scattering, polarization, or splitting events. By selecting individual sequences, their corresponding ray paths are displayed in the embedded layout view. These sequences can be generated at any time using the Sequence Generator...Use straight through paths for all sources option.
Example: using sequence filters in other analyses
In the cell phone camera lens system discussed earlier in this article, open the Sequence Selector tool, navigate to Sequence Generator tab and select "Use straight through paths for all sources" option and check "Paths must end in a detector". Next, click "Generate sequences". All generated sequences appear in the "All Sequences" list, as shown in Figure 3. These sequences become available to other analysis tools through a sequence-based filter string, which is the sequence name displayed under the "Filter" column. These filters can be applied to any analysis tool that supports Filter Strings, including, but not limited to:
- NSC Shaded Model to isolate specific ray paths,
- Detector Viewer to visualize detector footprints from selected sequences, provided that a ZRD file is loaded,
- Ray Database Viewer.
The filter string SEQ[n1:n2] allows for the selection of a specific range of sequences (limited to 100 sequences at a time) from All Sequences list. In particular, SEQ[:] can be used to display all sequences (or the first 100 sequences) within the list in a 3D Shaded Model.
The sequences generated within the Sequence Selector tool can be renamed, deleted and modified as needed. For example, rename SEQ3 to MySEQ, the new sequence name will become immediately available in NSC Shaded Model as shown below:
In addition, for reusing generated sequences across different sessions, the sequence list can be saved into a non-sequential sequence file with .nseq extension.
Sequence Builder
Sequence Builder allows us to generate new sequences manually or modify the existing ones.
New sequences can be defined by specifying the ordered set of object interactions that form the desired ray path. The "Add Entry" button adds new rows to the builder panel. Each row represents a single interaction along the ray path, where the object is selected from the system and the corresponding face is specified. The first entry in the sequence defines the source object from which the rays originate, and the last entry is typically a detector.
Once all required objects and faces have been defined in the correct order, the sequence can be generated by selecting "Add Sequence". The new sequence is then added to the All Sequences list and is automatically assigned a sequence identifier. Selecting this sequence immediately displays its representative rays in the embedded layout view, providing visual confirmation that the intended optical path is correctly defined.
Example: using Sequence Builder for creating desired sequences
Sequence Builder also supports modifying existing sequences. In the cell phone camera system, assume that the goal is to create a new sequence that originates from Source 2 and includes a back-reflection from the back face of lens 23. This sequence can be generated by starting from the existing straight-through path, SEQ2, and modifying it using the Sequence Builder. By right-clicking SEQ2 in the All Sequences list and clicking "Edit", the sequence definition is loaded into the builder panel.
Next, add two additional rows using "Add Entry":
Reorder the new entries using the up and down controls:
Configure them to represent interactions with the front and back faces of lens 23.
After all the required changes are made, selecting "Add Sequence" adds the modified sequence to the list as a new sequence, labeled SEQ6.
Figure 6 - Using Sequence Builder for modifying existing sequences.
This capability allows sequences to be adjusted step by step, with each change immediately highlighted in the layout view, making it easier to verify that the defined sequence matches the intended ray path through the system.
Sequence Grouping
Sequence Grouping allows organizing large numbers of generated sequences into meaningful and analysis-ready categories. Once sequence generation is complete, sequences can be organized into groups, either manually or automatically, to further extend the analysis.
Groups provide a higher-level structure and make it easier to interpret complex ray behavior in non-sequential systems. Groups can be added, removed, or modified at any time if needed, while the sequence list remains unchanged. Sequence groups can also be used directly as filter strings in other analysis tools. These groups filters can be used in combination with individual sequences, which continue to retain their own filter strings.
Creating groups manually
Using the "Make New Group" feature, empty groups can be created. Individual sequences can then be selected from the All Sequences list and added to the new group. Note that removing groups does not delete sequences, and this allows different grouping strategies to be explored without the need to regenerate sequences.
Automatic Sequence Grouping
This feature analyzes existing sequences and organizes them based on their common properties. All ray sequences are first classified into a set of main categories that reflect their optical behavior, including:
Direct Sequences: sequences that follow a direct path, and end at a detector.
Ghost Sequences: sequences that have a ghost order of at least 1 and end at a detector.
TIR Sequences: sequences with Total Internal Reflection (TIR) events.
Diffractive Sequences: Sequences that have diffraction events associated with diffractive optical elements.
Object Interaction Groups: Sequences that interact with certain objects or faces such as the system Stop, side faces or detector.
Lost Sequences: Sequences that do not end at a detector.
Within each category, sequences are then categorized into smaller groups for easier analysis.
For example, Direct Sequences are grouped by source, making it easy to distinguish straight-through imaging paths originating from different field points. The Object Interaction category groups sequences based on how rays interact with specific objects or object faces in the system. One group consists of all sequences that pass through the aperture of a Stop object, while another isolates sequences that hit the mechanical face of the Stop. Additional groups collect sequences that interact with side faces of volumetric objects or that terminate at a specific detector.
Example: using Sequence Grouping for ghost analysis
The Ghost Sequences category gathers all ray paths that reach a detector after one or more ghost reflections into a structured set of groups. Ghost sequences are grouped by their originating source, their terminating detector, and ghost order. The term ghost order refers to the number of ghost reflections a ray undergoes before forming a ghost image. Additionally, if diffraction events are present in the system, additional ghost groups are created to distinguish ghost sequences that include diffraction events from those that do not. The ghost groups are particularly useful for ghost analysis, as they simplify the tasks of identifying, isolating, and comparing the most impactful ghost contributions in the system without requiring manual inspection of individual sequences.
In the cell phone camera lens system, run a non-sequential ray trace with 500 rays per source, use the filter string H25 to filter rays that land on the detector and save the ray trace data into a ZRD file. In Sequence Selector, choose "Use ZRD or PAF File" option, load the saved ZRD file and generate sequences.
Remark:
When generating sequences from ZRD files, it is not necessary to trace a very large number of rays. In practice, tracing a modest number of rays per source (for example, a few hundred) is sufficient to identify the relevant sequences and apply sequence grouping. Once the sequences and groups have been generated, more targeted ray tracing can be performed as needed. This approach highlights a key strength of the Sequence Selector: sequence and group filter strings are persistent and can be reused across analyses to enable efficient, targeted investigation.
Next, click "Automatic Sequence Grouping" in the Sequence Selector toolbar to allow the tool to analyze the generated sequences and categorize them. The resulting groups are listed in the bottom-left panel, as shown in the screenshot below:
The Ghosts group contains all sequences with at least one ghost event. The GhostsFromSource1–5 groups further divide these ghost sequences based on their originating source. Groups such as GhostOrder1, GhostOrder2, and so on contain sequences with exactly one, two, or more ghost events, respectively. The sequences within each group are sorted by their total ending flux by default. These groups can now be used directly as filter strings in other analysis tools.