|
82 | 82 | " )\n", |
83 | 83 | "\n", |
84 | 84 | " structures = [oxide, core]\n", |
85 | | - " return structures" |
| 85 | + " return structures\n", |
| 86 | + "\n", |
| 87 | + "\n", |
| 88 | + "structures = create_structures()" |
86 | 89 | ] |
87 | 90 | }, |
88 | 91 | { |
|
92 | 95 | "metadata": {}, |
93 | 96 | "outputs": [], |
94 | 97 | "source": [ |
95 | | - "mw.visualize(create_structures())" |
| 98 | + "mw.visualize(structures)" |
96 | 99 | ] |
97 | 100 | }, |
98 | 101 | { |
|
110 | 113 | "metadata": {}, |
111 | 114 | "outputs": [], |
112 | 115 | "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", |
138 | 126 | "mw.visualize(cells[-1])" |
139 | 127 | ] |
140 | 128 | }, |
141 | 129 | { |
142 | 130 | "cell_type": "markdown", |
143 | | - "id": "10", |
| 131 | + "id": "9", |
144 | 132 | "metadata": {}, |
145 | 133 | "source": [ |
146 | 134 | "### 3. Cross Sections\n" |
|
149 | 137 | { |
150 | 138 | "cell_type": "code", |
151 | 139 | "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", |
167 | 141 | "metadata": {}, |
168 | 142 | "outputs": [], |
169 | 143 | "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", |
171 | 146 | "mw.visualize(css[0])" |
172 | 147 | ] |
173 | 148 | }, |
174 | 149 | { |
175 | 150 | "cell_type": "markdown", |
176 | | - "id": "13", |
| 151 | + "id": "11", |
177 | 152 | "metadata": {}, |
178 | 153 | "source": [ |
179 | 154 | "### 4. Find Modes (FDE)" |
|
182 | 157 | { |
183 | 158 | "cell_type": "code", |
184 | 159 | "execution_count": null, |
185 | | - "id": "14", |
| 160 | + "id": "12", |
186 | 161 | "metadata": {}, |
187 | 162 | "outputs": [], |
188 | 163 | "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)]" |
196 | 167 | ] |
197 | 168 | }, |
198 | 169 | { |
199 | 170 | "cell_type": "markdown", |
200 | | - "id": "15", |
| 171 | + "id": "13", |
201 | 172 | "metadata": {}, |
202 | 173 | "source": [ |
203 | 174 | "### 5. Calculate S-matrix (EME)" |
|
206 | 177 | { |
207 | 178 | "cell_type": "code", |
208 | 179 | "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", |
238 | 181 | "metadata": {}, |
239 | 182 | "outputs": [], |
240 | 183 | "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}\")" |
243 | 191 | ] |
244 | 192 | } |
245 | 193 | ], |
|
0 commit comments