This example demonstrates how to design a metalens-based fiber-optic endoscope. The target phase profile of the metalens is optimized in Ansys Zemax OpticStudio using its powerful ray-tracing capabilities and optimization engine. Then, the nano-scale physical structure of the metalens is accurately modelled in Lumerical FDTD. Finally, Speos is used to evaluate the full system performance and visualize image acquisition in a realistic scene.
Software prerequesites
To be able to use this example, the following tools and assets need to be installed on your computer:
- Ansys Lumerical 2024 R1 or later (assembly group)
- Ansys Speos 2023 R2 or later
- Ansys Zemax OpticStudio 2023 R2 or later
Overview
Understand the simulation workflow and key results
Endoscopy enables minimally invasive optical imaging of internal organs, which facilitates medical diagnostics, image-driven biopsy, and experimental surgery. One of the most critical parameters of endoscopes is their size, which poses main limitations on clinical applications. Therefore, research and development aim for miniaturization, since smaller and less rigid devices allow for higher agility and accessibility, as well as induce less stress on the surrounding tissue. Fiber-optic endoscopes using metalenses provide promising alternative designs to conventional devices to significantly decrease the size of the optics, while maintaining similar image quality.
In this example, the endoscope consists of a fiber bundle and a metalens used for illumination and collection.
Step 1: Target phase optimization in Ansys Zemax OpticStudio
The first step is to determine the target phase profile for the metalens. In the case of collimated input beam, the phase function of common lens types, such as spherical or cylindrical lenses, can be calculated analytically. However, for complex optical systems, such as this endoscope design with a fiber bundle, an alternative approach is required to define the ideal phase profile. Therefore, we take advantage of Ansys Zemax OpticStudio’s powerful ray tracing and optimization capabilities and design the target phase for the metalens in OpticStudio.
Step 2: Unit cell simulations in Lumerical RCWA (not covered here)
The next step is to analyze how the unit cell geometry, its radius and height, as well as the incoming beam parameters, its incident and rotation angles, affect the phase and transmission values. By sweeping these parameters and analyzing the E-field after the unit cell, we create a multi-dimensional library that correlates the input beam parameters and the unit cell geometry to the phase addition. This step is fully described in the Small-Scale Metalens – Field Propagation article.
Step 3: Full metalens design in Lumerical
Based on the target phase mask and unit-cell library determined in the previous steps, we can now construct the full nano-structure of the metalens and propagate light through it. We calculate the far-field distribution and export the intensity angular distribution for further system-level analysis in Speos.
Step 4: Endoscope performance analysis and visualization in Ansys Speos
After the propagation through the metalens, ray tracing can be used again for comprehensive full system analysis and visualization in Speos. For the forward illumination path of the endoscope the intensity distribution exported from Lumerical is used as a source to describe the illumination beam after the metalens, while for the backward imaging path a reduced order camera model is taken into account based on the ideal Zemax model of the system. To evaluate the device performance in a realistic scene, image acquisition is simulated inside of a blood vessel CAD model.
Step 5: GDS Export from Lumerical (not covered here)
Once the physical design of the metalens is finalized, and the shapes and geometries of the unit cells across the whole lens are determined, the structure can be exported to GDS format for fabrication. The details of the GDS export process are discussed in the Large-Scale Metalens – Ray Propagation article.
Run and Results
Instructions for running the model and discussion of key results
Step 1: Target phase optimization in Ansys Zemax OpticStudio
- Open Endoscope_metalens.zprj file
- Observe the system set up (System Explorer, Lens data Editor and Merit function Editor)
- Optimize the system
- Observe the Binary 2 surface coefficients after optimization (these will be passed to Lumerical, STEP 3)
- Save the Endoscope_metalens.OPTDistortion file (this will be passed to SPEOS, STEP 4).
As a first step, we determine the target phase profile for the metalens in the endoscope device. Since in this case the light source is a fiber bundle and the metalens is incorporated in a complex optical system, the ideal phase profile cannot be described analytically. Thus, we design the metalens in OpticStudio by utilizing its powerful ray tracing and optimization capabilities. We model the system and optimize the target phase profile in the sequential mode of OpticStudio, where the fiber bundle source uniformly illuminates the metalens. This is achieved by using “Float by Stop Size” Aperture type where the STOP surface coincides with the metalens.
In this endoscope design the metalens, which has a 1 mm diameter, is located 100 mm behind the object (image to be collected from the endoscope, “sample”), and focuses the light on the fiber bundle which is 2mm away. As the design is rotationally symmetric, the metalens is represented by the Binary 2 diffractive surface type, which describes the additional phase profile, independent of the surface sag and index of refraction, as radial polynomials:
$$ \Phi = M \sum_{i=1}^N A_i \rho^{2i} $$
where
\( \Phi \) phase on the metalens surface
\( M \) diffraction order
\( N \) number of polynomial coefficients in the series
\( \rho \) normalized radial coordinate with respect to Norm Radius (1mm)
In order to optimize the metalens not only considering for the on-axis performance in this endoscope setup, but for an extended field of view, we use 3 Field Points, up to 15 degrees object half angle with equal area field distribution. In this case, we optimize the coefficients of the ρ^2, ρ^4, and ρ^6 phase terms, and target the default smallest RMS Spot Size in the Merit Function to achieve the best image quality with the metalens. The optimization results in the following target phase profile:
$$ \Phi (\rho) = -2864.992263 \rho^2 + 222.149840 \rho^4 - 26.552158 \rho^6 $$
The phase profile as well as the cross-section of the metalens can be observed using the surface analysis tool of Zemax Optics Studio:
Once the target phase profile is determined, we pass the data (the three coefficients) from OpticStudio to Lumerical (Step 3) to model the physical structure of the sub-wavelength unit cells in the metalens.
Additionally, we save an .OPTDistortion file which will be used to pass the data from Zemax to SPEOS (Step 4). More information about this data exchange can be found at Using the Export to Speos Lens System tool .
Note: Before exporting the OPTDistortion file through the Export Reduced Order Model to Speos the user needs to save any changes or updates that might have been done. In this case the file is changed after step 3, hence saving is required.
Step 3: Full metalens design in Lumerical FDTD
To define the illumination in Speos, we need to propagate the light through the metalens and calculate the far field projection. For small to medium size metalenses, we can use near-field stitching or far field summing to reconstruct the output of the metalens from the output of each meta-atom. For a 1mm diameter metalens made of over 6 million meta-atoms, this approach is not efficient. For that reason, we decided to run a full 3D FDTD simulation of the metalens using cloud-based Hight Performance Computing.
The first step is to generate the phase profile from the binary2 surface coefficients obtained in OpticStudio.
- Open the script file get_ZOS_phase.lsf in Lumerical FDTD script file editor.
- Check the radius normalization factor and the phase definition in the 2 functions. Make sure they match with the value and coefficients obtained in Step 1.
- Check the parameters (lens radius, focal length).
- Run the script.
The script will calculate the target phase profile on the meta-atom grid, and store it in a .mat file that will be used to build the metalens structure. If you set “do_plots” to true, the script will plot the phase profile (1D and 2D plots, left and right images respectively):
The next step is to build the full metalens using the target phase profile we just generated.
- Open the file full_lens_540nm.fsp
- Open the script metalens_build_assembly_group.lsf
- Check the script parameters
- Run the script
The script builds the metalens using an assembly group, making the simulation file much lighter and easier to manipulate. We use the file full_lens_540nm.fsp as a template: it already includes an assembly group with a pillar as prototype. The script will set the parameters of the assembly group (the position x,y and radius of the pillars), and the mapping table based on the target phase profile. We will use symmetries to reduce the simulation size by a factor of 4.
As the assembly group can handle a limited number of of unique variations (1024), we limit the radius variations to a 1nm step.
## Define assembly group mapping table
mapping = matrix(3, length(nfil));
mapping(1, :) = X(nfil);
mapping(2, :) = Y(nfil);
mapping(3, :) = round(radius_mask(nfil)*1e9)*1e-9; # 1nm resolution
Note if the assembly contains more than 32000 objects, the structure will not be displayed.
Copy the simulation file, the script file export_farfield.lsf and the python script submit_lumslurm.py to your HPC.
-
On the HPC headnode, edit the python script (you can use idlelib for instance:
python -m idlelib submit_lumslurm.py - Check the script settings (paths, file name, partitions, etc.)
- Run the script
We will use lumslurm to run the simulation on HPC, using lumslurm.run_solve(), and calculate the far field projection using lumslurm.run_script(). This python module allows to submit simulation and script jobs using Slurm job scheduler.
if os.path.exists(os.path.join(CWD, fname)):
print("Simulation and script files exist, proceeding with job submission")
print("Submitting simulation")
job1 = lumslurm.run_solve(os.path.join(CWD, fname),
partition="Execute-AMDv3",
nodes=16,
processes_per_node=15,
threads_per_process=8)
print("solver job submitted:", job1)
else:
print("Cannot find simulation file?")
if os.path.exists(os.path.join(CWD, fname)) and os.path.exists(os.path.join(CWD, sname)):
print("Simulation and script files exist, proceeding with job submission")
print("Submitting processing")
job2 = lumslurm.run_script(script_file=os.path.join(CWD, sname),
fsp_file=os.path.join(CWD, fname),
partition="Execute-AMDv4",
threads=176,
dependency=job1)
print("script job submitted:", job2)
else:
print("Cannot find files?")
This simulation requires about 2TB of memory to run. We use 16 nodes of 120 cores each. To reduce the memory communication between processes, we used 8 threads per process, 15 processes per node. The far field projection is run on a single node, using 176 cores. The far field is saved into a file (metalens_farfield_R500um_F2mm.ldf) for further processing.
The 2 jobs are submitted at the same time. Using the dependency, we make sure the script job will only be started if the solve job ends successfully.
- Open the script SPEOS_export_E2.lsf in Lumerical script editor
- Check the parameters (file name, radius, etc.)
- Run the script
This script will load the far field intensity angular distribution (picture on the left) and will export it as an extended map that will be used in Speos for illumination (picture on the right, extended map imported in Speos Labs).
Note: The script exports the data to a text file. To use the intensity distribution in Speos, import the text file in Speos Labs and save the extended map as a .xmp file.
Step 4: Endoscope performance analysis and visualization in Ansys Speos
In the final step we want to analyze the full system performance in a realistic scenario.
For that we are considering all the information from the previous steps. We are taking the reduced order model created in OpticStudio, and the Far-field information from the fiber and putting these into a scene. This scene is an Artery. Then we apply Materials to that scene.
- Open VHPA_Arteries.scdocx project in Speos
- Check material description (material node name)
- Load sensor Definition (Endoscope_metalens.OPTDistortion)
- Load XMP in source define power of source
- Run Simulation on CPU
The picture below shows the geometry set in Speos as well as the location of the camera.
You can visualize the mage recorded by the camera by opening the Idea_Fiber_Camera sensor irradiance map.
The picture shows a bright spot caused by a sharp peak in the illumination (visible in the metalens far field). The main artery (located in front of the camera) and 2 arteries on the sides are visible and identifiable.
Important Model Settings
Description of important objects and settings used in this model
Lumerical FDTD
Metalens simulation:
- The lens radius and pillar height are set in the scripts.
- A PEC aperture is used to block the injection of field beyond the lens. The radius of the aperture is automatically set by the script in “model”.
- We use symmetric and anti-symmetric boundary conditions to reduce the size of the simulation (see Symmetric and anti-symmetric BCs in FDTD and MODE ).
Far field projection:
- We use farfieldsettings to downsample the nearfield data point and accelerate the far field calculation.
- The resolution of the far field projection is set in the script
Speos
In this simulation, we separate the metalens functionalities (illumination and collection)
Light source:
- We use the far field angular distribution calculated using Lumerical FDTD, assuming it doesn't depend on the wavelength and the illuminated object are beyond the focal plane (2mm).
Camera
- The Reduced Order Model (ROM) camera sensor which uses *.OPTdistortion data from Zemax OpticStudio model (also called Speos Lens System) is usually the best balance between accuracy and simulation time for most of the analysis.
Updating the Model With Your Parameters
Instructions for updating the model based on your device parameters
- The focal length, size of the lens, and phase function are defined in Step 1 and may be customized to generate different functions
Taking the Model Further
Information and tips for users that want to further customize the model
Metalens design - FDTD
- We use the same meta-atoms (materials and shape) as in previous examples. Other material stacks and geometries can be used. This requires to run the full meta-atom analysis and export the phase/transmission database.
- The metalens simulation was done at a single wavelength (540nm), considering the angular distribution of the far field is not wavelength dependent. A more accurate model can be extracted by running a broadband simulation covering the same range as used in Speos (400nm to 700nm). Note this will affect the mesh and increase the memory requirements.
Endoscope simulation - Speos
- For the Material definition we use as simplified surface description for the Artery wall and assume that we only have water to content with. This could be much improved by using more sophisticated material and scattering models but would also drastically increase the simulation time.
- The current models are assuming perfect light transport through the fiber. This could be adjusted through a XMP postprocessing.
Additional Resources
Additional documentation, examples and training material
Related Publications
- Fröch et al, “Real time full‑color imaging in a Meta‑optical fiber endoscope”. Springer Open eLight, 3:13, (2023)
- Baethge et al, "Fiber endoscope design utilizing metalens for illumination and collection," Proc. SPIE 13006, Biomedical Spectroscopy, Microscopy, and Imaging III, 1300610 (20 June 2024); https://doi.org/10.1117/12.3017414
See Also
- Large-Scale Metalens – Ray Propagation
- Small-Scale Metalens – Field Propagation
- Endoscope Lighting & Imaging
Related Ansys Innovation Courses
Appendix
Additional background information and theory
Fiber bundle illumination and collection
In this example, we consider a fiber bundle for illumination and collection. To achieve a uniform illumination of the metalens, we need the fiber cores to be close enough while making sure there is no coupling from one core to the other to avoid any crosstalk.
To validate this, we first look at the coupling between 2 neighboring cores as a function of their distance. Using the difference in the effective indices of the coupled modes, we can calculate the length required to get 10% coupling from one core to the other (see evanescent waveguide coupler):
$$ L_{10\%} = \frac{\lambda_0}{\pi \Delta n_{eff}} sin^{-1} (\sqrt{10\%}) $$
Where \(λ_0\) is the wavelength of interest, and \(\Delta n_{eff}\) the difference in effective index between the coupled modes. We used a 8.2um core diameter, and a wavelength of 540nm. The pictures below show the structure designed in Lumerical MODE (left) and the coupled modes calculated by the FDE solver (right).
Using a script, we vary the distance between the 2 cores and calculate the propagation distance required to get 10% coupling:
We can see in the plot above, for a distance above 9um, we would need over 100m fiber length to get 10% coupling. As the actual fiber length will be much shorter, we can assume there is no coupling between neighboring fibers.
Next, we’re considering a fiber bundle made of a hexagonal array of fibers with a pitch of 20um (so a distance between cores over 10um), as shown in the picture below:
To obtain the emission of this bundle, we calculate the far field projection at a 2mm distance (right picture below) of the fiber mode (left picture below).
The bundle emission can be calculated as the incoherent sum of the far field projections of each individual fiber:
$$ \vert {\vec E}_{bundle}^{far field} (x,y) \vert^2 = \sum_{i,j} \vert {\vec E}_{i,j}^{far field} (x,y) \vert^2 $$
Each far field projection is obtained by shifting the mode profile to the fiber position and projecting the fields to the metalens location. The resulting field intensity profile is shown below:
The field intensity shows a good uniformity over the area covered by the metalens, validating our initial assumption.