Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Boolean or operation on a Repetition #191

Open
the-dave-power opened this issue Jul 14, 2023 · 5 comments
Open

Error with Boolean or operation on a Repetition #191

the-dave-power opened this issue Jul 14, 2023 · 5 comments

Comments

@the-dave-power
Copy link

Hi @heitzmann ,

I am trying to do a boolean or operation on a Repetition I am not having much success.

I looked at your how-to (https://heitzmann.github.io/gdstk/how-tos.html) and tried to follow it. But I am getting to following error:

File "/home/dpower/PycharmProjects/pythonProject/wafer_map_yh_hour_glass_checker.py", line 31, in
checker = gdstk.boolean(rect_array_odd,rect_array_even,"or",layer=3, datatype=0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Unable to parse item 3 from sequence operand1.

Any chance you can take a look at this?

Thanks,
Dave.

code:
import gdstk

cell = gdstk.Cell('Top')

wafer_circum = 300
wafer_diam = wafer_circum/2
triangle_width = 180
rect_array_size = 0.030
#n_rows_cols = int(wafer_diam//0.030)
n_rows_cols = 2

wafer = gdstk.ellipse((0, 0), wafer_diam, tolerance=0.01,layer=1, datatype=0)

top_triangle =gdstk.Polygon([(0,0),( (triangle_width/2) ,wafer_diam ),( (triangle_width/-2), wafer_diam )], layer=1, datatype=0)
bot_triangle =gdstk.Polygon([(0,0),( (triangle_width/2),(-1wafer_diam) ),( (triangle_width/-2),(-1wafer_diam) )], layer=1, datatype=0)
or_triangle = gdstk.boolean(top_triangle,bot_triangle,"or",layer=2, datatype=0)

rect_array_odd = gdstk.rectangle(( (-1wafer_diam), (-1wafer_diam)), ((-1wafer_diam+rect_array_size), (-1wafer_diam+rect_array_size)), layer=3, datatype=0)
rect_array_even = gdstk.rectangle(( (-1wafer_diam+rect_array_size), (-1wafer_diam+rect_array_size)), ((-1wafer_diam+(rect_array_size2)), (-1wafer_diam+(rect_array_size2))), layer=3, datatype=0)
rect_array_odd.repetition = gdstk.Repetition(columns=n_rows_cols,rows=n_rows_cols,spacing=((rect_array_size2),(rect_array_size2)))
rect_array_even.repetition = gdstk.Repetition(columns=n_rows_cols,rows=n_rows_cols,spacing=((rect_array_size2),(rect_array_size2)))

https://heitzmann.github.io/gdstk/how-tos.html

rect_array_odd = rect_array_odd.apply_repetition()
rect_array_even = rect_array_even.apply_repetition()

rect_array_odd.append(rect_array_odd)
rect_array_even.append(rect_array_even)

checker = gdstk.boolean(rect_array_odd,rect_array_even,"or",layer=3, datatype=0)

yh_image_1 = gdstk.boolean(or_triangle,wafer,"and",layer=0, datatype=1)
yh_image_1 = gdstk.boolean(yh_image_1,wafer,"and",layer=0, datatype=1)

cell.add(wafer)

cell.add(*or_triangle)
cell.add(*yh_image)

lib = gdstk.Library(unit=0.001)
lib.add(cell)

lib.write_oas('/home/dpower/layout/yh_wafer_maps/hour_glass_checker.oas'

@heitzmann
Copy link
Owner

The problem is that you are appending a list to itself in these lines:

rect_array_odd = rect_array_odd.apply_repetition()
...
rect_array_odd.append(rect_array_odd)

Maybe try:

rect_odd = gdstk.rectangle((-wafer_diam, -wafer_diam), (-wafer_diam+rect_array_size, -wafer_diam+rect_array_size), layer=3, datatype=0)
rect_odd.repetition = gdstk.Repetition(columns=n_rows_cols, rows=n_rows_cols, spacing=(rect_array_size*2, rect_array_size*2))
rect_array_odd = rect_odd.apply_repetition()
rect_array_odd.append(rect_odd)

By the way, you can use 3 backticks to format your code:

```python
# python code goes here
x = 1
y = 2 * x
``` 

@the-dave-power
Copy link
Author

@heitzmann

thanks for the suggestion. I took the append statement. The code executes but does not finish running.

any ideas?

Code:

wafer_map_yh_hour_glass_checker.py.txt

@the-dave-power
Copy link
Author

Hi @heitzmann

Sorry read your initial response too quickly. The below code works well using your suggestion :)

wafer_map_yh_hour_glass_checker.py.txt

My last issue is that I am trying to make a array of 5k x 5k rectangles. It takes a couple of hours to run. Is there a way to improve the performance?

Thanks,
Dave.

Thanks,
Dave.

@heitzmann
Copy link
Owner

Hi @the-dave-power, unfortunately that's not so straightforward. You could try breaking your boolean operation in smaller sets if that's an option. For example, dividing your geometry in a few rectangular windows and operating on each window separately to reduce the total number of vertices used in each operation.

@the-dave-power
Copy link
Author

Thanks @heitzmann

I understand what you are saying and I'll give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants