- This topic has 2 replies, 2 voices, and was last updated 3 years, 12 months ago by Dagi.
-
AuthorPosts
-
30 November 2020 at 13:37 #6289DagiParticipant
Hello,
I am trying to implement photonic crystal structures using Nazca.
Particularly, I would like to manuplate the holes after I created them.The code below creates the triangular lattice of holes, find the ones I want to delete. But, I don’t know how to delete them. I belive, I don’t have the correct reference to the instanced hole object. I would highly appreciate your help.
Of course, I could have not “put” the holes that I don’t want. But it is pretty much handy to have the possibility to access the holes either to move or delete them as per the requirement of the user.
Below is the code for creating triangular lattice of holes
import nazca as nd import numpy as np # Add layer nd.add_layer(name='ebeam',layer=1,overwrite=(True),fill_color=('red')) # Define PhC parameters hole_radius=0.125 PhC_ax = 0.425 PhC_ay = 0.5*PhC_ax*np.sqrt(3) hole_polygon = 20 nx = 20 ny = 10 ### Define hole shape and geometry with nd.Cell('hole') as hole: hole_shape = nd.geometries.circle(radius=hole_radius,N=hole_polygon) nd.Polygon(points=hole_shape,layer='ebeam').put(0) # ================================ # make triangular lattice of holes # ================================ hole_reference = [] for ix in np.arange(-np.floor(nx/2),np.floor(nx/2)): for iy in np.arange(-np.floor(ny/2),np.floor(ny/2)+1): x = (ix+np.mod(iy,2)*0.5)*PhC_ax y = iy*PhC_ay if (ix !=-np.floor(nx/2) or np.mod(iy,2)!=0): hole_reference.append(hole.put(x,y)) # ============================= # Add line-defect PhC waveguide # ============================= # find the middle row for making the waveguide wg_row = 0 to_remove=[] for g in hole_reference: if g.cnode.y == wg_row*PhC_ay: to_remove.append(g) # Remove selected holes # I would like to delete these particular holes del to_remove # Convert the PhC to a building block with input and output pins # ...to be implemented # Export gds file nd.export_gds(filename='PhC.gds')
7 December 2020 at 21:14 #6292RonaldKeymasterDear Dagi,
If you makes cells of the holes, as in cell ‘hole’, the work would need to be done on the cell instances in your pxtal. This is possible via the cell_iter(), but here there may be a simpler solution by placing hole polygon objects directly in the pxtal cell. This is not something I have used before a lot, but you can scan and update directly on the polygon attribute in the cell object and filter it based on e.g. x-position of a hole, as demonstrated in the example below.
I also added pins to make it a circuit type waveguide.import nazca as nd import numpy as np # Add layer nd.add_layer(name="ebeam", layer=1, overwrite=(True), fill_color=("red")) # Define PhC parameters hole_radius = 0.125 PhC_ax = 0.425 PhC_ay = 0.5 * PhC_ax * np.sqrt(3) hole_polygon = 20 nx = 20 ny = 10 # Define hole shape and geometry hole_shape = nd.geometries.circle(radius=hole_radius, N=hole_polygon) hole1 = nd.Polygon(points=hole_shape, layer="ebeam") # ================================ # make triangular lattice of holes # ================================ with nd.Cell('pxtal', instantiate=False) as pxtal: hole_reference = [] for ix in np.arange(-np.floor(nx / 2), np.floor(nx / 2)): for iy in np.arange(-np.floor(ny / 2), np.floor(ny / 2) + 1): x = (ix + np.mod(iy, 2) * 0.5) * PhC_ax y = iy * PhC_ay if ix != -np.floor(nx / 2) or np.mod(iy, 2) != 0: hole1.put(x, y) nd.Pin('a0').put(0, 2, 90) nd.Pin('b0').put(0, -2, -90) nd.put_stub() # ============================= # Add line-defect PhC waveguide # ============================= pgons_new = [] for pgon in pxtal.polygons: node, Poly = pgon x, y, a = node.xya() if abs(x) > 0.2: pgons_new.append((node, Poly)) pxtal.polygons = pgons_new pxtal.put(0, 0, 90) # Export gds file nd.export_gds(filename="PhC.gds")
Ronald
16 December 2020 at 09:48 #6306DagiParticipantDear Ronald,
This is exactly what I wanted!
Thanks a lot
Dagi -
AuthorPosts
- You must be logged in to reply to this topic.