forked from huangqiangsheng/Ruby_mask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGratingCoupler_class.rb
288 lines (268 loc) · 11.4 KB
/
GratingCoupler_class.rb
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
load "waveguide.rb"
#creat grating coupler
class GratingCoupler
include MyBasic
include RBA
attr_accessor :period, :duty, :width_in, :width_out, :grating_length,
:taper_length, :layer_grating, :dbu
def initialize(period = 0.64,
duty = 0.38,
width_in = 0.45,
width_out = 10.0,
grating_length = 15.0,
taper_length = 150.0,
layer_grating = CellView::active.layout.layer(1, 0),
dbu = CellView::active.layout.dbu)
@dbu = dbu
@period = period/@dbu
@duty = duty
@width_in = width_in/@dbu
@width_out = width_out/@dbu
@grating_length = grating_length/@dbu
@behind_length = 5.0/@dbu
@taper_length = taper_length/@dbu
@layer_grating = layer_grating
@ports = []
end
def shapes(cell)
pts = [DPoint::new(0.0,0.0),DPoint::new(@taper_length,0.0)]
@ports.push(Ports::new(width = @width_in,
direction = line_angle(pts[1],pts[0]),
face_angle = direction+Math::PI/2.0,
point = pts[0]))
taper = Taper.new(pts,@width_in,@width_out,'x')
cell.shapes(@layer_grating).insert(taper.poly)
grtg_len = 0
while grtg_len < @grating_length do
pts = [DPoint::new(@taper_length+grtg_len+@period*(1-@duty),0.0),
DPoint::new(@taper_length+grtg_len+@period,0.0)]
wg = Waveguide.new(pts,@width_out)
cell.shapes(@layer_grating).insert(wg.poly)
grtg_len = grtg_len+@period
end
pts = [DPoint::new(@taper_length+grtg_len+@period*(1-@duty),0.0),
DPoint::new(@taper_length+grtg_len+@behind_length,0.0)]
wg = Waveguide.new(pts,@width_out)
cell.shapes(@layer_grating).insert(wg.poly)
end
def ports
return @ports
end
end
class FocusingGratingCoupler
# reference :'Reflectionless grating couplers for Silicon-on-Insulator photonic integrated circuits'
# reference :'Compact Focusing Grating Couplers for Silicon-on-Insulator Integrated Circuits'
include MyBasic
include RBA
attr_accessor :period, :duty, :width_in, :width_out, :grating_length,
:taper_length, :layer_grating,
:phi, :nc, :lambda0, :eta, :r0, :dbu
def initialize(period = 0.64,
duty = 0.50,
width_in = 0.5,
width_out = 0.5,
grating_length =15.5,
taper_length = 1.0,
phi = 10.0, #incident angle
nc = 1.0, #cladding index
lambda0 = 1.55, #centre wavelength
eta = 36.56, #aperture opening angle degree
r0 = 12.5, #focusing length
layer_grating = CellView::active.layout.layer(1, 0),
dbu = CellView::active.layout.dbu)
@dbu = dbu
@period = period/@dbu
@duty = duty
@width_in = width_in/@dbu
@width_out = width_out/@dbu
@grating_length = grating_length/@dbu
@taper_length = taper_length/@dbu
@phi = phi
@nc = nc
@lambda0 = lambda0/@dbu
@ns = @lambda0/@period+@nc*Math::sin(@phi/180.0*Math::PI)
@eta = eta
@r0 = r0/@dbu
@layer_grating = layer_grating
@ports = []
end
def shapes(cell)
shape = []
pts = [DPoint::new(0.0,0.0),DPoint::new(@taper_length,0.0)]
@ports.push(Ports::new(width = @width_in,
direction = line_angle(pts[1],pts[0]),
face_angle = direction+Math::PI/2.0,
point = pts[0]))
taper = Taper.new(pts,@width_in,@width_out,'x')
shape.push(taper.poly)
pts = [DPoint::new(@taper_length,@width_out/2.0),DPoint::new(@taper_length,-@width_out/2.0)]
start_angle = -@eta/2.0
end_angle = @eta/2.0
f0 = DPoint::new(@taper_length,0.0)
q = @r0*(1-@nc/@ns*Math::sin(@phi/180.0*Math::PI))*@ns/@lambda0
a = q * @lambda0 * @ns/(@ns**2-(@nc*Math::sin(@phi/180.0*Math::PI))**2)
e = @nc*Math::sin(@phi/180.0*Math::PI)/@ns
pts = pts + linearc_ellipse(f0,a,e,start_angle,end_angle)
poly = DPolygon.new(pts)
shape.push(Polygon::from_dpoly(poly))
grtg_len = 0
q -= @duty/2.0
while grtg_len < @grating_length do
q = q+1.0
a = q * @lambda0 * @ns/(@ns**2-(@nc*Math::sin(@phi/180.0*Math::PI))**2)
e = @nc*Math::sin(@phi/180.0*Math::PI)/@ns
pts = linearc_ellipse(f0,a,e,start_angle,end_angle)
shape.push(Waveguide.new(pts,@duty*@period).poly)
grtg_len = grtg_len+@period
end
shape.each {|p| cell.shapes(@layer_grating).insert(p)}
end
def ports
return @ports
end
end
class ReflectionlessFocusingGratingCoupler < FocusingGratingCoupler
# reference :'Reflectionless grating couplers for Silicon-on-Insulator photonic integrated circuits'
# reference :'Compact Focusing Grating Couplers for Silicon-on-Insulator Integrated Circuits'
include MyBasic
include RBA
attr_accessor :delta, :bend_radius, :straight_length
def initialize(delta = 30.0,
bend_radius = 50.0,
straight_length = 28.4,
period = 0.551,
duty = 0.40,
width_in = 0.65,
width_out = 1.0,
grating_length =21.5,
taper_length = 30.0,
phi = 10.0, #incident angle
nc = 1.543, #cladding index
lambda0 = 1.55, #centre wavelength
eta = 56.0, #aperture opening angle degree
r0 = 16.54, #focusing length
layer_grating = CellView::active.layout.layer(1, 0),
dbu = CellView::active.layout.dbu)
super(period,duty,width_in,width_out,grating_length,taper_length,phi,nc,lambda0,eta,r0,layer_grating,dbu)
@delta = delta
@bend_radius = bend_radius/@dbu
@straight_length = straight_length/@dbu
@ns = @lambda0/@period+@nc*Math::sin(@phi/180.0*Math::PI)*Math::cos(@delta/180.0*Math::PI)
end
def shapes(cell)
shape = []
#r0 = @r0*(@ns-@nc*Math::sin(@phi/180.0*Math::PI)*Math::cos(@delta/180.0*Math::PI))/(@ns-@nc*Math::sin(@phi/180.0*Math::PI))
pts = [DPoint::new(0.0,0.0),DPoint::new(-@straight_length,0.0)]
@ports.push(Ports::new(width = @width_in,
direction = line_angle(pts[1],pts[0]),
face_angle = direction+Math::PI/2.0,
point = pts[0]))
centre = DPoint::new(-@straight_length,-@bend_radius)
pts += linearc(centre,@bend_radius,90.0,120.0)
offset = 2.0/@dbu
pts += [pts[-1] - DPoint::new(offset*Math::cos(@delta/180.0*Math::PI),offset*Math::sin(@delta/180.0*Math::PI))]
wg = Waveguide.new(pts,@width_in)
shape.push(wg.poly)
pts2 = [pts[-1],pts[-1]+DPoint::new(-taper_length*Math::cos(@delta/180.0*Math::PI),-taper_length*Math::sin(@delta/180.0*Math::PI))]
taper = Taper.new(pts2,@width_in,@width_out)
shape.push(taper.poly)
pts3 = [pts2[-1] + DPoint::new(-@width_out/2.0*Math::sin(@delta/180.0*Math::PI),@width_out/2.0*Math::cos(@delta/180.0*Math::PI)),
pts2[-1] + DPoint::new(@width_out/2.0*Math::sin(@delta/180.0*Math::PI),-@width_out/2.0*Math::cos(@delta/180.0*Math::PI))]
start_angle =-@eta/2.0-@delta
end_angle = @eta/2.0-@delta
f0 = DPoint::new(-pts2[-1].x,pts2[-1].y)
q = @r0*(1-@nc/@ns*Math::sin(@phi/180.0*Math::PI)*Math::cos(@delta/180.0*Math::PI))*@ns/@lambda0
a = q * @lambda0 * @ns/(@ns**2-(@nc*Math::sin(@phi/180.0*Math::PI))**2)
e = @nc*Math::sin(@phi/180.0*Math::PI)/@ns
tmp_pts = linearc_ellipse(f0,a,e,start_angle,end_angle)
tmp_pts.collect! {|p| DPoint::new(-p.x,p.y)}
pts = pts3 + tmp_pts
poly = DPolygon.new(pts)
shape.push(Polygon::from_dpoly(poly))
q -= (duty/2.0)
grtg_len = 0
while grtg_len < @grating_length do
q = q+1.0
a = q * @lambda0 * @ns/(@ns**2-(@nc*Math::sin(@phi/180.0*Math::PI))**2)
e = @nc*Math::sin(@phi/180.0*Math::PI)/@ns
pts = linearc_ellipse(f0,a,e,start_angle,end_angle)
pts.collect! {|p| DPoint::new(-p.x,p.y)}
shape.push(Polygon::from_dpoly(DPath.new(pts,@duty*@period,@duty*@period/2.0,@duty*@period/2.0,true).polygon))
grtg_len = grtg_len+@period
end
shape.each {|p| cell.shapes(@layer_grating).insert(p)}
end
def ports
return @ports
end
end
class ReflectionlessFocusingGratingCoupler_220nmSOI_70nmetch_1550nm < ReflectionlessFocusingGratingCoupler
# reference :'Reflectionless grating couplers for Silicon-on-Insulator photonic integrated circuits'
# reference :'Compact Focusing Grating Couplers for Silicon-on-Insulator Integrated Circuits'
def initialize(delta = 30.0, #title angle
bend_radius = 50.0, #minmum bending radius
straight_length = 28.4, #extended straight wg length
period = 0.551,
duty = 0.40,
width_in = 0.65,
width_out = 1.0,
grating_length =21.5,
taper_length = 30.0,
phi = 10.0, #incident angle
nc = 1.543, #cladding index
lambda0 = 1.55, #centre wavelength
eta = 56.0, #aperture opening angle degree
r0 = 16.54, #focusing length
layer_grating = CellView::active.layout.layer(1, 0),
dbu = CellView::active.layout.dbu)
super(delta,bend_radius,straight_length,period,duty,width_in,width_out,grating_length,taper_length,phi,nc,lambda0,eta,r0,layer_grating,dbu)
end
end
class FocusingGratingCoupler_220nmSOI_70nmetch_1550nm < FocusingGratingCoupler
def initialize(period = 0.63,
duty = 0.50,
width_in = 0.5,
width_out = 0.5,
grating_length =15.5,
taper_length = 1.0,
phi = 10.0, #incident angle
nc = 1.0, #cladding index
lambda0 = 1.55, #centre wavelength
eta = 36.56, #aperture opening angle degree
r0 = 12.5, #focusing length
layer_grating = CellView::active.layout.layer(1, 0),
dbu = CellView::active.layout.dbu)
super(period,duty,width_in,width_out,grating_length,taper_length,phi,nc,lambda0,eta,r0,layer_grating,dbu)
end
end
class GratingCoupler_340nmSOI_200nmetch_1550nm < GratingCoupler
def initialize(period = 0.64,
duty = 0.38,
width_in = 0.45,
width_out = 10.0,
grating_length = 15.0,
taper_length = 150.0,
layer_grating = CellView::active.layout.layer(1, 0),
dbu = CellView::active.layout.dbu)
super(period,duty,width_in,width_out,grating_length,taper_length,layer_grating,dbu)
end
end
# create a new view (mode 1) with an empty layout
if __FILE__ == $0
include MyBasic
include RBA
# create a new view (mode 1) with an empty layout
main_window =Application::instance.main_window
layout = main_window.create_layout(1).layout
layout_view = main_window.current_view
# set the database unit (shown as an example, the default is 0.001)
dbu = 0.001
layout.dbu = dbu
# create a cell
cell = layout.create_cell("GC_340nm")
gcoupler = GratingCoupler_340nmSOI_200nmetch_1550nm.new()
gcoupler.shapes(cell)
layout_view.select_cell(cell.cell_index, 0)
layout_view.add_missing_layers
layout_view.zoom_fit
end