Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
flaport committed Nov 12, 2024
1 parent ccc971c commit 4ffc9b9
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 19 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ repos:
rev: 0.6.0
hooks:
- id: nbstripout
args: ['--extra-keys="metadata.papermill"']
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
apidoc:
sphinx-apidoc ../../sax -o . -e && rm modules.rst
sphinx-apidoc -f ../../sax -o . -e && rm modules.rst
1 change: 1 addition & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ examples/05_thinfilm.ipynb
examples/06_additive_backend.ipynb
examples/07_layout_aware.ipynb
examples/08_sparse_coo.ipynb
examples/09_forward_only_backend.ipynb
```

```{toctree}
Expand Down
1 change: 1 addition & 0 deletions docs/source/sax.backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Submodules

sax.backends.additive
sax.backends.filipsson_gunnar
sax.backends.forward_only
sax.backends.klu

Module contents
Expand Down
18 changes: 18 additions & 0 deletions examples/01_quick_start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,24 @@
"The `circuit` function just creates a similar function as we created for the waveguide and the coupler, but in stead of taking parameters directly it takes parameter *dictionaries* for each of the instances in the circuit. The keys in these parameter dictionaries should correspond to the keyword arguments of each individual subcomponent. "
]
},
{
"cell_type": "markdown",
"id": "ef312bcf-4061-4467-a521-890756d701f2",
"metadata": {},
"source": [
"There is also some circuit metadata information returned as a second return value of the `sax.circuit` call:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "937c6075-c55f-4125-862c-d549ef67ff00",
"metadata": {},
"outputs": [],
"source": [
"info"
]
},
{
"cell_type": "markdown",
"id": "23",
Expand Down
2 changes: 1 addition & 1 deletion examples/02_all_pass_filter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/03_circuit_from_yaml.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/04_multimode_simulations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
24 changes: 12 additions & 12 deletions examples/05_thinfilm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@
" ymax=1,\n",
" color=\"k\",\n",
" linestyle=\"--\",\n",
" label=\"m$\\pi$/nd\",\n",
" label=r\"m$\\pi$/nd\",\n",
")\n",
"plt.xlabel(\"k = 2$\\pi$/λ [1/nm]\")\n",
"plt.xlabel(r\"k = 2$\\pi$/λ [1/nm]\")\n",
"plt.ylabel(\"Transmitted and reflected intensities\")\n",
"plt.legend(loc=\"upper right\")\n",
"plt.show()"
Expand Down Expand Up @@ -810,17 +810,17 @@
" ymax=1,\n",
" color=\"k\",\n",
" linestyle=\"--\",\n",
" label=\"m$\\pi$/nd\",\n",
" label=r\"m$\\pi$/nd\",\n",
")\n",
"plt.xlabel(\"k = 2$\\pi$/$\\lambda$ [1/nm]\")\n",
"plt.xlabel(r\"k = 2$\\pi$/$\\lambda$ [1/nm]\")\n",
"plt.ylabel(\"Power (units of input)\")\n",
"plt.legend()\n",
"plt.show()\n",
"\n",
"plt.title(f\"t={t_initial:1.3f}, d={d_gap} nm, n={n_gap}\")\n",
"plt.plot(wls * 1e3, T_analytical_initial, label=\"T\")\n",
"plt.plot(wls * 1e3, R_analytical_initial, label=\"R\")\n",
"plt.xlabel(\"$\\lambda$ (nm)\")\n",
"plt.xlabel(r\"$\\lambda$ (nm)\")\n",
"plt.ylabel(\"Power (units of input)\")\n",
"plt.legend()\n",
"plt.show()"
Expand Down Expand Up @@ -1008,7 +1008,7 @@
"plt.scatter(wls, jnp.abs(transmitted_initial) ** 2, label=\"T SAX\")\n",
"plt.plot(wls, R_analytical_initial, label=\"R theory\")\n",
"plt.scatter(wls, jnp.abs(reflected_initial) ** 2, label=\"R SAX\")\n",
"plt.xlabel(\"k = 2$\\pi$/$\\lambda$ [1/nm]\")\n",
"plt.xlabel(r\"k = 2$\\pi$/$\\lambda$ [1/nm]\")\n",
"plt.ylabel(\"Power (units of input)\")\n",
"plt.figlegend(framealpha=1.0)\n",
"plt.show()"
Expand Down Expand Up @@ -1242,7 +1242,7 @@
},
"outputs": [],
"source": [
"optim_init, optim_update, optim_params = opt.adam(step_size=0.001)\n",
"optim_init, optim_update, optim_params = opt.adam(step_size=0.01)\n",
"\n",
"\n",
"def train_step(step, optim_state):\n",
Expand All @@ -1269,7 +1269,7 @@
},
"outputs": [],
"source": [
"range_ = tqdm.trange(2000)\n",
"range_ = tqdm.trange(200)\n",
"\n",
"optim_state = optim_init(ts_initial)\n",
"for step in range_:\n",
Expand Down Expand Up @@ -1315,15 +1315,15 @@
"plt.scatter(wls * 1e3, ts_initial[:N], label=\"t initial\")\n",
"plt.scatter(wls * 1e3, ts_optimal[:N], label=\"t optimal\")\n",
"plt.xlabel(\"λ [nm]\")\n",
"plt.ylabel(\"|t| $(\\lambda)$\")\n",
"plt.ylabel(r\"|t| $(\\lambda)$\")\n",
"plt.legend(loc=\"best\")\n",
"plt.title(f\"d={d_gap} nm, n={n_gap}\")\n",
"plt.show()\n",
"\n",
"plt.scatter(wls * 1e3, ts_initial[N:], label=\"t initial\")\n",
"plt.scatter(wls * 1e3, ts_optimal[N:], label=\"t optimal\")\n",
"plt.xlabel(\"λ [nm]\")\n",
"plt.ylabel(\"angle $t (\\lambda)$ (rad)\")\n",
"plt.ylabel(r\"angle $t (\\lambda)$ (rad)\")\n",
"plt.legend(loc=\"best\")\n",
"plt.title(f\"d={d_gap} nm, n={n_gap}\")\n",
"plt.show()"
Expand Down Expand Up @@ -1398,7 +1398,7 @@
"plt.xlabel(\"λ [nm]\")\n",
"plt.ylabel(\"Transmitted and reflected intensities\")\n",
"plt.legend(loc=\"upper right\")\n",
"plt.title(f\"Optimized t($\\lambda$), d={d_gap} nm, n={n_gap}\")\n",
"plt.title(r\"Optimized t($\\lambda$), \" + f\"d={d_gap} nm, n={n_gap}\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -1438,7 +1438,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/06_additive_backend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/08_sparse_coo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
17 changes: 17 additions & 0 deletions examples/09_forward_only_backend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@
"> An efficient backend when the components in circuit have low back-reflection. In this case, only forward-direction matrix multiplication is calculated to reduce computational cost for complicated circuit. The improvement compared to other backends ('klu' for example) is demonstrated with an example of cascaded AMZI structure."
]
},
{
"cell_type": "markdown",
"id": "9892c1c9",
"metadata": {
"papermill": {
"duration": 0.057769,
"end_time": "2024-06-17T18:16:29.603571",
"exception": false,
"start_time": "2024-06-17T18:16:29.545802",
"status": "completed"
},
"tags": []
},
"source": [
"> This notebook as well as the forward-only backend itself was contributed by [zhetaoj](https://github.com/zhetaoj)."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 4ffc9b9

Please sign in to comment.