# 2.2. Design variations and hierarchical layout¶

The next step is to use the MZI PCell defined in the previous section to create a sweep of MZIs with different length of the right arm. Also for this case we will use CircuitCell, so that we can easily simulate each MZI that is part of our design to check their behaviour.

When submitting designs to a foundry, more often than not you are allowed limited space to fit your designs. To make sure that the design is not bigger than the allowed area, it is useful to use a frame. The IPKISS PDK for SiEPIC contains a PCell called FloorPlan, which can be used exactly for this purpose. The height and width of this PCell can be adjusted according to your requirements. In this tutorial, we are going to use the floorplan to make sure the three MZIs don’t exceed our design area.

Let’s now have a look at how we can define design variations using IPKISS. Open the file “design_variations.py” in your PyCharm project, so that you can follow along the explanation.

## 2.2.1. Parameters for the MZI sweep¶

First of all, we define the parameters that we will use for the MZI sweep. We want to design three different MZIs. The right arm of each MZI will pass through a different coordinate in order to control its length. We provide this coordinate to the MZI PCell using the through_point property.

The following parameters are defined at the beginning of the file:

• through_points: A list of coordinates [(x1, y1), (x2, y2), (x3, y3)] that will be used to instantiate the MZI PCells of the three MZIs we want to design.
• bend_radius: The waveguide bend radius we will use for our designs.
• x0 and y0: The x- and y-coordinates where we will place the bottom left fiber coupler of the first MZI. They are defined to be a bit distant from the origin because the bottom left corner of the floorplan will be placed at the origin.
• spacing_x: The horizontal spacing between the fiber grating couplers of the three MZIs.

After defining these parameters, we create an empty child_cells dictionary and an empty place_specs lists. We will add to them all the child cells and the placement specifications that we need to provide to CircuitCell to create our final design.

# Parameters for the MZI sweep
through_points = [(70.0, 240.0), (100.0, 240.0), (150.0, 240.0)]
x0 = 40.0
y0 = 20.0
spacing_x = 180.0

child_cells = dict()
place_specs = []



## 2.2.2. Floorplan¶

Before designing the MZIs, it is good to have clear what are the boundaries for our design. We instantiate the floorplan from the IPKISS PDK for SiEPIC, we add it to the child cells and we place the bottom left corner at the origin.

# Create the floorplan
floorplan = pdk.FloorPlan(name="FLOORPLAN", size=(605.0, 410.0))

# Add the floorplan to the child cells and place it at (0.0, 0.0)
child_cells["floorplan"] = floorplan
place_specs.append(i3.Place("floorplan", (0.0, 0.0)))



## 2.2.3. MZI sweep¶

To create the MZI sweep, we use a practical for-loop over the list of through points. Each time, we instantiate an MZI with the correct through point, we add this instance to the dictionary of child cells and we place it at coordinates (x0, y0). For the first MZI, these are the coordinates we defined in the initial parameters. For each following MZI, the value of x0 is increased by the value in spacing_x.

For our own reference, after each MZI is instantiated, we calculate the delay length between the two arms of the MZI and print it.

Very important! Each time we instantiate an MZI, we have to assign a unique name. Otherwise, the tree instantiated MZIs will be an exact copy of each other and changing the design of one of them will result in a change in all of them. To make sure the names are all different, we use the for-loop counter ind to call them MZI0, MZI1, MZI2.

# Create the MZI sweep
for ind, tp in enumerate(through_points):
mzi = MZI(
name="MZI{}".format(ind),
through_point=tp,
)

# Calculate the actual delay length and print the results
right_arm_length = mzi.get_connector_instances()[1].reference.trace_length()
left_arm_length = mzi.get_connector_instances()[0].reference.trace_length()
delay_length = right_arm_length - left_arm_length

print(
mzi.name,
"Delay length = {} um".format(delay_length),
"Through point = {}".format(tp)
)

mzi_cell_name = "mzi{}".format(ind)
child_cells[mzi_cell_name] = mzi
place_specs.append(i3.Place(mzi_cell_name, (x0, y0)))

x0 += spacing_x



## 2.2.4. Final design¶

We are now ready to create the final design using CircuitCell. All the heavy work is done, we only need to instantiate a circuit cell which contains the child cells and the placement specifications that we carefully defined before.

# Create the final design with circuit cell
cell = CircuitCell(
name="EBeam_chiara_v1",
child_cells=child_cells,
place_specs=place_specs,
)



## 2.2.5. Layout and circuit simulation¶

We can now instantiate the layout and save it to gds:

# Layout
cell_lv = cell.Layout()
cell_lv.visualize(annotate=True)
cell_lv.write_gdsii("EBeam_chiara.gds")



Next, we can extract the S-matrix and plot the results of the circuit simulation to visualize the behaviour of our MZIs:

# Circuit model
cell_cm = cell.CircuitModel()
wavelengths = np.linspace(1.52, 1.58, 4001)
S_total = cell_cm.get_smatrix(wavelengths=wavelengths)

# Plotting
fig, axs = plt.subplots(3, sharex='all')

for ind, tp in enumerate(through_points):
tr_out1 = 20 * np.log10(np.abs(S_total['mzi{}_out1:0'.format(ind), 'mzi{}_in:0'.format(ind)]))
tr_out2 = 20 * np.log10(np.abs(S_total['mzi{}_out2:0'.format(ind), 'mzi{}_in:0'.format(ind)]))

axs[ind].plot(wavelengths, tr_out1, '-', linewidth=2.2, label="TE - MZI{}:out1".format(ind))
axs[ind].plot(wavelengths, tr_out2, '-', linewidth=2.2, label="TE - MZI{}:out2".format(ind))

axs[ind].set_ylabel('Transmission [dB]', fontsize=16)
axs[ind].set_title('MZI{}'.format(ind), fontsize=16)
axs[ind].legend(fontsize=14, loc=4)

axs[2].set_xlabel('Wavelength [um]', fontsize=16)
plt.show()

print("Done")