Skip to content

Commit cedb7ae

Browse files
authored
reformat (#2504)
1 parent f8e79af commit cedb7ae

13 files changed

+324
-63
lines changed

python/adjoint/filters.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def cylindrical_filter(x, radius, Lx, Ly, resolution, periodic_axes=None):
180180
[1] Lazarov, B. S., Wang, F., & Sigmund, O. (2016). Length scale and manufacturability in
181181
density-based topology optimization. Archive of Applied Mechanics, 86(1-2), 189-218.
182182
"""
183-
Nx = int(round(Lx * resolution))
184-
Ny = int(round(Ly * resolution))
183+
Nx = int(round(Lx * resolution)) + 1
184+
Ny = int(round(Ly * resolution)) + 1
185185
x = x.reshape(Nx, Ny) # Ensure the input is 2D
186186

187187
xv = np.arange(0, Lx / 2, 1 / resolution)
@@ -231,8 +231,8 @@ def conic_filter(x, radius, Lx, Ly, resolution, periodic_axes=None):
231231
[1] Lazarov, B. S., Wang, F., & Sigmund, O. (2016). Length scale and manufacturability in
232232
density-based topology optimization. Archive of Applied Mechanics, 86(1-2), 189-218.
233233
"""
234-
Nx = int(round(Lx * resolution))
235-
Ny = int(round(Ly * resolution))
234+
Nx = int(round(Lx * resolution)) + 1
235+
Ny = int(round(Ly * resolution)) + 1
236236
x = x.reshape(Nx, Ny) # Ensure the input is 2D
237237

238238
xv = np.arange(0, Lx / 2, 1 / resolution)
@@ -284,8 +284,8 @@ def gaussian_filter(x, sigma, Lx, Ly, resolution, periodic_axes=None):
284284
[1] Wang, E. W., Sell, D., Phan, T., & Fan, J. A. (2019). Robust design of
285285
topology-optimized metasurfaces. Optical Materials Express, 9(2), 469-482.
286286
"""
287-
Nx = int(round(Lx * resolution))
288-
Ny = int(round(Ly * resolution))
287+
Nx = int(round(Lx * resolution)) + 1
288+
Ny = int(round(Ly * resolution)) + 1
289289
x = x.reshape(Nx, Ny) # Ensure the input is 2D
290290

291291
xv = np.arange(0, Lx / 2, 1 / resolution)

python/examples/adjoint_optimization/01-Introduction.ipynb

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@
112112
"outputs": [],
113113
"source": [
114114
"design_region_resolution = 10\n",
115-
"Nx = design_region_resolution\n",
116-
"Ny = design_region_resolution\n",
115+
"Nx = design_region_resolution + 1\n",
116+
"Ny = design_region_resolution + 1\n",
117117
"\n",
118118
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
119119
"design_region = mpa.DesignRegion(\n",
@@ -544,7 +544,38 @@
544544
"name": "python",
545545
"nbconvert_exporter": "python",
546546
"pygments_lexer": "ipython3",
547-
"version": "3.9.7"
547+
"version": "3.8.13"
548+
},
549+
"latex_envs": {
550+
"LaTeX_envs_menu_present": true,
551+
"autoclose": false,
552+
"autocomplete": true,
553+
"bibliofile": "biblio.bib",
554+
"cite_by": "apalike",
555+
"current_citInitial": 1,
556+
"eqLabelWithNumbers": true,
557+
"eqNumInitial": 1,
558+
"hotkeys": {
559+
"equation": "Ctrl-E",
560+
"itemize": "Ctrl-I"
561+
},
562+
"labels_anchors": false,
563+
"latex_user_defs": false,
564+
"report_style_numbering": false,
565+
"user_envs_cfg": false
566+
},
567+
"toc": {
568+
"base_numbering": 1,
569+
"nav_menu": {},
570+
"number_sections": true,
571+
"sideBar": true,
572+
"skip_h1_title": false,
573+
"title_cell": "Table of Contents",
574+
"title_sidebar": "Contents",
575+
"toc_cell": false,
576+
"toc_position": {},
577+
"toc_section_display": true,
578+
"toc_window_display": false
548579
}
549580
},
550581
"nbformat": 4,

python/examples/adjoint_optimization/02-Waveguide_Bend.ipynb

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
"]\n",
7878
"\n",
7979
"design_region_resolution = 10\n",
80-
"Nx = design_region_resolution\n",
81-
"Ny = design_region_resolution\n",
80+
"Nx = design_region_resolution + 1\n",
81+
"Ny = design_region_resolution + 1\n",
8282
"\n",
8383
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
8484
"design_region = mpa.DesignRegion(\n",
@@ -572,7 +572,38 @@
572572
"name": "python",
573573
"nbconvert_exporter": "python",
574574
"pygments_lexer": "ipython3",
575-
"version": "3.9.7"
575+
"version": "3.8.13"
576+
},
577+
"latex_envs": {
578+
"LaTeX_envs_menu_present": true,
579+
"autoclose": false,
580+
"autocomplete": true,
581+
"bibliofile": "biblio.bib",
582+
"cite_by": "apalike",
583+
"current_citInitial": 1,
584+
"eqLabelWithNumbers": true,
585+
"eqNumInitial": 1,
586+
"hotkeys": {
587+
"equation": "Ctrl-E",
588+
"itemize": "Ctrl-I"
589+
},
590+
"labels_anchors": false,
591+
"latex_user_defs": false,
592+
"report_style_numbering": false,
593+
"user_envs_cfg": false
594+
},
595+
"toc": {
596+
"base_numbering": 1,
597+
"nav_menu": {},
598+
"number_sections": true,
599+
"sideBar": true,
600+
"skip_h1_title": false,
601+
"title_cell": "Table of Contents",
602+
"title_sidebar": "Contents",
603+
"toc_cell": false,
604+
"toc_position": {},
605+
"toc_section_display": true,
606+
"toc_window_display": false
576607
}
577608
},
578609
"nbformat": 4,

python/examples/adjoint_optimization/03-Filtered_Waveguide_Bend.ipynb

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"cell_type": "code",
2424
"execution_count": 1,
2525
"metadata": {
26-
"collapsed": false,
2726
"jupyter": {
2827
"outputs_hidden": false
2928
},
@@ -85,7 +84,6 @@
8584
"cell_type": "code",
8685
"execution_count": 2,
8786
"metadata": {
88-
"collapsed": false,
8987
"jupyter": {
9088
"outputs_hidden": false
9189
},
@@ -125,7 +123,6 @@
125123
"cell_type": "code",
126124
"execution_count": 3,
127125
"metadata": {
128-
"collapsed": false,
129126
"jupyter": {
130127
"outputs_hidden": false
131128
},
@@ -169,7 +166,6 @@
169166
"cell_type": "code",
170167
"execution_count": 4,
171168
"metadata": {
172-
"collapsed": false,
173169
"jupyter": {
174170
"outputs_hidden": false
175171
},
@@ -219,7 +215,6 @@
219215
"cell_type": "code",
220216
"execution_count": 5,
221217
"metadata": {
222-
"collapsed": false,
223218
"jupyter": {
224219
"outputs_hidden": false
225220
},
@@ -229,8 +224,8 @@
229224
},
230225
"outputs": [],
231226
"source": [
232-
"Nx = int(design_region_resolution * design_region_width)\n",
233-
"Ny = int(design_region_resolution * design_region_height)\n",
227+
"Nx = int(design_region_resolution * design_region_width) + 1\n",
228+
"Ny = int(design_region_resolution * design_region_height) + 1\n",
234229
"\n",
235230
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
236231
"design_region = mpa.DesignRegion(\n",
@@ -257,7 +252,6 @@
257252
"cell_type": "code",
258253
"execution_count": 6,
259254
"metadata": {
260-
"collapsed": false,
261255
"jupyter": {
262256
"outputs_hidden": false
263257
},
@@ -300,7 +294,6 @@
300294
"cell_type": "code",
301295
"execution_count": 7,
302296
"metadata": {
303-
"collapsed": false,
304297
"jupyter": {
305298
"outputs_hidden": false
306299
},
@@ -350,7 +343,6 @@
350343
"cell_type": "code",
351344
"execution_count": 8,
352345
"metadata": {
353-
"collapsed": false,
354346
"jupyter": {
355347
"outputs_hidden": false
356348
},
@@ -402,7 +394,6 @@
402394
"cell_type": "code",
403395
"execution_count": 9,
404396
"metadata": {
405-
"collapsed": false,
406397
"jupyter": {
407398
"outputs_hidden": false
408399
},
@@ -442,7 +433,6 @@
442433
"cell_type": "code",
443434
"execution_count": 10,
444435
"metadata": {
445-
"collapsed": false,
446436
"jupyter": {
447437
"outputs_hidden": false
448438
},
@@ -476,7 +466,6 @@
476466
"cell_type": "code",
477467
"execution_count": 11,
478468
"metadata": {
479-
"collapsed": false,
480469
"jupyter": {
481470
"outputs_hidden": false
482471
},
@@ -510,7 +499,6 @@
510499
"cell_type": "code",
511500
"execution_count": 12,
512501
"metadata": {
513-
"collapsed": false,
514502
"jupyter": {
515503
"outputs_hidden": false
516504
},
@@ -555,7 +543,6 @@
555543
"cell_type": "code",
556544
"execution_count": 13,
557545
"metadata": {
558-
"collapsed": false,
559546
"jupyter": {
560547
"outputs_hidden": false
561548
},
@@ -612,7 +599,6 @@
612599
"cell_type": "code",
613600
"execution_count": 14,
614601
"metadata": {
615-
"collapsed": false,
616602
"jupyter": {
617603
"outputs_hidden": false
618604
},
@@ -659,7 +645,6 @@
659645
"cell_type": "code",
660646
"execution_count": 15,
661647
"metadata": {
662-
"collapsed": false,
663648
"jupyter": {
664649
"outputs_hidden": false
665650
},
@@ -40476,7 +40461,6 @@
4047640461
"cell_type": "code",
4047740462
"execution_count": 17,
4047840463
"metadata": {
40479-
"collapsed": false,
4048040464
"jupyter": {
4048140465
"outputs_hidden": false
4048240466
},
@@ -40532,7 +40516,6 @@
4053240516
"cell_type": "code",
4053340517
"execution_count": 18,
4053440518
"metadata": {
40535-
"collapsed": false,
4053640519
"jupyter": {
4053740520
"outputs_hidden": false
4053840521
},
@@ -40596,7 +40579,6 @@
4059640579
"cell_type": "code",
4059740580
"execution_count": 19,
4059840581
"metadata": {
40599-
"collapsed": false,
4060040582
"jupyter": {
4060140583
"outputs_hidden": false
4060240584
},
@@ -40625,7 +40607,6 @@
4062540607
"cell_type": "code",
4062640608
"execution_count": 20,
4062740609
"metadata": {
40628-
"collapsed": false,
4062940610
"jupyter": {
4063040611
"outputs_hidden": false
4063140612
},
@@ -40695,7 +40676,38 @@
4069540676
"name": "python",
4069640677
"nbconvert_exporter": "python",
4069740678
"pygments_lexer": "ipython3",
40698-
"version": "3.10.5"
40679+
"version": "3.8.13"
40680+
},
40681+
"latex_envs": {
40682+
"LaTeX_envs_menu_present": true,
40683+
"autoclose": false,
40684+
"autocomplete": true,
40685+
"bibliofile": "biblio.bib",
40686+
"cite_by": "apalike",
40687+
"current_citInitial": 1,
40688+
"eqLabelWithNumbers": true,
40689+
"eqNumInitial": 1,
40690+
"hotkeys": {
40691+
"equation": "Ctrl-E",
40692+
"itemize": "Ctrl-I"
40693+
},
40694+
"labels_anchors": false,
40695+
"latex_user_defs": false,
40696+
"report_style_numbering": false,
40697+
"user_envs_cfg": false
40698+
},
40699+
"toc": {
40700+
"base_numbering": 1,
40701+
"nav_menu": {},
40702+
"number_sections": true,
40703+
"sideBar": true,
40704+
"skip_h1_title": false,
40705+
"title_cell": "Table of Contents",
40706+
"title_sidebar": "Contents",
40707+
"toc_cell": false,
40708+
"toc_position": {},
40709+
"toc_section_display": true,
40710+
"toc_window_display": false
4069940711
}
4070040712
},
4070140713
"nbformat": 4,

python/examples/adjoint_optimization/04-Splitter.ipynb

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132
"metadata": {},
133133
"outputs": [],
134134
"source": [
135-
"Nx = int(design_region_resolution * design_region_width)\n",
136-
"Ny = int(design_region_resolution * design_region_height)\n",
135+
"Nx = int(design_region_resolution * design_region_width) + 1\n",
136+
"Ny = int(design_region_resolution * design_region_height) + 1\n",
137137
"\n",
138138
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
139139
"design_region = mpa.DesignRegion(\n",
@@ -2203,7 +2203,38 @@
22032203
"name": "python",
22042204
"nbconvert_exporter": "python",
22052205
"pygments_lexer": "ipython3",
2206-
"version": "3.9.7"
2206+
"version": "3.8.13"
2207+
},
2208+
"latex_envs": {
2209+
"LaTeX_envs_menu_present": true,
2210+
"autoclose": false,
2211+
"autocomplete": true,
2212+
"bibliofile": "biblio.bib",
2213+
"cite_by": "apalike",
2214+
"current_citInitial": 1,
2215+
"eqLabelWithNumbers": true,
2216+
"eqNumInitial": 1,
2217+
"hotkeys": {
2218+
"equation": "Ctrl-E",
2219+
"itemize": "Ctrl-I"
2220+
},
2221+
"labels_anchors": false,
2222+
"latex_user_defs": false,
2223+
"report_style_numbering": false,
2224+
"user_envs_cfg": false
2225+
},
2226+
"toc": {
2227+
"base_numbering": 1,
2228+
"nav_menu": {},
2229+
"number_sections": true,
2230+
"sideBar": true,
2231+
"skip_h1_title": false,
2232+
"title_cell": "Table of Contents",
2233+
"title_sidebar": "Contents",
2234+
"toc_cell": false,
2235+
"toc_position": {},
2236+
"toc_section_display": true,
2237+
"toc_window_display": false
22072238
}
22082239
},
22092240
"nbformat": 4,

0 commit comments

Comments
 (0)