Exemple #1
0
def give_loopmirror(gap=.5):
    # just an example of augmenting a normal phidl device (loop_mirror_terminator)
    # giving it as a phidl Device as well as port, bounding box, and source things used by MEEP
    D = Device('loopmirror')

    cell = D << pg.rectangle([31, 15], layer=lys['FLOORPLAN'])
    cell.center = (0, 0)

    access = D << pg.compass([8, .35], layer=lys['wg_deep'])
    access.y = cell.y
    access.xmin = cell.xmin

    mmi = mmi1x2(gap_mmi=.5)
    loop = D << loop_mirror_terminator(y_splitter=mmi)
    loop.connect('wg_in_1', access.ports['E'])

    medium_map = get_layer_mapping(lys)

    port = D << pg.rectangle([.1, 1], layer=1)
    source = D << pg.rectangle([.1, 1], layer=2)
    port.y = 0
    source.y = 0
    port.x = loop.xmin - 6
    source.x = loop.xmin - 7

    D.flatten()
    return D
Exemple #2
0
def test_flatten():
    D = Device()
    E1 = Device()
    E2 = Device()
    E1.add_polygon( [(8,6,7,9,7,0), (6,8,9,5,7,0)], layer = 8)
    E2.add_polygon( [(18,16,17,19,17,10), (16,18,19,15,17,10)], layer = 9)
    D << E1
    D << E2
    h = D.hash_geometry(precision = 1e-4)
    assert(h == '8a057feca51d8097f2a915eda558fe2a9b88fb13')
    D.flatten()
    h = D.hash_geometry(precision = 1e-4)
    assert(h == '8a057feca51d8097f2a915eda558fe2a9b88fb13')
    D.flatten(single_layer = (5,5))
    h = D.hash_geometry(precision = 1e-4)
    assert(h == 'cfc1ba30384f5f1f7d888f47f16d1f310f95b464')
# Flattening a Device
#==============================================================================
# Sometimes you want to remove cell structure from a Device while keeping all
# of the shapes/polygons intact and in place.  The D.flatten() keeps all the
# polygons in D, but removes all the underlying references it's attached to.
# Also, if you specify the `single_layer` argument it will move all of the
# polyons to that single layer

D = Device()
E1 = pg.ellipse(layer=1)
E2 = pg.ellipse(layer=2)
D.add_ref(E1)
D.add_ref(E2).movex(15)

D.write_gds('D_ellipses.gds')
D.flatten()
D.write_gds('D_ellipses_flattened.gds')
D.flatten(single_layer=5)
D.write_gds('D_ellipses_flattened_singlelayer.gds')

#==============================================================================
# Decluttering - Absorbing references into a main Device
#==============================================================================
# Say you had a Device "D" which contains several references named
# "ref1", "ref2", "ref_cluttered".  Suppose the reference "ref_cluttered" is
# cluttering up your cell hierarchy when you're viewing it in your favorite
# GDS viewer.  The D.absorb() function can eliminate the "ref_cluttered"
# hierarchy while maintaining the geometry -- it strips out all the polygons
# from "ref_cluttered" and adds them directly to "D", then removes
# the reference "ref_cluttered" from D entirely
Exemple #4
0
def gds_to_meep(filename):
    D = Device('gdsext')
    D.load_gds(filename)
    D.flatten()
    return device_to_meep(D)