From 3d6f5a783ac3cd2fb3f2fb73d43011e683321e6f Mon Sep 17 00:00:00 2001
From: Tomas Polakovic <tom.polakovic@gmail.com>
Date: Wed, 16 Feb 2022 10:43:47 -0600
Subject: [PATCH] example file

---
 example.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100755 example.py

diff --git a/example.py b/example.py
new file mode 100755
index 0000000..0ec2cee
--- /dev/null
+++ b/example.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3
+
+import gdspy
+
+lib = gdspy.GdsLibrary('Lib')
+pi = 3.1416
+p = {-1:'r',1:'l'}
+
+def make_resonator(length, width, trench, coupling_length, coupling_radius, turn_length, turn_radius, n_turns=0):
+    res = gdspy.Path(width)
+    res.segment(coupling_length,'+x')
+    res.turn(coupling_radius,'r')
+    if n_turns == 0:
+        res.segment(length, '-y')
+    else:
+        _p = 1
+        ext_length = (n_turns+1)*pi
+        length = length - ext_length
+        res.segment(length/2,'-y')
+        res.turn(turn_radius,'r')
+        for i in range(n_turns):
+            res.turn(turn_radius,p[_p])
+            res.turn(turn_radius,p[_p])
+            res.segment(turn_length)
+            _p *= -1
+        res.turn(turn_radius, p[_p])
+        res.segment(length/2,'-y')
+
+
+    res_poly = gdspy.boolean(res, res, 'or', max_points=10000)
+    tr = gdspy.offset(res_poly, trench)
+    res.segment(trench)
+
+    out = gdspy.boolean(tr, res, 'not', layer=1, max_points=10000)
+    #out.fracture(max_points=5)
+    return out
+
+def _cpw(length, width, pad_length, pad_width, tapper_length):
+    cpw = gdspy.Path(pad_width)
+    cpw.segment(pad_length)
+    cpw.segment(tapper_length, final_width=width)
+    cpw.segment(length)
+    cpw.segment(tapper_length, final_width=pad_width)
+    cpw.segment(pad_length)
+
+    cpw = gdspy.boolean(cpw, cpw, 'or', layer=2)
+    return cpw
+
+def make_cpw(length, width, pad_length, pad_width, tapper_length, trench):
+    cpw = _cpw(length, width, pad_length, pad_width, tapper_length)
+    cpw_tr = _cpw(length,width+2*trench,pad_length*2,pad_width*2,tapper_length+trench)
+    cpw_tr.translate(-(pad_length+trench), 0)
+
+
+    out = gdspy.boolean(cpw_tr, cpw, 'not', layer=2)
+    return out
+
+# Construction of gds file
+cell_res = gdspy.Cell('Resonator')
+res = make_resonator(5e3,2,1,20,5,100,100,3)
+cell_res.add(res)
+lib.add(cell_res)
+
+cell_cpw = gdspy.Cell('CPW')
+cpw = make_cpw(5e3, 10, 350, 350, 100, 5)
+cell_cpw.add(cpw)
+lib.add(cell_cpw)
+
+gdspy.LayoutViewer(lib)
+lib.write_gds('example.gds')
-- 
GitLab