Skip to content

Commit c3e07ef

Browse files
authored
Merge pull request #685 from David-GERARD/fix/cascaded-mzi-notebook
Fix: cascaded mzi notebook + tidy3d pluggin bug fixes
2 parents 0d0fc60 + 0ead3d3 commit c3e07ef

4 files changed

Lines changed: 4354 additions & 4317 deletions

File tree

gplugins/tidy3d/component.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ def write_sparameters(
523523
symmetry=symmetry,
524524
**kwargs,
525525
)
526-
527-
path_dir = pathlib.Path(dirpath) / modeler._hash_self()
526+
task_name = modeler._hash_self()
527+
path_dir = pathlib.Path(dirpath) / task_name
528528
modeler = modeler.updated_copy()
529529

530530
sp = {}
@@ -587,7 +587,12 @@ def write_sparameters(
587587
return dict(np.load(filepath))
588588
else:
589589
time.sleep(0.2)
590-
modeler_data = web.run(modeler, verbose=verbose, path=dirpath / "simulation.hdf5")
590+
modeler_data = web.run(
591+
modeler, # TODO: web.run does not currently support ComponentModeler, need to convert to tidy3d_stub.SimulationType
592+
task_name=task_name,
593+
verbose=verbose,
594+
path=path_dir / "simulation.hdf5",
595+
)
591596
s = modeler_data.smatrix()
592597
for port_in in s.port_in.values:
593598
for port_out in s.port_out.values:

notebooks/workflow_3_cascaded_mzi.ipynb

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,6 @@
157157
"id": "9",
158158
"metadata": {},
159159
"outputs": [],
160-
"source": [
161-
"# s_params_list = [dict(np.load(PATH.sparameters_repo / f\"dc_{length}.npz\")) for length in sim_lengths]"
162-
]
163-
},
164-
{
165-
"cell_type": "code",
166-
"execution_count": null,
167-
"id": "10",
168-
"metadata": {},
169-
"outputs": [],
170160
"source": [
171161
"wavelengths = s_params_list[0][\"wavelengths\"]\n",
172162
"drop = np.array([np.abs(s[\"o3@0,o1@0\"]) ** 2 for s in s_params_list])\n",
@@ -200,7 +190,7 @@
200190
},
201191
{
202192
"cell_type": "markdown",
203-
"id": "11",
193+
"id": "10",
204194
"metadata": {
205195
"lines_to_next_cell": 2
206196
},
@@ -213,7 +203,7 @@
213203
{
214204
"cell_type": "code",
215205
"execution_count": null,
216-
"id": "12",
206+
"id": "11",
217207
"metadata": {},
218208
"outputs": [],
219209
"source": [
@@ -246,7 +236,7 @@
246236
},
247237
{
248238
"cell_type": "markdown",
249-
"id": "13",
239+
"id": "12",
250240
"metadata": {},
251241
"source": [
252242
"Finally, we simulate the couplers with the calculated lengths to guarantee the fitting error is within tolerance.\n",
@@ -256,21 +246,19 @@
256246
{
257247
"cell_type": "code",
258248
"execution_count": null,
259-
"id": "14",
249+
"id": "13",
260250
"metadata": {},
261251
"outputs": [],
262252
"source": [
263-
"sims = gt.write_sparameters_batch(\n",
264-
" [\n",
265-
" {\n",
266-
" \"component\": coupler_sc(gap=gap, length=length),\n",
267-
" \"filepath\": PATH.sparameters_repo / f\"dc_{length}.npz\",\n",
268-
" }\n",
269-
" for length in lengths\n",
270-
" ],\n",
271-
" layer_stack=layer_stack,\n",
272-
" # overwrite=True,\n",
273-
")\n",
253+
"jobs = [\n",
254+
" dict(\n",
255+
" component=coupler_sc(gap=gap, length=length),\n",
256+
" filepath=PATH.sparameters_repo / f\"dc_{length}.npz\",\n",
257+
" layer_stack=layer_stack,\n",
258+
" )\n",
259+
" for length in sim_lengths\n",
260+
"]\n",
261+
"sims = gt.write_sparameters_batch(jobs)\n",
274262
"s_params_list = [sim.result() for sim in sims]\n",
275263
"fig, ax = plt.subplots(1, 3, figsize=(12, 3))\n",
276264
"errors = []\n",
@@ -300,7 +288,7 @@
300288
},
301289
{
302290
"cell_type": "markdown",
303-
"id": "15",
291+
"id": "14",
304292
"metadata": {
305293
"lines_to_next_cell": 2
306294
},
@@ -317,7 +305,7 @@
317305
{
318306
"cell_type": "code",
319307
"execution_count": null,
320-
"id": "16",
308+
"id": "15",
321309
"metadata": {},
322310
"outputs": [],
323311
"source": [
@@ -362,7 +350,7 @@
362350
},
363351
{
364352
"cell_type": "markdown",
365-
"id": "17",
353+
"id": "16",
366354
"metadata": {
367355
"lines_to_next_cell": 2
368356
},
@@ -373,7 +361,7 @@
373361
{
374362
"cell_type": "code",
375363
"execution_count": null,
376-
"id": "18",
364+
"id": "17",
377365
"metadata": {},
378366
"outputs": [],
379367
"source": [
@@ -388,7 +376,7 @@
388376
},
389377
{
390378
"cell_type": "markdown",
391-
"id": "19",
379+
"id": "18",
392380
"metadata": {},
393381
"source": [
394382
"Finally, we want to build a complete simulation of the filter based on individual models for its components.\n",
@@ -399,7 +387,7 @@
399387
{
400388
"cell_type": "code",
401389
"execution_count": null,
402-
"id": "20",
390+
"id": "19",
403391
"metadata": {},
404392
"outputs": [],
405393
"source": [
@@ -409,7 +397,7 @@
409397
},
410398
{
411399
"cell_type": "markdown",
412-
"id": "21",
400+
"id": "20",
413401
"metadata": {},
414402
"source": [
415403
"The model for the straight sections is based directly on the waveguide mode, including dispersion effects."
@@ -418,7 +406,7 @@
418406
{
419407
"cell_type": "code",
420408
"execution_count": null,
421-
"id": "22",
409+
"id": "21",
422410
"metadata": {},
423411
"outputs": [],
424412
"source": [
@@ -438,7 +426,7 @@
438426
{
439427
"cell_type": "code",
440428
"execution_count": null,
441-
"id": "23",
429+
"id": "22",
442430
"metadata": {},
443431
"outputs": [],
444432
"source": [
@@ -467,7 +455,7 @@
467455
},
468456
{
469457
"cell_type": "markdown",
470-
"id": "24",
458+
"id": "23",
471459
"metadata": {
472460
"lines_to_next_cell": 2
473461
},
@@ -480,7 +468,7 @@
480468
{
481469
"cell_type": "code",
482470
"execution_count": null,
483-
"id": "25",
471+
"id": "24",
484472
"metadata": {},
485473
"outputs": [],
486474
"source": [
@@ -513,7 +501,7 @@
513501
{
514502
"cell_type": "code",
515503
"execution_count": null,
516-
"id": "26",
504+
"id": "25",
517505
"metadata": {},
518506
"outputs": [],
519507
"source": [
@@ -533,7 +521,7 @@
533521
{
534522
"cell_type": "code",
535523
"execution_count": null,
536-
"id": "27",
524+
"id": "26",
537525
"metadata": {},
538526
"outputs": [],
539527
"source": [
@@ -596,7 +584,7 @@
596584
},
597585
{
598586
"cell_type": "markdown",
599-
"id": "28",
587+
"id": "27",
600588
"metadata": {
601589
"lines_to_next_cell": 2
602590
},
@@ -607,7 +595,7 @@
607595
{
608596
"cell_type": "code",
609597
"execution_count": null,
610-
"id": "29",
598+
"id": "28",
611599
"metadata": {},
612600
"outputs": [],
613601
"source": [
@@ -704,7 +692,7 @@
704692
{
705693
"cell_type": "code",
706694
"execution_count": null,
707-
"id": "30",
695+
"id": "29",
708696
"metadata": {},
709697
"outputs": [],
710698
"source": [
@@ -714,7 +702,7 @@
714702
{
715703
"cell_type": "code",
716704
"execution_count": null,
717-
"id": "31",
705+
"id": "30",
718706
"metadata": {},
719707
"outputs": [],
720708
"source": [
@@ -724,7 +712,7 @@
724712
{
725713
"cell_type": "code",
726714
"execution_count": null,
727-
"id": "32",
715+
"id": "31",
728716
"metadata": {},
729717
"outputs": [],
730718
"source": [
@@ -734,7 +722,7 @@
734722
{
735723
"cell_type": "code",
736724
"execution_count": null,
737-
"id": "33",
725+
"id": "32",
738726
"metadata": {},
739727
"outputs": [],
740728
"source": [
@@ -743,7 +731,7 @@
743731
},
744732
{
745733
"cell_type": "markdown",
746-
"id": "34",
734+
"id": "33",
747735
"metadata": {},
748736
"source": [
749737
"Finally, we can simulate the complete filter response around the central wavelength and get the desired FSR and box-like shape."
@@ -752,7 +740,7 @@
752740
{
753741
"cell_type": "code",
754742
"execution_count": null,
755-
"id": "35",
743+
"id": "34",
756744
"metadata": {},
757745
"outputs": [],
758746
"source": [
@@ -780,7 +768,7 @@
780768
"custom_cell_magics": "kql"
781769
},
782770
"kernelspec": {
783-
"display_name": "Python 3 (ipykernel)",
771+
"display_name": "gplugins (3.11.14)",
784772
"language": "python",
785773
"name": "python3"
786774
},
@@ -794,7 +782,7 @@
794782
"name": "python",
795783
"nbconvert_exporter": "python",
796784
"pygments_lexer": "ipython3",
797-
"version": "3.12.8"
785+
"version": "3.11.14"
798786
}
799787
},
800788
"nbformat": 4,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ classifiers = [
1313
"Operating System :: OS Independent"
1414
]
1515
dependencies = [
16-
"gdsfactory>=9.15.1",
16+
"gdsfactory>=9.29.1",
1717
"pint",
1818
"tqdm",
1919
"numpy>=2.0,<3",

0 commit comments

Comments
 (0)