Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General polarization ray tracing #112

Open
kalosu opened this issue Dec 18, 2024 · 3 comments
Open

General polarization ray tracing #112

kalosu opened this issue Dec 18, 2024 · 3 comments

Comments

@kalosu
Copy link

kalosu commented Dec 18, 2024

Hello there community from poke,

First at all, thanks a lot for putting this nice tool available for everyone.

I would like to know if what I want to do is supported at the moment by your tool.

I have some electric field components (Ex, Ey and Ez) which I extracted from a FDTD simulation. With this, I am able to generate a ray bundle, i.e, a set of rays which are perpendicular to the common wavefront to these field components.

Using this I have performend non sequential ray tracing using Zemax but in this case, the rays just carry the "intensity" obtained from the Poynting vector.

I would like to extend this to the case in where I trace the field components along the ray directions and consequently calculate the transmitted field components through a non sequential optical system.

At the end, I want to have a detector and I want to be able to "observe" each individual field component traced through the system.

Would this be something that I could consider doing with poke? Do you have any reference on how to define a general ray set source?

Since I am doing a non sequential ray tracing, this would mean that I need to set the amplitude and phase for all components associated to each ray right? Any idea on how could this be performed?

Thanks for the comments!!

@Jashcraf
Copy link
Owner

Hi there and thanks for considering Poke 😀

If you can represent the output of your FDTD into a vector in the global coordinates of your optical system (array of [x, y. z]) or the local coordinates of the system's entrance pupil (array of [x, y]) then you can propagate it via polarization ray tracing, which Poke does support!

What Poke does not currently support is a way to load data from Nonsequential ray traces. This isn't a hard limit, I just haven't gotten around to implementing it yet.

If you would like to work on a PR to get non-sequential ray tracing working for Poke, I'd be happy to send you some resources to get started!

@kalosu
Copy link
Author

kalosu commented Dec 18, 2024 via email

@Jashcraf
Copy link
Owner

Yes, from my FDTD simulation I basically obtain the far-field components
Ex, Ey and Ez which I guess I can directly use to set the polarisation
associated to each ray?

We should take a look at the details, but in principle if you have the far-field components you can use it (or its Fourier transform) as the input to a polarization ray trace simulation. The effect is essentially setting the polarization of each ray, but there are some computational tricks that might help if your input signal has high-frequency components.

As for the non sequential ray tracing, what do you mean that currently it
does not support loading data from non sequential ray tracers? Are the ray
tracing calculations performed using sequential ray tracing?

Poke operates by the following principle:

    1. Use ray tracer (OpticStudio/CODE V) Python API to do ray tracing (poke.raytrace)
    1. Save ray data to a poke.Rayfront object
    1. Perform the 3D polarization ray tracing calculus using poke.polarization

Step 1. requires the writing of an interface with a given ray tracer's Python API. For example, we currently support OpticStudio's sequential ray tracing mode:

def trace_through_zos(raysets, pth, surflist, nrays, wave, global_coords):

Unfortunately, the interface between OpticStudio's sequential and non-sequential ray tracing modes are different - so we would need a trace_through_zos_nonsequential function to support non-sequential ray traces. However, I have an example file from the Zemax knowledgebase that has everything you need to do pretty rapid non-sequential ray tracing via the OpticStudio Python API.

Btw, I just have access to OpticStudio. I am aware that polarisation ray
tracing works in the sequential mode there but I did not find any relevant
information on the non sequential case. Do you maybe know something about
this?

My experience with OpticStudio is that the single polarization ray trace in sequential mode tends to work, but the other analysis functions (e.g. polarization pupil map) tend to experience erroneous phase wrapping for some reason. One of the reasons I wrote Poke was to make an open-source platform for these kinds of simulations so that I could work with the community on figuring out the origin of some of these discrepancies. And now it's been validated against both OpticStudio + CODE V's sequential ray tracing modes to (near) machine precision.

Here's one of the sample files from Michael Humphreys, whose Raytrace.dll has saved me hours of simulation time.
https://github.com/Jashcraf/Polarization-Raytrace/blob/df53bad3047c59fd562b0cb49a2361497f1d37ab/ZOS-API-samples/PythonNET_ZRDLoaderFull.py#L129

You just need to create a function that loads in the non-sequential file you want to simulate, and then get all of the ray data from the resulting "results" object.

https://github.com/Jashcraf/Polarization-Raytrace/blob/df53bad3047c59fd562b0cb49a2361497f1d37ab/ZOS-API-samples/PythonNET_ZRDLoaderFull.py#L174

There may be some debugging required if OpticStudio's "results" is different between non-sequential and sequential. But that's the gist of what needs to get added before you can use Poke to do PRT on non-sequential files. I would note that this is a pretty substantial addition in terms of expanding Poke's capabilities, so I'd be happy to add you as a co-author to the next conference proceedings I publish for Poke if you have the time to make a PR :D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants