class CNT(object): def __init__(self, n, m, InitDiagnosticPlots=False): '''start from n and m, carve up a graphene flake, and make a unit cell corresponding to a carbon nanotube. Warning. Doesn;t work well if m >> n Make sure to check the diangostic plots. Cutting sometimes fails. Another warning. Finding root cells in failing sometimes. It's a rounding problem. Something like it gets the coordinates and rounds them. Then it rotates and maybe rounds again, and then it doesn't quite line up with the lattice vetor, which hasn't been rounded. and I don't have roundDepth arguments enough places to fix it This seems to have been fixed by using numpy.isclose(x,y) rather than round (x) == round(y) in the find_root_cell_function of the unit cell But we should continue to be wary. ''' self.n = n self.m = m self.name = 'nanotube_' + str(n) + '_' + str(m) self.InitDiagnosticPlots = InitDiagnosticPlots self.roundDepth = 3 #graphene properties self.K = numpy.asarray([0, 4 * numpy.pi / 3]) self.Kprime = numpy.asarray([0, -4 * numpy.pi / 3]) self.b1 = 2 * numpy.pi * numpy.asarray([1 / numpy.sqrt(3), 1]) self.b2 = 2 * numpy.pi * numpy.asarray([1 / numpy.sqrt(3), -1]) #general nanotube properties (don't need to make the graph for these) self.c_hat = self.find_c_hat() self.D = self.find_D() self.c_perp_hat = self.find_c_perp_hat() self.find_dirac_approach(valley=1) a = n b = m Ccoeffs = [a, b] #set up the lattice vectors grapheneCell = UnitCell('kagome') mya1 = grapheneCell.a1 mya2 = grapheneCell.a2 A1 = numpy.copy(mya1) A2 = mya1 - mya2 #set up the nanotube and find the size of the unit cell self.Cvec = Ccoeffs[0] * A1 + Ccoeffs[ 1] * A2 #vector around nanotube diameter self.theta = numpy.arctan2(self.Cvec[1], self.Cvec[0]) self.That = numpy.asarray([ numpy.cos(self.theta + numpy.pi / 2), numpy.sin(self.theta + numpy.pi / 2) ]) #direction along the nanotube #from much algebra, we can find the lattice vector along the nanotube multiple = self.lcm(4 * a + 2 * b, 2 * a + 4 * b) k = -multiple / (2 * a + 4 * b) j = multiple / (4 * a + 2 * b) self.Tvec = j * A1 + k * A2 #the lattice vector along the nanotube #make a flake to carve the unit cell out of collumns = a + b + 1 extra = numpy.abs(numpy.abs(k) - numpy.abs(j)) + 1 xSize = collumns + extra ySize = numpy.abs(k) + numpy.abs(b) + 1 grapheneFlake_0 = EuclideanLayout(int(xSize), int(ySize), 'kagome', resonatorsOnly=True) #shiftVec = -(extra-1)*mya1 + -(b)*mya2 - 1* numpy.asarray([ 1/numpy.sqrt(3) ,0]) # shiftVec = -(extra-1)*mya1 + -(b)*mya2 - 0* numpy.asarray([ 1/numpy.sqrt(3) ,0]) #+ numpy.asarray([0, 0.1]) #fudge to keep sights off unit cell boundary if b >= 0: shiftVec = -(extra - 1) * mya1 + -(b) * mya2 - 0 * numpy.asarray( [1 / numpy.sqrt(3), 0]) else: shiftVec = -(extra - 1) * mya1 + numpy.abs( 0) * mya2 - 0 * numpy.asarray([1 / numpy.sqrt(3), 0]) resonators = grapheneFlake_0.resonators #resonators = grapheneFlake_1.resonators resonators = shift_resonators(resonators, shiftVec[0], shiftVec[1]) self.grapheneFlake = GeneralLayout( resonators, name='grapheneFlake', roundDepth=self.roundDepth ) #I think this all the rotating, rounding is causing a problem if self.InitDiagnosticPlots: #show the original flake and important vectors pylab.figure(101) pylab.clf() ax = pylab.subplot(1, 1, 1) self.grapheneFlake.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=2.5) self.grapheneFlake.draw_resonator_end_points(ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) #pylab.plot([0,mya1[0]], [0, mya1[1]], linewidth = 2, color = 'firebrick') #pylab.plot([0,mya2[0]], [0, mya2[1]], linewidth = 2, color = 'maroon') pylab.plot([0, A1[0]], [0, A1[1]], linewidth=2, color='darkgoldenrod') pylab.plot([0, A2[0]], [0, A2[1]], linewidth=2, color='darkorange') pylab.plot([0, self.Cvec[0]], [0, self.Cvec[1]], linewidth=2.5, color='firebrick') pylab.plot([0, self.Tvec[0]], [0, self.Tvec[1]], linewidth=2.5, color='firebrick') pylab.plot([self.Tvec[0], self.Cvec[0] + self.Tvec[0]], [self.Tvec[1], self.Cvec[1] + self.Tvec[1]], linewidth=2.5, color='firebrick') pylab.plot([self.Cvec[0], self.Tvec[0] + self.Cvec[0]], [self.Cvec[1], self.Tvec[1] + self.Cvec[1]], linewidth=2.5, color='firebrick') ax.set_aspect('equal') ax.axis('off') pylab.title('sorting out the tube and unit cell size') pylab.tight_layout() pylab.show() # rotate everything to cardinal axes self.Cmag = numpy.linalg.norm(self.Cvec) self.Tmag = numpy.linalg.norm(self.Tvec) self.cellAngle = numpy.arctan2(self.Cvec[0], self.Cvec[1]) resonators2 = numpy.copy(self.grapheneFlake.resonators) resonators2 = rotate_resonators(resonators2, self.cellAngle) self.tubeFlake = GeneralLayout(resonators2, name='tubeFlake', roundDepth=self.roundDepth, resonatorsOnly=True) #this flake is now set up so that the unit cell is easy to find if self.InitDiagnosticPlots: pylab.figure(102) pylab.clf() ax = pylab.subplot(1, 1, 1) self.tubeFlake.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=2.5) self.tubeFlake.draw_resonator_end_points(ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) pylab.plot([0, 0], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [0, 0], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, -self.Tmag], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [self.Cmag, self.Cmag], linewidth=2.5, color='firebrick') #find the resonators of the unit cell self.newResonators = numpy.zeros(self.tubeFlake.resonators.shape) nind = 0 for rind in range(0, self.tubeFlake.resonators.shape[0]): res = self.tubeFlake.resonators[rind, :] x0, y0, x1, y1 = res #check if this is internal, external, or going across the edge of the unit cell. firstEndIn = False if (numpy.round(y0, self.roundDepth) < self.Cmag) and (numpy.round( y0, self.roundDepth) >= 0): if (numpy.round(x0, self.roundDepth) > -self.Tmag) and ( numpy.round(x0, self.roundDepth) <= 0): firstEndIn = True #change from default secondEndIn = False if (numpy.round(y1, self.roundDepth) < self.Cmag) and (numpy.round( y1, self.roundDepth) >= 0): if (numpy.round(x1, self.roundDepth) > -self.Tmag) and ( numpy.round(x1, self.roundDepth) <= 0): secondEndIn = True #change from default if (firstEndIn and secondEndIn): colorStr = 'darkorange' self.newResonators[nind, :] = [ x0, y0, x1, y1 ] #this is an internal resonator. Keep it nind = nind + 1 else: if (firstEndIn or secondEndIn): #one end of this guy is inside, and one is not colorStr = 'deepskyblue' #I only want to keep resonators going out the top side #and to fix redundancy, I don't want to fix the bottom flag1 = numpy.round(y0, self.roundDepth) >= self.Cmag flag2 = numpy.round(y1, self.roundDepth) >= self.Cmag if (flag1) or (flag2): #keep this one, but modify it if flag1: shiftVec = numpy.asarray([0, -self.Cmag, 0, 0]) elif flag2: shiftVec = numpy.asarray([0, 0, 0, -self.Cmag]) temp = numpy.asarray([x0, y0, x1, y1]) self.newResonators[nind, :] = temp + shiftVec nind = nind + 1 #to make the tube work out I also need to keep #stragglers on one side if (numpy.round(x0, self.roundDepth) > 0) or (numpy.round( x1, self.roundDepth) > 0): #keep this one self.newResonators[nind, :] = numpy.asarray( [x0, y0, x1, y1]) nind = nind + 1 else: #external resonator. Pass colorStr = 'gray' if self.InitDiagnosticPlots: pylab.plot([x0, x1], [y0, y1], linewidth=2.5, color=colorStr, zorder=11) if self.InitDiagnosticPlots: ax.set_aspect('equal') ax.axis('off') pylab.title('sorting unitcell from rest of flake') pylab.tight_layout() pylab.show() #trim the unfilled rows from newREsonators self.newResonators = self.newResonators[ ~numpy.all(self.newResonators == 0, axis=1)] #general layout caontaining just the resonators of a single unit cell of the #carbon nanotube self.singleTubeCellGraph = GeneralLayout(self.newResonators, 'resonators of a unit cell', resonatorsOnly=True) #make a unitcell object of the cabon nanotube name = str(a) + '_' + str(b) + '_nanotube' self.tubeCell = UnitCell(name, resonators=self.newResonators, a1=numpy.asarray([self.Tmag, 0]), a2=numpy.asarray([0, 2 * self.Cmag])) self.tubeCell.find_root_cell(roundDepth=self.roundDepth) if self.InitDiagnosticPlots: pylab.figure(103) pylab.clf() ax = pylab.subplot(1, 1, 1) self.singleTubeCellGraph.draw_resonator_lattice( ax, color=layoutLineColor, alpha=1, linewidth=2.5) self.singleTubeCellGraph.draw_resonator_end_points( ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) pylab.plot([0, 0], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [0, 0], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, -self.Tmag], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [self.Cmag, self.Cmag], linewidth=2.5, color='firebrick') ax.set_aspect('equal') ax.axis('off') pylab.title('single unit cell (hopefully)') pylab.tight_layout() pylab.show() #compute unit cell band structures as a test plotLattice = EuclideanLayout(xcells=2, ycells=1, modeType='FW', resonatorsOnly=False, initialCell=self.tubeCell) fig = pylab.figure(105) pylab.clf() gs = gridspec.GridSpec(1, 5) ax = fig.add_subplot(gs[0, 0:4]) plotLattice.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=1.5) plotLattice.draw_resonator_end_points(ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) ax.set_aspect('equal') ax.axis('off') numSteps = 200 ksize = 2 * numpy.pi / numpy.linalg.norm(self.tubeCell.a1) kxs, kys, cutx = self.tubeCell.compute_band_structure( -ksize, 0, ksize, 0, numsteps=numSteps, modeType='FW', returnStates=False) ax = fig.add_subplot(gs[0, 4]) #tubeCell.plot_band_cut(ax, cutx) self.tubeCell.plot_band_cut(ax, cutx, linewidth=2.5) pylab.ylabel('Energy (|t|)') pylab.xlabel('$k_x$ ($\pi$/a)') pylab.xticks([0, cutx.shape[1] / 2, cutx.shape[1]], [-2, 0, 2], rotation='horizontal') pylab.suptitle('checking cell band structure: ' + name) pylab.tight_layout() pylab.show() return def find_dirac_approach(self, valley=1): '''find closest approach to the Dirac point for the current nanotube Dpoint = 1 is the K point. 2 is the K prime point''' if valley == 1: Dpoint = self.K else: Dpoint = self.Kprime Mat = numpy.zeros((2, 2)) Mat[:, 0] = 2 * numpy.pi * self.c_hat / self.D Mat[:, 1] = self.c_perp_hat #decompose the K point in the c_perp and 2pi/D *chat basis temp = numpy.linalg.solve(Mat, Dpoint) alpha = temp[0] beta = temp[1] #find the closest approach to the Dirac point round1 = alpha - numpy.floor(alpha) round2 = numpy.ceil(alpha) - alpha if round1 < round2: #alpha is farether from ceil(alpha) than from floor(alpha) #so to get from Dirac to the point of closest approach, I need to go backwards signum = -1 else: signum = 1 minRound = numpy.min([round1, round2]) minPerp = signum * minRound * 2 * numpy.pi * self.c_hat / self.D minDist = numpy.linalg.norm(minPerp) absolutePos = Dpoint + minPerp self.closestPointToDirac = absolutePos self.minVecFromDirac = minPerp self.minDistFromDirac = minDist self.gap = self.graphene_energy(self.closestPointToDirac) return #graphene helpers def find_D(self): #return numpy.sqrt(n**2 +m**2 + n*m/numpy.pi) #ERRORRRRRR!!!! was multiplying by pi before #####ACTUALLY!!!!!!! there should be NO factor of pi at all!!!!!!!!!! return numpy.sqrt(1. * self.n**2 + 1. * self.m**2 + 1. * self.n * self.m) def find_theta(self): '''find the chiral angle ''' return numpy.arctan2(numpy.sqrt(3) * self.m, 2 * self.n + self.m) def find_c_hat(self): ''' find the chiral vector''' vec = numpy.zeros(2) vec[0] = numpy.cos(numpy.pi / 6 - self.find_theta()) vec[1] = numpy.sin(numpy.pi / 6 - self.find_theta()) return vec def find_c_perp_hat(self): '''find the unit vector perpendicular to the chiral vector ''' # #!!!!!! the old form is of this was wrong. Found it on 6/10/20 # vec= numpy.zeros(2) # vec[0] = numpy.cos(numpy.pi/3 + theta(n,m)) # vec[1] = numpy.sin(numpy.pi/3 + theta(n,m)) vec = numpy.zeros(2) vec[0] = numpy.cos(-numpy.pi / 3 - self.find_theta()) vec[1] = numpy.sin(-numpy.pi / 3 - self.find_theta()) return vec def graphene_energy(self, vec): '''find energy in graphene band structure of a given kx,ky ''' kx = vec[0] ky = vec[1] term1 = 1 term2 = 4 * numpy.cos(numpy.sqrt(3) * kx / 2) * numpy.cos(ky / 2) term3 = 4 * (numpy.cos(ky / 2))**2 val = numpy.sqrt(term1 + term2 + term3) return val def graphene_energy_reduced(self, thetaVec): ''' Find energy inthe graphene band structure of a given thetax, thetay ''' thetax = thetaVec[0] thetay = thetaVec[1] term1 = 1 term2 = 4 * numpy.cos(thetax) * numpy.cos(thetay) term3 = 4 * (numpy.cos(thetay))**2 val = numpy.sqrt(term1 + term2 + term3) return val def lcm(self, x, y): '''least common multiple ''' return numpy.abs(x * y) // fractions.gcd(x, y)
def __init__(self, n, m, InitDiagnosticPlots=False): '''start from n and m, carve up a graphene flake, and make a unit cell corresponding to a carbon nanotube. Warning. Doesn;t work well if m >> n Make sure to check the diangostic plots. Cutting sometimes fails. Another warning. Finding root cells in failing sometimes. It's a rounding problem. Something like it gets the coordinates and rounds them. Then it rotates and maybe rounds again, and then it doesn't quite line up with the lattice vetor, which hasn't been rounded. and I don't have roundDepth arguments enough places to fix it This seems to have been fixed by using numpy.isclose(x,y) rather than round (x) == round(y) in the find_root_cell_function of the unit cell But we should continue to be wary. ''' self.n = n self.m = m self.name = 'nanotube_' + str(n) + '_' + str(m) self.InitDiagnosticPlots = InitDiagnosticPlots self.roundDepth = 3 #graphene properties self.K = numpy.asarray([0, 4 * numpy.pi / 3]) self.Kprime = numpy.asarray([0, -4 * numpy.pi / 3]) self.b1 = 2 * numpy.pi * numpy.asarray([1 / numpy.sqrt(3), 1]) self.b2 = 2 * numpy.pi * numpy.asarray([1 / numpy.sqrt(3), -1]) #general nanotube properties (don't need to make the graph for these) self.c_hat = self.find_c_hat() self.D = self.find_D() self.c_perp_hat = self.find_c_perp_hat() self.find_dirac_approach(valley=1) a = n b = m Ccoeffs = [a, b] #set up the lattice vectors grapheneCell = UnitCell('kagome') mya1 = grapheneCell.a1 mya2 = grapheneCell.a2 A1 = numpy.copy(mya1) A2 = mya1 - mya2 #set up the nanotube and find the size of the unit cell self.Cvec = Ccoeffs[0] * A1 + Ccoeffs[ 1] * A2 #vector around nanotube diameter self.theta = numpy.arctan2(self.Cvec[1], self.Cvec[0]) self.That = numpy.asarray([ numpy.cos(self.theta + numpy.pi / 2), numpy.sin(self.theta + numpy.pi / 2) ]) #direction along the nanotube #from much algebra, we can find the lattice vector along the nanotube multiple = self.lcm(4 * a + 2 * b, 2 * a + 4 * b) k = -multiple / (2 * a + 4 * b) j = multiple / (4 * a + 2 * b) self.Tvec = j * A1 + k * A2 #the lattice vector along the nanotube #make a flake to carve the unit cell out of collumns = a + b + 1 extra = numpy.abs(numpy.abs(k) - numpy.abs(j)) + 1 xSize = collumns + extra ySize = numpy.abs(k) + numpy.abs(b) + 1 grapheneFlake_0 = EuclideanLayout(int(xSize), int(ySize), 'kagome', resonatorsOnly=True) #shiftVec = -(extra-1)*mya1 + -(b)*mya2 - 1* numpy.asarray([ 1/numpy.sqrt(3) ,0]) # shiftVec = -(extra-1)*mya1 + -(b)*mya2 - 0* numpy.asarray([ 1/numpy.sqrt(3) ,0]) #+ numpy.asarray([0, 0.1]) #fudge to keep sights off unit cell boundary if b >= 0: shiftVec = -(extra - 1) * mya1 + -(b) * mya2 - 0 * numpy.asarray( [1 / numpy.sqrt(3), 0]) else: shiftVec = -(extra - 1) * mya1 + numpy.abs( 0) * mya2 - 0 * numpy.asarray([1 / numpy.sqrt(3), 0]) resonators = grapheneFlake_0.resonators #resonators = grapheneFlake_1.resonators resonators = shift_resonators(resonators, shiftVec[0], shiftVec[1]) self.grapheneFlake = GeneralLayout( resonators, name='grapheneFlake', roundDepth=self.roundDepth ) #I think this all the rotating, rounding is causing a problem if self.InitDiagnosticPlots: #show the original flake and important vectors pylab.figure(101) pylab.clf() ax = pylab.subplot(1, 1, 1) self.grapheneFlake.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=2.5) self.grapheneFlake.draw_resonator_end_points(ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) #pylab.plot([0,mya1[0]], [0, mya1[1]], linewidth = 2, color = 'firebrick') #pylab.plot([0,mya2[0]], [0, mya2[1]], linewidth = 2, color = 'maroon') pylab.plot([0, A1[0]], [0, A1[1]], linewidth=2, color='darkgoldenrod') pylab.plot([0, A2[0]], [0, A2[1]], linewidth=2, color='darkorange') pylab.plot([0, self.Cvec[0]], [0, self.Cvec[1]], linewidth=2.5, color='firebrick') pylab.plot([0, self.Tvec[0]], [0, self.Tvec[1]], linewidth=2.5, color='firebrick') pylab.plot([self.Tvec[0], self.Cvec[0] + self.Tvec[0]], [self.Tvec[1], self.Cvec[1] + self.Tvec[1]], linewidth=2.5, color='firebrick') pylab.plot([self.Cvec[0], self.Tvec[0] + self.Cvec[0]], [self.Cvec[1], self.Tvec[1] + self.Cvec[1]], linewidth=2.5, color='firebrick') ax.set_aspect('equal') ax.axis('off') pylab.title('sorting out the tube and unit cell size') pylab.tight_layout() pylab.show() # rotate everything to cardinal axes self.Cmag = numpy.linalg.norm(self.Cvec) self.Tmag = numpy.linalg.norm(self.Tvec) self.cellAngle = numpy.arctan2(self.Cvec[0], self.Cvec[1]) resonators2 = numpy.copy(self.grapheneFlake.resonators) resonators2 = rotate_resonators(resonators2, self.cellAngle) self.tubeFlake = GeneralLayout(resonators2, name='tubeFlake', roundDepth=self.roundDepth, resonatorsOnly=True) #this flake is now set up so that the unit cell is easy to find if self.InitDiagnosticPlots: pylab.figure(102) pylab.clf() ax = pylab.subplot(1, 1, 1) self.tubeFlake.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=2.5) self.tubeFlake.draw_resonator_end_points(ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) pylab.plot([0, 0], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [0, 0], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, -self.Tmag], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [self.Cmag, self.Cmag], linewidth=2.5, color='firebrick') #find the resonators of the unit cell self.newResonators = numpy.zeros(self.tubeFlake.resonators.shape) nind = 0 for rind in range(0, self.tubeFlake.resonators.shape[0]): res = self.tubeFlake.resonators[rind, :] x0, y0, x1, y1 = res #check if this is internal, external, or going across the edge of the unit cell. firstEndIn = False if (numpy.round(y0, self.roundDepth) < self.Cmag) and (numpy.round( y0, self.roundDepth) >= 0): if (numpy.round(x0, self.roundDepth) > -self.Tmag) and ( numpy.round(x0, self.roundDepth) <= 0): firstEndIn = True #change from default secondEndIn = False if (numpy.round(y1, self.roundDepth) < self.Cmag) and (numpy.round( y1, self.roundDepth) >= 0): if (numpy.round(x1, self.roundDepth) > -self.Tmag) and ( numpy.round(x1, self.roundDepth) <= 0): secondEndIn = True #change from default if (firstEndIn and secondEndIn): colorStr = 'darkorange' self.newResonators[nind, :] = [ x0, y0, x1, y1 ] #this is an internal resonator. Keep it nind = nind + 1 else: if (firstEndIn or secondEndIn): #one end of this guy is inside, and one is not colorStr = 'deepskyblue' #I only want to keep resonators going out the top side #and to fix redundancy, I don't want to fix the bottom flag1 = numpy.round(y0, self.roundDepth) >= self.Cmag flag2 = numpy.round(y1, self.roundDepth) >= self.Cmag if (flag1) or (flag2): #keep this one, but modify it if flag1: shiftVec = numpy.asarray([0, -self.Cmag, 0, 0]) elif flag2: shiftVec = numpy.asarray([0, 0, 0, -self.Cmag]) temp = numpy.asarray([x0, y0, x1, y1]) self.newResonators[nind, :] = temp + shiftVec nind = nind + 1 #to make the tube work out I also need to keep #stragglers on one side if (numpy.round(x0, self.roundDepth) > 0) or (numpy.round( x1, self.roundDepth) > 0): #keep this one self.newResonators[nind, :] = numpy.asarray( [x0, y0, x1, y1]) nind = nind + 1 else: #external resonator. Pass colorStr = 'gray' if self.InitDiagnosticPlots: pylab.plot([x0, x1], [y0, y1], linewidth=2.5, color=colorStr, zorder=11) if self.InitDiagnosticPlots: ax.set_aspect('equal') ax.axis('off') pylab.title('sorting unitcell from rest of flake') pylab.tight_layout() pylab.show() #trim the unfilled rows from newREsonators self.newResonators = self.newResonators[ ~numpy.all(self.newResonators == 0, axis=1)] #general layout caontaining just the resonators of a single unit cell of the #carbon nanotube self.singleTubeCellGraph = GeneralLayout(self.newResonators, 'resonators of a unit cell', resonatorsOnly=True) #make a unitcell object of the cabon nanotube name = str(a) + '_' + str(b) + '_nanotube' self.tubeCell = UnitCell(name, resonators=self.newResonators, a1=numpy.asarray([self.Tmag, 0]), a2=numpy.asarray([0, 2 * self.Cmag])) self.tubeCell.find_root_cell(roundDepth=self.roundDepth) if self.InitDiagnosticPlots: pylab.figure(103) pylab.clf() ax = pylab.subplot(1, 1, 1) self.singleTubeCellGraph.draw_resonator_lattice( ax, color=layoutLineColor, alpha=1, linewidth=2.5) self.singleTubeCellGraph.draw_resonator_end_points( ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) pylab.plot([0, 0], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [0, 0], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, -self.Tmag], [0, self.Cmag], linewidth=2.5, color='firebrick') pylab.plot([-self.Tmag, 0], [self.Cmag, self.Cmag], linewidth=2.5, color='firebrick') ax.set_aspect('equal') ax.axis('off') pylab.title('single unit cell (hopefully)') pylab.tight_layout() pylab.show() #compute unit cell band structures as a test plotLattice = EuclideanLayout(xcells=2, ycells=1, modeType='FW', resonatorsOnly=False, initialCell=self.tubeCell) fig = pylab.figure(105) pylab.clf() gs = gridspec.GridSpec(1, 5) ax = fig.add_subplot(gs[0, 0:4]) plotLattice.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=1.5) plotLattice.draw_resonator_end_points(ax, color=layoutCapColor, edgecolor='k', marker='o', size=smallCdefault, zorder=5) ax.set_aspect('equal') ax.axis('off') numSteps = 200 ksize = 2 * numpy.pi / numpy.linalg.norm(self.tubeCell.a1) kxs, kys, cutx = self.tubeCell.compute_band_structure( -ksize, 0, ksize, 0, numsteps=numSteps, modeType='FW', returnStates=False) ax = fig.add_subplot(gs[0, 4]) #tubeCell.plot_band_cut(ax, cutx) self.tubeCell.plot_band_cut(ax, cutx, linewidth=2.5) pylab.ylabel('Energy (|t|)') pylab.xlabel('$k_x$ ($\pi$/a)') pylab.xticks([0, cutx.shape[1] / 2, cutx.shape[1]], [-2, 0, 2], rotation='horizontal') pylab.suptitle('checking cell band structure: ' + name) pylab.tight_layout() pylab.show() return
def run(): ############# #defaults ########## bigCdefault = 110 smallCdefault = 30 layoutLineColor = 'mediumblue' layoutCapColor = 'goldenrod' FWlinkAlpha = 0.7 FWsiteAlpha = 0.6 HWlinkAlpha = 0.8 HWsiteAlpha = 0.6 FWlinkColor = 'dodgerblue' FWsiteColor = 'lightsteelblue' FWsiteEdgeColor = 'mediumblue' HWlinkColor = 'lightsteelblue' HWminusLinkColor = 'b' HWsiteColor = 'lightgrey' HWsiteEdgeColor = 'midnightblue' stateColor1 = 'gold' stateEdgeColor1 = 'darkgoldenrod' stateEdgeWidth1 = 1.25 stateColor2 = 'firebrick' stateEdgeColor2 = 'maroon' stateEdgeWidth2 = 1 DefaultFig = True if DefaultFig: fig444 = pylab.figure(444) pylab.clf() testEuclidLattice = EuclideanLayout(3, 3, lattice_type='kagome', modeType='FW') kagomeLattice = GeneralLayout(testEuclidLattice.get_all_resonators(), modeType=testEuclidLattice.modeType, name=testEuclidLattice.lattice_type) testEuclidLattice = EuclideanLayout(3, 3, lattice_type='kagome', modeType='HW') kagomeLatticeHW = GeneralLayout(testEuclidLattice.get_all_resonators(), modeType=testEuclidLattice.modeType, name=testEuclidLattice.lattice_type) red = [3, 5, 13, 18, 20, 21, 24, 32, 33, 35] yellow = [4, 8, 9, 19, 22, 25, 31, 36, 34, 37] red2 = [9, 12, 15, 0, 18, 27, 34] yellow2 = [10, 13, 16, 5, 14, 23] ####layout graph ax1 = pylab.subplot(1, 5, 1, adjustable='box', aspect=1) pylab.cla() kagomeLattice.draw_resonator_lattice(ax1, color=layoutLineColor, alpha=1, linewidth=2.5) #testLattice.draw_resonator_end_points(ax, color = 'goldenrod', edgecolor = 'k', marker = 'o' , size = 30) xs = kagomeLattice.coords[:, 0] ys = kagomeLattice.coords[:, 1] pylab.sca(ax1) pylab.scatter(xs, ys, c=layoutCapColor, s=smallCdefault, marker='o', edgecolors='k', zorder=5) #ax.set_aspect('equal') ax1.axis('off') pylab.title('layout') ax2 = pylab.subplot(1, 5, 2, adjustable='box', aspect=1) pylab.cla() kagomeLattice.draw_SDlinks(ax2, color=FWlinkColor, linewidth=3, minus_links=True, minus_color='gold', alpha=1) pylab.sca(ax2) pylab.scatter(kagomeLattice.SDx, kagomeLattice.SDy, c=FWsiteColor, s=smallCdefault, marker='o', edgecolors=FWsiteEdgeColor, zorder=5, alpha=1) pylab.title('FW lattice') ax2.set_aspect('equal') ax2.axis('off') ax3 = pylab.subplot(1, 5, 3, adjustable='box', aspect=1) pylab.cla() kagomeLatticeHW.draw_SDlinks(ax3, color=HWlinkColor, linewidth=3, minus_links=True, minus_color=HWminusLinkColor, alpha=1) pylab.sca(ax3) pylab.scatter(kagomeLatticeHW.SDx, kagomeLatticeHW.SDy, c=HWsiteColor, s=smallCdefault, marker='o', edgecolors=HWsiteEdgeColor, zorder=5, alpha=1) pylab.title('HW lattice') ax3.set_aspect('equal') ax3.axis('off') ax4 = pylab.subplot(1, 5, 4, adjustable='box', aspect=1) pylab.cla() kagomeLattice.draw_SDlinks(ax4, color=FWlinkColor, linewidth=3, minus_links=True, minus_color='gold', alpha=FWlinkAlpha) pylab.sca(ax4) pylab.scatter(kagomeLattice.SDx, kagomeLattice.SDy, c=FWsiteColor, s=smallCdefault, marker='o', edgecolors=FWsiteEdgeColor, zorder=5, alpha=FWsiteAlpha) pylab.scatter(kagomeLattice.SDx[yellow], kagomeLattice.SDy[yellow], c=stateColor1, s=bigCdefault, marker='o', edgecolors=stateEdgeColor1, zorder=5, linewidth=stateEdgeWidth1) pylab.scatter(kagomeLattice.SDx[red], kagomeLattice.SDy[red], c=stateColor2, s=bigCdefault, marker='o', edgecolors=stateEdgeColor2, zorder=5, linewidth=stateEdgeWidth2) pylab.title('FW state') ax4.set_aspect('equal') ax4.axis('off') ax5 = pylab.subplot(1, 5, 5, adjustable='box', aspect=1) pylab.cla() kagomeLatticeHW.draw_SDlinks(ax5, color=HWlinkColor, linewidth=3, minus_links=True, minus_color=HWminusLinkColor, alpha=HWlinkAlpha) pylab.sca(ax5) pylab.scatter(kagomeLatticeHW.SDx, kagomeLatticeHW.SDy, c=HWsiteColor, s=smallCdefault, marker='o', edgecolors=HWsiteEdgeColor, zorder=5, alpha=HWsiteAlpha) pylab.scatter(kagomeLatticeHW.SDx[yellow], kagomeLatticeHW.SDy[yellow], c=stateColor1, s=bigCdefault, marker='o', edgecolors=stateEdgeColor1, zorder=5, linewidth=stateEdgeWidth1) pylab.scatter(kagomeLatticeHW.SDx[red], kagomeLatticeHW.SDy[red], c=stateColor2, s=bigCdefault, marker='o', edgecolors=stateEdgeColor2, zorder=5, linewidth=stateEdgeWidth2) pylab.title('HW state') ax5.set_aspect('equal') ax5.axis('off') # pylab.suptitle('Defaults') fig444.set_size_inches(14.5, 3.5) pylab.tight_layout() else: pass ############### #make a unit cell cell = UnitCell('PeterChain') cell.a1 cell.a2 cell.resonators #(x0,y0) (x1,y1) pylab.figure(1) pylab.clf() ax = pylab.subplot(1, 3, 1) cell.draw_resonators(ax, linewidth=2, color='mediumblue') cell.draw_resonator_end_points(ax, color='goldenrod', edgecolor='k', marker='o', size=80) #cell.draw_site_orientations(ax) ax.set_aspect('equal') ax.axis('off') pylab.title('resonators') ax = pylab.subplot(1, 3, 2) cell.draw_SDlinks(ax, color='firebrick', linewidth=2.5, minus_color='goldenrod') ax.set_aspect('equal') ax.axis('off') pylab.title('links') ax = pylab.subplot(1, 3, 3) cell.draw_resonators(ax, linewidth=2, color='mediumblue') cell.draw_resonator_end_points(ax, color='goldenrod', edgecolor='k', marker='o', size=80) cell.draw_SDlinks(ax, color='firebrick', linewidth=2.5, minus_color='goldenrod') #cell.draw_site_orientations(ax) ax.set_aspect('equal') ax.axis('off') pylab.title('links') pylab.show() ################### #make a 1D lattice (not periodic boundary conditions) testLattice = EuclideanLayout(4, 1, lattice_type='PeterChain', modeType='FW') #testLattice = EuclideanLayout(3,1,lattice_type = 'PeterChain', modeType = 'HW') genlattice = GeneralLayout(testLattice.resonators, modeType=testLattice.modeType) pylab.figure(2) pylab.clf() ax = pylab.subplot(1, 3, 1) testLattice.draw_resonator_lattice(ax, linewidth=2, color='mediumblue') testLattice.draw_resonator_end_points(ax, color='goldenrod', edgecolor='k', marker='o', size=80) #testLattice.draw_site_orientations(ax) #ax.set_aspect('equal') ax.axis('off') pylab.title('resonators') ax = pylab.subplot(1, 3, 2) testLattice.draw_resonator_lattice(ax, linewidth=2, color='mediumblue') #testLattice.draw_resonator_end_points(ax, color = 'goldenrod', edgecolor = 'k', marker = 'o' , size = 80) testLattice.draw_SDlinks(ax, color='firebrick', linewidth=2.5, minus_color='goldenrod', minus_links=True) testLattice.plot_end_layout_state(0.35 * numpy.ones(len(testLattice.SDx)), ax, title='', colorbar=False, plot_links=False, cmap='Wistia', scaleFactor=0.5) ax.axis('off') pylab.title('links') ax = pylab.subplot(1, 3, 3) testLattice.draw_SDlinks(ax, color='firebrick', linewidth=0.5, minus_color='goldenrod', minus_links=True) #testLattice.plot_layout_state(0.5*numpy.ones(len(testLattice.SDx)), ax, title = '', colorbar = False, plot_links = False, cmap = 'Wistia') state = testLattice.Psis[:, -2] testLattice.plot_layout_state(state, ax, title='', colorbar=False, plot_links=False, cmap='Wistia') ax.axis('off') pylab.tight_layout() pylab.show() ############## #compute a simple band structure cellModeType = 'FW' cell2 = UnitCell('PeterChain_tail', side=1) #band structure numSurfPoints = 300 kx_x, ky_y, cutx = cell.compute_band_structure(-2 * numpy.pi, 0, 2 * numpy.pi, 0, numsteps=numSurfPoints, modeType=cellModeType) #kx_y, ky_y, cuty = cell.compute_band_structure(0, -2.5*numpy.pi, 0, 2.5*numpy.pi, numsteps = numSurfPoints, modeType = cellModeType) kx_x, ky_y, cutx2 = cell2.compute_band_structure(-2 * numpy.pi, 0, 2 * numpy.pi, 0, numsteps=numSurfPoints, modeType=cellModeType) #kx_y, ky_y, cuty2 = cell2.compute_band_structure(0, -2.5*numpy.pi, 0, 2.5*numpy.pi, numsteps = numSurfPoints, modeType = cellModeType) pylab.figure(3) pylab.clf() ax = pylab.subplot(1, 4, 1) cell.draw_resonators(ax, linewidth=2, color='mediumblue') cell.draw_resonator_end_points(ax, color='goldenrod', edgecolor='k', marker='o', size=80) #cell.draw_site_orientations(ax) ax.set_aspect('equal') ax.axis('off') pylab.title('resonators') ax = pylab.subplot(1, 4, 2) pylab.cla() cell.plot_band_cut(ax, cutx) pylab.title('') pylab.ylabel('Energy (|t|)') pylab.xlabel('$k_x$ ($\pi$/a)') pylab.xticks([0, cutx.shape[1] / 2, cutx.shape[1]], [-2.5, 0, 2.5], rotation='horizontal') ax = pylab.subplot(1, 4, 3) cell2.draw_resonators(ax, linewidth=2, color='mediumblue') cell2.draw_resonator_end_points(ax, color='goldenrod', edgecolor='k', marker='o', size=80) #cell.draw_site_orientations(ax) ax.set_aspect('equal') ax.axis('off') pylab.title('resonators') ax = pylab.subplot(1, 4, 4) pylab.cla() cell.plot_band_cut(ax, cutx2) pylab.title('') pylab.ylabel('Energy (|t|)') pylab.xlabel('$k_x$ ($\pi$/a)') pylab.xticks([0, cutx.shape[1] / 2, cutx.shape[1]], [-2.5, 0, 2.5], rotation='horizontal') pylab.suptitle('Basic Band Structures') pylab.show() ############### #decorate and compute ########## squareLattice = EuclideanLayout(4, 4, lattice_type='square', modeType='FW') #squareLattice = EuclideanLayout(4,4,lattice_type = 'kagome', modeType = 'FW') squareResonators = squareLattice.resonators peterResonators = cell.resonators peterResonators2 = cell2.resonators decorated_resonators = decorate_layout(squareResonators, peterResonators2) resonators = decorated_resonators decoratedLattice2 = GeneralLayout(resonators, modeType=squareLattice.modeType, name='Peter2_square') decorated_resonators = decorate_layout(squareResonators, peterResonators) resonators = decorated_resonators decoratedLattice = GeneralLayout(resonators, modeType=squareLattice.modeType, name='Peter_square') testLattice = decoratedLattice2 #need a new cell decorated_cell_resonators = decorate_layout( squareLattice.unitcell.resonators, peterResonators2) #peterSquareCell = UnitCell('peterSquare',resonators = decorated_cell_resonators, a1 = cell2.a1, a2 = cell2.a2) peterSquareCell = UnitCell(resonators=decorated_cell_resonators, a1=squareLattice.unitcell.a1, a2=squareLattice.unitcell.a2, lattice_type='peterSquare') ##cell0 = UnitCell('kagome') ##cell0 = UnitCell('square') #cell0 = squareLattice.unitcell #decCell = UnitCell('PeterChain_tail', side = 1) #res0 = cell0.resonators ##res1 = decorate_layout(res0, decCell.resonators) ##res1 = decorate_layout(res0, peterResonators2) #res1 = decorate_layout(squareLattice.unitcell.resonators, peterResonators2) #testCell = UnitCell('Peter_graphene', resonators = res1, a1 = cell0.a1, a2 = cell0.a2) #peterSquareCell = testCell #band structure numSurfPoints = 300 #kx_x, ky_y, cutx = peterSquareCell.compute_band_structure(-2*numpy.pi, 0, 2*numpy.pi, 0, numsteps = numSurfPoints, modeType = cellModeType) #kx_y, ky_y, cuty = peterSquareCell.compute_band_structure(0, -2.5*numpy.pi, 0, 2.5*numpy.pi, numsteps = numSurfPoints, modeType = cellModeType) #kx_x, ky_y, cutx = peterSquareCell.compute_band_structure(-2*numpy.pi, numpy.pi, 2*numpy.pi, numpy.pi, numsteps = numSurfPoints, modeType = cellModeType) #kx_y, ky_y, cuty = peterSquareCell.compute_band_structure(-numpy.pi, -2.5*numpy.pi, numpy.pi, 2.5*numpy.pi, numsteps = numSurfPoints, modeType = cellModeType) kx_x, ky_y, cutx = peterSquareCell.compute_band_structure( -2 * numpy.pi, -2 * numpy.pi, 2 * numpy.pi, 2 * numpy.pi, numsteps=numSurfPoints, modeType=cellModeType) kx_y, ky_y, cuty = peterSquareCell.compute_band_structure( -2 * numpy.pi, 2 * numpy.pi, 2 * numpy.pi, -2 * numpy.pi, numsteps=numSurfPoints, modeType=cellModeType) pylab.figure(4) pylab.clf() ax = pylab.subplot(1, 4, 1) pylab.cla() squareLattice.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=2.5) #testLattice.draw_resonator_end_points(ax, color = 'goldenrod', edgecolor = 'k', marker = 'o' , size = 30) xs = squareLattice.coords[:, 0] ys = squareLattice.coords[:, 1] pylab.sca(ax) pylab.scatter(xs, ys, c=layoutCapColor, s=smallCdefault, marker='o', edgecolors='k', zorder=5) #ax.set_aspect('equal') ax.axis('off') pylab.title('square') ax = pylab.subplot(1, 4, 2) pylab.cla() testLattice.draw_resonator_lattice(ax, color=layoutLineColor, alpha=1, linewidth=2.5) #peterSquareCell.draw_resonators(ax) #testLattice.draw_resonator_end_points(ax, color = 'goldenrod', edgecolor = 'k', marker = 'o' , size = 30) xs = testLattice.coords[:, 0] ys = testLattice.coords[:, 1] pylab.sca(ax) pylab.scatter(xs, ys, c=layoutCapColor, s=smallCdefault, marker='o', edgecolors='k', zorder=5) #ax.set_aspect('equal') ax.axis('off') pylab.title('decorated square') ax = pylab.subplot(1, 4, 3) pylab.cla() peterSquareCell.plot_band_cut(ax, cutx) pylab.title('') pylab.ylabel('Energy (|t|)') pylab.xlabel('$k_x$ ($\pi$/a)') pylab.xticks([0, cutx.shape[1] / 2, cutx.shape[1]], [-2.5, 0, 2.5], rotation='horizontal') #ax.set_ylim([-2.5, 4]) ax = pylab.subplot(1, 4, 4) pylab.cla() peterSquareCell.plot_band_cut(ax, cuty) pylab.title('') pylab.ylabel('Energy (|t|)') pylab.xlabel('$k_y$ ($\pi$/a)') pylab.xticks([0, cutx.shape[1] / 2, cutx.shape[1]], [-2.5, 0, 2.5], rotation='horizontal') #ax.set_ylim([-2.5, 4]) pylab.show()
def run(): #######hyperbolic #test1 = PlanarLayout(gon = 7, vertex = 3, side =1, radius_method = 'lin', modeType = 'FW') #test1.populate(2, resonatorsOnly=False) #resonators = test1.get_all_resonators() #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = '7gon_3vertex_2') #######single ring #test1 = PlanarLayout(gon = 7, vertex = 3, side =1, radius_method = 'lin', modeType = 'FW') #test1.populate(2, resonatorsOnly=False) #resonators = test1.get_all_resonators() #resonators = resonators[0:test1.gon, :] #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'ring') #######split hyperbolic #test1 = PlanarLayout(gon = 7, vertex = 3, side =1, radius_method = 'lin') #test1.populate(2, resonatorsOnly=False) #resonators = test1.get_all_resonators() #splitGraph = split_resonators(resonators) #resonators = splitGraph #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'split7gon_3vertex_2') # #######Euclidean #test1 = EuclideanLayout(3,3,lattice_type = 'kagome', modeType = 'FW') #resonators = test1.resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'kagome') #######Euclidean #test1 = EuclideanLayout(4,4,lattice_type = 'square', modeType = 'FW') #resonators = test1.resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'square') #######Euclidean ##test1 = EuclideanLayout(4,3,lattice_type = 'Huse', modeType = 'FW') #test1 = EuclideanLayout(3,2,lattice_type = 'Huse', modeType = 'FW') #resonators = test1.resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'Huse') #######tree #test1 = TreeResonators(degree = 3, iterations = 5, side = 1, file_path = '', modeType = 'FW') #resonators = test1.get_all_resonators() ###Tree2 = TreeResonators(file_path = '3regularTree_ 3_.pkl') #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'TREEEEE') #######split tree #test1 = TreeResonators(degree = 3, iterations = 4, side = 1, file_path = '', modeType = 'FW') #resonators = test1.get_all_resonators() #splitGraph = split_resonators(resonators) #resonators = splitGraph #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'McLaughlinTree') #######line graph of split tree #test1 = TreeResonators(degree = 3, iterations = 4, side = 1, file_path = '', modeType = 'FW') #resonators = test1.get_all_resonators() #splitGraph = split_resonators(resonators) #resonators = splitGraph #LGresonators = generate_line_graph(resonators) #resonators = LGresonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'LG_McLaughlinTree') ########split Euclidean #test1 = EuclideanLayout(3,2,lattice_type = 'kagome', modeType = 'FW') #resonators = test1.resonators #splitGraph = split_resonators(resonators) #resonators = splitGraph #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'Splitkagome') ########split Euclidean #test1 = EuclideanLayout(3,3,lattice_type = 'square', modeType = 'FW') #resonators = test1.resonators #splitGraph = split_resonators(resonators) #resonators = splitGraph #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'SplitSquare') #########split Euclidean, hoffman attemps #test1 = EuclideanLayout(3,3,lattice_type = 'kagome', modeType = 'FW') #resonators0 = test1.resonators #graphene layout #splitGraph = split_resonators(resonators0) #split graphene layout #resonators1 = generate_line_graph(splitGraph) #McLaughlin-esque kagome #resonators2 = split_resonators(resonators1) #split further #resonators = resonators2 #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'hofmannAttempt') #########split Euclidean, hoffman attemps #test1 = EuclideanLayout(3,3,lattice_type = 'kagome', modeType = 'FW') #resonators0 = test1.resonators #graphene layout #splitGraph = split_resonators(resonators0) #split graphene layout #resonators1 = generate_line_graph(splitGraph) #McLaughlin-esque kagome #resonators2 = split_resonators(resonators1) #split further #resonators3 = generate_line_graph(resonators2) #resonators = resonators3 #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'L(hofmannAttempt)') ########split Euclidean 1.5 (n-way split) #splitIn = 3 #test1 = EuclideanLayout(3,2,lattice_type = 'kagome', modeType = 'FW') #resonators = test1.resonators #splitGraph = split_resonators(resonators, splitIn = splitIn) #resonators = splitGraph #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = str(splitIn) + 'SplitGraphene') ########split Euclidean2 #test1 = EuclideanLayout(3,2,lattice_type = 'Huse', modeType = 'FW') #resonators = test1.resonators #splitGraph = split_resonators(resonators) #resonators = splitGraph #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'split_HPG') ########line graph of Euyclidean #test1 = EuclideanLayout(4,4,lattice_type = 'kagome', modeType = 'FW') #resonators = test1.resonators #LGresonators = generate_line_graph(resonators) #resonators = LGresonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'LG_kagome') ########line graph of Euyclidean2 #test1 = EuclideanLayout(3,2,lattice_type = 'Huse', modeType = 'FW') #resonators = test1.resonators #LGresonators = generate_line_graph(resonators) #resonators = LGresonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'LG_Huse') ########line graph of line graph of Euyclidean #test1 = EuclideanLayout(2,2,lattice_type = 'kagome', modeType = 'FW') #resonators = test1.resonators #LGresonators = generate_line_graph(resonators) #resonators = LGresonators #LGresonators = generate_line_graph(resonators) #resonators = LGresonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'LG_LG_kagome') ######non-trivial tree #test1 = TreeResonators(cell ='Peter', degree = 3, iterations = 3, side = 1, file_path = '', modeType = 'FW') #resonators = test1.get_all_resonators() #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'PeterTREEEEE') # #######non-trivial tree, 2 #test1 = TreeResonators(cell ='', degree = 3, iterations = 3, side = 1, file_path = '', modeType = 'FW') #ucell = UnitCell('PeterChain_tail', side = 1) #resonators = test1.get_all_resonators() #decorated_resonators = decorate_layout(resonators, ucell.resonators) #resonators = decorated_resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'PeterTREEEEE2') # #########decorated Euyclidean #test1 = EuclideanLayout(3,3,lattice_type = 'kagome', modeType = 'FW') #ucell = UnitCell('PeterChain_tail', side = 1) #resonators = test1.resonators #decorated_resonators = decorate_layout(resonators, ucell.resonators) #resonators = decorated_resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'Peter-graphene') # #########decorated Euyclidean #test1 = EuclideanLayout(3,3,lattice_type = 'kagome', modeType = 'FW') #ucell = UnitCell('PeterChain_tail', side = 1) #resonators = test1.resonators #LGresonators = generate_line_graph(resonators) #resonators = LGresonators #decorated_resonators = decorate_layout(resonators, ucell.resonators) #resonators = decorated_resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'Peter-kagome') # #########decorated Euyclidean #test1 = EuclideanLayout(3,2,lattice_type = 'Huse', modeType = 'FW') #ucell = UnitCell('PeterChain_tail', side = 1) #resonators = test1.resonators #decorated_resonators = decorate_layout(resonators, ucell.resonators) #resonators = decorated_resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'Peter-HPG') # # ######decorated hyperbolic test1 = PlanarLayout(gon = 7, vertex = 3, side =1, radius_method = 'lin') test1.populate(2, resonatorsOnly=False) #resonators = test1.get_all_resonators() #splitGraph = split_resonators(resonators) #resonators = splitGraph ucell = UnitCell('PeterChain_tail', side = 1) resonators = test1.get_all_resonators() decorated_resonators = decorate_layout(resonators, ucell.resonators) resonators = decorated_resonators testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'decorated_hyperbolic') ###### #plot results ###### fig1 = pylab.figure(1) pylab.clf() ax = pylab.subplot(1,1,1) testLattice.draw_resonator_lattice(ax, color = 'mediumblue', alpha = 1 , linewidth = 2.5) testLattice.draw_SDlinks(ax, color = 'deepskyblue', linewidth = 1.5, minus_links = True, minus_color = 'firebrick') xs = testLattice.coords[:,0] ys = testLattice.coords[:,1] pylab.sca(ax) #pylab.scatter(xs, ys ,c = 'goldenrod', s = 20, marker = 'o', edgecolors = 'k', zorder = 5) pylab.scatter(xs, ys ,c = 'goldenrod', s = 30, marker = 'o', edgecolors = 'k', zorder = 5) #pylab.scatter(xs, ys ,c = 'goldenrod', s = 40, marker = 'o', edgecolors = 'k', zorder = 5) ax.set_aspect('equal') ax.axis('off') pylab.title(testLattice.name) fig1.set_size_inches(5, 5) pylab.tight_layout() pylab.show() eigNum = 168 eigNum = 167 eigNum = 0 pylab.figure(2) pylab.clf() ax = pylab.subplot(1,2,1) pylab.imshow(testLattice.H,cmap = 'winter') pylab.title('Hamiltonian') ax = pylab.subplot(1,2,2) pylab.imshow(testLattice.H - numpy.transpose(testLattice.H),cmap = 'winter') pylab.title('H - Htranspose') pylab.suptitle(testLattice.name) pylab.show() xs = numpy.arange(0,len(testLattice.Es),1) eigAmps = testLattice.Psis[:,testLattice.Eorder[eigNum]] pylab.figure(3) pylab.clf() ax1 = pylab.subplot(1,2,1) pylab.plot(testLattice.Es, 'b.') pylab.plot(xs[eigNum],testLattice.Es[testLattice.Eorder[eigNum]], color = 'firebrick' , marker = '.', markersize = '10' ) pylab.title('eigen spectrum') pylab.ylabel('Energy (t)') pylab.xlabel('eigenvalue number') ax2 = pylab.subplot(1,2,2) titleStr = 'eigenvector weight : ' + str(eigNum) testLattice.plot_layout_state(eigAmps, ax2, title = titleStr, colorbar = True, plot_links = True, cmap = 'Wistia') pylab.suptitle(testLattice.name) pylab.show() ########teting vertex finding codes ##vertexInd = 11 #vertexInd = int(numpy.floor(testLattice.coords.shape[0]/2.)) # #fig4 = pylab.figure(4) #pylab.clf() #ax = pylab.subplot(1,1,1) #testLattice.draw_resonator_lattice(ax, color = 'mediumblue', alpha = 1 , linewidth = 2.5) #testLattice.draw_SDlinks(ax, color = 'deepskyblue', linewidth = 1.5, minus_links = True, minus_color = 'goldenrod') # ##newCoords = get_coords(testLattice.resonators) #vertexx = testLattice.coords[vertexInd,0] #vertexy = testLattice.coords[vertexInd,1] #pylab.scatter(vertexx, vertexy ,c = 'firebrick', s = 200, marker = 'o', edgecolors = 'k', zorder = 0, alpha = 1) # ##testLattice.generate_vertex_dict() #connectedResonators = testLattice.vertexDict[vertexInd] #for rind in connectedResonators: # [x0,y0,x1,y1] = testLattice.resonators[rind] # pylab.plot([x0, x1],[y0, y1] , color = 'gold', linewidth = 4, alpha = 1, zorder = 10) # #xs = testLattice.coords[:,0] #ys = testLattice.coords[:,1] #pylab.sca(ax) #pylab.scatter(xs, ys ,c = 'goldenrod', s = 34, marker = 'o', edgecolors = 'k', zorder = 5) # # #ax.set_aspect('equal') #ax.axis('off') #pylab.title('checking vertex dictionary : ' + testLattice.name) #fig1.set_size_inches(5, 5) #pylab.tight_layout() #pylab.show() fig5 = pylab.figure(5) pylab.clf() ax = pylab.subplot(1,2,1) pylab.cla() testLattice.draw_resonator_lattice(ax, color = 'mediumblue', alpha = 1 , linewidth = 2.5) xs = testLattice.coords[:,0] ys = testLattice.coords[:,1] pylab.sca(ax) pylab.scatter(xs, ys ,c = 'goldenrod', s = 30, marker = 'o', edgecolors = 'k', zorder = 5) ax.set_aspect('equal') ax.axis('off') pylab.title('layout graph') ax2 = pylab.subplot(1,2,2) testLattice.draw_SDlinks(ax2, color = 'dodgerblue', linewidth = 2.5, minus_links = True, minus_color = 'gold') #testLattice.draw_SD_points(ax, color = 'mediumblue', edgecolor = 'goldenrod', marker = 'o' , size = 30, extra = False) pylab.sca(ax2) pylab.scatter(testLattice.SDx, testLattice.SDy ,c = 'lightsteelblue', s = 30, marker = 'o', edgecolors = 'mediumblue', zorder = 5) ax2.set_aspect('equal') ax2.axis('off') pylab.title('effective (line) graph') pylab.suptitle(testLattice.name) fig5.set_size_inches(10, 5) pylab.tight_layout() pylab.show() fig6 = pylab.figure(6) pylab.clf() ax = pylab.subplot(1,1,1) #testLattice.draw_resonator_lattice(ax, color = 'mediumblue', alpha = 1 , linewidth = 0.5) testLattice.draw_SDlinks(ax, color = 'firebrick', linewidth = 1., minus_links = True, minus_color = 'goldenrod') xs = testLattice.coords[:,0] ys = testLattice.coords[:,1] pylab.sca(ax) ##pylab.scatter(xs, ys ,c = 'goldenrod', s = 20, marker = 'o', edgecolors = 'k', zorder = 5) #pylab.scatter(xs, ys ,c = 'goldenrod', s = 30, marker = 'o', edgecolors = 'k', zorder = 5) ##pylab.scatter(xs, ys ,c = 'goldenrod', s = 40, marker = 'o', edgecolors = 'k', zorder = 5) ax.set_aspect('equal') ax.axis('off') #pylab.title(testLattice.name) pylab.tight_layout() pylab.show()
def __init__(self, cellNum, coverLinks='', coverPolarity='', coverDim='2d', lattice_type='square', mag=2.5, baseTheta=0): '''start from a number in the table is CKS book and make a basic unit cell, then cover it in 2D.''' self.cellNum = cellNum self.mag = mag self.lattice_type = lattice_type self.coverDim = coverDim self.baseTheta = baseTheta #allow some rotation to help the graphs look nice. if self.lattice_type == 'square': self.a1 = numpy.asarray([self.mag, 0]) # self.a1 = numpy.asarray([self.mag,0.6]) #!!!!!hack!!!!! self.a2 = numpy.asarray([0.0, self.mag]) else: raise ValueError( 'other types not yet supported. Should be: square') # if lattice_type == 'triangular': # angle = numpy.pi/3 # mag = 2.5 # a1 = numpy.asarray([mag,0]) # a2 = numpy.asarray([numpy.cos(angle)*mag,numpy.sin(angle)*mag]) if coverLinks == '': self.coverLinks = [0, 2] else: self.coverLinks = coverLinks if coverPolarity == '': self.coverPolarity = [0, 0] else: self.coverPolarity = coverPolarity if self.cellNum == 26: self.numNodes = 10 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 5], [1, 6], [4, 9], [1, 9], [3, 7], [2, 0], [0, 8]]) self.removals = numpy.asarray([[0, 1], [0, 9]]) elif self.cellNum == 7: self.numNodes = 8 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 3], [7, 4], [1, 6], [2, 5]]) self.removals = numpy.asarray([]) elif self.cellNum == 3: self.numNodes = 6 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 3], [1, 5], [2, 4]]) self.removals = numpy.asarray([]) elif self.cellNum == 82: self.numNodes = 12 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 3], [11, 8], [2, 9], [1, 6], [10, 5], [4, 7]]) self.removals = numpy.asarray([]) elif self.cellNum == 35: self.numNodes = 12 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 6], [1, 3], [11, 9], [5, 7], [4, 10], [2, 8]]) self.removals = numpy.asarray([]) elif self.cellNum == 6: self.numNodes = 8 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 4], [1, 6], [7, 2], [3, 5]]) self.removals = numpy.asarray([]) elif self.cellNum == 105: self.numNodes = 12 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 3], [1, 10], [2, 5], [4, 7], [6, 9], [8, 11]]) self.removals = numpy.asarray([]) elif self.cellNum == 1: self.numNodes = 4 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 2], [1, 3]]) self.removals = numpy.asarray([]) elif self.cellNum == 52: self.numNodes = 12 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 6], [1, 11], [2, 4], [10, 8], [5, 7], [3, 9]]) self.removals = numpy.asarray([]) elif self.cellNum == 2: self.numNodes = 6 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 3], [1, 4], [2, 5]]) self.removals = numpy.asarray([]) elif self.cellNum == 1: self.numNodes = 4 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 2], [1, 3]]) self.removals = numpy.asarray([]) elif self.cellNum == 5: self.numNodes = 8 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[2, 6], [0, 4], [1, 3], [7, 5]]) self.removals = numpy.asarray([]) elif self.cellNum == 452: self.numNodes = 18 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 9], [3, 12], [6, 15], [1, 17], [2, 4], [5, 7], [8, 10], [11, 13], [14, 16]]) self.removals = numpy.asarray([]) elif self.cellNum == 8: self.numNodes = 8 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 2], [1, 7], [3, 5], [4, 6]]) self.removals = numpy.asarray([]) elif self.cellNum == 16: self.numNodes = 10 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 5], [1, 3], [2, 6], [4, 8], [7, 9]]) self.removals = numpy.asarray([]) elif self.cellNum == 110: self.numNodes = 12 self.numBonds = 3 * self.numNodes / 2 self.cellResonators = numpy.zeros((int(self.numBonds), 4)) self.baseRing = numpy.zeros((int(self.numNodes), 4)) self.chords = numpy.asarray([[0, 6], [1, 11], [2, 4], [3, 8], [5, 10], [7, 11], [9, 0]]) self.removals = numpy.asarray([[0, 11]]) else: raise ValueError('this number is not supported yet') self.folderName = 'CDS_' + lattice_type + 'Primitive_cell_' + str( cellNum) ######### #fill in the basic ring # x0 = 0. # y0 = 1. x0 = numpy.sin(self.baseTheta) y0 = numpy.cos(self.baseTheta) self.theta = 2 * numpy.pi / (self.numNodes) for bind in range(0, int(self.numNodes)): x1 = numpy.cos(self.theta) * x0 + numpy.sin(self.theta) * y0 y1 = -numpy.sin(self.theta) * x0 + numpy.cos(self.theta) * y0 self.baseRing[bind, :] = [x0, y0, x1, y1] x0 = x1 y0 = y1 #flag the necessary azimuthals for removal self.skips = [] for bind in range(0, self.removals.shape[0]): mind = numpy.min(self.removals[bind, :]) maxind = numpy.max(self.removals[bind, :]) if maxind == self.numNodes - 1: startind = maxind else: startind = mind self.skips.append(startind) #gather the remaining azimuthals bind = 0 for rind in range(0, int(self.numNodes)): if rind in self.skips: #this one should not be included. Skip pass else: self.cellResonators[bind, :] = self.baseRing[rind, :] bind = bind + 1 #add the chords for rind in range(0, self.chords.shape[0]): startind = self.chords[rind, 0] stopind = self.chords[rind, 1] x0 = self.baseRing[startind, 0] y0 = self.baseRing[startind, 1] x1 = self.baseRing[stopind, 0] y1 = self.baseRing[stopind, 1] self.cellResonators[bind, :] = [x0, y0, x1, y1] bind = bind + 1 #starting unit cell graph self.baseGraph = GeneralLayout(resonators=self.cellResonators, name=str(cellNum), resonatorsOnly=True) #fill in 2D self.update_cover(self.coverLinks, self.coverPolarity, self.coverDim)
def update_cover(self, coverLinks, coverPolarity, coverDim='2d'): self.coverLinks = coverLinks self.coverPolarity = coverPolarity self.coverDim = coverDim #go to 2D #make the lattice unit cell self.latticeCellResonators = numpy.copy(self.cellResonators) xlink = self.coverLinks[0] xpol = self.coverPolarity[0] ylink = self.coverLinks[1] ypol = self.coverPolarity[1] if self.coverDim == '2d': if xpol == 0: vec1 = numpy.asarray([self.a1[0], self.a1[1], 0, 0]) else: vec1 = numpy.asarray([0, 0, self.a1[0], self.a1[1]]) if ypol == 0: vec2 = numpy.asarray([self.a2[0], self.a2[1], 0, 0]) else: vec2 = numpy.asarray([0, 0, self.a2[0], self.a2[1]]) # tempVec = numpy.asarray([self.a2[0], self.a2[1], 0,0]) + numpy.asarray([self.a1[0], self.a1[1], 0,0]) elif self.coverDim == 'xx': #tempVec = numpy.asarray([self.a1[0], self.a1[1], 0,0]) # vec1 = tempVec #!!!!!!!!!hack!!!!!!!!!! # vec2 = tempVec#!!!!!!!!!hack!!!!!!!!!! list0 = [self.a1[0], self.a1[1]] if xpol == 0: tempVec = numpy.asarray(list0 + [0, 0]) vec1 = tempVec else: tempVec = numpy.asarray([0, 0] + list0) vec1 = tempVec if ypol == 0: tempVec = numpy.asarray(list0 + [0, 0]) vec2 = tempVec else: tempVec = numpy.asarray([0, 0] + list0) vec2 = tempVec elif self.coverDim == 'x-x': # tempVec = numpy.asarray([self.a1[0], self.a1[1], 0,0]) # vec1 = tempVec #!!!!!!!!!hack!!!!!!!!!! # vec2 = -tempVec#!!!!!!!!!hack!!!!!!!!!! list0 = [self.a1[0], self.a1[1]] list1 = [-self.a1[0], -self.a1[1]] if xpol == 0: tempVec = numpy.asarray(list0 + [0, 0]) vec1 = tempVec else: tempVec = numpy.asarray([0, 0] + list0) vec1 = tempVec if ypol == 0: tempVec = numpy.asarray(list1 + [0, 0]) vec2 = tempVec else: tempVec = numpy.asarray([0, 0] + list1) vec2 = tempVec elif self.coverDim == 'x0': if xpol == 0: tempVec = numpy.asarray([self.a1[0], self.a1[1], 0, 0]) else: tempVec = numpy.asarray([0, 0, self.a1[0], self.a1[1]]) vec1 = tempVec #!!!!!!!!!hack!!!!!!!!!! vec2 = 0 * tempVec #!!!!!!!!!hack!!!!!!!!!! else: raise ValueError('invalid cover type. should be : 2d, xx, x-x') self.latticeCellResonators[ xlink, :] = self.latticeCellResonators[xlink, :] + vec1 self.latticeCellResonators[ ylink, :] = self.latticeCellResonators[ylink, :] + vec2 # tempInd = 6 ## self.latticeCellResonators[tempInd,:] = self.latticeCellResonators[tempInd,:] -vec1#!!!!!!!!!hack!!!!!! # self.latticeCellResonators[tempInd,:] = self.latticeCellResonators[tempInd,:] +vec2 ## self.latticeCellGraph = GeneralLayout( resonators=self.latticeCellResonators, name=str(self.cellNum) + '_mod', resonatorsOnly=True) self.latticeCell = UnitCell(lattice_type=str(self.cellNum) + '_mod', side=1, resonators=self.latticeCellResonators, a1=self.a1, a2=self.a2) #make the Euclidean lattice self.lattice = EuclideanLayout(xcells=3, ycells=3, modeType='FW', resonatorsOnly=False, initialCell=self.latticeCell) return
def run(): ####### #hyperbolic lattices ####### test = PlanarLayout(gon=7, vertex=3, side=1, modeType='FW') test.populate(maxItter=2) pylab.figure(1) pylab.clf() ax = pylab.subplot(1, 1, 1) test.draw_resonator_lattice(ax, color='mediumblue', linewidth=2) test.draw_resonator_end_points(ax, color='cornflowerblue', edgecolor='c', size=150) ax.axis('off') #reomves the outside box ax.set_aspect('equal') pylab.tight_layout() #don't waste space pylab.show() ####### #Euclidean lattice ####### testCell = UnitCell('kagome') #fundamental domain object testLattice = EuclideanLayout(3, 3, lattice_type='kagome', modeType='FW') #The full lattice pylab.figure(2) pylab.clf() ax = pylab.subplot(1, 2, 1) testLattice.draw_resonator_lattice(ax, color='mediumblue', linewidth=2) testLattice.draw_resonator_lattice(ax, color='firebrick', linewidth=2, extras=True) testLattice.draw_resonator_end_points(ax, color='cornflowerblue', edgecolor='c', size=150) ax.axis('off') #reomves the outside box ax.set_aspect('equal') pylab.title('lattice') ax = pylab.subplot(1, 2, 2) testLattice.unitcell.draw_resonators(ax, color='mediumblue', linewidth=2) testLattice.unitcell.draw_resonator_end_points(ax, color='cornflowerblue', edgecolor='c', size=150) ax.axis('off') #reomves the outside box ax.set_aspect('equal') pylab.title('cell') pylab.show() ###### #General layout ###### #######hyperbolic #test1 = PlanarLayout(gon = 7, vertex = 3, side =1, radius_method = 'lin', modeType = 'FW') #test1.populate(2, resonatorsOnly=False) #resonators = test1.get_all_resonators() #genLattice = GeneralLayout(resonators , modeType = test1.modeType, name = '7gon_3vertex_2') #######euclidean #resonators = testLattice.get_all_resonators() #genLattice = GeneralLayout(resonators , modeType = testLattice.modeType, name = 'kagome33') #######modified euclidean #resonators = testLattice.get_all_resonators() #resonators = split_resonators(resonators) #genLattice = GeneralLayout(resonators , modeType = testLattice.modeType, name = 'splitkagome33') # #######tree #test1 = TreeResonators(degree = 3, iterations = 5, side = 1, file_path = '', modeType = 'FW') #resonators = test1.get_all_resonators() #genLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'TREEEEE') ######split tree #test1 = TreeResonators(degree = 3, iterations = 4, side = 1, file_path = '', modeType = 'FW') #resonators = test1.get_all_resonators() #splitGraph = split_resonators(resonators) #resonators = splitGraph #genLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'McLaughlinTree') #######line graph of split tree test1 = TreeResonators(degree=3, iterations=4, side=1, file_path='', modeType='FW') resonators = test1.get_all_resonators() splitGraph = split_resonators(resonators) resonators = splitGraph LGresonators = generate_line_graph(resonators) resonators = LGresonators genLattice = GeneralLayout(resonators, modeType=test1.modeType, name='LG_McLaughlinTree') pylab.figure(3) pylab.clf() ax = pylab.subplot(1, 1, 1) genLattice.draw_resonator_lattice(ax, color='mediumblue', linewidth=2) genLattice.draw_resonator_end_points(ax, color='cornflowerblue', edgecolor='c', size=150) ax.axis('off') #reomves the outside box ax.set_aspect('equal') pylab.title('general') pylab.show() ######## #line graph a.k.a. medial lattice ####### #####split tree test1 = TreeResonators(degree=3, iterations=4, side=1, file_path='', modeType='FW') resonators = test1.get_all_resonators() splitGraph = split_resonators(resonators) resonators = splitGraph genLattice = GeneralLayout(resonators, modeType=test1.modeType, name='McLaughlinTree') #######line graph of split tree test1 = TreeResonators(degree=3, iterations=4, side=1, file_path='', modeType='FW') resonators = test1.get_all_resonators() splitGraph = split_resonators(resonators) resonators = splitGraph LGresonators = generate_line_graph(resonators) resonators = LGresonators genLattice2 = GeneralLayout(resonators, modeType=test1.modeType, name='LG_McLaughlinTree') pylab.figure(4) pylab.clf() ax = pylab.subplot(1, 2, 1) genLattice.draw_resonator_lattice(ax, color='mediumblue', linewidth=2) genLattice.draw_resonator_end_points(ax, color='cornflowerblue', edgecolor='c', size=150) ax.axis('off') #reomves the outside box ax.set_aspect('equal') pylab.title('hardware layout') ax = pylab.subplot(1, 2, 2) genLattice.draw_resonator_lattice(ax, color='mediumblue', linewidth=2, alpha=0.5) genLattice.draw_resonator_end_points(ax, color='cornflowerblue', edgecolor='c', size=75) genLattice2.draw_resonator_lattice(ax, color='k', linewidth=2) genLattice2.draw_resonator_end_points(ax, color='firebrick', edgecolor='c', size=75) ax.axis('off') #reomves the outside box ax.set_aspect('equal') pylab.title('both') pylab.show()