Introduction to Ray Tracing

1 Learning Objectives

By the end of this lab you will have…

  • Set up and understand how to configure optical ray tracing simulations using the Python package RayTracing.
  • Perform ray tracing simulations of simple imaging systems and analyze their performance

2 Setup

2.1 Download and Install the RayTracing Package

https://github.com/DCC-Lab/RayTracing

https://raytracing.readthedocs.io/

The first step in this lab is to set up the RayTracing Python package. You may do this using either Spyder on your personal machine or by using a Jupyter notebook either locally or in Google Colaboratory (Colab). In this lab we will use an Jupyter notebook hosted on Google Colab.

To start, open the Colab notebook here and save a copy to your Google Drive. The Jupyter Notebook walks you through the steps necessary to set up and use the RayTracing package to perform a simple simulation. Follow the steps to try it out for yourself and get familiar with the basic interface. You may also find the catalog of examples listed here (accompanying code for easy copy-paste in the GitHub repository here)

3 Analysis of Finite and Infinite Conjugate Optical Systems

3.0.1 Ray Tracing of a Finite Conjugate Optical System

In this section you will perform a simulation of a finite conjugate microscope. This system is composed of two lenses: the microscope objective and the tube lens. The objective forms an intermediate image which is then used by the tube lens to form the final image. This system is called finite conjugate because the intermediate image plane is at a finite distance. This is in contrast to the infinite conjugate system which you will learn more about in the next section.

Set up a new simulation using two lenses with focal lengths of 10 cm (objective lens) and 40 cm (tube lens). Place the object 20 cm in front of the first lens (the objective lens) and separate the lenses by a distance of 70 cm. You may assume that the diameter of the lenses is infinite for this example.

3.0.2 Paper Calculation

First, use basic ray tracing diagrams and calculations to predict the behavior of this system and answer the questions below.

  1. For the first lens (objective lens) and intermediate image
    1. Where is the image located?
    2. Is it real or virtual?
    3. Upright or inverted?
    4. What is its magnification?
  2. For the second lens (tube lens) and final image
    1. Where is the final image of the imaging system located?
    2. Is it real or virtual?
    3. Upright or inverted?
    4. What is its magnification (with respect to the initial object)?
  3. Are the rays between the two lenses converging, diverging, or traveling parallel?

3.0.3 Computer Simulation

Next you will simulate the system to confirm your calculations. We will follow steps similar to the tutorial in the Colab notebook.

  1. Create variables to store the important properties of the system.
    1. obj_h to store the value of the object.
    2. f1 and f2 for the focal lengths of the objects
    3. lens_separation for the distance between the two lenses
    4. diameter for the diameter of the lenses
  2. Use the ObjectRays() function to create the rays object with a diameter equal to the value specified in obj_h. You may choose any parameters that you would like for the half angle (halfAngle), number of rays bundles (H) and the number of rays per bundle (T). A good starting point is around halfAngle = 0.05 rad, H=2, T=5.
  3. Create an ImagingPath object and add the lenses to the path.
  4. Display the imaging path.

Do the results of your ray tracing simulation match your expectations? Why or why not? Upload a screenshot of your ray tracing simulation.

3.0.4 Ray Tracing Analysis of an Infinite Conjugate System

In this section we will analyze an infinite conjugate system. An infinite conjugate system is the most common configuration for microscopes for reasons that we will see shortly. It is a subset of a type of optical system called a 4-f system. The 4-f system is a canonical optical system composed of two lenses separated by the sum of their focal lengths. In this section, you will simulate a 4-f system and investigate how different parameters in it affect its performance.

Give the first lens a focal length of 10 cm and the second with a focal length of 40 cm. Separate the two lenses by a distance given by the sum of their focal lengths (50 cm) and place an aperture at the back focal plane of the first lens in your system (this will also by definition be at the front focal plane of your second lens). Place your object at the front focal plane of the first lens.

3.0.5 Paper Calculation

First, use basic ray tracing diagrams and calculations to predict the behavior of this system and answer the questions below.

  1. For the first lens (objective lens) and intermediate image
    1. Where is the image located?
    2. Is it real or virtual?
    3. Upright or inverted?
    4. What is its magnification?
  2. For the second lens (tube lens) and final image
    1. Where is the final image of the imaging system located?
    2. Is it real or virtual?
    3. Upright or inverted?
    4. What is its magnification (with respect to the initial object)?
  3. Are the rays between the two lenses converging, diverging, or traveling parallel?

3.0.6 Computer Simulation

Set up a new simulation with two lenses as in the section before. Launch a set of rays through the optical system to answer the following questions again for the infinite conjugate system:

  1. For the first lens (objective lens) and intermediate image
    1. Where is the image located?
    2. Is it real or virtual?
    3. Upright or inverted?
    4. What is its magnification?
  2. For the second lens (tube lens) and final image
    1. Where is the final image of the imaging system located?
    2. Is it real or virtual?
    3. Upright or inverted?
    4. What is its magnification (with respect to the initial object)?
  3. Are the rays between the two lenses converging, diverging, or traveling parallel?

3.0.7 Aperture

How does the aperture at the back focal plane impact what rays can pass through the optical system? (Hint: create a large cone of rays and then see how changing its size impacts the bundle of rays)

Do the results of your ray tracing simulation match your expectations? Why or why not? Upload a screenshot of your ray tracing simulation.

3.0.8 The advantage of infinite conjugate systems

In this section we will investigate the advantages of an infinite conjugate optical system compared to a finite conjugate one. Keep the objects and distances between the lenses at the same distances as you set in the respective sections above.

We will compare the two systems by investigating what happens when we place a slab of glass into the optical path. Add a 5 cm thick slab of glass (\(n=1.5\)) in the space between the two lenses in both systems (making sure that you reduce the amount of space on either side to keep the lens separation the same). You can do this using the DielectricSlab object. Run the simulations again and comment on your observations for each system using the questions below.

  1. Does the location of the image change?
  2. Does the magnification of the system change?
  3. How does the image location and magnification change as the thickness of the glass slab increases?

Based on this analysis, why do you think that infinite conjugate systems are the preferred architecture in modern microscopes?

Hint

Consider that it is often advantageous to put filters in the microscope system to, for example, block certain wavelength ranges.

4 Raspberry Pi Camera Module

4.1 Raspberry Pi Camera Module Specs

Explore the datasheet and specifications for the Raspberry Pi v2 camera here and fill in the table below.

Specification Value Units Notes
Lens focal length
Lens f-number
Sensor pixel size (w x h)
Sensor size (w x h) in physical units
Pixel count (total number of pixels)

4.2 Ray Tracing Simulation of the 3d-printed Raspberry Pi Microscope

For this section, you will perform a ray tracing simulation of the 3d-printed microscope architecture we will use in later labs. You may find a copy of the paper describing the system here.

This microscope is designed by removing the lens of the Raspberry Pi camera and displacing it from the sensor to create a microscope with a working distance of ~7 mm. Using the parameters of the camera and lens that you found from the datasheet and completed in the table above, set up a simulation to analyze this microscope configuration. Photos of the lens with a scale bar are provided below for your reference.

Figure 1: Image of the lens from the Raspberry Pi Camera 2 Module.

4.2.1 Camera Lens Questions

  1. Estimate the diameter of the lens from the photos.
  2. Does this lens have a front or rear stop?
  3. Estimate the size of the stop from the photos. Then using the parameters from the lens data sheet that you collected in the table above, calculate the diameter of the stop. Do these values match?

4.2.2 Simulation

Set up a ray tracing simulation of the Raspberry Pi microscope using this single lens as a simple single-lens imaging system. Include any stops as appropriate. For example, you should consider the stop on the lens assembly and the finite size of the camera sensor. You may place the stop on the lens assembly at a distance of 1 mm from the lens. Then, use your simulation to answer the following questions.

  1. Write an expression to calculate the lateral magnification of the optical system. (Hint: make sure you set the objectHeight property of the ImagingPath object and check out the imageSize function with the useObject parameter set to True.)
  2. How far in front of the lens should the object be located in order to achieve a lateral magnification of 1.5x?
  3. At this magnification of 1.5x, what is the image distance (i.e., how far behind the sensor is the image located)?
  4. What is the maximum object size that you can image? Note that the field of view is normally defined as the diameter of the object where half the cone of rays from the edge of the object passes through the optical system.
  5. What is the maximum angle that a ray emitted from the center of the object can have with respect to the optical axis such that it still passes through the optical system? This quantity is called the half-angle of the acceptance cone and is used in calculating the numerical aperture (NA) of the optical system using the expression. The NA is an important parameter for determining the resolution of the optical system. What is the NA of this optical system?
  6. How would you change the optical system to achieve a magnification of 2x?

Save a copy of your simulation figure to submit.

5 Resources

Documentation