API for pygrin package

Submodules

pygrin.pygrin module

Gradient Index lens calculations and plots.

More documentation at <https://pygrin.readthedocs.io>

Typical usage:

import pygin

length = 7               # mm
diameter = 2             # mm
r = np.linspace(-1,1,11) # mm
n_0 = 1.48               # refractive index at r=0
theta_i = 0              # launch angle
pitch = 0.25             # quarter pitch lens

pygrin.plot_principal_planes(n_0, pitch, length, diameter)
for r_i in r:
    z,r = pygrin.meridional_curve(n_0, pitch, length, r_i, theta_i)
    plt.plot(z,r,color='blue')
plt.show()

Functions to locate focal points and cardinal points:

BFL(n_0, pitch, length)
EFL(n_0, pitch, length)
FFL(n_0, pitch, length)
NA(n_0, pitch, length, diameter)
cardinal_points(n_0, pitch, length)

Functions to find properties of GRIN lens:

gradient(pitch, length)
period(grad, length)
max_angle(n_0, pitch, length, diameter)
ABCD(n_0, pitch, length, z)
image_distance(n_0, pitch, length, s)
image_mag(n_0, pitch, length, s)

Functions to determine refractive index profile:

hyperbolic_secant_profile_index(n_0, alpha, r)
parabolic_profile_index(n_0, pitch, length, r)

Functions to help raytrace through GRIN lens:

full_meridional_curve(n_0, pitch, length, z_obj, r_obj, r_lens)
meridional_curve(n_0, pitch, length, r_i, theta_i)
plot_principal_planes(n_0, pitch, length, diameter)
pygrin.pygrin.ABCD(n_0, pitch, length, z)[source]

ABCD matrix for meridonal ray propagation.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • z – distance within lens from front surface [mm]
Returns:

float – the ABCD matrix for meridonal ray propagation [radians]

pygrin.pygrin.BFL(n_0, pitch, length)[source]

Back focal length of a grin lens.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
Returns:

float – the back focal length of the grin lens [mm]

pygrin.pygrin.EFL(n_0, pitch, length)[source]

Effective focal length of a grin lens.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
Returns:

float – the effective focal length of the grin lens [mm]

pygrin.pygrin.FFL(n_0, pitch, length)[source]

Front focal length of a grin lens.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
Returns:

float – the front focal length of the grin lens [mm]

pygrin.pygrin.NA(n_0, pitch, length, diameter)[source]

Numerical aperture of a grin lens in air.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • diameter – diameter of the lens [mm]
Returns:

float – the numerical aperture of the grin lens in air [unitless]

pygrin.pygrin.cardinal_points(n_0, pitch, length, offset=0)[source]

Cardinal points of a grin lens relative to first surface.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • offset – float (optional) origin relative to first lens surface
Returns:

float – location of the front focal point [mm] float: location of the first lens surface [mm] float: location of the first principal plane [mm] float: location of the second principal plane [mm] float: location of the second lens surface [mm] float: location of the back focal point [mm]

pygrin.pygrin.full_meridional_curve(n_0, pitch, length, z_obj, r_obj, r_lens, npoints=40)[source]

Points on a path from an object to image through a GRIN lens.

The light ray starts at (z_obj,r_obj) and hits the front surface of the front face of the GRIN lens at (0,r_lens).

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • z_obj – axial position of the object [mm]
  • r_obj – radius at which the ray leaves the object [mm]
  • r_lens – radius at which the ray hits the lens [mm]
  • npoints – integer (optional) number of points in the returned curve
Returns:

z

array

axial points along path from object to image [mm]

r: array

radial points along path from object to image [mm]

pygrin.pygrin.gradient(pitch, length)[source]

Gradient of a grin lens based on its pitch and length.

Parameters:
  • pitch – pitch or period of the lens [unitless]
  • length – length of grin lens [mm]
Returns:

float – the gradient characterizing the index of refraction profile [1/mm]

pygrin.pygrin.hyperbolic_secant_profile_index(n_0, alpha, r)[source]

Index of a hyperbolic secant grin lens at a particular radius.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • alpha – parameter (like gradient for parabolic lens) [1/mm]
  • r – distance from center of lens [mm]
Returns:

float – the index of a parabolic grin lens at r [unitless]

pygrin.pygrin.image_distance(n_0, pitch, length, s)[source]

Image distance for an object.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • s – distance from front of lens to object [mm]
Returns:

float – the image distance from the back of the lens [mm]

pygrin.pygrin.image_mag(n_0, pitch, length, s)[source]

Transverse magnification of an object located at s.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • s – distance from front of lens to object [mm]
Returns:

float – the transvers magnification [unitless]

pygrin.pygrin.max_angle(n_0, pitch, length, diameter)[source]

Maximum acceptance angle of a grin lens in air.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • diameter – diameter of the lens [mm]
Returns:

float – the maximum acceptance angle of the lens in air [radians]

pygrin.pygrin.meridional_curve(n_0, pitch, length, r_i, theta_i, npoints=40)[source]

Points on path of a ray passing through a grin lens.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • r_i – radial distance that ray hits grin lens [mm]
  • theta_i – angle of incidence [radians]
  • npoints – integer number of points in the returned curve
Returns:

z

array

axial points along the curve inside the grin lens [mm]

r: array

radial points along the curve inside the grin lens [mm]

pygrin.pygrin.parabolic_profile_index(n_0, pitch, length, r)[source]

Index of a parabolic grin lens at a particular radius.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • r – distance from center of lens [mm]
Returns:

float – the index of a parabolic grin lens at r [unitless]

pygrin.pygrin.period(grad, length)[source]

Period or pitch of a grin lens based on its gradient and length.

Parameters:
  • grad – geometric gradient of the lens [1/mm]
  • length – length of grin lens [mm]
Returns:

float – the pitch or period of the grin lens [unitless]

pygrin.pygrin.plot_principal_planes(n_0, pitch, length, diameter)[source]

Create a plot for a grin lens showing the cardinal points.

Parameters:
  • n_0 – index of refraction at center of grin lens [unitless]
  • pitch – pitch or period of the lens [unitless]
  • length – axial length of the lens [mm]
  • diameter – diameter of the lens [mm]