diff --git a/klayout/EBeam/pymacros/pcells_EBeam_Dream/ebeam_dream_FAVE_SiN_1550_BB.py b/klayout/EBeam/pymacros/pcells_EBeam_Dream/ebeam_dream_FAVE_SiN_1550_BB.py index 098005c6..5fcad491 100644 --- a/klayout/EBeam/pymacros/pcells_EBeam_Dream/ebeam_dream_FAVE_SiN_1550_BB.py +++ b/klayout/EBeam/pymacros/pcells_EBeam_Dream/ebeam_dream_FAVE_SiN_1550_BB.py @@ -31,6 +31,7 @@ def __init__(self): self.param("textl", self.TypeLayer, "Text Layer", default=TECHNOLOGY['Text'], hidden=True) self.param("bb",self.TypeLayer,"BB Layer", default=TECHNOLOGY['BlackBox'], hidden=True) self.param("dt",self.TypeLayer,"DT Layer", default=TECHNOLOGY['Deep Trench'], hidden=True) + self.param("dt_bezier_corner",self.TypeDouble,"Rounded corners (Bezier) fraction, 0 to 1, (0=off)", default=0.2, hidden=False) def can_create_from_shape_impl(self): return False @@ -100,21 +101,6 @@ def circle(x,y,r): #place fibre target circle shapes(LayerFbrTgtN).insert(pya.Polygon(align_circle)) - #draw devrec box - devrec_pts = [ - pya.Point(-100/dbu,50/dbu), - pya.Point(0,50/dbu), - pya.Point(0,25/dbu), - pya.Point(x,1/dbu), - pya.Point(x,-1/dbu), - pya.Point(0,-25/dbu), - pya.Point(0,-50/dbu), - pya.Point(-100/dbu,-50/dbu), - ] - - #place devrec box - shapes(LayerDevRecN).insert(pya.Polygon(devrec_pts)) - #BB description t = pya.Trans(pya.Trans.R0,0,-15/dbu) @@ -133,40 +119,56 @@ def circle(x,y,r): dir_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../gds/EBeam_Dream/")) filename = os.path.join(dir_path, 'DP_logo.gds') - ''' - cell_text = ly.create_cell('TEXT', 'Basic', - {'text':'FAVE:\\nFacet-attached\\nVertical Emitter', - 'layer':self.bb, - 'lspacing':3, - 'mag':9}) - t = pya.Trans(pya.Trans.R0, -98e3, -26e3) - ''' cell_text = ly.create_cell('TEXT', 'Basic', - {'text':'Facet-attached\\nVertical Emitter', + {'text':' Facet-attached\\n Vertical Emitter', 'layer':self.bb, 'lspacing':3, 'mag':9}) - t = pya.Trans(pya.Trans.R0, -98e3, -36e3) + t = pya.Trans(pya.Trans.R0, -98e3, -33e3) inst_text = cell.insert(pya.CellInstArray(cell_text.cell_index(), t)) ly2=pya.Layout() ly2.read(filename) top_cell = ly2.top_cell() top_cell.flatten(True) - top_cell.transform(pya.Trans(-90e3,28e3)) + top_cell.transform(pya.Trans(-91e3,27e3)) self.cell.copy_shapes(top_cell) - #draw lenses + # draw lens width_lens = to_itype(50, dbu) length_lens = to_itype(50, dbu) + n_ch = 0 + lens_pts = [pya.Point(0,-width_lens/2+pitch*n_ch), pya.Point(0,width_lens/2+pitch*n_ch), pya.Point(-length_lens,width_lens/2+pitch*n_ch),pya.Point(-length_lens,-width_lens/2+pitch*n_ch)] + shapes(LayerBBN).insert(pya.Polygon(lens_pts)) + lens = circle(-length_lens,pitch*n_ch,25/dbu) + shapes(LayerBBN).insert(pya.Polygon(lens)) + + # Draw Deep Trench + # Use Bezier corners for aesthetic purposes, + # and perhaps for better fabrication outcomes + width, height = 100e3, 100e3 + if self.dt_bezier_corner == 0: + polygon = pya.Box(-width,-height/2,0,height/2) + else: + from SiEPIC.utils.geometry import box_bezier_corners + polygon = box_bezier_corners(width*dbu, height*dbu, self.dt_bezier_corner).to_itype(dbu).transformed(pya.Trans(-width/2,0)) + shapes(ly.layer(self.dt)).insert(polygon) - for n_ch in range(int(1)): - lens_pts = [pya.Point(0,-width_lens/2+pitch*n_ch), pya.Point(0,width_lens/2+pitch*n_ch), pya.Point(-length_lens,width_lens/2+pitch*n_ch),pya.Point(-length_lens,-width_lens/2+pitch*n_ch)] - shapes(LayerBBN).insert(pya.Polygon(lens_pts)) - lens = circle(-length_lens,pitch*n_ch,25/dbu) - shapes(LayerBBN).insert(pya.Polygon(lens)) + #draw devrec box + devrec_pts = [ + pya.Point(0,25/dbu), + pya.Point(x,1/dbu), + pya.Point(x,-1/dbu), + pya.Point(0,-25/dbu), + ] + #place devrec box + # merge + + shapes(LayerDevRecN).insert( + (pya.Region(pya.Polygon(devrec_pts)) + + pya.Region(polygon)).merge() + ) - shapes(ly.layer(self.dt)).insert(pya.Box(-100e3,-50e3,0,50e3)) # Shift cell origin, so that (0,0) is at the pin self.cell.transform(pya.Trans(-95e3,0)) @@ -175,3 +177,60 @@ def display_text_impl(self): # Provide a descriptive text for the cell return "ebeam_dream_FAVE_SiN_1550_BB" + + + + +class test_lib(pya.Library): + def __init__(self): + tech = "EBeam" + library = tech + "test_lib" + self.technology = tech + self.layout().register_pcell("ebeam_dream_FAVE_SiN_1550_BB", ebeam_dream_FAVE_SiN_1550_BB()) + self.register(library) + + +if __name__ == "__main__": + print("Test layout for: ebeam_dream_FAVE_SiN_1550_BB") + + from SiEPIC.utils.layout import new_layout + from SiEPIC.scripts import zoom_out + from SiEPIC._globals import Python_Env + + if Python_Env == 'Script': + # For external Python mode, when installed using pip install siepic_ebeam_pdk + import siepic_ebeam_pdk + + # load the test library, and technology + t = test_lib() + tech = t.technology + + # Create a new layout + topcell, ly = new_layout(tech, "test", GUI=True, overwrite=True) + + # instantiate the cell + library = tech + "test_lib" + + # Instantiate, with default parameters + pcell = ly.create_cell("ebeam_dream_FAVE_SiN_1550_BB", library, {}) + t = pya.Trans(pya.Trans.R0, 0, 0) + topcell.insert(pya.CellInstArray(pcell.cell_index(), t)) + + # Instantiate, with default parameters + pcell = ly.create_cell("ebeam_dream_FAVE_SiN_1550_BB", library, {'dt_bezier_corner':0}) + t = pya.Trans(pya.Trans.R0, 0, 125e3) + topcell.insert(pya.CellInstArray(pcell.cell_index(), t)) + + zoom_out(topcell) + + # Export for fabrication, removing PCells + import os + from SiEPIC.scripts import export_layout + thisfilepath = os.path.dirname(os.path.realpath(__file__)) + filename, extension = os.path.splitext(os.path.basename(__file__)) + file_out = export_layout(topcell, thisfilepath, filename, relative_path = '', format='oas', screenshot=True) + + # Display the layout in KLayout, using KLayout Package "klive", which needs to be installed in the KLayout Application + if Python_Env == 'Script': + from SiEPIC.utils import klive + klive.show(file_out, technology=tech)