component_from_netlist¶
- photonforge.component_from_netlist(netlist)¶
Create a component from a netlist description.
- Parameters:
netlist (dict[str, Any]) – Dictionary with the component description. The only required key is
'instances', which describes the references to all sub-components. See other keys in the example below.- Return type:
Examples
>>> coupler = parametric.dual_ring_coupler( ... port_spec="Strip", ... coupling_distance=0.6, ... radius=4, ... ) ... bus = parametric.ring_coupler( ... port_spec="Strip", ... coupling_distance=0.6, ... radius=4, ... bus_length=5, ... ) >>> netlist1 = { ... "name": "RING", ... "instances": {"COUPLER": coupler, "BUS_0": bus, "BUS_1": bus}, ... "instance_models": [ ... ("COUPLER", DirectionalCouplerModel(0.8, -0.5j)), ... ], ... "connections": [ ... (("COUPLER", "P0"), ("BUS_0", "P1")), ... (("BUS_1", "P1"), ("COUPLER", "P3")), ... ], ... "ports": [ ... ("BUS_0", "P0"), ... ("BUS_0", "P2"), ... ("BUS_1", "P2"), ... ("BUS_1", "P0"), ... ], ... "models": [CircuitModel()], ... } >>> component1 = component_from_netlist(netlist1)
>>> netlist2 = { ... "instances": [ ... coupler, ... {"component": bus, "origin": (0, -12)}, ... {"component": bus, "origin": (3, 7), "rotation": 180}, ... ], ... "virtual connections": [ ... ((0, "P0"), (1, "P1")), ... ((0, "P2"), (1, "P3")), ... ((2, "P3"), (0, "P1")), ... ], ... "routes": [ ... ((1, "P2"), (2, "P0"), {"radius": 6}), ... ((2, "P1"), (0, "P3"), pf.parametric.route_s_bend), ... ], ... "ports": [ ... (1, "P0", "In"), ... (2, "P2", "Add"), ... ], ... "models": [(pf.CircuitModel(), "Circuit")], ... } >>> component2 = pf.component_from_netlist(netlist2)
Notes
The value in
"instances"can be a dictionary or a list, in which case, index numbers are used in place of the keys. Each value is can be aComponentor another dictionary with keyword arguments to create aReference.Sub-components can receive extra models from
"instance_models". The last added model for each sub-component will be active.The
"connections"list specifies connections between instances. Each item is of the form((key1, port1), (key2, port2)), indicating that the referencekey1must be transformed to have itsport1connected toport2from the referencekey2.Items in the
"routes"list contain 2 reference ports, similarly to"connections", plus an optional routing function and a dictionary of keyword arguments to the function:((key1, port1), (key2, port2), route_function, kwargs_dict). Ifroute_functionis not provided,parameteric.routeis used.