Coder Social home page Coder Social logo

helgegehring / gdshelpers Goto Github PK

View Code? Open in Web Editor NEW
105.0 18.0 32.0 565 KB

GDSHelpers is an open-source package for automatized pattern generation for nano-structuring.

Home Page: https://www.uni-muenster.de/Physik.PI/Pernice/

License: GNU Lesser General Public License v3.0

Python 100.00%
integrated-circuits photonics electronics quantum-optics waveguides superconductors gdsii oasis nanofabrication microfabrication

gdshelpers's People

Contributors

antujin avatar fbeutel avatar frank-bp avatar helgegehring avatar jr2701 avatar robinstegmueller avatar thomasgrottke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdshelpers's Issues

Create Contributing guide

It would be helpful to have a small CONTRIBUTING.md in the root directory with the main instructions and conventions.

Especially the Flake8 flavor used, so people don't have to look it up in the CI script

flake8 gdshelpers/ --max-line-length=120

Shapely 2.0 Compatibility

I am curious if an update could be rolled out to make GDShelpers, compatible with Shapely 2.X.

When using with shapely 1.8 versions, the only depreciation error I saw was to use the .geoms property when iterating over multipolygon structures. However when I upgrade to shapely 2.0 in shapely_adaptor.py it cannot import shapely.topology because is doesn't exist in the new version.

Shapely error when running first example

Hello, I have just installed gdshelper on my python. I tried to run the first example on the tutorial, but it returns me the error "No module named 'shapely.topology'"
Shapely is installed in my python and up to date and I checked that the other modules works. However, it seems that this topology module does not exist and I am not sure how to fix it

Comment on the project

First of all, I think the project is pretty great.

I've been thinking for a long time about the fact that there is currently no Python package that allows easy layout creation and future-proof. The biggest counterpoint for me has always been that most packages do not support OASIS.

Somehow I had overslept the start of their project. And therefore I myself made a lot of thoughts on the subject. I would like to share this, maybe that's helpful in some way (if not just ignoring).

My current state is that I use the Klayout Python API. This offers a lot of different supported file formats (gds2, OASIS, etc). The C ++ implementation of the library may offer performance benefits for very large layouts (not tested).

Unfortunately, the disadvantages are pretty big too, the Klayout C ++ Geometry API is an integral part of Klayout and not a shared library. In addition, the Python API interface with a self-developed "generic scripting interface (GSI)" realized. Which adds an additional abstraction layer whose use I find at least questionable. It also seems to make it difficult to deploy a Python API documentation. Besides, this makes the Python API practically not pythonic.

In my own thinking about a Python layout package, I ended up with the lib2geom geometry from inkscape. The design seems relatively modern and is logically optimized for dealing with SVG. Cons there are some disadvantages, the Python interface is only Python 2. IO is not a part but it seems possible to use the IO part of inkscape. Thus, the choice of Shapely for me seems pretty sensible. I had just read from Shapely a few weeks ago and had probably been too unsettled by the GEO background (I had considered the whole thing too much a CAD problem).

A few more comments about the project:

  1. Is help required? Is there a roadmap or TODO list? I'm definitely interested in contributing.

  2. gdsCAD seems unmaintained are there any considerations to integrate the code / functionality into gdshelpers?

  3. Was there any contact to PHIDL? The goals seem pretty congruent to me. So developer resources could be bundled.
    The same applies to ZeroPDK. Also quite new and based on Klayout.
    or nazca also seems to go in the direction but has no git repo (not found?).

(Please excuse my bad english)

Rounding & Spacing Issue when writing Cell Array to gdsii

b.write((np.round(np.array((ref['spacing'][0] * ref['columns'], 0)) +
np.array(ref['origin'])) * grid_steps_per_unit).astype(
'>i4').tobytes()) # XY INTEGER_8 edge_x

So I am trying to implement 2 cells within a cell as an array. I am using the standard micron as the unit, but I am trying to have increased precision to 0.1nm [10000 grid steps per micron]. When I make the spacing equal micron steps apart, it works. When they are not, there is a spacing issue. I am pretty sure the problem is here in the code referenced above as internally the spacing kept in the gdspy_cell->references->spacing is correct. The code shown seems to round before the points are scaled by the grid_steps_per_unit rather than after, which I think is causing my problem.

First example Script error

Hi @HelgeGehring,

The first example script is flawed:

  1. numpy is missing
  2. Something is wrong with gdshelpers.parts.logo:
~/.local/lib/python3.7/site-packages/gdshelpers/parts/logo.py in get_shapely_object(self)
    180             # WWU width = 368.93 = 369     *M2 == w
    181             # box width unscaled = w = 336
--> 182             m2 = w / 369.  # scale width of WWU to width of logo
    183             m = self.height / (h + 10 + 114)  # scaling factor height
    184 

the code works with numpy and without logo:

import numpy as np
from gdshelpers.geometry.chip import Cell
from gdshelpers.parts.waveguide import Waveguide
from gdshelpers.parts.coupler import GratingCoupler
from gdshelpers.parts.resonator import RingResonator
from gdshelpers.parts.splitter import Splitter
#from gdshelpers.parts.logo import KITLogo, WWULogo
from gdshelpers.parts.optical_codes import QRCode
from gdshelpers.parts.text import Text
from gdshelpers.parts.marker import CrossMarker

# Generate a coupler with parameters from the coupler database
coupler1 = GratingCoupler.make_traditional_coupler_from_database([0, 0], 1, 'sn330', 1550)
coupler2 = GratingCoupler.make_traditional_coupler_from_database([150, 0], 1, 'sn330', 1550)

coupler1_desc = coupler1.get_description_text(side='left')
coupler2_desc = coupler2.get_description_text(side='right')

# And add a simple waveguide to it
wg1 = Waveguide.make_at_port(coupler1.port)
wg1.add_straight_segment(10)
wg1.add_bend(-np.pi/2, 10, final_width=1.5)

res = RingResonator.make_at_port(wg1.current_port, gap=0.1, radius=20,
                                 race_length=10, res_wg_width=0.5)

wg2 = Waveguide.make_at_port(res.port)
wg2.add_straight_segment(30)
splitter = Splitter.make_at_root_port(wg2.current_port, total_length=20, sep=10, wg_width_branches=1.0)

wg3 = Waveguide.make_at_port(splitter.right_branch_port)
wg3.add_route_single_circle_to_port(coupler2.port)

# Add a marker just for fun
marker = CrossMarker.make_traditional_paddle_markers(res.center_coordinates)

# The fancy stuff
#kit_logo = KITLogo([25, 0], 10)
#wwu_logo = WWULogo([100, 30], 30, 2)
qr_code = QRCode([25, -40], 'https://www.uni-muenster.de/Physik.PI/Pernice', 1.0)
dev_label = Text([100, 0], 10, 'A0', alignment='center-top')

# Create a Cell to hold the objects
cell = Cell('EXAMPLE')

# Convert parts to gdsCAD polygons
cell.add_to_layer(1, coupler1, wg1, res, wg2, splitter, wg3, coupler2)
#cell.add_to_layer(2, wwu_logo, kit_logo, qr_code, dev_label)
cell.add_to_layer(2, marker)
cell.add_to_layer(3, coupler1_desc, coupler2_desc)
cell.show()

best,
quearitis

Waveguide.add_parameterized_path fails with multiple widths

This seems to be a regression, because I think it worked before, but the following produces an error:

wg = Waveguide([0, 0], 0, [1, 2, 1])
wg.add_parameterized_path(lambda t: [10*t, 10*t])
wg.get_shapely_object()

Error:

Traceback (most recent call last):
  File "gdshelpers/tests/test_waveguide.py", line 40, in test_waveguide_multiple_widths
    wg.add_parameterized_path(some_path)
  File "gdshelpers/parts/waveguide.py", line 275, in add_parameterized_path
    poly_path_1 = sample_coordinates + start[..., None] * sample_coordinates_d1_normed_ortho
ValueError: operands could not be broadcast together with shapes (3,1) (28,2) 

I opened a pull request which adds a failing test case: #26

issue about Boolean operation: difference

Thanks for gdshelpers, this package is amazing!

When I used the boolean operation difference(), I got a small problem as shown in the figure, and it may occurr at the junction of the arc and the spiral. If I changed the parameter num, this issue would disapear.
I don't know how to fix it. I tried to get the same layout by boolean operation not from gdspy package, and it looked correct.

result_difference

The code is attached below.

from gdshelpers.geometry.chip import Cell
from gdshelpers.parts.spiral import Spiral
from gdshelpers.geometry import geometric_union

# create the spiral
spiral = Spiral(origin=(0,0), angle=0, width=0.45, num=16, gap=3, inner_gap=30)

# get the shapely 
device = geometric_union([spiral])
# Boolean operation: difference
buffer_device = device.buffer(3)
buffer_not_device = buffer_device.difference(device)

cell = Cell('cell_difference')
cell.add_to_layer(1, buffer_not_device)
# Here don't use cell.show() to verify the issue, and use cell.save() please.
cell.save('gdshelpers_difference.gds')


# And I found it's OK if I use "not" from gdspy.boolean()
from gdshelpers.geometry import convert_to_layout_objs
import gdspy
# STEP 1: 
lib = gdspy.GdsLibrary(precision = 1e-10)

# create a new cell to save 
cell_gdspy = lib.new_cell("cell_not_gdspy")

geo1 = convert_to_layout_objs(buffer_device,library='gdspy')
geo2 = convert_to_layout_objs(device,library='gdspy')
inv = gdspy.boolean(geo1, geo2, "not")

cell_gdspy.add(inv)
lib.write_gds("gdspy_not.gds")

Regression for Waveguide.add_parameterized_path

Commit 1f0fa3f introduced a different regression. The following works with v1.1.2, but doesn't anymore work as previously with the mentioned commit.

I guess the problem is that it's difficult to distingish whether an array passed as the width consists of the individual sampling points or describes slot-waveguides.

The following is a minimal example (adapted from code of @frank-bp ) shows the problem:

import numpy as np
from gdshelpers.parts.waveguide import Waveguide
from gdshelpers.parts import Port
from gdshelpers.geometry.chip import Cell

def path_function(t):
    return 10 * t, np.zeros((len(t)))

def width_function(t):
    return 0.5 + t

sample_coordinates = np.linspace(0, 1, 5)
path_vector = np.array(path_function(sample_coordinates)).T
width_vector = np.array(width_function(sample_coordinates)).T

wg = Waveguide.make_at_port(Port([0, 0], 0.5*np.pi, 1))
wg.add_parameterized_path(path=path_vector, width=width_vector,
                          sample_distance=None)

cell=Cell('foo')
cell.add_to_layer(1, wg)
cell.save('foo')

Before 1f0fa3f this produces a single waveguide with changing width, and afterwards it produces three waveguide rails and two slots.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.