Code Monkey home page Code Monkey logo

accelerator-control's Introduction

Accelerator Control

This 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.

For more information, see the accomanying paper here. The arxiv preprint is here and included as a pdf.

Installation / Usage

To use, simply clone this directory and import the DLA_Control/ package into your project.

See examples/ for more details on how to do this.

Code Structure:

The code is organized as follows

DLA_Control/
    alorithms.py
    mesh.py
    plots.py
    util.py
examples/
    Fig4.py
    Fig5.py
    Fig6.py
    mesh_demo.py
    optimize_demo.py
    phase_fun.py
tests/
    test_coupling.py
    test_mesh.py
    test_MZI.py

Package

The main package is contained in DLA_Control.

Meshes

In mesh.pyyou will find Mesh objects that define the MZI mesh and contain all of the relevant transfer matrices. Currently, Triangular and Clements meshes are supported. Printing these Mesh objects prints an ASCII representation of the mesh.

To make a Clements mesh with N ports and M layers and random phase shifter initialization:

mesh = Mesh(N, mesh_type='clements', initialization='random', M=M)
print(mesh)

To make a Triangular mesh with N ports and phase shifter initialized with all zeros (transmission):

mesh = Mesh(N, mesh_type='triangular', initialization='zeros')
print(mesh)

To couple light into the mesh and view the power through the device

input_values = np.random.random((N,))
mesh.input_couple(input_values)
im = plot_powers(mesh)
plt.show()

which will generate a plot like this

For an example see examples/mesh_demo.py or the methods of Mesh as defined in DLA_Control/mesh.py

Optimizers

For 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.

These can be initialized with the input and target (complex-valued) mode amplitudes as

TO = TriangleOptimizer(mesh, input_values=input_values, output_target=output_target)
CO = ClementsOptimizer(mesh, input_values=input_values, output_target=output_target)

Then, one can call the optimize() method on these optimizers with an algorithm to do the tuning. For example:

CO.optimize(algorithm='smart', verbose=False)

Triangular Optimizers contain up_down and spread algorithms. Here's a before and after:

Clements Optimizers contain smart, smart_seq (which is the one from the paper), and basic algorithms.

Read more about these in DLA_Control/algorithms.py or see examples/optmize_demo.py for more examples.

Plotting

plots.py defines a few plotting functions.

To plot the progression of power within the device:

im = plot_powers(mesh, ax=None)

To make a 3D bar plot of the same image (note, not beautified)

plot_bar_3d(power_map, ax=None)

Other

utils.py contains helper functions for normalizing vectors and getting powers from complex mode amplitudes.

Examples

As explained previously, the examples/ directory contains several examples of this package in use.

Fig{4,5,6}.py generate the figures in the paper, so you can see how these calculations were performed.

Tests

Tests cover the individual MZIs up to the full meshes and the optimization protocols.

To test the individual MZI construction:

python test_MZI.py

To test the Layer and Mesh objects:

python test_mesh.py

To test the optimizers

python test_coupling.py

To run all tests:

python -m unittest discover tests

This can take several minutes.

Contributing

This 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.

Things that would be nice to integrate:

  • Incorporate this code with an actual MZI mesh for controlling an experimental demo.
  • Simulating effects of noise, drift, fabrication errors, etc.
  • Implementing damage / nonlinear constraints. Fancy algorithms for even power distribution within the mesh itself.

Citing

If you use this package, please cite us as

@article{PhysRevApplied.11.064014,
  title = {Reconfigurable Photonic Circuit for Controlled Power Delivery to Laser-Driven Accelerators on a Chip},
  author = {Hughes, Tyler W. and England, R. Joel and Fan, Shanhui},
  journal = {Phys. Rev. Applied},
  volume = {11},
  issue = {6},
  pages = {064014},
  numpages = {10},
  year = {2019},
  month = {Jun},
  publisher = {American Physical Society},
  doi = {10.1103/PhysRevApplied.11.064014},
  url = {https://link.aps.org/doi/10.1103/PhysRevApplied.11.064014}
}

License

This project is licensed under the MIT License - see the LICENSE.md file for details. Copyright 2018 Tyler Hughes.

accelerator-control's People

Contributors

twhughes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.