1. Homepage
  2. Programming
  3. Assignment: Geometric Optics with Python

Assignment: Geometric Optics with Python

Engage in a Conversation
Geometric Optics with PythonTracing RaysPython

Kernel: Python 3 (system-wide)
Geometric Optics with Python CourseNana.COM

Instructions CourseNana.COM

Create a notebook named solutions.ipynb and answer the questions below. Use markdown cells to explain any theory you use, or to explain your code design choices. Include code you write and output in the same notebook. CourseNana.COM

When the assignment is collected, any material in the same folder as this notebook will be included. If you want to write importable modules for your code or tests then feel free. Code in module files will be marked along with the notebook. CourseNana.COM

To understand how your notebook will be marked, see the rubric. CourseNana.COM

Theory CourseNana.COM

Geometric, or matrix optics is a mathematical tool for modelling complex optical systems. It is a technique for tracing rays. Consider the optical system below. It is circularly symmetric and consists of a series of refracting surfaces all centered about the same axis - the optical axis. The z axis lies along the optical axis. CourseNana.COM

A ray at point z is completely described by two properties; its distance from the optical axis y and the angle of the ray θ. The ray going into the optical system has position and direction (y1, θ1) and the optical system bends the ray so it has an output position and direction (y2, θ2). CourseNana.COM

Now, if we further assume that all the angles are small, so that sin θ θ then the relationship between (y1, θ1) and (y2, θ2) is linear, and we can write: CourseNana.COM

y2 = Ay1 + 1 CourseNana.COM

θ2 = Cy1 + 1
This can be re-written as a matrix equation and therefore any optical system can be written as a CourseNana.COM

matrix M, so that: CourseNana.COM

[y2] = [A B][y1] = M[y1] θ2 CDθ1 θ1 CourseNana.COM

The matrix M is known as the ray-transfer matrix. Example 1: Free-space propagation CourseNana.COM

A ray travelling a distance d in free space, or through a material of constant refractive index travels in a straight line, so y2 = y1 + θ1d and θ1 = θ2. This means that CourseNana.COM

M=[1 d] 01 CourseNana.COM

Example 2: Refraction at a planar boundary CourseNana.COM

At a planar boundary between refractive indices n1 and n2, the ray angle changes according to Snell's law. y does not change. For small angles, Snell's law is n1θ1 = n2θ2, so CourseNana.COM

M=[1 0] 0 n1 n2
Using this transfer matrix we would have y2 = y1 and θ2 = n1θ1/n2, as expected. CourseNana.COM

A table of ray-transfer matrices for simple optical components is given on Wikipedia. Complex Optical Systems CourseNana.COM

The power of this technique is when modelling complex systems. Imagine a ray that starts at position (y0, θ0). It then travels through free space with transfer matrix M1, giving (y1, θ1). The it passes through a refractive boundary M2 to give (y2, θ2) and finally propagates in constant refractive index with transfer matrix M2 to give (y3, θ3). CourseNana.COM

Now, CourseNana.COM

(y3, θ3) = M2(y2, θ2) = M2M1(y1, θ1) = M3M2M1(y0, θ0) = Ms(y0, θ0), where CourseNana.COM

Ms = M3M2M1
In other words, one can propagate a ray through a optical system of made of up N individual CourseNana.COM

components by treating it as if it were a single optical elemenr with transfer matrix CourseNana.COM

M = MNMN1 ...M2M1 CourseNana.COM

Since NumPy is very good at matrix multiplication; this suggests we might be able to easily model optical systems in Python. CourseNana.COM

Questions Q1 CourseNana.COM

The documentation for the @ operator states that, given the expression a @ b , if both a and b are 2D arrays then matrix multiplication is performed. CourseNana.COM

Suppose M is a (2, 2) transfer matrix and rays is a (2, N ) array of (y0, θ0) values for N rays. i.e, with this notation rays[0, :] would be the y values of all N rays, and rays[1, :] would be the θ values for all N rays. CourseNana.COM

Explain why the output of M @ rays is a (2, N ) array of (y1, θ1) values, and why the rays have been correctly transformed to represent the output of the optical system with transfer matrix M . CourseNana.COM

Use LaTex mathematics in a markdown cell if appropriate. CourseNana.COM

Q2 CourseNana.COM

Using inheritance where appropriate, implement classes for the following optical elements: transmission in free space, or a material with constant refractive index;
a thin lens;
refraction at a planar surface;
CourseNana.COM

refraction at a spherical surface. CourseNana.COM

An optical element should possess a matrix attribute, and should implement the following method: CourseNana.COM

propagate(self, rays) : return an array of output rays from the element, where rays is a (2, N ) array of (y, θ) values for N rays. CourseNana.COM

Read back over Lab 4 if you can't remember what is meant by an attribute and a method . CourseNana.COM

The design of your code is up to you. You can write one class to represent any optical element, or you can have specific classes for each type of element - it is up to you to decide what will make for the most efficient, clear code. CourseNana.COM

Q3 CourseNana.COM

Enhance your classes for optical elements so that the following example would work, and system would also be an optical element that could propagate rays. In this example, FreeSpace and CourseNana.COM

SphericalMirror are classes representing specific types of optical systems. Your own code doesn't have to use the same names, or have classes to represent the same things - the design of your code is your choice! CourseNana.COM

Q4 CourseNana.COM

Parallel rays of light shine through an aperture of diameter 10mm and illuminate a lens made of two spherical surfaces of SiO2. The surfaces have radius of curvature R = 250 mm and the lens is of thickness t = 10 mm. CourseNana.COM


CourseNana.COM

By treating a thick lens as two spherical surfaces separated by propagation in a medium of constant refractive index, model the optical system above and, using code, find the focal length for blue light of wavelength 400 nm. CourseNana.COM

(The refractive index of SiO2 as a function of wavelength is available as a tab-separated text file, readable by Pandas, at https://www.filmetrics.com/refractive-index-database/download/SiO2. CourseNana.COM

Q5 CourseNana.COM

A screen is placed a distance from the lens that is equal to the focal length found in Q4 above and the lens is illuminated with redder light of wavelength 410 nm. CourseNana.COM

    system = FreeSpace(distance=10) + SphericalMirror(radius=1) + CourseNana.COM

FreeSpace(distance=20) CourseNana.COM


CourseNana.COM

The coordinate system of the screen is shown in the figure above. By allocating random values of φ to each ray, make a scatter plot of where the rays hit the screen. Use blue points to indicate rays with a wavelength of 400 nm and red points to indicate rays with a wavelength of 410 nm. CourseNana.COM

Comment on your results. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Geometric Optics with Python代写,Tracing Rays代写,Python代写,Geometric Optics with Python代编,Tracing Rays代编,Python代编,Geometric Optics with Python代考,Tracing Rays代考,Python代考,Geometric Optics with Pythonhelp,Tracing Rayshelp,Pythonhelp,Geometric Optics with Python作业代写,Tracing Rays作业代写,Python作业代写,Geometric Optics with Python编程代写,Tracing Rays编程代写,Python编程代写,Geometric Optics with Pythonprogramming help,Tracing Raysprogramming help,Pythonprogramming help,Geometric Optics with Pythonassignment help,Tracing Raysassignment help,Pythonassignment help,Geometric Optics with Pythonsolution,Tracing Rayssolution,Pythonsolution,