Home Forums Nazca Directional Coupler in Nazca Reply To: Directional Coupler in Nazca

#5548
Ronald
Keymaster

To make it more robust Xaveer’s example can be parametrized and pins can be set by reference:

import nazca as nd
import nazca.demofab as demo

def coupler(length=20, sep=100, gap=20):
    with nd.Cell("Coupler") as C:
        # Upper arm
        u1 = demo.shallow.sinebend(distance=100, offset=-0.5*(sep-gap)).put(0, 0.5*sep)
        demo.shallow.strt(length=length).put()
        u2 = demo.shallow.sinebend(distance=100, offset=0.5*(sep-gap)).put()

        # Lower arm
        l1 = demo.shallow.sinebend(distance=100, offset=0.5*(sep-gap)).put(0, -0.5*sep)
        demo.shallow.strt(length=length).put()
        l2 = demo.shallow.sinebend(distance=100, offset=-0.5*(sep-gap)).put()

        # Add pins
        nd.Pin("a0", pin=u1.pin['a0']).put()
        nd.Pin("a1", pin=l1.pin['a0']).put()
        nd.Pin("b0", pin=u2.pin['b0']).put()
        nd.Pin("b1", pin=l2.pin['b0']).put()
    return C

coupler().put(0, 0)
coupler(length=40, gap=5, sep=50).put(0, 100, 10)

nd.export_plt()

Note that setting pins by reference can be done using the ‘pin’ keyword. This will automatically copy all pin properties to the new pin.

# p is pin
nd.Pin("a0").put(p) # set the new pin at the position of p
nd.Pin("a0", pin=p).put() # copy all properties of p and put it on the position of p

Ronald