optical pins name revised. Pin type added

This commit is contained in:
=
2026-06-07 22:56:33 +08:00
parent a4ac88f002
commit 8462c3397f
262 changed files with 3251 additions and 1134 deletions
+345 -115
View File
@@ -175,11 +175,19 @@ class W_waveguide:
# ISL(xs=self.xs_isl,width=self.w_isl,length=L_isl_side).cell.put('a1',self.L_wg,self.w_metal/2+self.sp_isl_xs,90)
if (self.reverse):
nd.Pin(name='b1',pin=wg_begin.pin['a0']).put()
nd.Pin(name='a1',pin=wg_end.pin['b0']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b1',pin=wg_begin.pin['a0']).put()
nd.Pin(name='opt_b1',pin=wg_begin.pin['a0'],type="optical:").put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a1',pin=wg_end.pin['b0']).put()
nd.Pin(name='opt_a1',pin=wg_end.pin['b0'],type="optical:").put()
else :
nd.Pin(name='a1',pin=wg_begin.pin['a0']).put()
nd.Pin(name='b1',pin=wg_end.pin['b0']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a1',pin=wg_begin.pin['a0']).put()
nd.Pin(name='opt_a1',pin=wg_begin.pin['a0'],type="optical:").put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b1',pin=wg_end.pin['b0']).put()
nd.Pin(name='opt_b1',pin=wg_end.pin['b0'],type="optical:").put()
return C
@@ -324,13 +332,21 @@ class UMat_2x2_S:
with nd.Cell(name=self.name,instantiate=instantiate) as MZI_Unit:
pic_strip = Route(radius=self.R_bend,width=self.w_wg,xs=self.xs_wg)
self.dL_BS = np.abs(self.BS.pin['a1'].x - self.BS.pin['b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: self.dL_BS = np.abs(self.BS.pin['a1'].x - self.BS.pin['b1'].x)
self.dL_BS = np.abs(self.BS.pin['opt_a1'].x - self.BS.pin['opt_b1'].x)
## 2023.1.21 modified
dY_BS = abs(self.BS.pin['b1'].y - self.BS.pin['b2'].y)
## revised in 2026.06.07 by Qin Yue
# legacy: dY_BS = abs(self.BS.pin['b1'].y - self.BS.pin['b2'].y)
dY_BS = abs(self.BS.pin['opt_b1'].y - self.BS.pin['opt_b2'].y)
BS_L = self.BS.put('b1',-2*self.R_bend - self.L_arm/2-1,dY_BS/2,180)
BS_R = self.BS.put('a2', 2*self.R_bend + self.L_arm/2+1,dY_BS/2,0,flip=1)
## revised in 2026.06.07 by Qin Yue
# legacy: BS_L = self.BS.put('b1',-2*self.R_bend - self.L_arm/2-1,dY_BS/2,180)
BS_L = self.BS.put('opt_b1',-2*self.R_bend - self.L_arm/2-1,dY_BS/2,180)
## revised in 2026.06.07 by Qin Yue
# legacy: BS_R = self.BS.put('a2', 2*self.R_bend + self.L_arm/2+1,dY_BS/2,0,flip=1)
BS_R = self.BS.put('opt_a2', 2*self.R_bend + self.L_arm/2+1,dY_BS/2,0,flip=1)
if (self.bend_heaters):
wg_ht = W_waveguide(L_wg=self.L_arm,w_wg=self.w_wg,xs_wg=self.xs_wg,dL=self.dL_ht,R_bend=self.R_bend,
@@ -361,35 +377,75 @@ class UMat_2x2_S:
xs_heater=self.xs_heater,xs_metal=self.xs_metal).cell
if (self.ht_same_side):
wg_U = wg_oht.put('a1',-self.L_arm/2,self.D_arm/2,0)
wg_D = wg_ht.put('a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
## revised in 2026.06.07 by Qin Yue
# legacy: wg_U = wg_oht.put('a1',-self.L_arm/2,self.D_arm/2,0)
wg_U = wg_oht.put('opt_a1',-self.L_arm/2,self.D_arm/2,0)
## revised in 2026.06.07 by Qin Yue
# legacy: wg_D = wg_ht.put('a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
wg_D = wg_ht.put('opt_a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
else:
wg_U = wg_ht.put('a1',-self.L_arm/2,self.D_arm/2,0)
wg_D = wg_oht.put('a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
## revised in 2026.06.07 by Qin Yue
# legacy: wg_U = wg_ht.put('a1',-self.L_arm/2,self.D_arm/2,0)
wg_U = wg_ht.put('opt_a1',-self.L_arm/2,self.D_arm/2,0)
## revised in 2026.06.07 by Qin Yue
# legacy: wg_D = wg_oht.put('a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
wg_D = wg_oht.put('opt_a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
pic_strip.sbend_p2p(pin1=BS_L.pin['b1'],pin2=wg_U.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_L.pin['b2'],pin2=wg_D.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['a2'],pin2=wg_U.pin['b1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['a1'],pin2=wg_D.pin['b1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_L.pin['b1'],pin2=wg_U.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_L.pin['opt_b1'],pin2=wg_U.pin['opt_a1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_L.pin['b2'],pin2=wg_D.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_L.pin['opt_b2'],pin2=wg_D.pin['opt_a1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_R.pin['a2'],pin2=wg_U.pin['b1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['opt_a2'],pin2=wg_U.pin['opt_b1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_R.pin['a1'],pin2=wg_D.pin['b1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['opt_a1'],pin2=wg_D.pin['opt_b1']).put()
ps_U = wg_oht.put('b1',BS_L.pin['a1'].x-self.R_bend*2-1,self.D_arm/2,180,flip=1)
## revised in 2026.06.07 by Qin Yue
# legacy: ps_U = wg_oht.put('b1',BS_L.pin['a1'].x-self.R_bend*2-1,self.D_arm/2,180,flip=1)
ps_U = wg_oht.put('opt_b1',BS_L.pin['opt_a1'].x-self.R_bend*2-1,self.D_arm/2,180,flip=1)
ps_D = wg_ht.put('b1',BS_L.pin['a1'].x-self.R_bend*2-1,-self.D_arm/2,180,flip=0)
## revised in 2026.06.07 by Qin Yue
# legacy: ps_D = wg_ht.put('b1',BS_L.pin['a1'].x-self.R_bend*2-1,-self.D_arm/2,180,flip=0)
ps_D = wg_ht.put('opt_b1',BS_L.pin['opt_a1'].x-self.R_bend*2-1,-self.D_arm/2,180,flip=0)
pic_strip.sbend_p2p(pin1=ps_U.pin['b1'],pin2=BS_L.pin['a1']).put()
pic_strip.sbend_p2p(pin1=ps_D.pin['b1'],pin2=BS_L.pin['a2']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=ps_U.pin['b1'],pin2=BS_L.pin['a1']).put()
pic_strip.sbend_p2p(pin1=ps_U.pin['opt_b1'],pin2=BS_L.pin['opt_a1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=ps_D.pin['b1'],pin2=BS_L.pin['a2']).put()
pic_strip.sbend_p2p(pin1=ps_D.pin['opt_b1'],pin2=BS_L.pin['opt_a2']).put()
patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b2'].x+self.R_bend*2+1, self.D_arm/2,0)
patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b1'].x+self.R_bend*2+1,-self.D_arm/2,0)
## revised in 2026.06.07 by Qin Yue
# legacy: patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b2'].x+self.R_bend*2+1, self.D_arm/2,0)
patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['opt_b2'].x+self.R_bend*2+1, self.D_arm/2,0)
## revised in 2026.06.07 by Qin Yue
# legacy: patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b1'].x+self.R_bend*2+1,-self.D_arm/2,0)
patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['opt_b1'].x+self.R_bend*2+1,-self.D_arm/2,0)
pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_R.pin['b2']).put()
pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_R.pin['b1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_R.pin['b2']).put()
pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_R.pin['opt_b2']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_R.pin['b1']).put()
pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_R.pin['opt_b1']).put()
nd.Pin(name='a1',pin=ps_U.pin['a1'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='a2',pin=ps_D.pin['a1'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='b1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='b2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a1',pin=ps_U.pin['a1'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_a1',pin=ps_U.pin['opt_a1'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a2',pin=ps_D.pin['a1'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_a2',pin=ps_D.pin['opt_a1'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_b1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_b2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
nd.Pin(name='ep1',pin=ps_D.pin['ep1']).put()
nd.Pin(name='en1',pin=ps_D.pin['en1']).put()
@@ -401,8 +457,12 @@ class UMat_2x2_S:
nd.Pin(name='ep2',pin=wg_U.pin['ep1']).put()
nd.Pin(name='en2',pin=wg_U.pin['en1']).put()
dX_unit = abs(ps_U.pin['a1'].x - patch_U.pin['b0'].x)
dY_unit = abs(ps_U.pin['a1'].y - ps_D.pin['a1'].y)
## revised in 2026.06.07 by Qin Yue
# legacy: dX_unit = abs(ps_U.pin['a1'].x - patch_U.pin['b0'].x)
dX_unit = abs(ps_U.pin['opt_a1'].x - patch_U.pin['b0'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: dY_unit = abs(ps_U.pin['a1'].y - ps_D.pin['a1'].y)
dY_unit = abs(ps_U.pin['opt_a1'].y - ps_D.pin['opt_a1'].y)
return MZI_Unit
@@ -569,8 +629,12 @@ class MZI_mesh_U:
strip.bend_route(radius=R_compensate,angle=90).put()
strip_output = strip.strt(length=0.2).put()
nd.Pin(name='a1',width=self.w_wg).put(strip_input.pin['a0'])
nd.Pin(name='b1',width=self.w_wg).put(strip_output.pin['b0'])
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a1',width=self.w_wg).put(strip_input.pin['a0'])
nd.Pin(name='opt_a1',width=self.w_wg,type="optical:").put(strip_input.pin['a0'])
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b1',width=self.w_wg).put(strip_output.pin['b0'])
nd.Pin(name='opt_b1',width=self.w_wg,type="optical:").put(strip_output.pin['b0'])
nd.Pin(name='a0',width=self.w_wg).put(strip_input.pin['a0'])
nd.Pin(name='b0',width=self.w_wg).put(strip_output.pin['b0'])
return ICell
@@ -583,8 +647,12 @@ class MZI_mesh_U:
rows = self.n_ports-1
pic_strip = Route(radius=self.R_bend,width=self.w_wg,xs='strip')
dX_unit = abs(self.MZI_unit.pin['a1'].x-self.MZI_unit.pin['b1'].x)
dY_unit = abs(self.MZI_unit.pin['a1'].y-self.MZI_unit.pin['a2'].y)
## revised in 2026.06.07 by Qin Yue
# legacy: dX_unit = abs(self.MZI_unit.pin['a1'].x-self.MZI_unit.pin['b1'].x)
dX_unit = abs(self.MZI_unit.pin['opt_a1'].x-self.MZI_unit.pin['opt_b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: dY_unit = abs(self.MZI_unit.pin['a1'].y-self.MZI_unit.pin['a2'].y)
dY_unit = abs(self.MZI_unit.pin['opt_a1'].y-self.MZI_unit.pin['opt_a2'].y)
x_spacing = dX_unit ## incase of overlapping
y_spacing = dY_unit ## incase of overlapping
x_list = []
@@ -622,10 +690,16 @@ class MZI_mesh_U:
if (c_idx>=1 and r_idx==1): ### This will not happen in Triangle cases
# pic_strip.sbend_p2p(pin1=pin_up_pre,pin2=INSTR.pin['a1']).put()
pic_strip.strt(pin=pin_up_pre,length=self.L_arm).put()
bend_compensate = self.cell_compensate.put('a1',nd.Pin().put(),flip=True)
## revised in 2026.06.07 by Qin Yue
# legacy: bend_compensate = self.cell_compensate.put('a1',nd.Pin().put(),flip=True)
bend_compensate = self.cell_compensate.put('opt_a1',nd.Pin().put(),flip=True)
pic_strip.sbend_p2p(
pin1=bend_compensate.pin['b1'],
pin2=INSTR.pin['a1']
## revised in 2026.06.07 by Qin Yue
# legacy: pin1=bend_compensate.pin['b1'],
pin1=bend_compensate.pin['opt_b1'],
## revised in 2026.06.07 by Qin Yue
# legacy: pin2=INSTR.pin['a1']
pin2=INSTR.pin['opt_a1']
).put()
# self.cell_offset.put(flip=1)
# self.cell_offset.put(flip=0)
@@ -636,10 +710,16 @@ class MZI_mesh_U:
if (c_idx>=1 and r_idx==rows):
if self.mesh_type=='parallelogram':
pic_strip.strt(pin=pin_down_pre,length=self.L_arm).put()
bend_compensate = self.cell_compensate.put('a1',nd.Pin().put())
## revised in 2026.06.07 by Qin Yue
# legacy: bend_compensate = self.cell_compensate.put('a1',nd.Pin().put())
bend_compensate = self.cell_compensate.put('opt_a1',nd.Pin().put())
pic_strip.sbend_p2p(
pin1=bend_compensate.pin['b1'],
pin2=INSTR.pin['a2']
## revised in 2026.06.07 by Qin Yue
# legacy: pin1=bend_compensate.pin['b1'],
pin1=bend_compensate.pin['opt_b1'],
## revised in 2026.06.07 by Qin Yue
# legacy: pin2=INSTR.pin['a2']
pin2=INSTR.pin['opt_a2']
).put()
# self.cell_offset.put(flip=1)
# self.cell_offset.put(flip=0)
@@ -649,77 +729,151 @@ class MZI_mesh_U:
# pic_strip.sbend_p2p(pin2=pin_down_pre).put()
elif self.mesh_type=='triangle':
pic_strip.strt(pin=pin_down_pre,length=self.L_arm).put()
bend_compensate = self.cell_compensate.put('a1',nd.Pin().put())
## revised in 2026.06.07 by Qin Yue
# legacy: bend_compensate = self.cell_compensate.put('a1',nd.Pin().put())
bend_compensate = self.cell_compensate.put('opt_a1',nd.Pin().put())
pic_strip.sbend_p2p(
pin1=bend_compensate.pin['b1'],
pin2=INSTR.pin['a2']
## revised in 2026.06.07 by Qin Yue
# legacy: pin1=bend_compensate.pin['b1'],
pin1=bend_compensate.pin['opt_b1'],
## revised in 2026.06.07 by Qin Yue
# legacy: pin2=INSTR.pin['a2']
pin2=INSTR.pin['opt_a2']
).put()
# pic_strip.sbend_p2p(pin1=pin_down_pre,pin2=INSTR.pin['a2']).put()
pin_down_pre = INSTR.pin['b2']
pin_up_pre = INSTR.pin['b1']
## revised in 2026.06.07 by Qin Yue
# legacy: pin_down_pre = INSTR.pin['b2']
pin_down_pre = INSTR.pin['opt_b2']
## revised in 2026.06.07 by Qin Yue
# legacy: pin_up_pre = INSTR.pin['b1']
pin_up_pre = INSTR.pin['opt_b1']
""" recongizing pins """
if (self.mesh_type=='triangle'):
if (c_idx==0):
pin_a_list.append(INSTR.pin['a1'])
x_list.append(INSTR.pin['a1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_a_list.append(INSTR.pin['a1'])
pin_a_list.append(INSTR.pin['opt_a1'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['a1'].x)
x_list.append(INSTR.pin['opt_a1'].x)
if (c_idx==cols-1):
pin_b_list.append(INSTR.pin['b1'])
x_list.append(INSTR.pin['b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b1'])
pin_b_list.append(INSTR.pin['opt_b1'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b1'].x)
x_list.append(INSTR.pin['opt_b1'].x)
if (r_idx==rows):
if (c_idx==0):
pin_a_list.append(INSTR.pin['a2'])
x_list.append(INSTR.pin['a2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_a_list.append(INSTR.pin['a2'])
pin_a_list.append(INSTR.pin['opt_a2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['a2'].x)
x_list.append(INSTR.pin['opt_a2'].x)
elif (c_idx==cols-1):
pin_b_list.append(INSTR.pin['b2'])
x_list.append(INSTR.pin['b2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b2'])
pin_b_list.append(INSTR.pin['opt_b2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b2'].x)
x_list.append(INSTR.pin['opt_b2'].x)
else :
if (np.mod(self.n_ports,2)==1):
if (np.mod(r_idx,2)==1):
if (c_idx==0):
pin_a_list.append(INSTR.pin['a1'])
x_list.append(INSTR.pin['a1'].x)
pin_a_list.append(INSTR.pin['a2'])
x_list.append(INSTR.pin['a2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_a_list.append(INSTR.pin['a1'])
pin_a_list.append(INSTR.pin['opt_a1'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['a1'].x)
x_list.append(INSTR.pin['opt_a1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_a_list.append(INSTR.pin['a2'])
pin_a_list.append(INSTR.pin['opt_a2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['a2'].x)
x_list.append(INSTR.pin['opt_a2'].x)
if (c_idx==cols-1):
pin_b_list.append(INSTR.pin['b1'])
x_list.append(INSTR.pin['b1'].x)
pin_b_list.append(INSTR.pin['b2'])
x_list.append(INSTR.pin['b2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b1'])
pin_b_list.append(INSTR.pin['opt_b1'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b1'].x)
x_list.append(INSTR.pin['opt_b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b2'])
pin_b_list.append(INSTR.pin['opt_b2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b2'].x)
x_list.append(INSTR.pin['opt_b2'].x)
elif (r_idx==rows):
if (c_idx==0):
pin_a_list.append(INSTR.pin['a2'])
x_list.append(INSTR.pin['a2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_a_list.append(INSTR.pin['a2'])
pin_a_list.append(INSTR.pin['opt_a2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['a2'].x)
x_list.append(INSTR.pin['opt_a2'].x)
elif (c_idx==cols-1):
pin_b_list.append(INSTR.pin['b2'])
x_list.append(INSTR.pin['b2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b2'])
pin_b_list.append(INSTR.pin['opt_b2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b2'].x)
x_list.append(INSTR.pin['opt_b2'].x)
else :
if (np.mod(r_idx,2)==0 and c_idx==cols-1):
pin_b_list.append(INSTR.pin['b1'])
x_list.append(INSTR.pin['b1'].x)
pin_b_list.append(INSTR.pin['b2'])
x_list.append(INSTR.pin['b2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b1'])
pin_b_list.append(INSTR.pin['opt_b1'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b1'].x)
x_list.append(INSTR.pin['opt_b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b2'])
pin_b_list.append(INSTR.pin['opt_b2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b2'].x)
x_list.append(INSTR.pin['opt_b2'].x)
if (np.mod(r_idx,2)==1 and c_idx==0):
pin_a_list.append(INSTR.pin['a1'])
x_list.append(INSTR.pin['a1'].x)
pin_a_list.append(INSTR.pin['a2'])
x_list.append(INSTR.pin['a2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_a_list.append(INSTR.pin['a1'])
pin_a_list.append(INSTR.pin['opt_a1'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['a1'].x)
x_list.append(INSTR.pin['opt_a1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_a_list.append(INSTR.pin['a2'])
pin_a_list.append(INSTR.pin['opt_a2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['a2'].x)
x_list.append(INSTR.pin['opt_a2'].x)
if (r_idx==rows and c_idx==cols-1):
pin_b_list.append(INSTR.pin['b2'])
x_list.append(INSTR.pin['b2'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b2'])
pin_b_list.append(INSTR.pin['opt_b2'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b2'].x)
x_list.append(INSTR.pin['opt_b2'].x)
if (r_idx==1 and c_idx==cols-1):
pin_b_list.append(INSTR.pin['b1'])
x_list.append(INSTR.pin['b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: pin_b_list.append(INSTR.pin['b1'])
pin_b_list.append(INSTR.pin['opt_b1'])
## revised in 2026.06.07 by Qin Yue
# legacy: x_list.append(INSTR.pin['b1'].x)
x_list.append(INSTR.pin['opt_b1'].x)
xmax = np.max(x_list)
xmin = np.min(x_list)
@@ -735,10 +889,14 @@ class MZI_mesh_U:
for _num_ in range(num_compensate_cell) :
self.cell_compensate.put()
nd.strt(
length=abs(self.MZI_unit.pin['a1'].x-self.MZI_unit.pin['b1'].x)-abs(self.cell_compensate.pin['a1'].x-self.cell_compensate.pin['b1'].x),
## revised in 2026.06.07 by Qin Yue
# legacy: length=abs(self.MZI_unit.pin['a1'].x-self.MZI_unit.pin['b1'].x)-abs(self.cell_compensate.pin['a1'].x-self.cell_compensate.pin['b1'].x),
length=abs(self.MZI_unit.pin['opt_a1'].x-self.MZI_unit.pin['opt_b1'].x)-abs(self.cell_compensate.pin['opt_a1'].x-self.cell_compensate.pin['opt_b1'].x),
width=self.w_wg, xs=self.xs_wg
).put()
nd.Pin(name='a'+str(itn+1),pin=nd.Pin().put(),width=0.45).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a'+str(itn+1),pin=nd.Pin().put(),width=0.45).put()
nd.Pin(name='opt_a'+str(itn+1),pin=nd.Pin().put(),width=0.45,type="optical:").put()
nd.strt(length=0.2,width=self.w_wg,xs=self.xs_wg).put(pin_b_list[itn])
num_compensate_cell = len(pin_a_list)-2-itn
@@ -746,10 +904,14 @@ class MZI_mesh_U:
for _num_ in range(num_compensate_cell) :
self.cell_compensate.put(flip=True)
nd.strt(
length=abs(self.MZI_unit.pin['a1'].x-self.MZI_unit.pin['b1'].x)-abs(self.cell_compensate.pin['a1'].x-self.cell_compensate.pin['b1'].x),
## revised in 2026.06.07 by Qin Yue
# legacy: length=abs(self.MZI_unit.pin['a1'].x-self.MZI_unit.pin['b1'].x)-abs(self.cell_compensate.pin['a1'].x-self.cell_compensate.pin['b1'].x),
length=abs(self.MZI_unit.pin['opt_a1'].x-self.MZI_unit.pin['opt_b1'].x)-abs(self.cell_compensate.pin['opt_a1'].x-self.cell_compensate.pin['opt_b1'].x),
width=self.w_wg, xs=self.xs_wg
).put()
nd.Pin(name='b'+str(itn+1),pin=nd.Pin().put(),width=0.45).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b'+str(itn+1),pin=nd.Pin().put(),width=0.45).put()
nd.Pin(name='opt_b'+str(itn+1),pin=nd.Pin().put(),width=0.45,type="optical:").put()
elif self.mesh_type == "parallelogram" :
for itn in range(0,len(pin_a_list)):
@@ -757,17 +919,25 @@ class MZI_mesh_U:
nd.strt(length=self.L_arm,width=self.w_wg,xs=self.xs_wg).put(pin_a_list[itn])
temp = self.cell_compensate.put()
temp = nd.strt(length=abs(xmin-temp.pin['b0'].x),width=self.w_wg,xs=self.xs_wg).put()
nd.Pin(name='a'+str(itn+1) ,width=0.45, pin=temp.pin['b0'].move(-0.05,0,0)).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a'+str(itn+1) ,width=0.45, pin=temp.pin['b0'].move(-0.05,0,0)).put()
nd.Pin(name='opt_a'+str(itn+1) ,width=0.45, pin=temp.pin['b0'].move(-0.05,0,0),type="optical:").put()
else :
nd.Pin(name='a'+str(itn+1) ,width=0.45).put(pin_a_list[itn])
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a'+str(itn+1) ,width=0.45).put(pin_a_list[itn])
nd.Pin(name='opt_a'+str(itn+1) ,width=0.45,type="optical:").put(pin_a_list[itn])
if np.abs(xmax-pin_b_list[itn].x)>0.001 :
nd.strt(length=self.L_arm,width=self.w_wg,xs=self.xs_wg).put(pin_b_list[itn])
temp = self.cell_compensate.put(flip=(itn==0))
temp = nd.strt(length=abs(xmax-temp.pin['b0'].x)+0.001,width=self.w_wg,xs=self.xs_wg).put()
nd.Pin(name='b'+str(itn+1) ,width=0.45, pin=temp.pin['b0'].move(-0.05,0,0)).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b'+str(itn+1) ,width=0.45, pin=temp.pin['b0'].move(-0.05,0,0)).put()
nd.Pin(name='opt_b'+str(itn+1) ,width=0.45, pin=temp.pin['b0'].move(-0.05,0,0),type="optical:").put()
else :
nd.Pin(name='b'+str(itn+1) ,width=0.45).put(pin_b_list[itn])
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b'+str(itn+1) ,width=0.45).put(pin_b_list[itn])
nd.Pin(name='opt_b'+str(itn+1) ,width=0.45,type="optical:").put(pin_b_list[itn])
print("## ===== %s mesh DONE ===== ##" % (self.mesh_type))
@@ -922,18 +1092,28 @@ class AMZI_W:
pic_strip = Route(radius=self.R_bend,width=self.w_wg,xs=self.xs_wg)
self.dL_BS = np.abs(self.BS.pin['a1'].x - self.BS.pin['b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: self.dL_BS = np.abs(self.BS.pin['a1'].x - self.BS.pin['b1'].x)
self.dL_BS = np.abs(self.BS.pin['opt_a1'].x - self.BS.pin['opt_b1'].x)
dY_BS = abs(self.BS.pin['b1'].y - self.BS.pin['b2'].y)
## revised in 2026.06.07 by Qin Yue
# legacy: dY_BS = abs(self.BS.pin['b1'].y - self.BS.pin['b2'].y)
dY_BS = abs(self.BS.pin['opt_b1'].y - self.BS.pin['opt_b2'].y)
dYarm = self.D_arm/2 - self.BS.pin['b1'].y
## revised in 2026.06.07 by Qin Yue
# legacy: dYarm = self.D_arm/2 - self.BS.pin['b1'].y
dYarm = self.D_arm/2 - self.BS.pin['opt_b1'].y
dLmin = np.sqrt(abs(self.R_bend**2 - (self.R_bend-dYarm)**2))*2
if (dLmin>2*self.R_bend):
dLmin = 2*self.R_bend
BS_L = self.BS.put('b1',-dLmin - self.L_arm/2-1,dY_BS/2,180)
BS_R = self.BS.put('a2', dLmin + self.L_arm/2+1,dY_BS/2,0,flip=1)
## revised in 2026.06.07 by Qin Yue
# legacy: BS_L = self.BS.put('b1',-dLmin - self.L_arm/2-1,dY_BS/2,180)
BS_L = self.BS.put('opt_b1',-dLmin - self.L_arm/2-1,dY_BS/2,180)
## revised in 2026.06.07 by Qin Yue
# legacy: BS_R = self.BS.put('a2', dLmin + self.L_arm/2+1,dY_BS/2,0,flip=1)
BS_R = self.BS.put('opt_a2', dLmin + self.L_arm/2+1,dY_BS/2,0,flip=1)
wg_ht = W_waveguide(L_wg=self.L_arm,w_wg=self.w_wg,xs_wg=self.xs_wg,
dL=self.dL_ht+self.dL_AMZI/2/self.n_bend,R_bend=self.R_bend,
@@ -953,32 +1133,68 @@ class AMZI_W:
).cell
wg_U = wg_ht.put('a1',-self.L_arm/2,self.D_arm/2,0)
wg_D = wg_oht.put('a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
## revised in 2026.06.07 by Qin Yue
# legacy: wg_U = wg_ht.put('a1',-self.L_arm/2,self.D_arm/2,0)
wg_U = wg_ht.put('opt_a1',-self.L_arm/2,self.D_arm/2,0)
## revised in 2026.06.07 by Qin Yue
# legacy: wg_D = wg_oht.put('a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
wg_D = wg_oht.put('opt_a1',-self.L_arm/2,-self.D_arm/2,0,flip=1)
pic_strip.sbend_p2p(pin1=BS_L.pin['b1'],pin2=wg_U.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_L.pin['b2'],pin2=wg_D.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['a2'],pin2=wg_U.pin['b1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['a1'],pin2=wg_D.pin['b1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_L.pin['b1'],pin2=wg_U.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_L.pin['opt_b1'],pin2=wg_U.pin['opt_a1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_L.pin['b2'],pin2=wg_D.pin['a1']).put()
pic_strip.sbend_p2p(pin1=BS_L.pin['opt_b2'],pin2=wg_D.pin['opt_a1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_R.pin['a2'],pin2=wg_U.pin['b1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['opt_a2'],pin2=wg_U.pin['opt_b1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=BS_R.pin['a1'],pin2=wg_D.pin['b1']).put()
pic_strip.sbend_p2p(pin1=BS_R.pin['opt_a1'],pin2=wg_D.pin['opt_b1']).put()
patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_L.pin['a2'].x-self.R_bend*2-1, self.D_port/2,180)
patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_L.pin['a1'].x-self.R_bend*2-1,-self.D_port/2,180)
## revised in 2026.06.07 by Qin Yue
# legacy: patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_L.pin['a2'].x-self.R_bend*2-1, self.D_port/2,180)
patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_L.pin['opt_a2'].x-self.R_bend*2-1, self.D_port/2,180)
## revised in 2026.06.07 by Qin Yue
# legacy: patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_L.pin['a1'].x-self.R_bend*2-1,-self.D_port/2,180)
patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_L.pin['opt_a1'].x-self.R_bend*2-1,-self.D_port/2,180)
pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_L.pin['a1']).put()
pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_L.pin['a2']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_L.pin['a1']).put()
pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_L.pin['opt_a1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_L.pin['a2']).put()
pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_L.pin['opt_a2']).put()
nd.Pin(name='a1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='a2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_a1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='a2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_a2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b2'].x+self.R_bend*2+1, self.D_port/2,0)
patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b1'].x+self.R_bend*2+1,-self.D_port/2,0)
## revised in 2026.06.07 by Qin Yue
# legacy: patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b2'].x+self.R_bend*2+1, self.D_port/2,0)
patch_U = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['opt_b2'].x+self.R_bend*2+1, self.D_port/2,0)
## revised in 2026.06.07 by Qin Yue
# legacy: patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['b1'].x+self.R_bend*2+1,-self.D_port/2,0)
patch_D = nd.strt(length=0.5,width=self.w_wg,xs=self.xs_wg).put('a0',BS_R.pin['opt_b1'].x+self.R_bend*2+1,-self.D_port/2,0)
pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_R.pin['b2']).put()
pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_R.pin['b1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_R.pin['b2']).put()
pic_strip.sbend_p2p(pin1=patch_U.pin['a0'],pin2=BS_R.pin['opt_b2']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_R.pin['b1']).put()
pic_strip.sbend_p2p(pin1=patch_D.pin['a0'],pin2=BS_R.pin['opt_b1']).put()
nd.Pin(name='b1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='b2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_b1',pin=patch_U.pin['b0'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
## revised in 2026.06.07 by Qin Yue
# legacy: nd.Pin(name='b2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg).put()
nd.Pin(name='opt_b2',pin=patch_D.pin['b0'].move(-0.05,0,0),width=self.w_wg,type="optical:").put()
if (self.w_ht>0):
nd.Pin(name='ep1',pin=wg_U.pin['ep1']).put()
@@ -1003,23 +1219,37 @@ class AMZI_W:
GC3Instr = gc_cell.put('g1',0,-dYgc2gc,180)
GC4Instr = gc_cell.put('g1',dXgc2gc,-dYgc2gc,0)
dYcell = abs(self.cell.pin['a1'].y - self.cell.pin['a2'].y)
## revised in 2026.06.07 by Qin Yue
# legacy: dYcell = abs(self.cell.pin['a1'].y - self.cell.pin['a2'].y)
dYcell = abs(self.cell.pin['opt_a1'].y - self.cell.pin['opt_a2'].y)
dYoffset = (dYcell - dYgc2gc)/2
dXcell = abs(self.cell.pin['a1'].x - self.cell.pin['b1'].x)
## revised in 2026.06.07 by Qin Yue
# legacy: dXcell = abs(self.cell.pin['a1'].x - self.cell.pin['b1'].x)
dXcell = abs(self.cell.pin['opt_a1'].x - self.cell.pin['opt_b1'].x)
dXoffset = -(dXcell - dXgc2gc)/2
cellInstr = self.cell.put('a1',dXoffset,dYoffset,0)
## revised in 2026.06.07 by Qin Yue
# legacy: cellInstr = self.cell.put('a1',dXoffset,dYoffset,0)
cellInstr = self.cell.put('opt_a1',dXoffset,dYoffset,0)
pic = Route(xs=self.xs_wg,width=w_wg,radius=R_bend)
pic.sbend_p2p(pin1=cellInstr.pin['a1'],pin2=GC1Instr.pin['g1']).put()
pic.sbend_p2p(pin1=cellInstr.pin['b1'],pin2=GC2Instr.pin['g1']).put()
pic.sbend_p2p(pin1=cellInstr.pin['a2'],pin2=GC3Instr.pin['g1']).put()
pic.sbend_p2p(pin1=cellInstr.pin['b2'],pin2=GC4Instr.pin['g1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic.sbend_p2p(pin1=cellInstr.pin['a1'],pin2=GC1Instr.pin['g1']).put()
pic.sbend_p2p(pin1=cellInstr.pin['opt_a1'],pin2=GC1Instr.pin['g1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic.sbend_p2p(pin1=cellInstr.pin['b1'],pin2=GC2Instr.pin['g1']).put()
pic.sbend_p2p(pin1=cellInstr.pin['opt_b1'],pin2=GC2Instr.pin['g1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic.sbend_p2p(pin1=cellInstr.pin['a2'],pin2=GC3Instr.pin['g1']).put()
pic.sbend_p2p(pin1=cellInstr.pin['opt_a2'],pin2=GC3Instr.pin['g1']).put()
## revised in 2026.06.07 by Qin Yue
# legacy: pic.sbend_p2p(pin1=cellInstr.pin['b2'],pin2=GC4Instr.pin['g1']).put()
pic.sbend_p2p(pin1=cellInstr.pin['opt_b2'],pin2=GC4Instr.pin['g1']).put()