We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Pyrate - Optical Raytracing Based on Python

00:00

Formal Metadata

Title
Pyrate - Optical Raytracing Based on Python
Title of Series
Number of Parts
43
Author
Contributors
License
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language
Production PlaceErlangen, Germany

Content Metadata

Subject Area
Genre
Abstract
Pyrate is a program for scientific optical lens design. It traces rays through an optical system and optimizes its properties, e.g. lens radii. The merit function to be minimized during optimization can vastly vary depending on the type of objective and constraints. During the design process, the merit function is changed a lot, as the system must fulfill ever more requirements when approaching production readiness. We present a variable container, storing the variable value, its status, and possible constraints. The status is used to indicate whether the variable shall be optimized or not. Designers often use only parts of the available variables, especially in early design stages. Before optimization, the highest hierarchy object collects all containers from its children and grandchildren, wraps them to a format usable by scipy.minimize and optimizes the system with the current merit function. We show several examples of optical systems optimized with our program.
5
Thumbnail
1:34:10
33
Thumbnail
1:31:57
34
Thumbnail
1:28:12
35
Thumbnail
1:27:32
41
Thumbnail
1:31:21
43
OpticsRay tracingRay tracingMultiplication signConstructor (object-oriented programming)Computer animation
Digital photographyOpticsQuantum stateCASE <Informatik>SoftwareCore dumpRay tracingWebsiteComputer fontSystem callLevel (video gaming)RootkitProjective planeComputer animation
Mathematical analysisGraphical user interfaceRay tracingCore dumpTensorfeldHypermediaPrice indexGradientSymmetry (physics)System programmingOpticsSymmetry (physics)Order (biology)Level (video gaming)Mathematical optimizationFunctional (mathematics)Internet service providerPlanningMaterialization (paranormal)Arithmetic meanQuantum stateHypermediaSystem programmingOpticsRootkitGraphical user interfaceProcess (computing)GeometryPoint (geometry)Sign (mathematics)Electronic mailing listRule of inferenceMedical imagingFocus (optics)Computer animation
OpticsFunction (mathematics)Maxima and minimaMedical imagingPosition operatorGeometryPlanningPoint (geometry)Order (biology)OpticsCASE <Informatik>Maxima and minimaFunctional (mathematics)Quantum stateRay tracingRow (database)Multiplication sign2 (number)Right angleWebsiteArithmetic meanComputer animation
OpticsVariable (mathematics)MathematicsPhysical systemVariable (mathematics)Functional (mathematics)RadiusRow (database)PlanningObject (grammar)SoftwareSet (mathematics)AngleMaxima and minimaHierarchyGraphical user interfaceElement (mathematics)Slide ruleOpticsComputer animation
OpticsSystem programmingElement (mathematics)Data structureVariable (mathematics)RadiusPointer (computer programming)Category of beingSurfaceMaterialization (paranormal)Object (grammar)Social classDampingComputer programmingOpticsElement (mathematics)Electronic mailing listFunctional (mathematics)Level (video gaming)Offenes KommunikationssystemOperating systemSoftware testingComputer animation
Constraint (mathematics)Boundary value problemOpticsSocial classData structureRadiusInstance (computer science)Social classVariable (mathematics)Well-formed formulaMathematical optimizationFunctional (mathematics)HierarchySoftware testingConstraint (mathematics)Level (video gaming)Greatest elementComputer animation
OpticsSocial classData structureSystem programmingElement (mathematics)Social classVariable (mathematics)OpticsWrapper (data mining)outputFunctional (mathematics)Level (video gaming)Electronic mailing listObject (grammar)SurfaceGreatest elementPointer (computer programming)RadiusType theoryComputer animation
Ray tracingVariable (mathematics)Mathematical optimizationoutputFront and back endsOpticsOpticsOperating systemoutputWebsiteFunctional (mathematics)State of matterVariable (mathematics)AlgorithmCategory of beingPhysical systemElectronic mailing listMeasurementMathematical optimizationGraphics tabletComputer programmingObject (grammar)CASE <Informatik>Set (mathematics)Social classRepetitionSpecial unitary groupMaxima and minimaCybersexWrapper (data mining)PlanningFront and back endsComputer animation
Variable (mathematics)Maxima and minimaOpticsSocial classVariable (mathematics)CASE <Informatik>Wrapper (data mining)Computer animation
OpticsTime domainSource codeMaxwell's equationsCore dumpDatabaseMultiplication signRadiusMereologyMathematical optimizationFunctional (mathematics)System programmingGAUSS (software)Doubling the cubeExpert systemPhysical systemReverse engineeringDegrees of freedom (physics and chemistry)SimulationNichtlineares GleichungssystemCASE <Informatik>Open setSoftwareRay tracingCompilerSurfaceSingle-precision floating-point formatMoment (mathematics)Formal languageEndliche ModelltheorieInclusion mapOffice suiteSelf-organizationMultiplicationMatrix (mathematics)Computer animation
System programmingOpticsElement (mathematics)Data structureFunction (mathematics)Maxima and minimaCategory of beingComputer animation
Computer animation
Transcript: English(auto-generated)
Thank you. I want to present you our hobby project, which is about ray tracing. The goal we have, why we want to do this is we want to be able to design optics. So we want to construct optics, make technical drawings of the lenses and fabricate them.
And we want to do that, for example, for photography, for microscope lenses and also for telescopes. We found that commercially available software has some drawbacks concerning special cases that are maybe of purely academic interest.
But we decided that we want to have a ray tracer that does it correctly. So we decided to write our own ray trace core.
So our whole project, I show you a roadmap here. We start down at the roots. We want to have a ray trace core. We are almost finished with that. And it shall be able to correctly ray trace anisotropic lossy materials and also tensorial media.
It shall be able to correctly work with inhomogeneous media and also provide convenience functions to be able to efficiently work with systems without symmetry. With the last point, systems without symmetry, we are not completely done yet. We are still working on that.
The next step is we need an optimizer in order to optimize an optical system. The following steps will be GUI and tools to analyze lenses. As soon as we have the tool to analyze lenses, we can evaluate designs made by other people.
From there it is a small step to the ability to design our own lenses. And we also have some further plans what we could do next like increase the level of automation in the whole lens design process. But first let me tell you what optical design means.
Optical design in a nutshell means that we optimize the geometry of lenses so that an objective focuses light to a sharp image. And sharp image means sharp spot always shall be focused to the same point or to a very small spot.
So we perform a ray trace. We throw rays at an optical system. We then calculate the positions in the image plane. We define a merit function. Merit function means a function that defines the quality of the optical system. In our case that could be, for example, the spot size.
And then we use a function, for example, Cyper Minimize to optimize the merit function value, so to change the lens geometries in order to have a small spot. How that looks in practice is like in the following. In the top row I start with some plane plates of glass.
They do not focus light at all. In the second row I told the system that I want to have a system that focuses light. I allowed the last two radii to vary.
And I shot in monochromatic light. And in the next steps I allowed more and more variables to be optimized. I used polychromatic light and I used light coming in from different angles. So what you usually do is you start with very few variables.
You start with few requirements and you try to push the system in a way that it goes into the correct local minimum. Usually if you define the merit function in the beginning and then just start to optimize,
it would probably result in a low minimum, but it would be one that is not fabricable. Therefore we have to somehow guide the whole system and we have to change the set of variables often. And we have to change the merit function very often. Commercial software for example provides functions that you can switch on and off the variables in the GUI very quickly.
Additionally we want to have a hierarchical structure of our objects. We want our optical system to consist of several optical elements. And the optical element objects then contain materials and surfaces surrounding the materials.
And the surface has for example a property radius and we want to optimize this radius. When we define the merit function we do not want to specify explicitly the private variables of the optical system, but instead we would like to have a function that we only talk to the top level,
that we only talk to the optical system and say hey optical system give me all your variables. And then we get a list of variables and we can work with that. In C programming you would have a float variable radius and then hand a pointer on that radius through.
However in Python we do not have pointers on floats or variables, so what we decided to is we wrote a class that contains the radius. And this class has some properties, for example it has value, that would be the radius value, the actual radius,
and it has a status. The status can be for example fixed, that means I lock the value and I do not want the optimizer to change that. It can be variable and it can be something like a LaGrange constraint,
that means we have an analytic formula that defines the value and it is not optimized by CyberOptimize, but after each optimization step it has to be updated. And we have a class with optimizable variables that may contain several of these optimizable variables,
and more importantly it has the function getAllVariables. And that function just searches the dict of the class for instances of the optimizable variable or of the class with optimizable variable. I'll apply that to the hierarchical structure and for that I color the optimizable variable in green
and the class with optimizable variables in red. You see at the bottom we have the radius that is all optimizable variables and all higher levels are of the type class with optimizable variable.
So if I call the method getAllVariables on the optical system, the optical system says I don't have variables on my own, but I have classes with optimizable variables, it finally drops down to the surface that says I have an optimizable variable and hence that through up to the optical system.
And now the optical system puts them all together to a list, and now I have a list on all variables. Or I have a list of pointers on optimizable variable objects and I cannot feed that directly into the CyberOptimize function
and so we wrote a wrapper that uses an optical system as user input. This can be for example the system of plane plates and we have a merit function as a user input and the merit function is a function of the optical system.
So there are more complicated merit functions than just use the spot size. It can contain stuff like that the system shall have a lot of favorable properties and I do not want to write a new merit function for each optical system
with four lenses, with five lenses and so on. So I just make that general that it gets an optical system object and gives me in the end a measure whether the system is good. And with that user input we go into our algorithm
and it first calls the getAllVariables method, gets the list, then it picks out only those optimizable variables where the status is set to variable because Cyber shall only see those and we write a simple wrapper function that is done automatically by the program where we now have a function that is a function of the variable values.
So that Cyber Minimize gets the variable values and a function of the variable values and can optimize the whole system. The wrapper function sets the variable values on the optical system
and then performs the merit function on the optical system with the new variable set. We put that into the backend which is in this case Cyber Minimize and get the modified system with optimized properties. So to summarize, we need to switch on and off variables often
and therefore we decided to use a variable container class and a transparent wrapper. In case you have suggestions how to improve our code, we are more than happy. Also if you want to have a look at our repo,
and in case you are interested in our physical model, how we implemented all the way from Maxwell's equation to our optical raytracer, we also have a folder called RTFM.
You can find the documentation there. Thank you. We have time for a couple of questions.
Two questions. One, is it optimized enough or would the automatic optimization profit from doing the core of the simulation in a compiled language?
And question two, I guess it's impossible to arrive at the global optimum. There is a huge experience in doing proper optical design. So I guess this is a nice solution to part of the problem and the other part of the problem would have to be covered by an expert system
that is aware of existing optical designs and question about that. Is there an open database of successful designs or would it be useful to do reverse engineering of excellent cameras, microscopes and so on?
To the first question, we have no optimization yet in there. We wrote it purely in Python, but we use of course NumPy matrix multiplication. That's the only speed increase we used. And with the other thing, you are definitely right. If I have a system with just six lenses and I only have one radius on each surface, that means 12 degrees of freedom
and it's impossible to find the global optimum in such a system. Also, if there is some hole in your merit function, a global optimizer will definitely find it. So there is commercial software that has something like a global optimizer
that works reasonably well for systems with low degree of freedom and if you use that, after a short time you will notice what you didn't expect to happen because there is something in your merit function that allows a system
that is not possible to be fabricated like negative thicknesses or something. You have to include everything. With the database, that would be definitely helpful. I know of a commercially available database that contains lots of patents for starting systems.
As soon as our ray tracer works, we also intend to make some starting systems that work quite nice. For example, this double gauss system shown here I made myself.
Yeah, but it doesn't have a very large aperture or very good properties yet. Sorry, we are moving on to the next speaker, so let's thank the speaker again.