ehpor / hcipy

A framework for performing optical propagation simulations, meant for high contrast imaging, in Python.
https://hcipy.org
MIT License
90 stars 30 forks source link

Planar to spherical propagation #109

Open syhaffert opened 3 years ago

syhaffert commented 3 years ago

For several end-to-end instrument simulations it would be helpful if there is a spherical to planar propagator based on Fresnel diffraction. I think the Zemax documentation has a pretty good description of the different transforms and regions. I wanted to open an issue to discuss the implementation.

I was thinking of adding a function like: propagator = choose_propagator(wavefront_in, distance)

I have assumed that the wavefront_in has an internal Gaussian beam that keeps track of the divergence during all propagations. Then based on the divergence of the Gaussian beam it selects Fresnel/ASP or the SphericalFresnelPropagator.

For the propagator itself, we can just add SphericalFresnelPropagator to differentiate it from the Planar version. And I think it is best to not rename the old propagator to keep backwards compatibility.

Any thoughts?

ehpor commented 3 years ago

My original plan for this was to have a Propagator child class that did this, without any function like the one you propose. That class would decide on the propagator to use based on its input wavefront (including the pilot Gaussian beam). It would internally use the FresnelPropagator and FraunhoferPropagator to propagate from plate to spherical and spherical to plane (via the waist of the Gaussian beam). Why do you need your proposed function? It avoids the need for internal storage of the propagators, but it complicates user code.

FYI, something related: I'd like to revert to the old way of doing the agnostic optical elements. I realize now that having the optical element be agnostic to input grid was a mistake and overcomplicates things. I'm currently using an intermediate solution myself, where the input grid and future Gaussian beam are fixed after (lazy) initialization, but optical elements should still be able to handle input wavefronts with different wavelengths. That has worked out so far, and I aim to push that after SPIE (and my holiday). It simplifies internal hcipy code, especially for the planned multi-backend support, and is almost equivalent for user code.

I wholeheartedly agree with never renaming classes. Having aliases however is always an option.

syhaffert commented 3 years ago

A child class works for me too. The planar to spherical (and vice-versa propagation) is a bit different from the Fraunhofer propagation, right? It's factor * quadratic_phase(output_grid) * Fourier Transform{ quadratic_phase(input_grid) }. The quadratic phases have to be added and the spatial frequency sampling is different? Or is the sampling equal if the propagation distance is chosen instead of the focal length?

Yeah I think the current agnostic implementation is indeed a little bit over engineered.

philhinzatucsc commented 3 years ago

Just writing to say that this would be a very nice feature enhancement for HCIpy. I use but dislike the ZEMAX Physical Optics Propagation, and was playing around with HCIpy to see whether it could provide an alternative. I am looking for something that can model the surface errors from optics, and estimate the PSF for a realistic optical system (in this case, Keck AO + SCALES). Unless I am missing something this is not possible to do (easily? at all?) since much of the propagation I will want to model is in non-collimated space.

Great tool, otherwise - by the way.