# pygrin.pygrin Module

Gradient Index lens calculations and plots.

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)
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)
```

## Functions

 `ABCD`(n_0, pitch, length, z) ABCD matrix for meridonal ray propagation. `BFL`(n_0, pitch, length) Back focal length of a grin lens. `EFL`(n_0, pitch, length) Effective focal length of a grin lens. `FFL`(n_0, pitch, length) Front focal length of a grin lens. `NA`(n_0, pitch, length, diameter) Numerical aperture of a grin lens in air. `cardinal_points`(n_0, pitch, length[, offset]) Cardinal points of a grin lens relative to first surface. `full_meridional_curve`(n_0, pitch, length, ...) Points on a path from an object to image through a GRIN lens. `gradient`(pitch, length) Gradient of a grin lens based on its pitch and length. `hyperbolic_secant_profile_index`(n_0, alpha, r) Index of a hyperbolic secant grin lens at a particular radius. `image_distance`(n_0, pitch, length, s) Image distance for an object. `image_mag`(n_0, pitch, length, s) Transverse magnification of an object located at s. `max_angle`(n_0, pitch, length, diameter) Maximum acceptance angle of a grin lens in air. `meridional_curve`(n_0, pitch, length, r_i, ...) Points on path of a ray passing through a grin lens. `parabolic_profile_index`(n_0, pitch, length, r) Index of a parabolic grin lens at a particular radius. `period`(grad, length) Period or pitch of a grin lens based on its gradient and length. `plot_principal_planes`(n_0, pitch, length, ...) Create a plot for a grin lens showing the cardinal points.