Home Forums Nazca Questions and Answers problems running python files

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6203
    AlexChen93
    Participant

    I recently was trying out codes according to the free form curves tutorial and the March 28, 2020 response from Ronald listed here (https://nazca-design.org/forums/users/ronald/replies/page/2/) in an attempt to create spiral waveguides (still a work in progress), and I had to update my nazca to the most recent version. Previously, I was running into an error that said I was “Reusing an existing layer_name ‘Shallow’. Use a different layer name or set overwrite=True.” After exiting Anaconda and re-entering, I did not run into this error anymore and was able to run the tutorial example and the March 28, 2020 example with no problem. However, when I tried to run some of my older python files, it returns the error “No xsection object existing under xsection name ‘None’,” etc. I never used the xsection layer before, so I was wondering what could be done to fix this problem.

    Below is a sample code that used to work and now doesn’t and returns the above error:

    import math
    import numpy as np
    import nazca as nd
    from nazca.interconnects import Interconnect
    import nazca.demofab as demo
    
    nd.mask_layers.clear_layers()
    
    # DEFINE LAYERS
    siName = 'SiDevLayer'
    siLayer = 1
    nd.add_layer(name=siName,layer=siLayer,accuracy=0.001)
    nd.add_layer(name='Sleeve',layer=2,accuracy=0.001)
    nd.add_layer2xsection(xsection='myXS', layer='SiDevLayer')
    
    w0 = 1 #width of the guiding waveguide
    r0 = 120 #bend radius
    #ic = Interconnect(width=w0,radius=r0,layer=siLayer)
    ic = Interconnect(width=w0,radius=r0,layer=siLayer)
    ic65 = Interconnect(width=.65,radius=r0,layer=siLayer)
    ic56 = Interconnect(width=.56,radius=r0,layer=siLayer)
    ic50 = Interconnect(width=.5,radius=r0,layer=siLayer)
    ws = 5
    rs = 100
    ics = Interconnect(width = ws, radius = rs, layer=2)
    
    '''    
    
    #'''
    def Dis_Spiral(ic=ic50,Rmin=30,dR=40,path_length=2000):
        #Structure as defined at https://ieeexplore.ieee.org/document/6589985
        with nd.Cell(name='Spiral_PL=%0.2fum'%(path_length)) as cell:
            #All units in um
            show_Arrow = False #don't show arrow on actual AIM run - nazca Layer not supported by default
            #Rmin = 30
            if path_length<2*math.pi*Rmin:
                #Desired Path length too short to spiral
                alpha = path_length/Rmin #in radians
                a=ic.bend(angle=180*alpha/math.pi,radius=Rmin,arrow=show_Arrow).put()
                b=ic.bend(angle=180*alpha/math.pi,radius=Rmin,arrow=show_Arrow).put('a0',a.pin['a0'])
            else:
                #Desired Path length requires a spiral path
                #Approximated by half-circles of constant radius
                a=ic.bend(angle=180,radius=Rmin,arrow=show_Arrow).put()
                b=ic.bend(angle=180,radius=Rmin,arrow=show_Arrow).put('a0',a.pin['a0'])
                
                #dR = 40
                #N=10
                #Determine how many half-circles will be needed to reach the desired path length
                N=0
                iterLen = 2*math.pi*Rmin
                while  iterLen <= path_length:
                    iterLen += 2*math.pi*(Rmin+(N+0.5)*dR) 
                    N+=1
                    #This will exit with the first number of loops Greater than the desired total path length
                N-=1 #actual number of full turns which exceeds the desired path length
                alpha = (path_length - (iterLen - 2*math.pi*(Rmin+(N+0.5)*dR)))/(2*math.pi*(Rmin+(N+0.5)*dR)) #radians of the arc that needs to be added
                for i in range(0,N):
                    
                #if i == 0:
                #    a = ic.bend(angle=-180,radius=2*Rmin+(i+.5)*dR).put(a.pin['a0'])
                #    b = ic.bend(angle=-180,radius=2*Rmin+(i+.5)*dR).put(b.pin['b0'])
                #else:
                    a = ic.bend(angle=180,radius=2*Rmin+(i+.5)*dR,arrow=show_Arrow).put(a.pin['b0'])
                    b = ic.bend(angle=180,radius=2*Rmin+(i+.5)*dR,arrow=show_Arrow).put(b.pin['b0'])
                a = ic.bend(angle=(180*alpha/math.pi)/2,radius=2*Rmin+(N+.5)*dR,arrow=show_Arrow).put(a.pin['b0'])
                b = ic.bend(angle=(180*alpha/math.pi)/2,radius=2*Rmin+(N+.5)*dR,arrow=show_Arrow).put(b.pin['b0']) 
            nd.Pin('a0',width=ic.width).put(a.pin['b0'])
            nd.Pin('b0',width=ic.width).put(b.pin['b0'])
            #TODO: adjust Pin definitions when an interleaved spiral is being used, so that it is easier to connect to other structures with Nazca
        return cell
    
    Dis_Spiral(ic50,Rmin=200,dR=20,path_length=140000).put(0,0)
    
    nd.export_gds(filename="spiral4.gds")

    Any help would be appreciated. Thank you.

    #6205
    Ronald
    Keymaster

    Dear Alex,

    Nazca allows you to be a bit “sloppy” by auto defining a xsection in cases where one would be needed in Interconnects but where none was provided. However, an extra check on connection symmetry was added in 0.5.11 that in your case did not like a missing xsection. This will be adapted so it will not warn/stop on the missing xsection anymore. For now an easy way out is to define the xsection explicitly and also add it to the interconnect initialization, which is best practice anyway:

    siName = 'SiDevLayer'
    siLayer = 1
    # even nicer is to add the xsections explicitly: 
    # nd.add_xsection(name='myXS')
    # nd.add_xsection(name='myXS2')
    nd.add_layer(name=siName, layer=siLayer, accuracy=0.001)
    nd.add_layer(name='Sleeve', layer=2, accuracy=0.001)
    nd.add_layer2xsection(xsection='myXS', layer='SiDevLayer')  # This will define the xsection as well when none exists yet with name 'myXS'.
    nd.add_layer2xsection(xsection='myXS2', layer='Sleeve')  # This will define the xsection as well when none exists yet with name 'myXS2'.
    
    w0 = 1  
    r0 = 120
    ic   = Interconnect(xs='myXS', width=w0, radius=r0)
    ic65 = Interconnect(xs='myXS', width=0.65, radius=r0)
    ic56 = Interconnect(xs='myXS', width=0.56, radius=r0)
    ic50 = Interconnect(xs='myXS', width=0.5, radius=r0)
    ws = 5
    rs = 100
    ics = Interconnect(xs='myXS2', width=ws, radius=rs)

    Ronald

    #6206
    AlexChen93
    Participant

    Thanks Ronald! The solution you provided fixed it up.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.