Skip to content

Commit

Permalink
increase array size of material grid by 1 in each dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
mawc2019 committed May 4, 2023
1 parent 9bd6ec4 commit f61c5aa
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 56 deletions.
12 changes: 6 additions & 6 deletions python/adjoint/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def cylindrical_filter(x, radius, Lx, Ly, resolution, periodic_axes=None):
[1] Lazarov, B. S., Wang, F., & Sigmund, O. (2016). Length scale and manufacturability in
density-based topology optimization. Archive of Applied Mechanics, 86(1-2), 189-218.
"""
Nx = int(round(Lx * resolution))
Ny = int(round(Ly * resolution))
Nx = int(round(Lx * resolution)) + 1
Ny = int(round(Ly * resolution)) + 1
x = x.reshape(Nx, Ny) # Ensure the input is 2D

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

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

xv = np.arange(0, Lx / 2, 1 / resolution)
Expand Down
37 changes: 34 additions & 3 deletions python/examples/adjoint_optimization/01-Introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
"outputs": [],
"source": [
"design_region_resolution = 10\n",
"Nx = design_region_resolution\n",
"Ny = design_region_resolution\n",
"Nx = design_region_resolution + 1\n",
"Ny = design_region_resolution + 1\n",
"\n",
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
"design_region = mpa.DesignRegion(\n",
Expand Down Expand Up @@ -544,7 +544,38 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.13"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
37 changes: 34 additions & 3 deletions python/examples/adjoint_optimization/02-Waveguide_Bend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
"]\n",
"\n",
"design_region_resolution = 10\n",
"Nx = design_region_resolution\n",
"Ny = design_region_resolution\n",
"Nx = design_region_resolution + 1\n",
"Ny = design_region_resolution + 1\n",
"\n",
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
"design_region = mpa.DesignRegion(\n",
Expand Down Expand Up @@ -572,7 +572,38 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.13"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -85,7 +84,6 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -125,7 +123,6 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -169,7 +166,6 @@
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -219,7 +215,6 @@
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand All @@ -229,8 +224,8 @@
},
"outputs": [],
"source": [
"Nx = int(design_region_resolution * design_region_width)\n",
"Ny = int(design_region_resolution * design_region_height)\n",
"Nx = int(design_region_resolution * design_region_width) + 1\n",
"Ny = int(design_region_resolution * design_region_height) + 1\n",
"\n",
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
"design_region = mpa.DesignRegion(\n",
Expand All @@ -257,7 +252,6 @@
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -300,7 +294,6 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -350,7 +343,6 @@
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -402,7 +394,6 @@
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -442,7 +433,6 @@
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -476,7 +466,6 @@
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -510,7 +499,6 @@
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -555,7 +543,6 @@
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -612,7 +599,6 @@
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -659,7 +645,6 @@
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -40476,7 +40461,6 @@
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -40532,7 +40516,6 @@
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -40596,7 +40579,6 @@
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -40625,7 +40607,6 @@
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -40695,7 +40676,38 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
"version": "3.8.13"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
37 changes: 34 additions & 3 deletions python/examples/adjoint_optimization/04-Splitter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
"metadata": {},
"outputs": [],
"source": [
"Nx = int(design_region_resolution * design_region_width)\n",
"Ny = int(design_region_resolution * design_region_height)\n",
"Nx = int(design_region_resolution * design_region_width) + 1\n",
"Ny = int(design_region_resolution * design_region_height) + 1\n",
"\n",
"design_variables = mp.MaterialGrid(mp.Vector3(Nx, Ny), SiO2, Si, grid_type=\"U_MEAN\")\n",
"design_region = mpa.DesignRegion(\n",
Expand Down Expand Up @@ -2203,7 +2203,38 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.13"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit f61c5aa

Please sign in to comment.