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

Does FresnelWavefront.apply_lens_power have inaccessible if branches? #516

Open
Jordan-Dennis opened this issue Jul 21, 2022 · 1 comment

Comments

@Jordan-Dennis
Copy link

Hi all,
My question pertains to the following snippet of code from FresnelWavefront.apply_lens_power.

if not self.spherical
    if np.abs(self.z_w0 - self.z) < self.z_r:
        _log.debug('Near-field, Plane-to-Plane Propagation.')
        z_eff = 1 * optic.fl

    else:
        # find the radius of curvature of the lens output beam
        # curvatures are multiplicative exponentials
        # e^(1/z) = e^(1/x)*e^(1/y) = e^(1/x+1/y) -> 1/z = 1/x + 1/y
        # z = 1/(1/x+1/y) = xy/x+y
        z_eff = 1.0 / (1.0 / optic.fl + 1.0 / (self.z - self.z_w0))
        _log.debug('Inside Rayleigh distance to Outside Rayleigh distance.')
        self.spherical = True

else:  # spherical input wavefront
    if np.abs(self.z_w0 - self.z) > self.z_r:
        _log.debug('Spherical to Spherical wavefront propagation.')
        _log.debug("1/fl={0:0.4e}".format(1.0 / optic.fl))
        _log.debug("1.0/(R_input_beam)={0:0.4e}".format(1.0 / r_input_beam))
        _log.debug("1.0/(self.z-self.z_w0)={0:0.4e}".format(1.0 / (self.z - lf.z_w0)))

        if (self.z - self.z_w0) == 0:
            z_eff = 1.0 / (1.0 / optic.fl + 1.0 / (self.z - self.z_w0))
        else:
            z_eff = 1.0 / (1.0 / optic.fl + 1.0 / (self.z - self.z_w0) - 1.0 / r_input_beam)

    else:
        _log.debug('Spherical to Planar.')
        z_eff = 1.0 / (1.0 / optic.fl - 1.0 / r_input_beam)
        self.spherical = False

Specifically, I believe that the if (self.z - self.z_w0) == 0: in the else branch of the outer if statement is not reachable. If I have interpreted it correctly, (self.z - self.z_w0) == 0 implies that the wavefront is at the waist, where it is planar. Under this assumption the else branch of the outer if statement should not have been accessed. Furthermore, at the next level of nesting np.abs(self.z_w0 - self.z) > self.z_r is checked and since the Rayleigh distance, z_r, is a definitely positive quantity it should not be possible to satisfy both: np.abs(self.z_w0 - self.z) > self.z_r and (self.z - self.z_w0) == 0.

As a second note the (self.z - self.z_w0) == 0 is used in division, implying it is a known amount and z_eff is 0 (1 / inf). If you don't mind me asking is there an original reference for this code, I have scrolled back through Lawrence et. al. but have been unable to find any references to z_eff (I do vaguely remember it been there). If you could point me in that direction it would be greatly appreciated.

@Jordan-Dennis Jordan-Dennis changed the title Does FresnelWavefront.apply_lens_power has inaccessible if branches? Does FresnelWavefront.apply_lens_power have inaccessible if branches? Jul 21, 2022
@Jordan-Dennis
Copy link
Author

Jordan-Dennis commented Jul 21, 2022

Hello again,
Upon further review I believe that I may have spotted a second inconsistency in if the wavefront is considered spherical. The line np.abs(self.z - self.z_w0) < (or >) self.z_r seems to be used to determine if the wavefront is spherical or planar at many if statement branches. However, the top if statement of the same function uses np.abs(self.z_w0 - self.z) > self.rayleigh_factor * self.z_r considering also the rayleigh_factor (2. by default). I do not perceive the reason for this difference.

Thanks again

Jordan

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

1 participant