Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Ray phase in ray tracing

Please login with a confirmed email address before reporting spam

Hello,

I'm trying to measure the phase of a bundle of rays that are reflected from an aspherical surface.
File 1 attached is the ray tracing and the red plane in file 2 is the surface on which I want to know the phase of the rays.
I can see that there is an option but every time I try to plot the phase on a curtain plane I recieve an error message:

Cannot evaluate expression.
Undefined variable.
- Variable: comp1.gop.Psi
- Geometry: geom1
- Domain: 3
Failed to evaluate expression.
- Expression: comp1.gop.Psi
- Plot: surf1 (Surface)

The 3rd domain is the aspherical surface that reflects the light (the circle in the files attached).
Any ideas of what is the reason?

Thank you!


11 Replies Last Post 2016年5月23日 GMT-4 11:00
Daniel Smith COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年3月30日 GMT-4 16:37
Hi Andrey, the phase is a property of the rays, rather then the geometry, so when you try to evaluate it on a geometric entity, it fails.

The solution is to define a cut plane where you want to evaluate the phase, then use the Poincare Map plot type to create a spot map of the phase. The Poincare Map plot type allows you to plot quantities defined only on the rays at the intersection point between the rays and a geometric entity. You can refer to the attached (V5.2) model to see how to do this.

Dan
Hi Andrey, the phase is a property of the rays, rather then the geometry, so when you try to evaluate it on a geometric entity, it fails. The solution is to define a cut plane where you want to evaluate the phase, then use the Poincare Map plot type to create a spot map of the phase. The Poincare Map plot type allows you to plot quantities defined only on the rays at the intersection point between the rays and a geometric entity. You can refer to the attached (V5.2) model to see how to do this. Dan


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年3月31日 GMT-4 02:23
Hi Daniel

Poincare plots are grate in 3D, but how do you get the same type of plot in 2D on a "Cut line" ?

Furthermore, if I want the Phase Difference (or path length difference OPD) between a Reference ray and the other Rays, on a plane intercept. Then I need to get the reference ray intercept phase and subtract that, else the difference is done in the time domain outside my plane and then the (wrong) result is projected on the plane (at least that is what I interpret what is happening).
Any good trick for 3D and 2D here ?

--
Good luck
Ivar
Hi Daniel Poincare plots are grate in 3D, but how do you get the same type of plot in 2D on a "Cut line" ? Furthermore, if I want the Phase Difference (or path length difference OPD) between a Reference ray and the other Rays, on a plane intercept. Then I need to get the reference ray intercept phase and subtract that, else the difference is done in the time domain outside my plane and then the (wrong) result is projected on the plane (at least that is what I interpret what is happening). Any good trick for 3D and 2D here ? -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年3月31日 GMT-4 02:52
Hello Dan,
Thank you for your answer.

In my simulation I defined a cut plane and used the "Accumulator" node I understood that I should use to transfer physical information from rays to the domains they pass through. But it didn't work since I do not know how to define it correctly. Can you please help with that method?

I tried the poincare map and it works well when I'm using the color expression and plot gop.Psi, but the results are a little bit weird, I expect a symmetrical phase map and it is not symmetrical (see attached file).
Maybe, has Ivar said, I need a reference ray. How can I define a reference ray that will intersect with the middle of my "cut plane"?

Can't open the example, I'm using 5.0.

Edit:
Actually I want the wavefront reflected from the aspheric surface, I have the normal components of the wavefront but that doesn't give me much. Is there a way to plot the wavefront reflected as a 3D curve in a defined volume using the accumulator maybe?

Thank you!
Hello Dan, Thank you for your answer. In my simulation I defined a cut plane and used the "Accumulator" node I understood that I should use to transfer physical information from rays to the domains they pass through. But it didn't work since I do not know how to define it correctly. Can you please help with that method? I tried the poincare map and it works well when I'm using the color expression and plot gop.Psi, but the results are a little bit weird, I expect a symmetrical phase map and it is not symmetrical (see attached file). Maybe, has Ivar said, I need a reference ray. How can I define a reference ray that will intersect with the middle of my "cut plane"? Can't open the example, I'm using 5.0. Edit: Actually I want the wavefront reflected from the aspheric surface, I have the normal components of the wavefront but that doesn't give me much. Is there a way to plot the wavefront reflected as a 3D curve in a defined volume using the accumulator maybe? Thank you!


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年3月31日 GMT-4 05:50
Hi

not sure how to assist you there, I'm also fighting with these issues, I have only v5.2 though.

Now to catch a ray you have the "ray index "gop.pidx" but it's a pointer into the full bundle of all rays. You have also a variable (in 5.2) for the total number of rays, as well as one per inlet feature node (use the node tag).
I found these explanations under the help for a search on "particle index", but I did not identify it under a search for "ray index", but since the "physics" are the same, it's natural that what apply for one does so also for the other, you will also find the variable definitions under the GUI variable selection pop-up in the plot nodes.

One way to get a variable attached to one given ray is to use the internal operator "sum over rays" and this works the standard way in COMSOL (not obvious I must admit) you can take a field or set variable and make it "global" by summing over "n=1 to 1". This gives you just one value from the field or array

for example for the Optical Path Length gop.L you get the value of a given ray with the operator:

gop.gopop1(gop.L*(gop.pidx==1)

read physics: "gop.", operator sum over all particles/rays: ".gopop1()" of variable OPL: "gop.L" but only
when the Boolean operation is true of particle index "gop.pidx==1" . I was just reminded by Linus at support about this "COMSOL" way ;)

Now you must know which index number to use: "1" here is the first ray you define (of first release node), I usually add a Point release node with one ray for my reference rays (i.e. chief ray, but I need to estimate the Entrance Pupil each time to know where to send the ray).

Be aware as since COMSOL solves in time, the results are first extracted and calculated at a given time, then projected onto the Poincarré plane, so as the "sum of squares is NOT equal to the square of the sums" keep carefully track on the order of the operations, the results are often not as one could expect, but there is a good logic behind.

Hope this helps, Optics Ray tracing was all new in V5 so they are improving it steadily, that will go on I assume, its really great (and exceptional if not unique today) to be able to mix all these physics with a good ray tracing program too :)

--
Good luck
Ivar
Hi not sure how to assist you there, I'm also fighting with these issues, I have only v5.2 though. Now to catch a ray you have the "ray index "gop.pidx" but it's a pointer into the full bundle of all rays. You have also a variable (in 5.2) for the total number of rays, as well as one per inlet feature node (use the node tag). I found these explanations under the help for a search on "particle index", but I did not identify it under a search for "ray index", but since the "physics" are the same, it's natural that what apply for one does so also for the other, you will also find the variable definitions under the GUI variable selection pop-up in the plot nodes. One way to get a variable attached to one given ray is to use the internal operator "sum over rays" and this works the standard way in COMSOL (not obvious I must admit) you can take a field or set variable and make it "global" by summing over "n=1 to 1". This gives you just one value from the field or array for example for the Optical Path Length gop.L you get the value of a given ray with the operator: gop.gopop1(gop.L*(gop.pidx==1) read physics: "gop.", operator sum over all particles/rays: ".gopop1()" of variable OPL: "gop.L" but only when the Boolean operation is true of particle index "gop.pidx==1" . I was just reminded by Linus at support about this "COMSOL" way ;) Now you must know which index number to use: "1" here is the first ray you define (of first release node), I usually add a Point release node with one ray for my reference rays (i.e. chief ray, but I need to estimate the Entrance Pupil each time to know where to send the ray). Be aware as since COMSOL solves in time, the results are first extracted and calculated at a given time, then projected onto the Poincarré plane, so as the "sum of squares is NOT equal to the square of the sums" keep carefully track on the order of the operations, the results are often not as one could expect, but there is a good logic behind. Hope this helps, Optics Ray tracing was all new in V5 so they are improving it steadily, that will go on I assume, its really great (and exceptional if not unique today) to be able to mix all these physics with a good ray tracing program too :) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年3月31日 GMT-4 13:09
Hi,
There was a productive discussion on a particle or ray index. Here is the link: www.comsol.com/community/forums/general/thread/46259 . I do understand that this link is tangentially related to the topic, but still.
Hi, There was a productive discussion on a particle or ray index. Here is the link: https://www.comsol.com/community/forums/general/thread/46259 . I do understand that this link is tangentially related to the topic, but still.

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年3月31日 GMT-4 15:14
Hi Alexey

Thanks for the link, I had missed that discussion, it covers indeed part of the problem: "indexing". But remains the catching of particle ray properties when they traverses a given plane to use these properties to normalize or compare full ray bundles.

I was hoping there were another index pointer than only the global "gop.pidx", that allowed us to point into a given release node ray bundle i.e. "gop.pnt1.pidx", not only the full total ray bundle, as there the number of rays and the identification of individual rays seems difficult, today.

--
Good luck
Ivar
Hi Alexey Thanks for the link, I had missed that discussion, it covers indeed part of the problem: "indexing". But remains the catching of particle ray properties when they traverses a given plane to use these properties to normalize or compare full ray bundles. I was hoping there were another index pointer than only the global "gop.pidx", that allowed us to point into a given release node ray bundle i.e. "gop.pnt1.pidx", not only the full total ray bundle, as there the number of rays and the identification of individual rays seems difficult, today. -- Good luck Ivar

Daniel Smith COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年3月31日 GMT-4 15:48
Hi Ivar, you can always use a second release feature which only releases 1 ray, then use the fact that each release feature has a unique index given by the variable gop.prf (Available under the Ray Statistics section of the postprocessing expressions). The ray release variable gop.prf is assigned an integer value, starting at 1. This number corresponds to the order of release features in the Model Builder.

In the attached example, all rays released from "Release from Grid 1" have gop.prf=1. The lone ray released from "Release from Grid 2" has gop.prf=2. Therefore, to plot the difference in phase between the lone ray and the ray bundle, I can use:
gop.Psi-gop.gopop1(if(gop.prf==2,gop.Psi,0))

This is of course on a geometric plane. To do this at a specific point in time, you can use the same expression for the Color Expression in a Ray Trajectories plot.

We are working on making it easier to perform this type of analysis in a future release, including the ability to do it in 2D.

Dan
Hi Ivar, you can always use a second release feature which only releases 1 ray, then use the fact that each release feature has a unique index given by the variable gop.prf (Available under the Ray Statistics section of the postprocessing expressions). The ray release variable gop.prf is assigned an integer value, starting at 1. This number corresponds to the order of release features in the Model Builder. In the attached example, all rays released from "Release from Grid 1" have gop.prf=1. The lone ray released from "Release from Grid 2" has gop.prf=2. Therefore, to plot the difference in phase between the lone ray and the ray bundle, I can use: gop.Psi-gop.gopop1(if(gop.prf==2,gop.Psi,0)) This is of course on a geometric plane. To do this at a specific point in time, you can use the same expression for the Color Expression in a Ray Trajectories plot. We are working on making it easier to perform this type of analysis in a future release, including the ability to do it in 2D. Dan


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年4月1日 GMT-4 01:34
Hi Dan

This is excellent news I'll test it asap, it completes a discussion over "support" with Linus, take a look.
By the way I have uploaded thereby many lens parts which for me have an improved usage compared to yours, I prefer my v2, see the case. PLS feel free to use these files for the best of next COMSOL generation, but I did not manage to document them with nice images :)

In fact what I lack the most is to define the optical Aperture stop (I have made one in my lens part library) and then to have COMSOL give me an approximate Entrance pupil location, such that when I have a ray bundle, I can define a "reference/chief ray" ray therein (i.e. the first indexed one) pointing to the Entrance pupil center and use that as normalization for the other rays of the bundle. And have this repeated per release node ...

I'm looking forward for next release again :)

--
Good luck
Ivar
Hi Dan This is excellent news I'll test it asap, it completes a discussion over "support" with Linus, take a look. By the way I have uploaded thereby many lens parts which for me have an improved usage compared to yours, I prefer my v2, see the case. PLS feel free to use these files for the best of next COMSOL generation, but I did not manage to document them with nice images :) In fact what I lack the most is to define the optical Aperture stop (I have made one in my lens part library) and then to have COMSOL give me an approximate Entrance pupil location, such that when I have a ray bundle, I can define a "reference/chief ray" ray therein (i.e. the first indexed one) pointing to the Entrance pupil center and use that as normalization for the other rays of the bundle. And have this repeated per release node ... I'm looking forward for next release again :) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年4月2日 GMT-4 04:18
Hi Daniel,
Thank you very much for the comprehensive explanation. That`s great.

Hi Ivar,
I have spotted that there is another operator for calculating the phase difference - gop.delta. However, I was not able to figure out what it is for.
Broadly speaking, the documentation for Ray Optics module lack of any explanations and typical examples (I do not take into consideration the Applecation library) how to use expressions and what these expressions for. Of course, I do not address the expressions that speak for themselves (ray position - qx, qy, qz; ray intensity - gop.I, etc.).
As for the lens parts, it was quite unusual for me to provide COMSOL with edge thickness for a `spherical equi convex lens 3d` (`Te` dimension) in Part Library. It is preferable to type an axial thickness, radii of carvature and a diameter for a lens to be built. Attached you will find a typical lens drawing for a lens. Such drawings are very common in Russia.
Lastly, I hope that one day COMSOL will give as an opportunity to perform Zernike analysis as you mentioned at www.comsol.com/community/forums/general/thread/236 .
Hi Daniel, Thank you very much for the comprehensive explanation. That`s great. Hi Ivar, I have spotted that there is another operator for calculating the phase difference - gop.delta. However, I was not able to figure out what it is for. Broadly speaking, the documentation for Ray Optics module lack of any explanations and typical examples (I do not take into consideration the Applecation library) how to use expressions and what these expressions for. Of course, I do not address the expressions that speak for themselves (ray position - qx, qy, qz; ray intensity - gop.I, etc.). As for the lens parts, it was quite unusual for me to provide COMSOL with edge thickness for a `spherical equi convex lens 3d` (`Te` dimension) in Part Library. It is preferable to type an axial thickness, radii of carvature and a diameter for a lens to be built. Attached you will find a typical lens drawing for a lens. Such drawings are very common in Russia. Lastly, I hope that one day COMSOL will give as an opportunity to perform Zernike analysis as you mentioned at https://www.comsol.com/community/forums/general/thread/236 .


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年4月3日 GMT-4 14:47
Hi

Indeed the edge thickness, a nice to have lens feature, is not the easiest to use, to set up a lens system, I have told this also to COMSOL, and they agree on that. I have made my own lens part items, based on center thickness including an aperture stop. I have provided these to "support" hoping they will complete them and include them in next release so we have a more conventional approach for lens design. The edge thickness has only really a sense, and a use, for concave surfaces. Normally for convex surfaces the lens diameter is much smaller than the radius of curvature so the edge thickness is driven that way, but it's NOT a driving parameter.

I have not identifies the "delta" variable yet, so far I have worked on gop.L but its rather complex to identify the OPD's for ray bundles, at different plane location today. I find the time domain solving is somewhat confusing, even if mathematically its "the" way to go, but we are so used to the position analysis in Optics, that at least I tend to take wrong conclusions, I will have to get used to this way of "sitting on the particle, and not on the shore" approach.
The Optical Ray tracing is an all new module, it will rapidly improve I hope, as COMSOL has managed for all their modules so far. Therefore its important to send suggestions to COMSOL for further improvements, I notice that many of mine do come in later releases, but the more we are to send suggestions the better the product will become, at least that is my hope.

There should be an old ZERNIKE identification via optimization model(s) in the Model Exchange see
www.comsol.eu/community/exchange/193/
but I have not updated it since 4.2a. So today one can do Zernike identification by optimization but you have some equation writing, or at least copying to do ;)

--
Good luck
Ivar
Hi Indeed the edge thickness, a nice to have lens feature, is not the easiest to use, to set up a lens system, I have told this also to COMSOL, and they agree on that. I have made my own lens part items, based on center thickness including an aperture stop. I have provided these to "support" hoping they will complete them and include them in next release so we have a more conventional approach for lens design. The edge thickness has only really a sense, and a use, for concave surfaces. Normally for convex surfaces the lens diameter is much smaller than the radius of curvature so the edge thickness is driven that way, but it's NOT a driving parameter. I have not identifies the "delta" variable yet, so far I have worked on gop.L but its rather complex to identify the OPD's for ray bundles, at different plane location today. I find the time domain solving is somewhat confusing, even if mathematically its "the" way to go, but we are so used to the position analysis in Optics, that at least I tend to take wrong conclusions, I will have to get used to this way of "sitting on the particle, and not on the shore" approach. The Optical Ray tracing is an all new module, it will rapidly improve I hope, as COMSOL has managed for all their modules so far. Therefore its important to send suggestions to COMSOL for further improvements, I notice that many of mine do come in later releases, but the more we are to send suggestions the better the product will become, at least that is my hope. There should be an old ZERNIKE identification via optimization model(s) in the Model Exchange see https://www.comsol.eu/community/exchange/193/ but I have not updated it since 4.2a. So today one can do Zernike identification by optimization but you have some equation writing, or at least copying to do ;) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 2016年5月23日 GMT-4 11:00
Dear Alexey, Ivar,

have you solved the wavefront problem yet? I solve exactly the same problem - different geom of course but I need the shape of the wavefront and naively hoped that I can obtain it as a kind of isosurface of the phase variable. But this is not possible in Ray Optics, as it seems... juts the poincare map...
So, any news, trics? :)

thx,
Katerina
Dear Alexey, Ivar, have you solved the wavefront problem yet? I solve exactly the same problem - different geom of course but I need the shape of the wavefront and naively hoped that I can obtain it as a kind of isosurface of the phase variable. But this is not possible in Ray Optics, as it seems... juts the poincare map... So, any news, trics? :) thx, Katerina

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.