-
Notifications
You must be signed in to change notification settings - Fork 1
/
ufIDT20210525.py
361 lines (319 loc) · 18.7 KB
/
ufIDT20210525.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# array of single finger and double finger IDTs with wavlength 4um set to create standing waves. Example of how to make array of standing wave unfocused IDTs
def double_finger_idt_wp(fw, frequency, wavelength, periods, height, surface_velocity, offset, finger_layer,
pad_layer, align_layer, coords, label):
# f_or_w should be entered as 0 for f or 1 for w, depending on whether you would like to specify wavelength or frequency
# if specifying wavelength, enter 1 for frequency and surface velocity (should be in um)
# pads will be finger overlap x length of IDT, width can be easily changed by changing the values,
# length should be changed by adding an additional waveguide in a separate function
# overlap with fingers is set by 2um, this can also be changed below if desired
# coords will be location of lower left corner
# coords = (x, y)
from gdshelpers.geometry.chip import Cell
from shapely.geometry import Polygon
from gdshelpers.parts.marker import CrossMarker
from gdshelpers.parts.text import Text
finger_overlap = 2
pad_height = finger_overlap
shift = pad_height - finger_overlap
idt = Cell(label)
if fw == 0:
wavelength = (surface_velocity/frequency)*10**6
width = wavelength/8
ox = coords[0]
oy = coords[1]
upper_coord = [(ox+2*width+wavelength/2, oy+offset+pad_height),
(ox+2*width+wavelength/2, oy+offset+height+pad_height+finger_overlap),
(ox+2*width+wavelength/2+width, oy+offset+height+pad_height+finger_overlap),
(ox+2*width+wavelength/2+width, oy+offset+pad_height)]
lower_coord = [(ox+2*width, oy+shift), (ox+2*width, oy+height+pad_height),
(ox+2*width+width, oy+height+pad_height), (ox+2*width+width, oy+shift)]
pad_width = 0
pu_coord = 0
for i in range(periods):
uc1 = [(upper_coord[0][0] + i*wavelength, upper_coord[0][1]),
(upper_coord[1][0] + i*wavelength, upper_coord[1][1]),
(upper_coord[2][0] + i*wavelength, upper_coord[2][1]),
(upper_coord[3][0] + i*wavelength, upper_coord[3][1])]
uc2 = [(upper_coord[0][0] + 2*width + i * wavelength, upper_coord[0][1]),
(upper_coord[1][0] + 2*width + i * wavelength, upper_coord[1][1]),
(upper_coord[2][0] + 2*width + i * wavelength, upper_coord[2][1]),
(upper_coord[3][0] + 2*width + i * wavelength, upper_coord[3][1])]
lc1 = [(lower_coord[0][0] + i*wavelength, lower_coord[0][1]),
(lower_coord[1][0] + i*wavelength, lower_coord[1][1]),
(lower_coord[2][0] + i*wavelength, lower_coord[2][1]),
(lower_coord[3][0] + i*wavelength, lower_coord[3][1])]
lc2 = [(lower_coord[0][0] + 2*width + i * wavelength, lower_coord[0][1]),
(lower_coord[1][0] + 2*width + i * wavelength, lower_coord[1][1]),
(lower_coord[2][0] + 2*width + i * wavelength, lower_coord[2][1]),
(lower_coord[3][0] + 2*width + i * wavelength, lower_coord[3][1])]
pad_width = uc2[2][0]
pu_coord = uc2[2][1]
u_rect1 = Polygon(uc1)
u_rect2 = Polygon(uc2)
l_rect1 = Polygon(lc1)
l_rect2 = Polygon(lc2)
idt.add_to_layer(finger_layer, u_rect1, l_rect1, u_rect2, l_rect2)
pl00 = min(4 * width + pad_width - 80, ox)
pl = [(pl00, oy-13), (pl00, oy + pad_height), (4 * width + pad_width, oy + pad_height), (4 * width + pad_width, oy-13)]
pu = [(pl00 - 50, pu_coord - finger_overlap), (pl00 - 50, pu_coord - finger_overlap + pad_height+13),
(4 * width + pad_width, pu_coord - finger_overlap + pad_height+13),
(4 * width + pad_width, pu_coord - finger_overlap)]
pu1 = [(pl00 - 50, pu_coord - finger_overlap + pad_height),
(pl00 - 20, pu_coord - finger_overlap + pad_height),
(pl00 - 20, oy + pad_height - 100),
(pl00 - 50, oy + pad_height - 100)]
pu2 = [(pl00 - 50, oy + pad_height - 100), (pl00 - 50, oy + pad_height - 70),
(4 * width + pad_width - 150, oy + pad_height - 70), (4 * width + pad_width - 150, oy + pad_height - 100)]
pua = Polygon(pu1)
pub = Polygon(pu2)
pud = pua.union(pub)
short_lower = Polygon(pl)
short_upper = Polygon(pu)
pla1 = [(4 * width + pad_width, oy + pad_height), (4 * width + pad_width - 30, oy + pad_height),
(4 * width + pad_width - 30, oy + pad_height - 75), (4 * width + pad_width, oy + pad_height - 75)]
bl = [(4 * width + pad_width + 20, oy + pad_height - 50), (4 * width + pad_width + 20, oy + pad_height - 200),
(4 * width + pad_width - 80, oy + pad_height - 200), (4 * width + pad_width - 80, oy + pad_height - 50)]
bu = [(4 * width + pad_width - 100, oy + pad_height - 200),
(4 * width + pad_width - 100, oy + pad_height - 50),
(4 * width + pad_width - 200, oy + pad_height - 50),
(4 * width + pad_width - 200, oy + pad_height - 200)]
plc = Polygon(bl)
pla = Polygon(pla1)
puc = Polygon(bu)
pad_upper = puc.union(pud)
pad_lower = plc.union(pla)
idt.add_to_layer(pad_layer, short_lower, short_upper, pad_lower, pad_upper)
ox1 = coords[0] + pad_width + 60
upper_coord1 = [(ox1 + 2 * width + 2 * width, oy + offset + shift + pad_height),
(ox1 + 2 * width + 2 * width, oy + offset + height + shift + finger_overlap + pad_height),
(ox1 + 3 * width + 2 * width, oy + offset + height + shift + finger_overlap + pad_height),
(ox1 + 3 * width + 2 * width, oy + offset + shift + pad_height)]
lower_coord1 = [(ox1 + 2 * width, oy + shift), (ox1 + 2 * width, oy + finger_overlap + height),
(ox1 + width + 2 * width, oy + finger_overlap + height), (ox1 + width + 2 * width, oy + shift)]
pad_width1 = 0
pu_coord1 = 0
for i in range(periods):
uc1 = [(upper_coord1[0][0] + 2*width + i*wavelength, upper_coord1[0][1]),
(upper_coord1[1][0] + 2*width + i*wavelength, upper_coord1[1][1]),
(upper_coord1[2][0] + 2*width + i*wavelength, upper_coord1[2][1]),
(upper_coord1[3][0] + 2*width + i*wavelength, upper_coord1[3][1])]
uc2 = [(upper_coord1[0][0] + 4*width + i * wavelength, upper_coord1[0][1]),
(upper_coord1[1][0] + 4*width + i * wavelength, upper_coord1[1][1]),
(upper_coord1[2][0] + 4*width + i * wavelength, upper_coord1[2][1]),
(upper_coord1[3][0] + 4*width + i * wavelength, upper_coord1[3][1])]
lc1 = [(lower_coord1[0][0] + i*wavelength, lower_coord1[0][1]),
(lower_coord1[1][0] + i*wavelength, lower_coord1[1][1]),
(lower_coord1[2][0] + i*wavelength, lower_coord1[2][1]),
(lower_coord1[3][0] + i*wavelength, lower_coord1[3][1])]
lc2 = [(lower_coord1[0][0] + 2*width + i * wavelength, lower_coord1[0][1]),
(lower_coord1[1][0] + 2*width + i * wavelength, lower_coord1[1][1]),
(lower_coord1[2][0] + 2*width + i * wavelength, lower_coord1[2][1]),
(lower_coord1[3][0] + 2*width + i * wavelength, lower_coord1[3][1])]
pad_width1 = uc2[2][0]
pu_coord1 = uc2[2][1]
u_rect1 = Polygon(uc1)
u_rect2 = Polygon(uc2)
l_rect1 = Polygon(lc1)
l_rect2 = Polygon(lc2)
idt.add_to_layer(finger_layer, u_rect1, l_rect1, u_rect2, l_rect2)
ql = [(ox1, oy-13), (ox1, oy + pad_height), (4 * width + pad_width1, oy + pad_height), (4 * width + pad_width1, oy-13)]
qu = [(ox1, pu_coord1 - finger_overlap), (ox1, pu_coord1 - finger_overlap + pad_height+13),
(4 * width + pad_width1 + 50, pu_coord1 - finger_overlap + pad_height+13),
(4 * width + pad_width1 + 50, pu_coord1 - finger_overlap)]
qu1a = [(4 * width + pad_width1 + 50, pu_coord1 - finger_overlap + pad_height),
(4 * width + pad_width1 + 20, pu_coord1 - finger_overlap + pad_height),
(4 * width + pad_width1 + 20, oy + pad_height - 75),
(4 * width + pad_width1 + 50, oy + pad_height - 75)]
qua = Polygon(qu1a)
qu1b = [(4 * width + pad_width1 + 20, oy + pad_height - 75),
(4 * width + pad_width1 + 20, oy + pad_height - 45),
(ox1 + 100, oy + pad_height - 45), (ox1 + 100, oy + pad_height - 75)]
qub = Polygon(qu1b)
qum = qua.union(qub)
short_lower1 = Polygon(ql)
short_upper1 = Polygon(qu)
pla10 = [(ox1, oy + pad_height), (ox1 + 30, oy + pad_height),
(ox1 + 30, oy + pad_height - 75), (ox1, oy + pad_height - 75)]
pla0 = Polygon(pla10)
bl1 = [(ox1 - 20, oy + pad_height - 50), (ox1 + 80, oy + pad_height - 50),
(ox1 + 80, oy + pad_height - 200), (ox1 - 20, oy + pad_height - 200)]
plc1 = Polygon(bl1)
pad_lower1 = pla0.union(plc1)
bu1 = [(ox1 + 100, oy + pad_height - 50), (ox1 + 200, oy + pad_height - 50),
(ox1 + 200, oy + pad_height - 200), (ox1 + 100, oy + pad_height - 200)]
puc1 = Polygon(bu1)
pad_upper1 = qum.union(puc1)
idt.add_to_layer(pad_layer, short_lower1, short_upper1, pad_lower1, pad_upper1)
cross_p = CrossMarker(origin=(ox - 100, oy + pad_height - 250),
cross_length=12.5, cross_width=2.5, paddle_length=12.5, paddle_width=2.5)
cross_q = CrossMarker(origin=(ox - 100, oy + pad_height + 250),
cross_length=12.5, cross_width=2.5, paddle_length=12.5, paddle_width=2.5)
cross_r = CrossMarker(origin=(ox + 400, oy + pad_height - 250),
cross_length=12.5, cross_width=2.5, paddle_length=12.5, paddle_width=2.5)
tag = Text(origin=(ox - 50, oy + pad_height - 250), height=40, text=label,
alignment='left-center')
idt.add_to_layer(align_layer, cross_p, cross_q, cross_r, tag)
return idt
def single_finger_idt_sw(fw, frequency, wavelength, periods, height, surface_velocity, offset,
finger_layer, pad_layer, align_layer, coords, label):
# fw should be entered as 0 for f or 1 for w, depending on whether you would like to specify wavelength or frequency
# if specifying wavelength, enter 1 for frequency and surface velocity (should be in um)
# pads will be finger overlap x length of IDT, width can be easily changed by changing the values,
# length should be changed by adding an additional waveguide in a separate function
# overlap with fingers is set by 2um, this can also be changed below if desired
# coords will be location of lower left corner
# coords = (x, y)
# velocity should be entered in meters/second, all other measurements should be in um
from gdshelpers.geometry.chip import Cell
from shapely.geometry import Polygon
from gdshelpers.parts.marker import CrossMarker
from gdshelpers.parts.text import Text
ox = coords[0]
oy = coords[1]
finger_overlap = 2
pad_height = finger_overlap
shift = pad_height - finger_overlap
cell = Cell(label)
if fw==0:
wavelength = (surface_velocity/frequency)*10**6
width = wavelength/4
upper_coord = [(ox+2*width+2*width, oy+offset+shift+pad_height),
(ox+2*width+2*width, oy+offset+height+shift+finger_overlap+pad_height),
(ox+3*width+2*width, oy+offset+height+shift+finger_overlap+pad_height),
(ox+3*width+2*width, oy+offset+shift+pad_height)]
lower_coord = [(ox+2*width, oy+shift), (ox+2*width, oy+finger_overlap+height+shift),
(ox+width+2*width, oy+finger_overlap+height+shift), (ox+width+2*width, oy+shift)]
pad_width = 0
pu_coord = 0
for i in range(periods):
uc = [(upper_coord[0][0] + i*wavelength, upper_coord[0][1]),
(upper_coord[1][0] + i*wavelength, upper_coord[1][1]),
(upper_coord[2][0] + i*wavelength, upper_coord[2][1]),
(upper_coord[3][0] + i*wavelength, upper_coord[3][1])]
lc = [(lower_coord[0][0] + i*wavelength, lower_coord[0][1]),
(lower_coord[1][0] + i*wavelength, lower_coord[1][1]),
(lower_coord[2][0] + i*wavelength, lower_coord[2][1]),
(lower_coord[3][0] + i*wavelength, lower_coord[3][1])]
pad_width = uc[2][0]
pu_coord = uc[2][1]
u_rect = Polygon(uc)
l_rect = Polygon(lc)
cell.add_to_layer(finger_layer, u_rect, l_rect)
pl00 = min(4*width+pad_width - 80, ox)
pl = [(pl00, oy-13), (pl00, oy+pad_height), (4*width+pad_width, oy+pad_height), (4*width+pad_width, oy-13)]
pu = [(pl00-50, pu_coord - finger_overlap), (pl00-50, pu_coord - finger_overlap + pad_height+13),
(4*width+pad_width, pu_coord - finger_overlap + pad_height+13), (4*width+pad_width, pu_coord - finger_overlap)]
pu1 = [(pl00-50, pu_coord - finger_overlap + pad_height),
(pl00-20, pu_coord - finger_overlap + pad_height),
(pl00-20, oy+pad_height - 100),
(pl00-50, oy+pad_height - 100)]
pu2 = [(pl00-50, oy+pad_height - 100), (pl00-50, oy+pad_height - 70),
(4*width+pad_width - 150, oy+pad_height - 70), (4*width+pad_width - 150, oy+pad_height - 100)]
pua = Polygon(pu1)
pub = Polygon(pu2)
pud = pua.union(pub)
short_lower = Polygon(pl)
short_upper = Polygon(pu)
pla1 = [(4*width+pad_width, oy+pad_height), (4*width+pad_width-30, oy+pad_height),
(4*width+pad_width-30, oy+pad_height-75), (4*width+pad_width, oy+pad_height-75)]
bl = [(4*width+pad_width + 20, oy+pad_height-50), (4*width+pad_width + 20, oy+pad_height - 200),
(4*width+pad_width - 80, oy+pad_height - 200), (4*width+pad_width - 80, oy+pad_height-50)]
bu = [(4*width+pad_width - 100, oy+pad_height - 200),
(4*width+pad_width - 100, oy+pad_height - 50),
(4*width+pad_width - 200, oy+pad_height - 50),
(4*width+pad_width - 200, oy+pad_height - 200)]
plc = Polygon(bl)
pla = Polygon(pla1)
puc = Polygon(bu)
pad_upper = puc.union(pud)
pad_lower = plc.union(pla)
cell.add_to_layer(pad_layer, short_lower, short_upper, pad_lower, pad_upper)
ox1 = coords[0]+pad_width+60
upper_coord1 = [(ox1 + 2 * width + 2 * width, oy + offset + shift + pad_height),
(ox1 + 2 * width + 2 * width, oy + offset + height + shift + finger_overlap + pad_height),
(ox1 + 3 * width + 2 * width, oy + offset + height + shift + finger_overlap + pad_height),
(ox1 + 3 * width + 2 * width, oy + offset + shift + pad_height)]
lower_coord1 = [(ox1 + 2 * width, oy + shift), (ox1 + 2 * width, oy + finger_overlap + height),
(ox1 + width + 2 * width, oy + finger_overlap + height), (ox1 + width + 2 * width, oy + shift)]
pad_width1 = 0
pu_coord1 = 0
for i in range(periods):
uc1 = [(upper_coord1[0][0] + i * wavelength, upper_coord1[0][1]),
(upper_coord1[1][0] + i * wavelength, upper_coord1[1][1]),
(upper_coord1[2][0] + i * wavelength, upper_coord1[2][1]),
(upper_coord1[3][0] + i * wavelength, upper_coord1[3][1])]
lc1 = [(lower_coord1[0][0] + i * wavelength, lower_coord1[0][1]),
(lower_coord1[1][0] + i * wavelength, lower_coord1[1][1]),
(lower_coord1[2][0] + i * wavelength, lower_coord1[2][1]),
(lower_coord1[3][0] + i * wavelength, lower_coord1[3][1])]
pad_width1 = uc1[2][0]
pu_coord1 = uc1[2][1]
u_rect = Polygon(uc1)
l_rect = Polygon(lc1)
cell.add_to_layer(finger_layer, u_rect, l_rect)
ql = [(ox1, oy-13), (ox1, oy + pad_height), (4 * width + pad_width1, oy + pad_height), (4 * width + pad_width1, oy-13)]
qu = [(ox1, pu_coord1 - finger_overlap), (ox1, pu_coord1 - finger_overlap + pad_height+13),
(4 * width + pad_width1 + 50, pu_coord1 - finger_overlap + pad_height+13),
(4 * width + pad_width1 + 50, pu_coord1 - finger_overlap)]
qu1a = [(4 * width + pad_width1 + 50, pu_coord1 - finger_overlap + pad_height),
(4 * width + pad_width1 + 20, pu_coord1 - finger_overlap + pad_height),
(4 * width + pad_width1 + 20, oy + pad_height - 75),
(4 * width + pad_width1 + 50, oy + pad_height - 75)]
qua = Polygon(qu1a)
qu1b = [(4 * width + pad_width1 + 20, oy + pad_height - 75),
(4 * width + pad_width1 + 20, oy + pad_height - 45),
(ox1 + 100, oy + pad_height - 45), (ox1 + 100, oy + pad_height - 75)]
qub = Polygon(qu1b)
qum = qua.union(qub)
short_lower1 = Polygon(ql)
short_upper1 = Polygon(qu)
pla10 = [(ox1, oy + pad_height), (ox1+30, oy + pad_height),
(ox1+30, oy+pad_height-75), (ox1, oy+pad_height-75)]
pla0 = Polygon(pla10)
bl1 = [(ox1-20, oy+pad_height-50), (ox1+80, oy+pad_height-50),
(ox1+80, oy+pad_height - 200), (ox1-20, oy+pad_height - 200)]
plc1 = Polygon(bl1)
pad_lower1 = pla0.union(plc1)
bu1 = [(ox1 + 100, oy + pad_height - 50), (ox1 + 200, oy + pad_height - 50),
(ox1 + 200, oy + pad_height - 200), (ox1 + 100, oy + pad_height - 200)]
puc1 = Polygon(bu1)
pad_upper1 = qum.union(puc1)
cell.add_to_layer(pad_layer, short_lower1, short_upper1, pad_lower1, pad_upper1)
cross_p = CrossMarker(origin=(ox-100, oy+pad_height - 250),
cross_length=12.5, cross_width=2.5, paddle_length=12.5, paddle_width=2.5)
cross_q = CrossMarker(origin=(ox-100, oy+pad_height + 250),
cross_length=12.5, cross_width=2.5, paddle_length=12.5, paddle_width=2.5)
cross_r = CrossMarker(origin=(ox+400, oy+pad_height - 250),
cross_length=12.5, cross_width=2.5, paddle_length=12.5, paddle_width=2.5)
tag = Text(origin=(ox-50, oy+pad_height - 250), height=40, text=label,
alignment='left-center')
cell.add_to_layer(align_layer, cross_p, cross_q, cross_r, tag)
return cell
import numpy as np
from gdshelpers.geometry.chip import Cell
top_cell = Cell("top")
xa = np.linspace(0, 5000, 6)
yb = np.linspace(0, 5000, 6)
pa = np.linspace(24, 48, 12)
x = xa.tolist()
y = yb.tolist()
tag_1 = ["A","B", "C", "D", "E", "F"]
tag_2 = ["1", "2", "3", "4", "5", "6"]
ind = [0,1,2,3,4,5]
for i1 in ind:
ta = tag_1[i1]
yi = y[i1]
for i2 in ind:
tb = tag_2[i2]
tag = ta+tb
p = int(pa[i2])
xi = x[i2]
if yi < 3000:
cell_i = single_finger_idt_sw(fw=1, frequency=1, wavelength=4, periods=p, height=20, surface_velocity=1, offset=1,
finger_layer=1, pad_layer=2, align_layer=3, coords=(0, 0), label=tag)
top_cell.add_cell(cell_i, origin=(xi, yi), angle=0)
else:
cell_i = double_finger_idt_wp(fw=1, frequency=1, wavelength=4, periods=p, height=20, surface_velocity=1,
offset=1, finger_layer=1, pad_layer=2, align_layer=3, coords=(0, 0), label=tag)
top_cell.add_cell(cell_i, origin=(xi, yi), angle=0)
top_cell.save("ufIDT20210525.gds")