This article explains how to use filter strings to identify and isolate specific rays in a Non-Sequential system. Examples are given which show how to isolate rays that have undergone surface scattering and bulk scattering, as well as rays that undergo diffraction and fluorescence.
Authored By Sanjay Gangadhara
When OpticStudio traces a ray, it records every interaction that ray undergoes. In Non-Sequential mode, this process can be very complec, which is why it can be useful to limit the observed ray paths using filter strings.
OpticStudio offers many filter strings that can be used to provide limitations on ray paths - either during the ray trace itself, or when viewing the results in the Layout plot or Detector Viewer—and supports the ability to combine filter strings using logical operands.
In this article, a few examples will be provided to illustrate the use of logical operands in constructing filter strings for isolating specific rays.
A simple example
A simple example of a system where a filter string may be useful to “clean up” the Layout plot is provided in the file “Simple Example.zmx.” The archive (.zar) file for this example is located on the last page of this article.
In this system, a Source Ray object is used to launch rays at a block of BK7 glass. The spectrum of the source is polychromatic, as defined by the three system wavelengths provided in the Wavelength Data dialog box:
The back face of the BK7 glass is specified to be a scattering surface, in which rays scatter according to a Lambertian distribution:
The Scatter Fraction parameter has been set to 0.5, indicating the 50% of the incident energy will be scattered. Ray splitting is also included in this system, so scattering can occur both in transmission and reflection. As a result, the Layout plot for this system is quite messy:
What if we were only interested in seeing those rays that do not have a wavelength of 0.55 microns and that undergo scattering only once before hitting the detector? We can easily create a filter string that will limit the Layout plot to just those rays.
Filter strings that can be used to isolate scattered rays are Sn, Fn, and X_SCATTER(n,b). The Sn and Fn filter strings allow you to target for rays that have scattered from a particular object, while the X_SCATTER(n,b) filter string targets those rays that have scattered "b" times and have hit object "n" (see the section entitled "The filter string" in the chapter of the OpticStudio manual entitled "Non-Sequential Components"). In our example, we are only interested in those rays that scatter once and then hit the detector, so the appropriate filter string would be X_SCATTER(3,1).
In this system, rays that scatter once may also scatter in reflection. Some of these rays may subsequently be reflected off the front face of the BK7 glass, and then transmit through the back face of the glass and hit the detector. These rays are said to undergo ghost reflection at the front face of the glass and can, therefore, be identified using the Gn filter string. In this case, we do not want to see any rays on the detector that have undergone ghost reflection, so the appropriate filter string would be G0 (this will isolate not only the first order ghost reflections described above, but higher order ghost reflections as well, e.g. when a ray reflects off of the front and back faces multiple times before finally passing through the back face and hitting the detector).
Finally, we also want to limit the rays shown in the Layout plot to those that do not have a wavelength of 0.55 microns. In this case, the Wn filter string can be used to filter for wavelength, since the ray wavelengths are defined explicitly in the Wavelength Data dialog box. The appropriate filter string for isolating rays at a wavelength of 0.55 microns is W2, since this wavelength corresponds to wavelength number 2 in the Wavelength Data dialog box.
We can combine the above filter strings together using the “&” and “!” logical operands to form the desired filter:
which will isolate those rays of interest in the Layout plot:
Conversely, imagine now that we were interested in seeing only those rays that have a wavelength of 0.55 microns and that do not ever undergo scattering. In this case, we could use the same filter string to isolate those rays with a wavelength of 0.55 microns, and remove the “!” logical operand from in front of the filter string. To filter for those rays that do not undergo scattering, we would use the filter string F2, and place the “!” logical operand in front of it. Combining these together using the “&” logical operand:
we find exactly what we expect:
The reason that the Fn filter string is used in this case is because ray splitting is on. With ray splitting on, it is very likely that some segment of every ray will undergo scattering (even if that segment was generated after a number of Fresnel reflections in the glass). Thus, the Fn filter string must be used to target segments from a ray that undergo scattering (Sn can only be used to target the ray itself, not any segments of the ray), in this case to isolate those segments out of the Layout plot.
A diffraction grating example
Another example of the use of filter strings is provided in the file “Diffraction Grating.zmx” (the archive file for this example is located on the last page of this article). In this system, the source spectrum has been defined to model the white color seen on computer monitors:
More details on source color modeling may be found in the article entitled “How To Perform Stray Light Analysis".
Once the data are saved to a ZRD file, the file may be loaded onto a Detector Viewer:
Then—and only then—can a filter string be applied to the data. However, filter strings may also be applied directly during the ray-trace, as seen in the Ray Trace dialog box above. The advantage of applying a filter string directly to the ray-trace is a reduction of the ZRD file size (which can be quite large when a large number of analysis rays are launched). However, once the ZRD is created from a filtered ray-set, the original ray data is lost. Thus, it is often more advantageous to save all rays to the ZRD file, and filter as desired within the Detector Viewer.
A fluorescent scattering example
A slightly more complicated system is provided in the sample file “Bulk Scattering.zmx” (the archive file for this example is located on the last page of this article). In this system, a collimated beam of light at 0.55 microns scatters off a fold mirror and then passes through a lens. However, the size of the lens is smaller than the size of the scattered beam, so some of the scattered light does not pass through the lens:
Light that does pass through the lens will undergo bulk scattering, and all of the rays that do scatter will also fluoresce, i.e. their wavelength will be changed from 0.55 to 0.65 microns:
You may read more about the wavelength-shifting capabilities of OpticStudio in the article entitled “How to Model Fluorescence using Bulk Scattering".
Rays that do and do not pass through the lens are recorded by a Detector Color object (more details are provided in the article entitled “How to Measure and Optimize Color Data"). The true color image of the ray distribution shows both the scattered light at 0.55 microns (green) and the fluorescent light at 0.65 microns (red):
There will be some small percentage of rays that do pass through the lens but do not undergo bulk scattering. They can be isolated using the filter string “!X_WAVESHIFT(1,2) & H3” (X_WAVESHIFT(a,b) filters for those rays that shift from wavelength "a" to "b" during bulk scattering, where "a" and "b" correspond to wave number in the Wavelength Data dialog box; see the section entitled "The filter string" in the chapter of the OpticStudio manual entitled "Non-Sequential Components"):
The filter string “X_WAVERANGE(4,0.54,0.56) & H3” could also have been used to yield the same result. If we wanted to eliminate these rays from the detector results, we would use the following filter string: “(X_WAVERANGE(4,0.64,0.66) & H3) | !H3:”
The first term in parentheses looks for those rays that bulk scattered in the lens, and the second term (“!H3”) looks for those rays that do not pass through the lens. Although the results with this filter look similar to the original results:
if you look closely you will see that the total power has been reduced from 259.1 Lumens to 258.1 Lumens. This reduction of 1.0 Lumen is consistent with the power of those rays that pass through the lens but do not scatter (the numbers may be different if you re-run a ray trace on your computer, but the result will be the same).
Please sign in to leave a comment.