Skip to content

scottprahl/pygrin

Repository files navigation

pygrin

A basic collection of routines to ray trace through graded index (GRIN) lenses with a parabolic radial profile.

pypi github conda doi

License Testing Docs Downloads

Try Online

full pitch lens

Example

Properties of a 0.25 pitch GRIN lens from an ancient Melles Griot Catalog:

import pygrin
n = 1.608
gradient = 0.339
length = 5.37
diameter = 1.8

pitch = pygrin.period(gradient, length)
ffl = pygrin.FFL(n,pitch,length)
efl = pygrin.EFL(n,pitch,length)
na = pygrin.NA(n,pitch,length,diameter)

angle = pygrin.max_angle(n,pitch,length,diameter)
print('expected pitch = 0.29,            calculated %.2f' % pitch)
print('expected FFL = 0.46 mm,           calculated %.2f' % ffl)
print('expected NA = 0.46,               calculated %.2f' % na)
print('expected full accept angle = 55°, calculated %.0f°' % (2*angle*180/np.pi))
print('working distance = %.2f mm'%(efl-ffl))

Produces:

expected pitch = 0.29,            calculated 0.29
expected FFL = 0.46,              calculated 0.47
expected NA = 0.46,               calculated 0.46
expected full accept angle = 55°, calculated 55°
working distance = 1.43 mm

But the real utility of this module is creating plots that show the path of rays through a GRIN lens. For examples, see <https://pygrin.readthedocs.io>

Installation

Use pip:

pip install pygrin

or conda:

conda install -c conda-forge pygrin

or use immediately in your browser via the JupyterLite button below

Try Online

Citation

If you use pygrin in academic or technical work, please cite:

Prahl, S. (2025). pygrin: A Python module for ray tracing through gradient-index (GRIN) lenses (Version 0.6.0) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.8370821

BibTeX

@software{pygrin_prahl_2025,
  author    = {Scott Prahl},
  title     = {pygrin: A Python module for ray tracing through gradient-index (GRIN) lenses},
  year      = {2025},
  version   = {0.6.0},
  doi       = {10.5281/zenodo.8370821},
  url       = {https://github.com/scottprahl/pygrin},
  publisher = {Zenodo}
}

License

pygrin is licensed under the terms of the MIT license.

About

A python module to ray trace through gradient index (GRIN) lenses.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •