padding = 2 print print "a=%f" %(a) print "w=%f" %(w) print "hx=%f" %(hx) print "hy=%f" %(hy) print def sumlist(list1, list2) : return [i + j for i,j in zip(list1,list2)] if __name__ == "__main__" : #First we must define a file to write to mydcfile= dcfile.dcfile('ladder_pos') mydcfile.initialize() origin = [0, 0] startposition = origin # sweep over a range of colors for each column for icolor in linspace(0,.2,5) : color = colorsys.hsv_to_rgb(icolor,1,1) # sweep over a range of resonant wavelengths for each row for wl in linspace(.6,.7,4) : a = .45 * wl #lattice parameter w = 3 * a # width of ladder (size in y-direction) hx = .5 * a # width of ladder rungs in x-direction hy = .7 * w
#!/usr/bin/python from __future__ import division import sys sys.path.append('../') import colorsys import dcfile import shapes from math import sqrt if __name__ == "__main__" : #First we must define a file to write to mydcfile= dcfile.dcfile('photonic_crystal_fs') mydcfile.initialize() def fshape(i, j) : a = shapes.circle(2) if i in (9,10,11) and j == 10 : return None if i == 2 and j == 2 : a.setradius(.2) a.position = [.1,.1] else : a.setradius(.3) return a mypc=shapes.photonic_crystal_fixed_spacing(fshape,[21,20], basis=((1,0),(.5,.5 * sqrt(3)))) mypc.write(mydcfile) #Finally, we close the file we are writing to. This is not always #necessary, but still recommended. mydcfile.close()
#!/usr/bin/python from __future__ import division import sys sys.path.append('../') sys.path.append('../shapes') import colorsys import dcfile import shapes if __name__ == "__main__" : #First we must define a file to write to mydcfile= dcfile.dcfile('demo') mydcfile.initialize() #Next, we define our shapes. #First we create a shape. This is the most basic object that we can write, #Normally we would never use this class as it is too primitive, but it #is included here for the sake of example. #First, define the shape myshape=shapes.shape(1,position=[-3, -3]) myshape.addline([5, 5, 5]) #Then we write the shape to a file. If we do not call this, the shape will #not be written. myshape.write(mydcfile) #Now we write something a little easier. A polyline can have any number of #straight edges. We can use this to write arbtitrary polygons. In this example #we write a triangle. Note how we use the color argument to make it blue. mypolyline=shapes.polyline(color=[0, 0, 1])