luceda ipkiss教程 48:求线路中波导的总长度

2023-12-13 04:08:26

当线路中有多条波导时,可以一次输出所有波导的总长度:
如:

在这里插入图片描述
在这里插入图片描述
代码如下:

from si_fab import all as pdk
from ipkiss3 import all as i3

class MZI_Lattice(i3.Circuit):
    mmi = i3.ChildCellProperty()
    mmi_spacing = i3.PositiveNumberProperty(default=210.0)
    bend_radius = i3.PositiveNumberProperty(default=50.0)

    def _default_mmi(self):
        return pdk.SiNDirectionalCouplerSPower(power_fraction=0.5, target_wavelength=1.55)

    def _default_insts(self):
        insts = {
            "mmi_1": self.mmi,
            "mmi_2": self.mmi,
            "mmi_3": self.mmi,
            "mmi_4": self.mmi,
            "mmi_5": self.mmi,
        }
        return insts

    def _default_specs(self):
        specs = [
            i3.Place("mmi_1:out2", (0, 0)),
            i3.PlaceRelative("mmi_2:in2", "mmi_1:out2", (self.mmi_spacing, 0)),
            i3.PlaceRelative("mmi_3:in2", "mmi_2:out2", (self.mmi_spacing, 0)),
            i3.PlaceRelative("mmi_4:in2", "mmi_3:out2", (self.mmi_spacing, 0)),
            i3.PlaceRelative("mmi_5:in2", "mmi_4:out2", (self.mmi_spacing, 0)),
            i3.ConnectManhattan("mmi_1:out2", "mmi_2:in2",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START + 750)], ),
            i3.ConnectManhattan("mmi_1:out1", "mmi_2:in1",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START - 130)], ),
            i3.ConnectManhattan("mmi_2:out2", "mmi_3:in2",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START + 740)], ),
            i3.ConnectManhattan("mmi_2:out1", "mmi_3:in1",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START - 130)], ),
            i3.ConnectManhattan("mmi_3:out2", "mmi_4:in2",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START + 120)], ),
            i3.ConnectManhattan("mmi_3:out1", "mmi_4:in1",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START - 720)], ),
            i3.ConnectManhattan("mmi_4:out2", "mmi_5:in2",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START + 120)], ),
            i3.ConnectManhattan("mmi_4:out1", "mmi_5:in1",
                                bend_radius=self.bend_radius,
                                control_points=[i3.H(i3.START - 710)], ),
        ]
        return specs

    def _default_exposed_ports(self):
        exposed_ports = {
            "mmi_1:in1": "in1",
            "mmi_1:in2": "in2",
            "mmi_5:out1": "out1",
            "mmi_5:out2": "out2",
        }
        return exposed_ports


if __name__ == '__main__':
    MZI_Lattice().Layout().visualize()

    total_length = 0
    for layout in MZI_Lattice().Layout().layout:
        ref = layout.reference
        if hasattr(ref, 'trace_length'):
            total_length += ref.trace_length()
    print("the total length is : {}".format(total_length))

文章来源:https://blog.csdn.net/qq_34316088/article/details/134960479
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。