diff --git a/gplugins/femwell/mode_solver.py b/gplugins/femwell/mode_solver.py index 91c3477a..ea0698db 100644 --- a/gplugins/femwell/mode_solver.py +++ b/gplugins/femwell/mode_solver.py @@ -95,8 +95,10 @@ def compute_component_slice_modes( wavelength: float = 1.55, num_modes: int = 4, order: int = 1, - radius: float = np.inf, wafer_padding: float = 2.0, + radius: float = np.inf, + metallic_boundaries: bool = False, + n_guess: float | None = None, solver: str = "scipy", **kwargs, ) -> Modes: @@ -109,8 +111,10 @@ def compute_component_slice_modes( wavelength: wavelength (um). num_modes: number of modes to return. order: order of the mesh elements. 1: linear, 2: quadratic. - radius: bend radius of the cross-section. wafer_padding: padding beyond bbox to add to WAFER layers. + radius: bend radius of the cross-section. + metallic_boundaries: if True, will set the boundaries to be metallic. + n_guess: initial guess for the effective index. solver: can be slepc or scipy. Keyword Args: @@ -160,6 +164,8 @@ def compute_component_slice_modes( order=order, radius=radius, solver=solver, + n_guess=n_guess, + metallic_boundaries=metallic_boundaries, ) @@ -167,7 +173,6 @@ def compute_component_slice_modes( import matplotlib.pyplot as plt start = time.time() - filtered_layer_stack = LayerStack( layers={ k: get_layer_stack().layers[k] diff --git a/gplugins/gmsh/get_mesh.py b/gplugins/gmsh/get_mesh.py index 3ceac2d2..bb5831b2 100644 --- a/gplugins/gmsh/get_mesh.py +++ b/gplugins/gmsh/get_mesh.py @@ -83,9 +83,9 @@ def get_mesh( # Default layer labels if layer_physical_map is None: - layer_physical_map = {} - for layer_name in layer_stack.layers.keys(): - layer_physical_map[layer_name] = layer_name + layer_physical_map = { + layer_name: layer_name for layer_name in layer_stack.layers.keys() + } else: for layer_name in layer_stack.layers.keys(): if layer_name not in layer_physical_map.keys(): @@ -93,23 +93,17 @@ def get_mesh( # Default meshing flags (all True) if layer_meshbool_map is None: - layer_meshbool_map = {} - for layer_name in layer_stack.layers.keys(): - layer_meshbool_map[layer_name] = True + layer_meshbool_map = { + layer_name: True for layer_name in layer_stack.layers.keys() + } else: for layer_name in layer_stack.layers.keys(): if layer_name not in layer_physical_map.keys(): layer_meshbool_map[layer_name] = True - if type == "xy": - if z is None: - raise ValueError( - 'For xy-meshing, a z-value must be provided via the float argument "z".' - ) - - return xy_xsection_mesh( + if type == "3D": + return xyz_mesh( component=padded_component, - z=z, layer_stack=layer_stack, default_characteristic_length=default_characteristic_length, resolutions=new_resolutions, @@ -136,9 +130,15 @@ def get_mesh( background_remeshing_file=background_remeshing_file, **kwargs, ) - elif type == "3D": - return xyz_mesh( + elif type == "xy": + if z is None: + raise ValueError( + 'For xy-meshing, a z-value must be provided via the float argument "z".' + ) + + return xy_xsection_mesh( component=padded_component, + z=z, layer_stack=layer_stack, default_characteristic_length=default_characteristic_length, resolutions=new_resolutions, diff --git a/notebooks/femwell_01_modes.ipynb b/notebooks/femwell_01_modes.ipynb index 19af8584..200905ba 100644 --- a/notebooks/femwell_01_modes.ipynb +++ b/notebooks/femwell_01_modes.ipynb @@ -61,6 +61,7 @@ " \"clad\",\n", " \"slab90\",\n", " \"box\",\n", + " \"substrate\",\n", " )\n", " }\n", ")\n", @@ -74,10 +75,10 @@ "].thickness = 0.09 # Perturb the layer_stack before simulating\n", "\n", "resolutions = {\n", - " \"core\": {\"resolution\": 0.02, \"distance\": 2},\n", - " \"clad\": {\"resolution\": 0.2, \"distance\": 1},\n", - " \"box\": {\"resolution\": 0.2, \"distance\": 1},\n", - " \"slab90\": {\"resolution\": 0.05, \"distance\": 1},\n", + " \"core\": {\"resolution\": 0.02, \"distance\": 1, \"SizeMax\": 0.2},\n", + " # \"clad\": {\"resolution\": 0.2, \"distance\": 1},\n", + " # \"box\": {\"resolution\": 0.2, \"distance\": 1},\n", + " # \"slab90\": {\"resolution\": 0.05, \"distance\": 1},\n", "}" ] }, @@ -92,8 +93,9 @@ " cross_section=rib(width=0.6),\n", " layer_stack=filtered_layer_stack,\n", " wavelength=1.55,\n", - " num_modes=4,\n", + " num_modes=1,\n", " resolutions=resolutions,\n", + " n_guess=2.630929889650573,\n", ")" ] }, @@ -137,9 +139,19 @@ ] }, { - "cell_type": "markdown", + "cell_type": "code", + "execution_count": null, "id": "8", "metadata": {}, + "outputs": [], + "source": [ + "print(modes[0].n_eff)" + ] + }, + { + "cell_type": "markdown", + "id": "9", + "metadata": {}, "source": [ "## Sweep waveguide width" ] @@ -147,7 +159,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "10", "metadata": { "lines_to_next_cell": 2 }, @@ -176,7 +188,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -196,6 +208,23 @@ "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" + }, + "kernelspec": { + "display_name": "base", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" } }, "nbformat": 4,