本文主要是介绍luceda ipkiss教程 48:求线路中波导的总长度,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
当线路中有多条波导时,可以一次输出所有波导的总长度:
如:
代码如下:
from si_fab import all as pdk
from ipkiss3 import all as i3class 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 instsdef _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 specsdef _default_exposed_ports(self):exposed_ports = {"mmi_1:in1": "in1","mmi_1:in2": "in2","mmi_5:out1": "out1","mmi_5:out2": "out2",}return exposed_portsif __name__ == '__main__':MZI_Lattice().Layout().visualize()total_length = 0for layout in MZI_Lattice().Layout().layout:ref = layout.referenceif hasattr(ref, 'trace_length'):total_length += ref.trace_length()print("the total length is : {}".format(total_length))
这篇关于luceda ipkiss教程 48:求线路中波导的总长度的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!