Replace tabulated Gaussian quadrature with rule#522
Replace tabulated Gaussian quadrature with rule#522rjmoerland wants to merge 6 commits intomasterfrom
Conversation
|
Thanks for adding this, @rjmoerland! I recognize the need to move away from a direct lookup here. Using your numbering:
What do you think? I'd say you can update the OPD difference function to make it mathematically consistent, then update the corresponding unit tests. Thanks, |
|
Hi @HarrisonKramer , thank you for the explanations. Keeping the numbering, but swapping them around a little:
I'll gladly update the |
|
Hi @rjmoerland, Same numbering:
AFAIK, there's no standard model used here. A Gaussian quadrature with G. W. Forbes, "Optical system assessment for design: numerical ray tracing in the Gaussian pupil," J. Opt. Soc. Am. A, Vol. 5, No. 11, pp. 1943-1956 (November 1988). |
Cool, agreed.
Agreed. I'll check what I can do. I'm thinking along the lines of extra switches like
My apologies for going completely off track here, but: I think the statement in the cited paper is possibly a mistake, or somewhat misleading. Indeed, Gaussian quadrature with I think I can provide and example of the above by doing the numerical integration. The analytical result for the integral of On the other hand, if you know that the function is circularly symmetric, then instead of approximating the 2D integral, it is more efficient to evaluate Anyway, this is as far as I'll bore you, but I think it's useful to establish what the 2D Gaussian quadrature can do and what it cannot do. Then, more on topic: I have implemented a few pytest to check for the accuracy of the numerical integration, but what I meant to ask is: are there any models for the Optical Path Difference that are typically used in geometrical optics? Something like the analytical result for the Optical Path Difference when a collimated beam is focused by a plano-convex lens for example? Anything that is non-trivial, but has an analytical solution would be perfect for this. Thanks! |
|
Just in case you might have missed it on Discord: I've been looking at that OPD function for this PR, but I cannot figure out what the correct value should be for the failing pytest (OPD of Hubble telescope). I also couldn't really match OPD values to a toy model I made for a plano-convex lens, so I must be misunderstanding something here. Is this something we can discuss? |
Rationale
Gaussian quadrature is an efficient scheme for numerical integration. The current GaussianQuadrature distribution in Optiland, for integration over the unit disk, uses tabulated numbers for orders 1 to 6. Higher order integration is therefore limited to other distribution types, that may be suboptimal, such as uniform or random sampling.
This PR implements a new GaussianQuadrature class, a subclass of BaseDistribution, where the number of rings and spokes can be adjusted at will. The correct locations are calculated on the fly, together with the integration weights.
Implementation
The implementation is based on the paper by William H. Peirce, "Numerical Integration Over the Planar Annulus,", Journal of the Society for Industrial and Applied Mathematics, Vol. 5, No. 2 (Jun., 1957), pp. 66-73.
I believe it is a drop-in replacement for many cases, but I still have open questions about the weights:
is_symmetricisFalseand 3.0 ifis_symmetricisTrue. Why the difference?is_symmetricand the implementation seem to differ - according to the text,is_symmetricis to indicate symmetry in y, but activating it seems to indicate that the distribution is circularly symmetric. Not activating it seems to imply mirror symmetry in x. Is this correct, and should it be maintained?ray.py, whenHx == Hy == 0. I tried to maintain the functionality ofOPD_difference, but I will need a little help because I don't understand the weights 😶As a consequence of my lack of understanding of these details, there are a few pytests failing.