Pyrate - Optical Raytracing Based on Python
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
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 | 10.5446/38201 (DOI) | |
Publisher | ||
Release Date | ||
Language | ||
Production Place | Erlangen, Germany |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
4
5
6
7
9
10
11
14
28
29
32
33
34
35
38
39
41
43
00:00
OpticsRay tracingRay tracingMultiplication signConstructor (object-oriented programming)Computer animation
00:13
Digital photographyOpticsQuantum stateCASE <Informatik>SoftwareCore dumpRay tracingWebsiteComputer fontSystem callLevel (video gaming)RootkitProjective planeComputer animation
00:59
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
02:19
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
03:15
OpticsVariable (mathematics)MathematicsPhysical systemVariable (mathematics)Functional (mathematics)RadiusRow (database)PlanningObject (grammar)SoftwareSet (mathematics)AngleMaxima and minimaHierarchyGraphical user interfaceElement (mathematics)Slide ruleOpticsComputer animation
04:46
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
05:54
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
07:05
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
08:05
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
09:59
Variable (mathematics)Maxima and minimaOpticsSocial classVariable (mathematics)CASE <Informatik>Wrapper (data mining)Computer animation
10:22
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
13:37
System programmingOpticsElement (mathematics)Data structureFunction (mathematics)Maxima and minimaCategory of beingComputer animation
14:00
Computer animation
Transcript: English(auto-generated)
00:05
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.
00:24
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.
00:51
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.
01:01
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.
01:20
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.
01:41
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.
02:03
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.
02:21
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.
02:40
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.
03:01
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.
03:23
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.
03:40
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.
04:04
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,
04:22
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.
04:45
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.
05:00
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,
05:24
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.
05:45
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,
06:06
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,
06:22
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,
06:46
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
07:08
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.
07:22
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.
07:41
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
08:03
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.
08:24
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
08:44
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
09:02
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.
09:25
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
09:40
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
10:03
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,
10:24
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.
10:40
You can find the documentation there. Thank you. We have time for a couple of questions.
11:01
Two questions. One, is it optimized enough or would the automatic optimization profit from doing the core of the simulation in a compiled language?
11:21
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
11:42
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?
12:00
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
12:24
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
12:43
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
13:02
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.
13:23
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.
13:41
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.