Skip to content

Commit ff9f8f7

Browse files
committed
sweep
1 parent b033e76 commit ff9f8f7

2 files changed

Lines changed: 34 additions & 86 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The documentation is available at
3434
## Contributors
3535

3636
- [@flaport](https://github.com/flaport): creator of MEOW
37-
- [@jan-david-black](https://github.com/jan-david-black): fixing mode overlaps and more
37+
- [@jan-david-fischbach](https://github.com/jan-david-fischbach): fixing mode overlaps and more
3838

3939
## Credits
4040

notebooks/02_taper_length_sweep.ipynb

Lines changed: 33 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@
8282
" )\n",
8383
"\n",
8484
" structures = [oxide, core]\n",
85-
" return structures"
85+
" return structures\n",
86+
"\n",
87+
"\n",
88+
"structures = create_structures()"
8689
]
8790
},
8891
{
@@ -92,7 +95,7 @@
9295
"metadata": {},
9396
"outputs": [],
9497
"source": [
95-
"mw.visualize(create_structures())"
98+
"mw.visualize(structures)"
9699
]
97100
},
98101
{
@@ -110,37 +113,22 @@
110113
"metadata": {},
111114
"outputs": [],
112115
"source": [
113-
"def create_cells(length, cell_length):\n",
114-
" num_cells = round(length / cell_length)\n",
115-
" structures = create_structures(length=length)\n",
116-
" cells = mw.create_cells(\n",
117-
" structures=structures,\n",
118-
" mesh=mw.Mesh2D(\n",
119-
" x=np.linspace(-2, 2, 101),\n",
120-
" y=np.linspace(-2, 2, 101),\n",
121-
" # specify possible conformal mesh specifications here:\n",
122-
" # bend_radius=2.0,\n",
123-
" # bend_axis=1,\n",
124-
" ),\n",
125-
" Ls=np.array([length / num_cells for _ in range(num_cells)]),\n",
126-
" )\n",
127-
" return cells"
128-
]
129-
},
130-
{
131-
"cell_type": "code",
132-
"execution_count": null,
133-
"id": "9",
134-
"metadata": {},
135-
"outputs": [],
136-
"source": [
137-
"cells = create_cells(10, 1)\n",
116+
"num_cells = 20\n",
117+
"\n",
118+
"cells = mw.create_cells(\n",
119+
" structures=structures,\n",
120+
" mesh=mw.Mesh2D(\n",
121+
" x=np.linspace(-2, 2, 101),\n",
122+
" y=np.linspace(-2, 2, 101),\n",
123+
" ),\n",
124+
" Ls=np.array([10.0 / num_cells] * num_cells),\n",
125+
")\n",
138126
"mw.visualize(cells[-1])"
139127
]
140128
},
141129
{
142130
"cell_type": "markdown",
143-
"id": "10",
131+
"id": "9",
144132
"metadata": {},
145133
"source": [
146134
"### 3. Cross Sections\n"
@@ -149,31 +137,18 @@
149137
{
150138
"cell_type": "code",
151139
"execution_count": null,
152-
"id": "11",
153-
"metadata": {},
154-
"outputs": [],
155-
"source": [
156-
"def create_cross_sections(length, cell_length, wl=1.55, T=25.0):\n",
157-
" cells = create_cells(length=length, cell_length=cell_length)\n",
158-
" env = mw.Environment(wl=1.55, T=25.0)\n",
159-
" css = [mw.CrossSection.from_cell(cell=cell, env=env) for cell in cells]\n",
160-
" return css"
161-
]
162-
},
163-
{
164-
"cell_type": "code",
165-
"execution_count": null,
166-
"id": "12",
140+
"id": "10",
167141
"metadata": {},
168142
"outputs": [],
169143
"source": [
170-
"css = create_cross_sections(10, 1)\n",
144+
"env = mw.Environment(wl=1.55, T=25.0)\n",
145+
"css = [mw.CrossSection.from_cell(cell=cell, env=env) for cell in cells]\n",
171146
"mw.visualize(css[0])"
172147
]
173148
},
174149
{
175150
"cell_type": "markdown",
176-
"id": "13",
151+
"id": "11",
177152
"metadata": {},
178153
"source": [
179154
"### 4. Find Modes (FDE)"
@@ -182,22 +157,18 @@
182157
{
183158
"cell_type": "code",
184159
"execution_count": null,
185-
"id": "14",
160+
"id": "12",
186161
"metadata": {},
187162
"outputs": [],
188163
"source": [
189-
"def find_modes(length, cell_length, num_modes, wl=1.55, T=25.0):\n",
190-
" css = create_cross_sections(length=length, cell_length=cell_length, wl=wl, T=T)\n",
191-
" modes: list[list[mw.Mode]] = []\n",
192-
" for cs in tqdm(css):\n",
193-
" modes_in_cs = mw.compute_modes(cs, num_modes=num_modes)\n",
194-
" modes.append(modes_in_cs)\n",
195-
" return modes"
164+
"num_modes = 20\n",
165+
"\n",
166+
"modes = [mw.compute_modes(cs, num_modes=num_modes) for cs in tqdm(css)]"
196167
]
197168
},
198169
{
199170
"cell_type": "markdown",
200-
"id": "15",
171+
"id": "13",
201172
"metadata": {},
202173
"source": [
203174
"### 5. Calculate S-matrix (EME)"
@@ -206,40 +177,17 @@
206177
{
207178
"cell_type": "code",
208179
"execution_count": null,
209-
"id": "16",
210-
"metadata": {},
211-
"outputs": [],
212-
"source": [
213-
"def find_s_matrix(length, cell_length, num_modes, wl=1.55, T=25.0):\n",
214-
" modes = find_modes(\n",
215-
" length=length, cell_length=cell_length, wl=wl, T=T, num_modes=num_modes\n",
216-
" )\n",
217-
" S, port_map = mw.compute_s_matrix(modes, cell_lengths=[cell_length for _ in modes])\n",
218-
" return S, port_map"
219-
]
220-
},
221-
{
222-
"cell_type": "code",
223-
"execution_count": null,
224-
"id": "17",
225-
"metadata": {},
226-
"outputs": [],
227-
"source": [
228-
"num_modes = 20\n",
229-
"cell_length = 0.5\n",
230-
"S1, pm1 = find_s_matrix(10.0, cell_length, num_modes)\n",
231-
"S2, pm2 = find_s_matrix(5.0, cell_length, num_modes)"
232-
]
233-
},
234-
{
235-
"cell_type": "code",
236-
"execution_count": null,
237-
"id": "18",
180+
"id": "14",
238181
"metadata": {},
239182
"outputs": [],
240183
"source": [
241-
"print(f\"long taper transmission: {abs(S1[0, num_modes]) ** 2}\")\n",
242-
"print(f\"short taper transmission: {abs(S2[0, num_modes]) ** 2}\")"
184+
"taper_lengths = [5.0, 10.0, 15.0, 20.0]\n",
185+
"\n",
186+
"for length in taper_lengths:\n",
187+
" cell_lengths = [length / num_cells] * num_cells\n",
188+
" S, pm = mw.compute_s_matrix(modes, cell_lengths=cell_lengths)\n",
189+
" T_00 = abs(S[0, num_modes]) ** 2\n",
190+
" print(f\"taper length {length:5.1f} | transmission: {T_00:.6f}\")"
243191
]
244192
}
245193
],

0 commit comments

Comments
 (0)