It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I'm trying to learn to create a Honeycomb PCell based on the circle example we have in Ruby (I didn't find the same example in Python).
The Circle function in Klayout in Basic works differently than the one in the example.
If I choose Instance -> Basic Lib -> Circle, than to create an Hexagon I change the Number of points to "6".
The distance between the 2 edge of the Hexagon equals to the 2*Radius defined in the PCell.
In the case of the circle example in Ruby, the distance will be by default the 2 * Radius * sqrt(3/4) of the Hexagon.
My target is to write a Pcell where I can define the Width of the Honeycomb and the Thickness of the wall, then adding the number repetition in line and in column as parameters.
I'm thinking to use the difference between two Hexagon (circle of 6 points) of difference radius.
Any suggestion to how to write the code in Ruby or Python will be very appreciated.
Thank you.
Comments
After verifying the result, I think The basic Circle create a polygon tan to the outside of the circle for 6 points. The ruby code of the circle, create the polygon on the inside of the circle.
Any help with the code will be welcome.
Thank you.
I was able to create a PCell to do one cell of the Honeycomb. I don't know how I can create an array in rectangular shape without flattening the PCell.
Any idea?
Hi,
I think the problem is that the array feature will not allow you to create a rectangular area filled with honeycombs. Will it help, if the basic cell is a rectangular cross section of the honeycomb as in this screenshot?
Matthias
Great idea. I will try to create a Pcell of this shape and use the array feature to create the final shape.
Sometimes the solution is more easy than what I was expected
Big thank Matthias. Hopefully, I will be able to create a Pcell with the suggestion shape.
I failed to write the script in Python
But I was able to reproduce the same result if I create the cell manually (less precise) directly in the display windows environment.
If you wish, I can send you the code I wrote and show me how to fix it.
Yes, please do. Ideally you'd attach it here or put it on a gist and link it here. This is a place where everyone can learn and this is a opportunity to do so.
Matthias
The code
I'm not sure yet how to create the outside polygon correctly.
I tried also to create a circle where I multiply the radius by sqrt(3/4) to have the internal distance exactly equal to the defined radius.
The final target is to create honeycombs cell to fit in a rectangular shape.
The 4 parameters I need to defined are:
The High of the rectangle
Hi euzada,
sorry for the late reply - your code isn't bad. Thanks for sharing it. There is a little redundancy with the hidden parameters, but unless you strive for maximum compatibility, that's fine.
I have changed the generator code to match the screenshot above:
Please note that I use Region objects to compute the final polygon. Regions offer boolean operations which come handy here.
You see below how the result looks like. I manually created the array to fill the rectangular area.
The handles are a bit strange as the right one is outside the cell itself. And the array's y pitch is not straightforward: its computed from the ri and ro by: ypitch =
2*(ri+ro)*sqrt(3/4)
. Because rounding happens to 1nm and there is y symmetry, the height is 382nm.By adding two more parameters for x and y step count, the array replication can happen inside the generation code.
Regards,
Matthias
Here is the screenshot:

Thank you very much Matthias.
I don't know why, DCplxTrans function didn't work in my case. So, I divided all the parameter by the unit of dbu.
I solve the handle proble by rotation all the shape 90 degree. That way the clipbox will fit perfectly.
I will share the code, maybe someone will be interested to use it.
Hi,
Thank you very much for your code, it helped me a lot to draw a honeycomb, however i want to make an array of honeycombs in a circle and be able to choose the number of hexagonal and choose the space between each pattern as well as the radius of the hexagonal. I have tried many codes but i failed to do it. If someone has an idea to do that.
Thank you.
I think you should first cover the whole area with a honeycomb pattern, then draw a circle on a different layer and use a boolean AND with a third output layer to select the honeycombs inside. The ring can be added using a boolean OR to that layer.
Matthias
Thank you.
The above code generates a single honeycomb cell, but you can place an array of cells (class
CellInstArray
with two dimension counts and two step vectors). Choosing the right pitch should enable you to create the full array as shown in the screenshot above.Matthias