{"id":24440050,"url":"https://github.com/twhughes/accelerator-control","last_synced_at":"2026-04-23T12:31:40.823Z","repository":{"id":81457524,"uuid":"152790380","full_name":"twhughes/Accelerator-Control","owner":"twhughes","description":":boom: Algorithms on a mesh of optical interferometers for control of laser-driven accelerators on a chip","archived":false,"fork":false,"pushed_at":"2019-06-11T20:49:37.000Z","size":8843,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T01:12:35.183Z","etag":null,"topics":["accelerator","interferometric-processing","optics","optimization"],"latest_commit_sha":null,"homepage":"https://journals.aps.org/prapplied/abstract/10.1103/PhysRevApplied.11.064014","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/twhughes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-12T18:09:57.000Z","updated_at":"2024-08-28T16:31:18.000Z","dependencies_parsed_at":"2023-05-31T01:45:35.448Z","dependency_job_id":null,"html_url":"https://github.com/twhughes/Accelerator-Control","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/twhughes/Accelerator-Control","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhughes%2FAccelerator-Control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhughes%2FAccelerator-Control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhughes%2FAccelerator-Control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhughes%2FAccelerator-Control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twhughes","download_url":"https://codeload.github.com/twhughes/Accelerator-Control/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twhughes%2FAccelerator-Control/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32181365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-23T11:42:27.955Z","status":"ssl_error","status_checked_at":"2026-04-23T11:42:18.877Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["accelerator","interferometric-processing","optics","optimization"],"created_at":"2025-01-20T20:27:57.903Z","updated_at":"2026-04-23T12:31:40.807Z","avatar_url":"https://github.com/twhughes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Accelerator Control\n\nThis code simulates a mesh of inteferometers that are used to couple power from an array of optical waveguides to an accelerator on a chip.  It provides mechanisms for simulating and controlling these interferometers using various protocols and algorithms.\n\nFor more information, see the accomanying paper [here](https://journals.aps.org/prapplied/abstract/10.1103/PhysRevApplied.11.064014). The arxiv preprint is [here](https://arxiv.org/abs/1902.09731) and included [as a pdf](./preprint.pdf).\n\n## Installation / Usage\n\nTo use, simply clone this directory and import the `DLA_Control/` package into your project.  \n\nSee `examples/` for more details on how to do this.\n\n## Code Structure:\nThe code is organized as follows\n\n    DLA_Control/\n        alorithms.py\n        mesh.py\n        plots.py\n        util.py\n    examples/\n        Fig4.py\n        Fig5.py\n        Fig6.py\n        mesh_demo.py\n        optimize_demo.py\n        phase_fun.py\n    tests/\n        test_coupling.py\n        test_mesh.py\n        test_MZI.py\n\n### Package\nThe main package is contained in `DLA_Control`.\n\n#### Meshes\nIn `mesh.py`you will find `Mesh` objects that define the MZI mesh and contain all of the relevant transfer matrices.\nCurrently, `Triangular` and `Clements` meshes are supported.  Printing these Mesh objects prints an ASCII representation of the mesh.\n\n![](img/ASCII.png)\n\nTo make a Clements mesh with N ports and M layers and random phase shifter initialization:\n    \n```python\nmesh = Mesh(N, mesh_type='clements', initialization='random', M=M)\nprint(mesh)\n```\n    \nTo make a Triangular mesh with N ports and phase shifter initialized with all zeros (transmission):\n\n```python\nmesh = Mesh(N, mesh_type='triangular', initialization='zeros')\nprint(mesh)\n```\n\nTo couple light into the mesh and view the power through the device\n    \n```python\ninput_values = np.random.random((N,))\nmesh.input_couple(input_values)\nim = plot_powers(mesh)\nplt.show()\n```\n\nwhich will generate a plot like this\n\n![](img/pow_spread.png)\n\nFor an example see `examples/mesh_demo.py` or the methods of `Mesh` as defined in `DLA_Control/mesh.py`\n\n#### Optimizers\n\nFor each `Clements` and `Triangular` meshes, there is an optimizer class that operates on the mesh, changing its MZI phase shifter settings to optimize for a given input-output relation.\n\nThese can be initialized with the input and target (complex-valued) mode amplitudes as\n\n```python\nTO = TriangleOptimizer(mesh, input_values=input_values, output_target=output_target)\nCO = ClementsOptimizer(mesh, input_values=input_values, output_target=output_target)\n```\n\nThen, one can call the `optimize()` method on these optimizers with an algorithm to do the tuning.  For example:\n\n```python\nCO.optimize(algorithm='smart', verbose=False)\n```   \n\nTriangular Optimizers contain `up_down` and `spread` algorithms.  Here's a before and after:\n\n![](img/traingular.png)\n\nClements Optimizers contain `smart`, `smart_seq` (which is the one from the paper), and `basic` algorithms.\n\n![](img/clements.png)\n\nRead more about these in `DLA_Control/algorithms.py` or see `examples/optmize_demo.py` for more examples.\n\n#### Plotting\n\n`plots.py` defines a few plotting functions.\n\nTo plot the progression of power within the device:\n\n```python\nim = plot_powers(mesh, ax=None)\n```\n\nTo make a 3D bar plot of the same image (note, not beautified)\n\n```python\nplot_bar_3d(power_map, ax=None)\n```\n\n#### Other\n\n`utils.py` contains helper functions for normalizing vectors and getting powers from complex mode amplitudes.\n\n\n### Examples\n\nAs explained previously, the `examples/` directory contains several examples of this package in use.\n\n`Fig{4,5,6}.py` generate the figures in the paper, so you can see how these calculations were performed.\n\n\n### Tests\n\nTests cover the individual MZIs up to the full meshes and the optimization protocols.  \n\nTo test the individual MZI construction:\n\n```python\npython test_MZI.py\n```\n\nTo test the `Layer` and `Mesh` objects:\n\n```python\npython test_mesh.py\n```\n\nTo test the optimizers\n\n```python\npython test_coupling.py\n```\n\nTo run all tests:\n\n```python\npython -m unittest discover tests\n```\n\nThis can take several minutes.\n\n\n## Contributing\n\nThis code is continuously developing and I am open to collaboration.  If you have any ideas for new features, or find any bugs, please make an issue or submit a pull request. \n\nThings that would be nice to integrate:\n\n-  Incorporate this code with an actual MZI mesh for controlling an experimental demo.\n-  Simulating effects of noise, drift, fabrication errors, etc.\n-  Implementing damage / nonlinear constraints.  Fancy algorithms for even power distribution *within* the mesh itself.\n\n## Citing\n\nIf you use this package, please cite us as\n\n    @article{PhysRevApplied.11.064014,\n      title = {Reconfigurable Photonic Circuit for Controlled Power Delivery to Laser-Driven Accelerators on a Chip},\n      author = {Hughes, Tyler W. and England, R. Joel and Fan, Shanhui},\n      journal = {Phys. Rev. Applied},\n      volume = {11},\n      issue = {6},\n      pages = {064014},\n      numpages = {10},\n      year = {2019},\n      month = {Jun},\n      publisher = {American Physical Society},\n      doi = {10.1103/PhysRevApplied.11.064014},\n      url = {https://link.aps.org/doi/10.1103/PhysRevApplied.11.064014}\n    }\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. Copyright 2018 Tyler Hughes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwhughes%2Faccelerator-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwhughes%2Faccelerator-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwhughes%2Faccelerator-control/lists"}