Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meow plugin #1015

Merged
merged 18 commits into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
216 changes: 216 additions & 0 deletions docs/notebooks/plugins/eme/01_meow.ipynb
@@ -0,0 +1,216 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# EME with MEOW\n",
"\n",
"Some components are more efficiently modeled with Eigenmode Expansion.\n",
"\n",
"Gdsfactory provides a plugin for MEOW to efficiently extract component S-parameters through EME.\n",
"\n",
"Currently the component needs to specifically have a single \"o1\" port facing west, and a single \"o2\" port facing east, like this taper:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import gdsfactory as gf\n",
"\n",
"c = gf.components.taper_cross_section_sine()\n",
"c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You also need to explicitly provide a LayerStack to define cross-sections, for instance the generic one:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layerstack = gf.tech.get_layer_stack_generic()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Since you need to make sure that your entire LayerStack has e.g. material information for all present layers, it is safer to only keep the layers that you need for your simulation:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"filtered_layerstack = gf.tech.LayerStack(\n",
" layers={\n",
" k: layerstack.layers[k]\n",
" for k in (\n",
" \"slab90\",\n",
" \"core\",\n",
" \"box\",\n",
" \"clad\",\n",
" )\n",
" }\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The EME simulator can be instantiated with only these two elements, alongside parameters:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from gdsfactory.simulation.eme.meow_simulation import MEOW_simulation\n",
"\n",
"eme = MEOW_simulation(component=c, layerstack=filtered_layerstack, wavelength=1.55)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plotting functions allow you to check your simulation:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"eme.plot_structure()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The cross-section themselves:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"eme.plot_cross_section(xs_num=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"eme.plot_cross_section(xs_num=-1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And the modes (after calculating them):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"eme.plot_mode(xs_num=0, mode_num=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"eme.plot_mode(xs_num=-1, mode_num=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The S-parameters can be calculated, and are returned in the same format as for the FDTD solvers (the original MEOW S-parameter results S and port_names are saved as attributes):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sp = eme.compute_sparameters()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sp"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(eme.port_map)\n",
"eme.plot_Sparams()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.8 ('meow_plugin')",
"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.10.8"
},
"vscode": {
"interpreter": {
"hash": "6d7223ce8465a0e0fac78de740ee4d551d77f92c9ee422f2ad1c5705fa088cac"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
3 changes: 3 additions & 0 deletions docs/plugins_mode_solver.md
Expand Up @@ -7,6 +7,8 @@ You can use 2 mode solvers:
1. MPB (open source).
2. tidy3d (open source). The tidy3d FDTD is not open source. Only the mode solver is open source.

The tidy3d mode solver is also used by the MEOW plugin to get the Sparameters of components via Eigenmode Expansion.

```{eval-rst}
.. toctree::
:maxdepth: 3
Expand All @@ -15,4 +17,5 @@ You can use 2 mode solvers:

notebooks/plugins/mpb/001_mpb_waveguide.ipynb
notebooks/plugins/tidy3d/01_tidy3d_modes.ipynb
notebooks/plugins/eme/01_meow.ipynb
```
5 changes: 5 additions & 0 deletions gdsfactory/simulation/eme/__init__.py
@@ -0,0 +1,5 @@
from gdsfactory.simulation.eme.meow_simulation import meow_calculation

__all__ = [
"meow_calculation",
]