コード例 #1
0
ファイル: test_factory.py プロジェクト: smartalecH/gdsfactory
def lock_component(
    component_type,
    component_factory=component_factory,
    path_library=path_library,
    flatten=True,
    with_settings_label=False,
):
    """ locks a component from the factory into the GDS lib

    TODO: flattening makes it slower for big mask
    """
    try:
        c = component_factory[component_type](cache=False, pins=False)
        if flatten:
            c.flatten()
        gdspath = path_library / (component_type + ".gds")
        pp.write_component(
            c,
            gdspath=gdspath,
            with_settings_label=with_settings_label,
        )
        assert gdspath.exists()
        return c
    except Exception as e:
        error = f"error building {component_type}"
        raise ValueError(error, e)
コード例 #2
0
def _demo():
    import pp
    c = pp.c.waveguide()
    gdspath = pp.write_component(c)

    layout1 = load_gds(gdspath)
    cell1 = layout1.top_cell()
    cell1_instance1 = pya.CellInstArray(cell1.cell_index(), pya.Trans(10, 0))

    layout2 = pya.Layout()
    cell2 = layout2.create_cell("TOP_LEVEL")

    layout2.cell("TOP_LEVEL").insert(cell1_instance1)
    layout2.write("test.gds")
コード例 #3
0
ファイル: test_factory.py プロジェクト: jaspreetj/gdsfactory
def lock_component(
    component_type,
    component_type2factory=component_type2factory,
    path_library=path_library,
    flatten=True,
):
    """ locks a component from the factory into the GDS lib

    TODO: flattening makes it slower for big mask
    """
    try:
        c = component_type2factory[component_type]()
        if flatten:
            c.flatten()
        gdspath = path_library / (component_type + ".gds")
        pp.write_component(
            c,
            gdspath=gdspath,
            verbose=False,
        )
        return c
    except Exception as e:
        error = f"error building {component_type} from {component_type2factory.keys()}"
        raise ValueError(error, e)
コード例 #4
0
def test_properties_components(component_type):
    """Write component to GDS with setttings_label"""
    cnew = pp.Component()
    c1 = component_factory[component_type]()
    c1ref = cnew << c1

    _add_settings_label(cnew, reference=c1ref)
    gdspath = pp.write_component(cnew)

    c2 = import_gds(gdspath)
    add_settings_from_label(c2)
    c1s = sort_dict(tuplify(c1.get_settings()))
    c2s = sort_dict(tuplify(c2.get_settings()))
    d = diff(c1s, c2s)
    print(c1s)
    print(c2s)
    assert len(d) == 0
    return c2
コード例 #5
0
            **port_params
        )
        component.add_port(port)

    for i in range(N):
        port = pp.Port(
            name="N{}".format(i),
            midpoint=p0 + ((i - N / 2) * port_pitch, dy),
            orientation=90,
            **port_params
        )
        component.add_port(port)

    for i in range(N):
        port = pp.Port(
            name="S{}".format(i),
            midpoint=p0 + ((i - N / 2) * port_pitch, -dy),
            orientation=-90,
            **port_params
        )
        component.add_port(port)
    return component

# create design
if __name__ == "__main__":
    bend_radius = 5.0
    c = big_device(N=10)
    c = add_io_optical(c, bend_radius=bend_radius, fanout_length=50.0)
    pp.write_component(c, "design.gds")

コード例 #6
0
    if isinstance(component, str):
        return klive.show(component)
    if component is None:
        raise ValueError(
            "Component is None, make sure that your function returns the component"
        )
    write_gds(
        component, gdspath, add_ports_to_all_cells=add_ports_to_all_cells, **kwargs
    )
    klive.show(gdspath)


if __name__ == "__main__":
    import pp

    c = pp.c.waveguide()
    pp.write_component(c)
    pp.show(c)

    # cc = pp.routing.add_io_optical(c)
    # gdspath = write_component(cc)

    # gdspath = write_component_type("ring_double_bus", overwrite=True, flatten=False)
    # gdspath = write_component_type("waveguide", length=5, overwrite=True, add_port_pins=False)
    # gdspath = write_component_type("mmi1x2", width_mmi=5, overwrite=True)
    # gdspath = write_component_type("mzi2x2", overwrite=True)
    # gdspath = write_component_type("bend_circular", overwrite=True)
    # print(gdspath)
    # print(type(gdspath))
    # klive.show(gdspath)
コード例 #7
0
    clear_cache()


if __name__ == "__main__":
    import pp

    # c = pp.c.waveguide(length=1.0016)  # rounds to 1.002 with 1nm precision
    # c = pp.c.waveguide(length=1.006)  # rounds to 1.005 with 5nm precision
    # c = pp.c.waveguide(length=1.009)  # rounds to 1.010 with 5nm precision
    # cc = pp.routing.add_fiber_array(c)
    # pp.write_component(cc, precision=5e-9)
    # pp.show(cc)

    gdspath = pp.CONFIG["gdsdir"] / "waveguide.gds"
    c = pp.c.waveguide()
    pp.write_component(c, gdspath=gdspath)
    pp.show(c)

    # print(c.settings)
    # gdspath = pp.write_component(c, precision=5e-9)
    # pp.show(gdspath)

    # cc = pp.routing.add_fiber_array(c)
    # gdspath = write_component(cc)

    # gdspath = write_component_type("ring_double_bus", overwrite=True, flatten=False)
    # gdspath = write_component_type("waveguide", length=5, overwrite=True)
    # gdspath = write_component_type("mmi1x2", width_mmi=5, overwrite=True)
    # gdspath = write_component_type("mzi2x2", overwrite=True)
    # gdspath = write_component_type("bend_circular", overwrite=True)
    # print(gdspath)
コード例 #8
0
        )
    clear_cache()


if __name__ == "__main__":
    import pp

    # c = pp.c.waveguide(length=1.0016)  # rounds to 1.002 with 1nm precision
    # c = pp.c.waveguide(length=1.006)  # rounds to 1.005 with 5nm precision
    # c = pp.c.waveguide(length=1.009)  # rounds to 1.010 with 5nm precision
    # cc = pp.routing.add_fiber_array(c)
    # pp.write_component(cc, precision=5e-9)
    # pp.show(cc)

    c = pp.c.waveguide(length=1.009)
    pp.write_component(c, gdspath="wg.gds")
    pp.show(c)

    # print(c.settings)
    # gdspath = pp.write_component(c, precision=5e-9)
    # pp.show(gdspath)

    # cc = pp.routing.add_fiber_array(c)
    # gdspath = write_component(cc)

    # gdspath = write_component_type("ring_double_bus", overwrite=True, flatten=False)
    # gdspath = write_component_type("waveguide", length=5, overwrite=True)
    # gdspath = write_component_type("mmi1x2", width_mmi=5, overwrite=True)
    # gdspath = write_component_type("mzi2x2", overwrite=True)
    # gdspath = write_component_type("bend_circular", overwrite=True)
    # print(gdspath)
コード例 #9
0
        klive.show(gdspath)
    else:
        raise ValueError(
            f"Component is {type(component)}, make sure pass a Component or a path"
        )


if __name__ == "__main__":
    import pp

    # c = pp.c.waveguide(length=1.0016)  # rounds to 1.002 with 1nm precision
    # c = pp.c.waveguide(length=1.006)  # rounds to 1.005 with 5nm precision

    c = pp.c.waveguide(length=1.009)  # rounds to 1.010 with 5nm precision
    cc = pp.routing.add_fiber_array(c)
    pp.write_component(cc, precision=5e-9)
    pp.show(cc)

    print(c.settings)

    # gdspath = pp.write_component(c, precision=5e-9)
    # pp.show(gdspath)

    # cc = pp.routing.add_fiber_array(c)
    # gdspath = write_component(cc)

    # gdspath = write_component_type("ring_double_bus", overwrite=True, flatten=False)
    # gdspath = write_component_type("waveguide", length=5, overwrite=True)
    # gdspath = write_component_type("mmi1x2", width_mmi=5, overwrite=True)
    # gdspath = write_component_type("mzi2x2", overwrite=True)
    # gdspath = write_component_type("bend_circular", overwrite=True)