{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": { "papermill": { "duration": 0.00368, "end_time": "2024-06-17T18:16:27.906405", "exception": false, "start_time": "2024-06-17T18:16:27.902725", "status": "completed" }, "tags": [] }, "source": [ "# Additive Backend" ] }, { "cell_type": "markdown", "id": "1", "metadata": { "papermill": { "duration": 0.002875, "end_time": "2024-06-17T18:16:27.912564", "exception": false, "start_time": "2024-06-17T18:16:27.909689", "status": "completed" }, "tags": [] }, "source": [ "> The additive backend can be used to obtain pathlengths and group delays." ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": { "papermill": { "duration": 2.135507, "end_time": "2024-06-17T18:16:30.050872", "exception": false, "start_time": "2024-06-17T18:16:27.915365", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "from functools import partial\n", "\n", "import jax\n", "import jax.example_libraries.optimizers as opt\n", "import jax.numpy as jnp\n", "import matplotlib.pyplot as plt # plotting\n", "import sax" ] }, { "cell_type": "markdown", "id": "3", "metadata": { "papermill": { "duration": 0.00293, "end_time": "2024-06-17T18:16:30.057179", "exception": false, "start_time": "2024-06-17T18:16:30.054249", "status": "completed" }, "tags": [] }, "source": [ "## Parametrized Models" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": { "papermill": { "duration": 0.014104, "end_time": "2024-06-17T18:16:30.074216", "exception": false, "start_time": "2024-06-17T18:16:30.060112", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "def coupler(length=50.0) -> sax.SDict:\n", " sdict = {\n", " (\"in0\", \"out0\"): length,\n", " (\"in0\", \"out1\"): length,\n", " (\"in1\", \"out0\"): length,\n", " (\"in1\", \"out1\"): length,\n", " }\n", " return sax.reciprocal(sdict)" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": { "papermill": { "duration": 0.01372, "end_time": "2024-06-17T18:16:30.090825", "exception": false, "start_time": "2024-06-17T18:16:30.077105", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "def waveguide(length=100.0) -> sax.SDict:\n", " sdict = {\n", " (\"in0\", \"out0\"): length,\n", " }\n", " return sax.reciprocal(sdict)" ] }, { "cell_type": "markdown", "id": "6", "metadata": { "papermill": { "duration": 0.002852, "end_time": "2024-06-17T18:16:30.096594", "exception": false, "start_time": "2024-06-17T18:16:30.093742", "status": "completed" }, "tags": [] }, "source": [ "## Circuit with additive backend" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": { "papermill": { "duration": 0.080753, "end_time": "2024-06-17T18:16:30.180131", "exception": false, "start_time": "2024-06-17T18:16:30.099378", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "mzi, _ = sax.circuit(\n", " netlist={\n", " \"instances\": {\n", " \"lft\": coupler,\n", " \"top\": partial(waveguide, length=500),\n", " \"btm\": partial(waveguide, length=100),\n", " \"rgt\": coupler,\n", " },\n", " \"connections\": {\n", " \"lft,out0\": \"btm,in0\",\n", " \"btm,out0\": \"rgt,in0\",\n", " \"lft,out1\": \"top,in0\",\n", " \"top,out0\": \"rgt,in1\",\n", " },\n", " \"ports\": {\n", " \"in0\": \"lft,in0\",\n", " \"in1\": \"lft,in1\",\n", " \"out0\": \"rgt,out0\",\n", " \"out1\": \"rgt,out1\",\n", " },\n", " },\n", " backend=\"additive\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": { "papermill": { "duration": 0.262389, "end_time": "2024-06-17T18:16:30.445628", "exception": false, "start_time": "2024-06-17T18:16:30.183239", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "mzi()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 5 }