Skip to content

Commit a4f712a

Browse files
authored
Merge pull request #535 from gdsfactory/fix_ruff
Fix ruff
2 parents f9fef2f + 4303d9e commit a4f712a

11 files changed

+108
-137
lines changed

gplugins/sax/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,9 @@ def mmi2x2(
413413
loss_dB: loss in dB.
414414
shift: shift in wavelength for both cross and thru ports.
415415
loss_dB_cross: loss in dB for the cross port.
416-
loss_dB_bar: loss in dB for the bar port.
416+
loss_dB_thru: loss in dB for the bar port.
417417
splitting_ratio_cross: splitting ratio for the cross port.
418418
splitting_ratio_thru: splitting ratio for the bar port.
419-
420419
"""
421420
loss_dB_cross = loss_dB_cross or loss_dB
422421
loss_dB_thru = loss_dB_thru or loss_dB

gplugins/sentaurus/sdevice.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def write_sdevice_quasistationary_ramp_voltage_dd(
9696
ramp_max_step: maximum ramping step.
9797
ramp_min_step: minimum ramping step.
9898
ramp_sample_voltages: list of voltages between 0V and ramp_final_voltage to report.
99-
filepath: str = Path to the TLC file to be written.
100-
file_settings: "File" field settings to add to the TCL file
101-
output_settings: "Output" field settings to add to the TCL file
102-
physics_settings: "Physics" field settings to add to the TCL file
103-
math_settings: str = "Math" field settings to add to the TCL file
104-
initialization_commands: in the solver, what to execute before the ramp
99+
filename: name of the TCL file to save.
100+
save_directory: directory to save the TCL file.
101+
execution_directory: directory to execute the TCL file.
102+
output_settings: "Plot" field settings to add to the TCL file.
103+
physics_settings: "Physics" field settings to add to the TCL file.
104+
math_settings: str = "Math" field settings to add to the TCL file.
105105
"""
106106
save_directory = (
107107
Path("./sdevice/") if save_directory is None else Path(save_directory)

gplugins/vlsir/export_netlist.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
"""Uses VLSIRTools for converting between Klayout's DB Netlist format and other electrical schematic file formats:
1+
"""Uses VLSIRTools for converting between Klayout's DB Netlist format and other electrical schematic file formats.
2+
23
- SPICE
34
- Spectre
45
- Xyce
56
- Verilog (Not supported yet).
67
78
Todo:
8-
- Add support for Verilog
9-
- Thoroughly test the parser with more complex netlists
9+
- Add support for Verilog.
10+
- Thoroughly test the parser with more complex netlists.
1011
"""
1112

1213
from io import StringIO
@@ -45,9 +46,7 @@ def _connections(**kwargs) -> list[Connection]:
4546

4647

4748
def _params(**kwargs) -> list[Param]:
48-
"""Create a list of `Param`s from keyword args of the form
49-
`r=ParamValue(double_value=1e3)`.
50-
"""
49+
"""Create a list of `Param`s from keyword args of the form r=ParamValue(double_value=1e3)."""
5150
return [Param(name=key, value=value) for key, value in kwargs.items()]
5251

5352

notebooks/elmer_01_electrostatic.ipynb

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"from math import inf\n",
4141
"\n",
4242
"import gdsfactory as gf\n",
43-
"import pyvista as pv\n",
4443
"from gdsfactory.components.interdigital_capacitor_enclosed import (\n",
4544
" interdigital_capacitor_enclosed,\n",
4645
")\n",
@@ -146,61 +145,48 @@
146145
]
147146
},
148147
{
149-
"cell_type": "code",
150-
"execution_count": null,
148+
"cell_type": "markdown",
151149
"id": "8",
152-
"metadata": {
153-
"lines_to_next_cell": 2
154-
},
155-
"outputs": [],
156-
"source": [
157-
"# results = run_capacitive_simulation_elmer(\n",
158-
"# c,\n",
159-
"# layer_stack=layer_stack,\n",
160-
"# material_spec=material_spec,\n",
161-
"# n_processes=1,\n",
162-
"# element_order=1,\n",
163-
"# simulation_folder=Path(os.getcwd()) / \"temporary\",\n",
164-
"# mesh_parameters=dict(\n",
165-
"# background_tag=\"vacuum\",\n",
166-
"# background_padding=(0,) * 5 + (700,),\n",
167-
"# port_names=c.ports.keys(),\n",
168-
"# default_characteristic_length=200,\n",
169-
"# resolutions={\n",
170-
"# \"bw\": {\n",
171-
"# \"resolution\": 15,\n",
172-
"# },\n",
173-
"# \"substrate\": {\n",
174-
"# \"resolution\": 40,\n",
175-
"# },\n",
176-
"# \"vacuum\": {\n",
177-
"# \"resolution\": 40,\n",
178-
"# },\n",
179-
"# **{\n",
180-
"# f\"bw__{port}\": { # `__` is used as the layer–port delimiter for Elmer\n",
181-
"# \"resolution\": 20,\n",
182-
"# \"DistMax\": 30,\n",
183-
"# \"DistMin\": 10,\n",
184-
"# \"SizeMax\": 14,\n",
185-
"# \"SizeMin\": 3,\n",
186-
"# }\n",
187-
"# for port in c.ports\n",
188-
"# },\n",
189-
"# },\n",
190-
"# ),\n",
191-
"# )\n",
192-
"# display(results)"
193-
]
194-
},
195-
{
196-
"cell_type": "code",
197-
"execution_count": null,
198-
"id": "9",
199-
"metadata": {
200-
"lines_to_next_cell": 2
201-
},
202-
"outputs": [],
150+
"metadata": {},
203151
"source": [
152+
"```python\n",
153+
"results = run_capacitive_simulation_elmer(\n",
154+
" c,\n",
155+
" layer_stack=layer_stack,\n",
156+
" material_spec=material_spec,\n",
157+
" n_processes=1,\n",
158+
" element_order=1,\n",
159+
" simulation_folder=Path(os.getcwd()) / \"temporary\",\n",
160+
" mesh_parameters=dict(\n",
161+
" background_tag=\"vacuum\",\n",
162+
" background_padding=(0,) * 5 + (700,),\n",
163+
" port_names=c.ports.keys(),\n",
164+
" default_characteristic_length=200,\n",
165+
" resolutions={\n",
166+
" \"bw\": {\n",
167+
" \"resolution\": 15,\n",
168+
" },\n",
169+
" \"substrate\": {\n",
170+
" \"resolution\": 40,\n",
171+
" },\n",
172+
" \"vacuum\": {\n",
173+
" \"resolution\": 40,\n",
174+
" },\n",
175+
" **{\n",
176+
" f\"bw__{port}\": { # `__` is used as the layer to port delimiter for Elmer\n",
177+
" \"resolution\": 20,\n",
178+
" \"DistMax\": 30,\n",
179+
" \"DistMin\": 10,\n",
180+
" \"SizeMax\": 14,\n",
181+
" \"SizeMin\": 3,\n",
182+
" }\n",
183+
" for port in c.ports\n",
184+
" },\n",
185+
" },\n",
186+
" ),\n",
187+
")\n",
188+
"display(results)\n",
189+
"\n",
204190
"if results.field_file_location:\n",
205191
" pv.start_xvfb()\n",
206192
" pv.set_jupyter_backend(\"trame\")\n",
@@ -212,12 +198,13 @@
212198
" p.show_grid()\n",
213199
" p.camera_position = \"xy\"\n",
214200
" p.enable_parallel_projection()\n",
215-
" p.show()"
201+
" p.show()\n",
202+
"```"
216203
]
217204
},
218205
{
219206
"cell_type": "markdown",
220-
"id": "10",
207+
"id": "9",
221208
"metadata": {},
222209
"source": [
223210
"## Bibliography\n",

notebooks/meep_01_sparameters.ipynb

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797
"source": [
9898
"import gdsfactory as gf\n",
9999
"import matplotlib.pyplot as plt\n",
100+
"import meep as mp\n",
100101
"import numpy as np\n",
101-
"from autograd import tensor_jacobian_product\n",
102102
"from gdsfactory.generic_tech import get_generic_pdk\n",
103103
"from meep import MaterialGrid, Medium, Vector3, Volume\n",
104104
"from meep.adjoint import (\n",
@@ -108,6 +108,7 @@
108108
"\n",
109109
"import gplugins\n",
110110
"import gplugins.gmeep as gm\n",
111+
"from gplugins.gmeep.get_simulation import get_simulation\n",
111112
"\n",
112113
"gf.config.rich_output()\n",
113114
"PDK = get_generic_pdk()\n",
@@ -812,16 +813,11 @@
812813
"id": "52",
813814
"metadata": {},
814815
"source": [
815-
"We'll define a simple objective function that returns the gradient, and records the figure of merit. We'll plot the new geometry after each iteration."
816-
]
817-
},
818-
{
819-
"cell_type": "code",
820-
"execution_count": null,
821-
"id": "53",
822-
"metadata": {},
823-
"outputs": [],
824-
"source": [
816+
"We'll define a simple objective function that returns the gradient, and records the figure of merit. We'll plot the new geometry after each iteration.\n",
817+
"\n",
818+
"```python\n",
819+
"\n",
820+
"\n",
825821
"evaluation_history = []\n",
826822
"cur_iter = [0]\n",
827823
"\n",
@@ -851,24 +847,19 @@
851847
"\n",
852848
" cur_iter[0] = cur_iter[0] + 1\n",
853849
"\n",
854-
" return np.real(f0)"
850+
" return np.real(f0)\n",
851+
"```"
855852
]
856853
},
857854
{
858855
"cell_type": "markdown",
859-
"id": "54",
860-
"metadata": {},
861-
"source": [
862-
"We can define bitmasks to describe the boundary conditions."
863-
]
864-
},
865-
{
866-
"cell_type": "code",
867-
"execution_count": null,
868-
"id": "55",
856+
"id": "53",
869857
"metadata": {},
870-
"outputs": [],
871858
"source": [
859+
"We can define bitmasks to describe the boundary conditions.\n",
860+
"\n",
861+
"```python\n",
862+
"\n",
872863
"# Define spatial arrays used to generate bit masks\n",
873864
"x_g = np.linspace(-design_region_width / 2, design_region_width / 2, Nx)\n",
874865
"y_g = np.linspace(-design_region_height / 2, design_region_height / 2, Ny)\n",
@@ -892,20 +883,21 @@
892883
" | (Y_g == design_region_height / 2)\n",
893884
")\n",
894885
"SiO2_mask = border_mask.copy()\n",
895-
"SiO2_mask[Si_mask] = False"
886+
"SiO2_mask[Si_mask] = False\n",
887+
"```"
896888
]
897889
},
898890
{
899891
"cell_type": "markdown",
900-
"id": "56",
892+
"id": "54",
901893
"metadata": {},
902894
"source": [
903895
"We can then finally run the optimizer, and visualize the optimized component."
904896
]
905897
},
906898
{
907899
"cell_type": "markdown",
908-
"id": "57",
900+
"id": "55",
909901
"metadata": {},
910902
"source": [
911903
"\n",
@@ -965,7 +957,7 @@
965957
},
966958
{
967959
"cell_type": "markdown",
968-
"id": "58",
960+
"id": "56",
969961
"metadata": {},
970962
"source": [
971963
"The final optimized structure should look like this:\n",
@@ -977,7 +969,7 @@
977969
},
978970
{
979971
"cell_type": "markdown",
980-
"id": "59",
972+
"id": "57",
981973
"metadata": {},
982974
"source": [
983975
"## Meep fields\n",
@@ -992,22 +984,7 @@
992984
{
993985
"cell_type": "code",
994986
"execution_count": null,
995-
"id": "60",
996-
"metadata": {},
997-
"outputs": [],
998-
"source": [
999-
"from __future__ import annotations\n",
1000-
"\n",
1001-
"import gdsfactory as gf\n",
1002-
"import meep as mp\n",
1003-
"\n",
1004-
"from gplugins.gmeep.get_simulation import get_simulation"
1005-
]
1006-
},
1007-
{
1008-
"cell_type": "code",
1009-
"execution_count": null,
1010-
"id": "61",
987+
"id": "58",
1011988
"metadata": {},
1012989
"outputs": [],
1013990
"source": [
@@ -1026,7 +1003,7 @@
10261003
{
10271004
"cell_type": "code",
10281005
"execution_count": null,
1029-
"id": "62",
1006+
"id": "59",
10301007
"metadata": {},
10311008
"outputs": [],
10321009
"source": [
@@ -1053,7 +1030,7 @@
10531030
{
10541031
"cell_type": "code",
10551032
"execution_count": null,
1056-
"id": "63",
1033+
"id": "60",
10571034
"metadata": {},
10581035
"outputs": [],
10591036
"source": [
@@ -1064,7 +1041,7 @@
10641041
{
10651042
"cell_type": "code",
10661043
"execution_count": null,
1067-
"id": "64",
1044+
"id": "61",
10681045
"metadata": {},
10691046
"outputs": [],
10701047
"source": [
@@ -1078,12 +1055,10 @@
10781055
{
10791056
"cell_type": "code",
10801057
"execution_count": null,
1081-
"id": "65",
1058+
"id": "62",
10821059
"metadata": {},
10831060
"outputs": [],
10841061
"source": [
1085-
"import numpy as np\n",
1086-
"\n",
10871062
"eps_data = sim.get_array(vol=nonpml_vol, component=mp.Dielectric)\n",
10881063
"ez_data = np.real(ez_dat)\n",
10891064
"\n",
@@ -1096,7 +1071,7 @@
10961071
},
10971072
{
10981073
"cell_type": "markdown",
1099-
"id": "66",
1074+
"id": "63",
11001075
"metadata": {},
11011076
"source": [
11021077
"We can also just run the time-domain simulation with the continuous source until the field is stabilized:"
@@ -1105,7 +1080,7 @@
11051080
{
11061081
"cell_type": "code",
11071082
"execution_count": null,
1108-
"id": "67",
1083+
"id": "64",
11091084
"metadata": {},
11101085
"outputs": [],
11111086
"source": [
@@ -1115,14 +1090,13 @@
11151090
{
11161091
"cell_type": "code",
11171092
"execution_count": null,
1118-
"id": "68",
1093+
"id": "65",
11191094
"metadata": {},
11201095
"outputs": [],
11211096
"source": [
11221097
"eps_data = sim.get_epsilon()\n",
11231098
"ez_data = np.real(sim.get_efield_z())\n",
11241099
"\n",
1125-
"import matplotlib.pyplot as plt\n",
11261100
"\n",
11271101
"plt.figure()\n",
11281102
"sim.plot2D(\n",

0 commit comments

Comments
 (0)