-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDoseTest_gdsCode.py
409 lines (354 loc) · 18.4 KB
/
DoseTest_gdsCode.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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 21 22:43:48 2016
@author: shintaro
"""
#import gdsCAD as gds
import gdspy as gds
import numpy as np
def saveCell2GDS(cell, gdsName):
""" This function save the given cell to GDS file with the name 'gdsName' """
layout = gds.GdsLibrary()
layout.add(cell, overwrite_duplicate=True)
layout.write_gds(gdsName+'.gds')
def createIDT3(period=[1, 3], # [initial period (um), final periof (um) (> initial period)]
idt_type = 3, # 1: single, 2: double 3: Split 52
center_length = 30, # [um]
edge_length = 35, # [um]
gap_length = 1, # [um] (if 0 there is no diffraction finger.)
metal_ratio = 1, # Ratio set to compensate proximity
# period_in_time = 40, # [ns] (period = ceil(period_in_time [ns] * saw_velocity [um/ns] / period [um]))
total_period = 100, #Total number of periods
saw_velocity = 2.77, # [um/ns]
cell_name = '', # name of the cell
layer = 1, # layer for idt
datatype = 0, # datatype for idt
pad_layer = 2, # layer number for bonding pad
pad_datatype = 0, # datatype for bonding pad
inv_GND_layer = 3, # layer number for inverse of GND plane
inv_GND_datatype = 0, # datatype for inverse of GND plane
):
"""
This function create a cell containing IDT with/without bonding pad.
"""
edge_configs = {
'single':[1,-1],
'double':[1,1,-1,-1],
'split52':[1,1,-1,0,-1],
'split4':[1,1,1,1,-1,-1,-1,-1],
'unidir':[-1,-2,-9,1],
'unidir0':[-1,-2,-9,1,2,9],
'unidir1':[-2,-9,-1,2,9,1],
'double3':[-1,-1,3,9],
'DART':[1,-3,-9,-1],
'iDART':[1,-1,-3,-9]
}
# MEANING OF NUMBERS:
# 0 ... floating
# +-1 ... single finger up/down
# +-2,+-9 ... double-width finger up/down
# +-3,+-9 ... tripple-width finger up/down;
# +-9 ... skip this finger
pad = 0
if idt_type == 1:
suffix = 'single'
elif idt_type == 2:
suffix = 'double'
elif idt_type == 3:
suffix = 'split52'
elif idt_type == 4:
suffix = 'split4'
elif idt_type == 5:
suffix = 'unidir'
elif idt_type == 6:
suffix = 'unidir0'
elif idt_type == 7:
suffix = 'unidir1'
elif idt_type == 8:
suffix = 'double3'
elif idt_type == 10:
suffix = 'DART'
elif idt_type == 11:
suffix = 'iDART'
edge_config = edge_configs[suffix]
if cell_name == '':
cell_name = 'idt'+str(int(period[0]*1000))+'-'+str(int(period[1]*1000))+'_'+suffix
idt = gds.Cell(cell_name, exclude_from_current=True)
# total_period = np.ceil(period_in_time * saw_velocity / ((period[0] + period[1])/2))
total_period = int(40 * saw_velocity / ((period[0] + period[1])/2))
total_length = total_period * (period[0] + period[1])/2
noFingerPerPeriod = len(edge_config)
center_pos = - total_length/2
x_compensation = (period[1]-period[0])/(2*2*noFingerPerPeriod)/2 # compensate x to keep symmetry about x for chirped IDTs
for i in range(total_period):
current_period = period[0]+(period[1]-period[0])/(total_period-1) * i
current_width = current_period /(2*noFingerPerPeriod)
proximity_width = current_width * metal_ratio
center_pos += current_period/2
for j, c in enumerate(edge_config):
x = center_pos - (noFingerPerPeriod - 1 - 2*j)*current_width + x_compensation
if c > 0:
sign = +1; connect = 1
elif c < 0:
sign = -1; connect = 1
elif c == 0:
sign = +1; connect = 0
y0 = - sign*center_length/2
y1 = sign*(center_length/2 + connect*edge_length)
if np.abs(c) == 1:
tempwidth = proximity_width
elif np.abs(c) == 2:
tempwidth = current_width*2.0 * metal_ratio
x += current_width
elif np.abs(c) == 3:
tempwidth = current_width*3.0 * metal_ratio
x += current_width
if np.abs(c) == 9:
dummy=0 # do nothing
else:
p = gds.PolyPath([(x,y0),(x,y1)],width=tempwidth, layer=layer, datatype=datatype)
idt.add(p)
# add additional fingers at side
if not gap_length == 0:
y2 = - center_length/2 - edge_length
y3 = - center_length/2 - gap_length
if c >= 0:
p = gds.PolyPath([(x,y2),(x,y3)],width=tempwidth, layer=layer, datatype=datatype)
idt.add(p)
if c <= 0:
p = gds.PolyPath([(x,-y2),(x,-y3)],width=tempwidth, layer=layer, datatype=datatype)
idt.add(p)
center_pos += current_period/2
# start creating bondig pad
overlap = 10 # Keep overlap of 10 [um] between the edge of IDT and pad
space2GND = 20 # Distance between the IDT and GND plane
padX_extra = 200 # Extra length for X of signal pad [um]
padY = 60 # Y size of signal pad [um]
pad = gds.Cell(cell_name+'_pad', exclude_from_current=True)
# Protection of the core part of the IDT
x0 = - total_length/2 - space2GND
y0 = - center_length/2 - edge_length + overlap
p = gds.Rectangle((x0,y0),(-x0,-y0), layer=inv_GND_layer, datatype=inv_GND_datatype)
pad.add(p)
# pad for signal pad
x0 = - total_length/2 - space2GND - padX_extra
y0 = center_length/2 + edge_length - overlap
x1 = total_length/2 + space2GND
y1 = y0 + padY
p = gds.Rectangle((x0,y0),(x1,y1), layer=pad_layer, datatype=pad_datatype)
pad.add(p)
# Protection of the signal pad
x0b = x0 - 2*space2GND
y0b = y0 - 2*space2GND
x1b = x1 + 2*space2GND
y1b = y1 + 2*space2GND
p = gds.Rectangle((x0b,y0b),(x1b,y1b), layer=inv_GND_layer, datatype=inv_GND_datatype)
pad.add(p)
return (idt, pad)
"""----------------
Utility functions
-------------------"""
def create_IDT_pair(name = 'pair', # Name of the cell
idt1 = createIDT3(), # Left IDT
idt2 = createIDT3(), # Right IDT
detector = None, # Detector IDT (Not created if None)
distance = 100, # [ns]
saw_velocity = 2.77, # [um/ns] SAW velocity
):
"""
Create a pair of IDTs for VNA measurement.
- This function is supposed to be used with createIDT3().
"""
pair = gds.Cell(name, exclude_from_current=True) # Cell to hold pairs
# distance_in_length = distance * saw_velocity # Distance between front of IDTs in [um]
distance_in_length = 130 # Distance between front of IDTs in [um]
pattern = [pair, idt1[0], idt1[1], idt2[0], idt2[1]]
# Add left IDT
bounding_box = idt1[0].get_bounding_box()
w = bounding_box[1][0] - bounding_box[0][0]
l = bounding_box[1][1] - bounding_box[0][1]
idt = gds.CellReference(idt1[0], origin=(-(distance_in_length+w)/2, 0))
pair.add(idt)
pad = gds.CellReference(idt1[1], origin=(-(distance_in_length+w)/2, 0))
pair.add(pad)
# Add right IDT
bounding_box = idt2[0].get_bounding_box()
w = bounding_box[1][0] - bounding_box[0][0]
l = max(l, (bounding_box[1][1] - bounding_box[0][1]))
idt = gds.CellReference(idt2[0], origin=((distance_in_length+w)/2, 0))
pair.add(idt)
pad = gds.CellReference(idt2[1], origin=((distance_in_length+w)/2, 0), rotation=180, x_reflection=True)
pair.add(pad)
# Get layer for pad and inverse GND from idt1
# Here we assume the layer number of pad < the layer number of inverse GND.
# Datatype of both is set to 0.
# layers = pair.get_bounding_box()
layers = list(idt1[1].get_layers())
inv_GND_layer = layers[1]
pair.add(gds.Rectangle((-distance_in_length/2, -l/2),(distance_in_length/2, l/2),layer=inv_GND_layer, datatype=0))
return pattern
def createMarks(nx = 4,
ny = 16,
dx = 3000,
dy = 600,
):
"""
Create marks at the junction of the lattice
"""
# Mark for EB
crmk = gds.Cell('cross', exclude_from_current=True)
crmk.add(gds.Rectangle((-100,-10),(-10, 10),layer=2, datatype=0))
crmk.add(gds.Rectangle((-120, -30),(10, 30),layer=3, datatype=0))
crmk.add(gds.Rectangle((100,-10),(10,10),layer=2, datatype=0))
crmk.add(gds.Rectangle((120,-30),(-10,30),layer=3, datatype=0))
crmk.add(gds.Rectangle((-10,-100),(10,-10),layer=2, datatype=0))
crmk.add(gds.Rectangle((-30,-120),(30, 10),layer=3, datatype=0))
crmk.add(gds.Rectangle((-10,100),(10,10),layer=2, datatype=0))
crmk.add(gds.Rectangle((-30,120),(30,-10),layer=3, datatype=0))
crmk.add(gds.Rectangle((-4,0),(0,1),layer=2, datatype=0))
crmk.add(gds.Rectangle((-1,1),(0,4),layer=2, datatype=0))
crmk.add(gds.Rectangle((4,0),(0,-1),layer=2, datatype=0))
crmk.add(gds.Rectangle((1,-1),(0,-4),layer=2, datatype=0))
# Make array
mkar = gds.CellArray(crmk, 2, 2, (2000,2000), origin=(0, 0))
return crmk, mkar
"""----------------------------------------------------
Actual pattern for devices
----------------------------------------------------"""
def idt_20190407():
"""
This program is used to create a set of different types of IDTs:
---- List of IDTs -------------
1. single finger IDTs: 100 nm, 125 nm and 250 nm A60P60
2. split 52 IDTs: 100 nm, 125 nm, 275 nm and 550 nm
3. split 4 IDTs: 125 nm and 250 nm
1, 2 Standard IDT without diffraction fingers [double finger, lambda = 1 um, period = 60, aperature = 30]
3~64. Split52 IDT (lambda = 2.76 [um]), period = [40, 60, 80, 100, 120] * aperature = [30, 60, 90, 120] * diffraction = [no (10 um), no (20 um), 1*lambda]
"""
dx = 500 # distance between set of IDTs [um]
dy = 200 # distance between set of IDTs [um]
nx = 4
ny = 10
space = 1000 # Space along the edge
idt_distance = 300 # distance between 2 IDTs [ns]
saw_velocity = 2.77 # [um/ns]
# define top cell
top = gds.Cell('TOP', exclude_from_current=True)
# Add top cell to pattern list
pattern = [top]
types1 = np.array( [
[2,2,2,2,2,2,2,2,2,2,2,2,2,2,11,10], # single finger and "special" double finger
[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10], # split 52
[10,10,10,10,10,10,10,10,10,10,10,10,0,10,11,10], #
[10,10,10,10,10,10,10,10,10,10,10,10,0,10,2,10] # split 4 and "special" IDTs
])
types2 = np.array( [
[2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,2], # single finger and "special" double finger
[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], # split 52
[11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,2], #
[11,11,11,11,11,11,11,11,11,11,11,11,11,11,2,2] # split 4 and "special" IDTs
])
wavelengths = np.array( [
[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,2,2,1,1,1,1],
[0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.5,0.5,0.75,0.75],
[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1,1,2,2,2,2],
[0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,1,1,2,2]
]) #[um]
total_periods = np.array( [
[90,90,90,90,90,90,90,90,90,90,110,110,110,110,110,110],
[90,90,90,90,90,90,90,90,90,90,110,110,90,90,90,90],
[110,110,110,110,110,110,110,110,90,90,90,90,90,90,90,90],
[110,110,110,110,90,90,90,90,130,130,130,130,130,130,130,130]
]) #Number of periods - transmitter
# total_periods2 = np.array( [
# [90,90,90,90,90,90,90,90,110,110,110,110,110,110,110,110],
# [130,130,130,130,130,130,130,130,110,110,110,110,90,90,90,90],
# [110,110,110,110,110,110,110,110,90,90,90,90,90,90,90,90],
# [110,110,110,110,90,90,90,90,130,130,130,130,130,130,130,130]
# ]) #Number of periods - reciever
apertures = np.array( [
[30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30],
[30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30],
[30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30],
[30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]
]) #[um]
# define IDTs
count = 0
for i in range(nx):
for j in range(ny):
xc = dx/2+i*dx
yc = dy/2+j*dy
idt1 = createIDT3(period=[wavelengths[i,j], wavelengths[i,j]], # [initial period (um), final periof (um) (> initial period)]
idt_type = types1[i,j], # 1: single, 2: double 3: Split 52
center_length = apertures[i,j], # [um]
edge_length = 65-apertures[i,j], # [um]
gap_length = 0, # [um] (if 0 there is no diffraction finger.)
metal_ratio = 1, # Ratio set to compensate proximity
# period_in_time = periods_in_time[i,j], # [ns] (period = ceil(period_in_time [ns] * saw_velocity [um/ns] / period [um]))
total_period = total_periods[i,j], #Number of periods
saw_velocity = saw_velocity, # [um/ns]
cell_name = 'didt_%d_%d' % (i,j), # name of the cell
layer = 1, # layer for idt
datatype = 0, # datatype for idt
pad_layer = 5, # layer number for bonding pad
pad_datatype = 0, # datatype for bonding pad
inv_GND_layer = 3, # layer number for inverse of GND plane
inv_GND_datatype = 0, # datatype for inverse of GND plane
)
# if types2[i,j] == 2:
# total_period2 = 110
# else:
total_period2 = total_periods[i,j]
idt2 = createIDT3(period=[wavelengths[i,j], wavelengths[i,j]], # [initial period (um), final periof (um) (> initial period)]
idt_type = types2[i,j], # 1: single, 2: double 3: Split 52
center_length = apertures[i,j], # [um]
edge_length = 65-apertures[i,j], # [um]
gap_length = 0, # [um] (if 0 there is no diffraction finger.)
metal_ratio = 1, # Ratio set to compensate proximity
# period_in_time = periods_in_time[i,j], # [ns] (period = ceil(period_in_time [ns] * saw_velocity [um/ns] / period [um]))
total_period = total_period2, #Number of periods
saw_velocity = saw_velocity, # [um/ns]
cell_name = 'didt_%d_%d_detect' % (i,j), # name of the cell
layer = 1, # layer for idt
datatype = 0, # datatype for idt
pad_layer = 5, # layer number for bonding pad
pad_datatype = 0, # datatype for bonding pad
inv_GND_layer = 3, # layer number for inverse of GND plane
inv_GND_datatype = 0, # datatype for inverse of GND plane
)
pair = create_IDT_pair(name = 'didt_pair_%d_%d' % (i,j), # Name of the cell
idt1 = idt1, # Left IDT
idt2 = idt2, # Right IDT
detector = None, # Detector IDT (Not created if None)
distance = idt_distance, # [ns]
saw_velocity = saw_velocity, # [um/ns] SAW velocity
)
# Add idt cell to pattern list
pattern += pair
idt1 = gds.CellReference(pair[0], origin=(xc, yc))
top.add(idt1)
print('The center position of the (%d,%d) pair cell is (xc=%d,yc=%d)' %(i,j,xc,yc) )
print('The center position of the first IDT in the pair is (%d,%d)' %(xc-idt_distance*saw_velocity/2-total_periods[i,j]*wavelengths[i,j]/2,yc))
print('The center position of the second IDT in the pair is (%d,%d)' %(xc+idt_distance*saw_velocity/2+total_period2*wavelengths[i,j]/2,yc))
# GND plane before boolean
# top.add(gds.Rectangle((-dx*nx/2-space, -dy*ny/2-space),(dx*nx/2+space, dy*ny/2+space), layer=4, datatype=0))
top.add(gds.Rectangle((0, 0),(2000, 2000), layer=4, datatype=0))
# Add square at corners for EB positioning
top.add(gds.Rectangle((-dx*nx/2-space, -dy*ny/2-space),(-dx*nx/2-space+0.05, -dy*ny/2-space+0.05), layer=1, datatype=0))
top.add(gds.Rectangle((-dx*nx/2-space, dy*ny/2+space),(-dx*nx/2-space+0.05, dy*ny/2+space-0.05), layer=1, datatype=0))
top.add(gds.Rectangle((dx*nx/2+space, -dy*ny/2-space),(dx*nx/2+space-0.05, -dy*ny/2-space+0.05), layer=1, datatype=0))
top.add(gds.Rectangle((dx*nx/2+space, dy*ny/2+space),(dx*nx/2+space-0.05, dy*ny/2+space-0.05), layer=1, datatype=0))
# Make EB marks
crmk, mkar = createMarks(nx = nx,
ny = ny,
dx = dx,
dy = dy,
)
pattern.append(crmk)
top.add(mkar)
saveCell2GDS(pattern, 'idt_DoseTest')
if __name__=='__main__':
# saveCell2GDS(createIDT2(), 'didt125')
# saveCell2GDS(ebDummy(),'test')
# idt_20181031()
idt_20190407()