{"id":22202447,"url":"https://github.com/matthewfilipovich/torchoptics","last_synced_at":"2025-10-26T04:52:23.533Z","repository":{"id":265147320,"uuid":"895275182","full_name":"MatthewFilipovich/torchoptics","owner":"MatthewFilipovich","description":"Differentiable wave optics simulation library built on PyTorch","archived":false,"fork":false,"pushed_at":"2025-08-17T22:12:09.000Z","size":39069,"stargazers_count":74,"open_issues_count":4,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-05T07:42:33.020Z","etag":null,"topics":["computational-optics","deep-learning","differentiable-optics","diffraction","fourier-optics","holography","imaging","inverse-design","machine-learning","microscopy","optical-neural-network","optics","physics","pytorch","wave-optics"],"latest_commit_sha":null,"homepage":"https://torchoptics.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatthewFilipovich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-27T22:32:02.000Z","updated_at":"2025-09-04T14:52:12.000Z","dependencies_parsed_at":"2025-01-13T18:35:50.596Z","dependency_job_id":"98c92b39-38c0-43c1-9281-3f2bc0bb04f7","html_url":"https://github.com/MatthewFilipovich/torchoptics","commit_stats":null,"previous_names":["matthewfilipovich/torchoptics"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/MatthewFilipovich/torchoptics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewFilipovich%2Ftorchoptics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewFilipovich%2Ftorchoptics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewFilipovich%2Ftorchoptics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewFilipovich%2Ftorchoptics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatthewFilipovich","download_url":"https://codeload.github.com/MatthewFilipovich/torchoptics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewFilipovich%2Ftorchoptics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281059638,"owners_count":26437057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational-optics","deep-learning","differentiable-optics","diffraction","fourier-optics","holography","imaging","inverse-design","machine-learning","microscopy","optical-neural-network","optics","physics","pytorch","wave-optics"],"created_at":"2024-12-02T16:21:54.454Z","updated_at":"2025-10-26T04:52:23.528Z","avatar_url":"https://github.com/MatthewFilipovich.png","language":"Python","funding_links":[],"categories":["simulation"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MatthewFilipovich/torchoptics/main/docs/source/_static/torchoptics_logo.png\" width=\"700px\"\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![build](https://github.com/MatthewFilipovich/torchoptics/actions/workflows/build.yml/badge.svg)](https://github.com/MatthewFilipovich/torchoptics/actions/workflows/build.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/matthewfilipovich/torchoptics?token=52MBM273IF)](https://codecov.io/gh/MatthewFilipovich/torchoptics)\n[![Documentation Status](https://readthedocs.org/projects/torchoptics/badge/?version=latest)](https://torchoptics.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://img.shields.io/pypi/v/torchoptics.svg)](https://pypi.org/project/torchoptics/)\n[![Python Version](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/downloads/)\n[![License](https://img.shields.io/github/license/MatthewFilipovich/torchoptics?color=blue)](https://github.com/MatthewFilipovich/torchoptics/blob/main/LICENSE)\n\n\u003c/div\u003e\n\n\u003e TorchOptics is a differentiable wave optics simulation library built on PyTorch.\n\n# Key Features\n\n- 🌊 **Differentiable Wave Optics** — Model, analyze, and optimize optical systems using Fourier optics.\n- 🔥 **Built on PyTorch** — GPU acceleration, batch processing, and automatic differentiation.\n- 🛠️ **End-to-End Optimization** — Joint optimization of optical hardware and machine learning models.\n- 🔬 **Optical Elements** — Lenses, modulators, detectors, polarizers, and more.\n- 🖼️ **Spatial Profiles** — Hermite-Gaussian, Laguerre-Gaussian, Zernike modes, and others.\n- 🔆 **Polarization and Coherence** — Simulate polarized light and fields with arbitrary spatial coherence.\n\nLearn more about TorchOptics in our research paper on [arXiv](https://arxiv.org/abs/2411.18591).\n\n# Installation\n\nTorchOptics is available on [PyPI](https://pypi.org/project/torchoptics/) and can be installed with:\n\n```bash\npip install torchoptics\n```\n\n## Documentation\n\nRead the full documentation at [torchoptics.readthedocs.io](https://torchoptics.readthedocs.io/).\n\n## Usage\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MatthewFilipovich/torchoptics/blob/main/docs/source/_static/torchoptics_colab.ipynb)\n\nThis example shows how to simulate a 4f imaging system using TorchOptics, computing and visualizing the field at each focal plane along the optical axis:\n\n```python\nimport torch\nimport torchoptics\nfrom torchoptics import Field, System\nfrom torchoptics.elements import Lens\nfrom torchoptics.profiles import checkerboard\n\n# Set simulation properties\nshape = 1000  # Number of grid points in each dimension\nspacing = 10e-6  # Spacing between grid points (m)\nwavelength = 700e-9  # Field wavelength (m)\nfocal_length = 200e-3  # Lens focal length (m)\ntile_length = 400e-6  # Checkerboard tile length (m)\nnum_tiles = 15  # Number of tiles in each dimension\n\n# Determine device\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n\n# Configure default properties\ntorchoptics.set_default_spacing(spacing)\ntorchoptics.set_default_wavelength(wavelength)\n\n# Initialize input field with checkerboard pattern\nfield_data = checkerboard(shape, tile_length, num_tiles)\ninput_field = Field(field_data).to(device)\n\n# Define 4f optical system with two lenses\nsystem = System(\n    Lens(shape, focal_length, z=1 * focal_length),\n    Lens(shape, focal_length, z=3 * focal_length),\n).to(device)\n\n# Measure field at focal planes along the z-axis\nmeasurements = [\n    system.measure_at_z(input_field, z=i * focal_length)\n    for i in range(5)\n]\n\n# Visualize the measured intensity distributions\nfor i, measurement in enumerate(measurements):\n    measurement.visualize(title=f\"z={i}f\", vmax=1)\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MatthewFilipovich/torchoptics/main/docs/source/_static/4f_simulation.png\" width=\"700px\"\u003e\n  \u003cbr\u003e\n  \u003cem\u003eIntensity distributions at different focal planes in the 4f system.\u003c/em\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"300px\" src=\"https://raw.githubusercontent.com/MatthewFilipovich/torchoptics/main/docs/source/_static/4f_propagation.gif\"\u003e\n  \u003cbr\u003e\n  \u003cem\u003ePropagation of the intensity distribution.\u003c/em\u003e\n\u003c/p\u003e\n\n_For more examples and detailed usage, please refer to the [documentation](https://torchoptics.readthedocs.io/)._\n\n## Contributing\n\nWe welcome contributions! See our [Contributing Guide](https://github.com/MatthewFilipovich/torchoptics/blob/main/CONTRIBUTING.md) for details.\n\n## Citing TorchOptics\n\nIf you use TorchOptics in your research, please cite our [paper](https://arxiv.org/abs/2411.18591):\n\n```bibtex\n@misc{filipovich2024torchoptics,\n      title={TorchOptics: An open-source Python library for differentiable Fourier optics simulations},\n      author={Matthew J. Filipovich and A. I. Lvovsky},\n      year={2024},\n      eprint={2411.18591},\n      archivePrefix={arXiv},\n      primaryClass={physics.optics},\n      url={https://arxiv.org/abs/2411.18591},\n}\n```\n\n## License\n\nTorchOptics is distributed under the MIT License. See the [LICENSE](https://github.com/MatthewFilipovich/torchoptics/blob/main/LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewfilipovich%2Ftorchoptics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewfilipovich%2Ftorchoptics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewfilipovich%2Ftorchoptics/lists"}