def compile_lambda_extrema(maxItt, gon = 7, tree = False, degree = 3, roundDepth = 6, save = True, saveFolder = '', secondEnergy = False):
    lambdaMax_vals = numpy.zeros(maxItt)
    lambdaMin_vals = numpy.zeros(maxItt)
    
    if secondEnergy:
        lambda2Max_vals = numpy.zeros(maxItt)
        lambda2Min_vals = numpy.zeros(maxItt)
    
    sizes = numpy.zeros(maxItt)
    
    
    
    if tree:
        stepSize = 2
        itts = scipy.arange(1,maxItt+1, 1)*stepSize #go up ins steps of 3 generations at a time
        maxItt = maxItt*stepSize
        
        for ind in range(0, len(itts)):
            itt = itts[ind]
            base = TreeResonators(degree = degree, iterations = itt)
            baseName = '3tree'
            print itt
            
            nameStr = baseName  + '_' + str(itt)
            test = GeneralLayout(resonators = base.get_all_resonators(), resonatorsOnly = True, modeType = 'FW', name = nameStr, roundDepth = roundDepth)
            
            Hsparse = generate_layout_Hamiltonian(test, roundDepth = roundDepth, t = 1, verbose = False, sparse = True, flags = 0)
            
            almostMaxs = scipy.sparse.linalg.eigsh(Hsparse, sigma = 3, return_eigenvectors = False)
            almostMins = scipy.sparse.linalg.eigsh(Hsparse, sigma = -3, return_eigenvectors = False)
            
            lambdaMax_vals[ind] = numpy.max(almostMaxs)
            lambdaMin_vals[ind] = numpy.min(almostMins)
            if secondEnergy:
                tempMaxs = almostMaxs
                tempMins = almostMins
                flagmax = numpy.where(tempMaxs == numpy.max(almostMaxs))[0][0]
                flagmin = numpy.where(tempMins == numpy.min(almostMins))[0][0]
                tempMaxs[flagmax] = -200
                tempMins[flagmin] = 200
                lambda2Max_vals[ind] = numpy.max(tempMaxs)
                lambda2Min_vals[ind] = numpy.min(tempMins)
            sizes[ind] = test.coords.shape[0]
        
    else:
        itts = scipy.arange(1,maxItt+1, 1)
        
        base = PlanarLayout(gon = gon, vertex = degree, side =1, radius_method = 'exp', modeType = 'FW')
        base.populate(maxItter = 1, resonatorsOnly = True)   
        baseName = str(gon) + 'gon_' + str(degree) + 'vertex'
        for itt in itts:
            if itt > 1:
                base.itter_generate()
                base.generate_semiduals()
                print itt
            
            nameStr = baseName  + '_' + str(itt)
            test = GeneralLayout(resonators = base.get_all_resonators(), resonatorsOnly = True, modeType = 'FW', name = nameStr, roundDepth = roundDepth)
            
            Hsparse = generate_layout_Hamiltonian(test, roundDepth = roundDepth, t = 1, verbose = False, sparse = True, flags = 0)
            
            almostMaxs = scipy.sparse.linalg.eigsh(Hsparse, sigma = 3, return_eigenvectors = False)
            almostMins = scipy.sparse.linalg.eigsh(Hsparse, sigma = -3, return_eigenvectors = False)
            
            lambdaMax_vals[itt-1] = numpy.max(almostMaxs)
            lambdaMin_vals[itt-1] = numpy.min(almostMins)
            if secondEnergy:
                tempMaxs = almostMaxs
                tempMins = almostMins
                flagmax = numpy.where(tempMaxs == numpy.max(almostMaxs))[0][0]
                flagmin = numpy.where(tempMins == numpy.min(almostMins))[0][0]
                tempMaxs[flagmax] = -200
                tempMins[flagmin] = 200
                lambda2Max_vals[itt-1] = numpy.max(tempMaxs)
                lambda2Min_vals[itt-1] = numpy.min(tempMins)
            sizes[itt-1] = test.coords.shape[0]
        
       
    pickleDict = {}
    pickleDict['itts'] = itts
    pickleDict['lambdaMax'] = lambdaMax_vals
    pickleDict['lambdaMin'] = lambdaMin_vals
    pickleDict['name'] = baseName
    pickleDict['systemSizes'] = sizes
    if secondEnergy:
        pickleDict['lambda2Max'] = lambda2Max_vals
        pickleDict['lambda2Min'] = lambda2Min_vals
    
    if save:
        if secondEnergy:
            saveName = baseName + '_layoutLambdaExtremaAndSecond_' + str(maxItt) + '.pkl'
        else:
            saveName = baseName + '_layoutLambdaExtrema_' + str(maxItt) + '.pkl'
        save_path = os.path.join(saveFolder, saveName)
        pickle.dump(pickleDict, open(save_path, 'wb'))
    
    print save_path
    
    fig1 = pylab.figure(1)
    pylab.clf()
    ax = pylab.subplot(1,2,1)
    pylab.plot(itts, lambdaMax_vals, 'b.-', label = 'sparse')
    if secondEnergy:
        pylab.plot(itts, lambda2Max_vals, color = 'dodgerblue', marker = '.', linestyle = '-', label = 'sparse, 2nd')
#    pylab.plot(itts_full[2:], lambdaMax_vals_full[2:], color = 'deepskyblue', linestyle = '-', marker = '.', label = 'full')
    ax.legend(loc = 'lower right')
    pylab.title('$\lambda_{max}$')
    pylab.xlabel('itterations')
    
    ax = pylab.subplot(1,2,2)
    pylab.plot(itts, lambdaMin_vals, 'r.-', label = 'sparse')
    if secondEnergy:
        pylab.plot(itts, lambda2Min_vals, color = 'firebrick', marker = '.', linestyle = '-', label = 'sparse, 2nd')
#    pylab.plot(itts_full[2:], lambdaMin_vals_full[2:], color = 'deepskyblue', linestyle = '-', marker = '.', label = 'full')
    ax.legend(loc = 'upper right')
    pylab.title('$\lambda_{min}$')
    pylab.xlabel('itterations')
    
    pylab.suptitle(baseName)
    
    fig1.set_size_inches([9.7,5.1])
    pylab.show()
    
    if save:
        fig_saveName = baseName + '_layoutLambdaExtremaFig_' + str(maxItt) + '.png'
        fig_save_path = os.path.join(saveFolder, fig_saveName)
        fig1.savefig(fig_save_path,transparent= False, dpi = 200)
        
    return lambdaMax_vals, lambdaMin_vals, itts
Exemplo n.º 2
0
kapheneCell = kagomeCell.split_cell(
    name='kaphene', splitIn=2)  #split graphene layout, kaphene effective
lineKapheneCell = kapheneCell.line_graph_cell(
    name='lineKaphene',
    resonatorsOnly=False)  #kaphene layout, line kaffene effective
splitKapheneLayoutCell = lineKapheneCell.split_cell(
    name='splitKapheneLay_CharonEff')  #split kaphene layout, Charon effective

EuclidLayout = EuclideanLayout(4,
                               4,
                               lattice_type=splitKapheneLayoutCell.type,
                               modeType='FW',
                               initialCell=splitKapheneLayoutCell)
layout = GeneralLayout(resonators=EuclidLayout.get_all_resonators(),
                       resonatorsOnly=True,
                       modeType='FW',
                       name=EuclidLayout.lattice_type,
                       roundDepth=3)
#make_layoutGraph_vid(layout, startInd = 0, stopInd = 3, figNum = 1, xsize = xsize, ysize = ysize)
#make_layoutGraph_vid(layout, startInd = 0, stopInd = -1, figNum = 1, xsize = xsize, ysize = ysize)

#showGon = 14
#showInds = [3]
##showGon = 12
##showInds = [3]
##showGon = 9
##showInds = [4,3]
##showGon = 8
##showInds = [5,4,3]
##showGon = 7
##showInds = [6,5,4,3]
def compile_lambda_target_sigma(maxItt, gon = 7, target = 1.51, numVals = 20, roundDepth = 6, save = True, saveFolder = ''):
    lambda_vals = numpy.zeros((maxItt, numVals))
    
    sizes = numpy.zeros(maxItt)


    itts = scipy.arange(1,maxItt+1, 1)
    
    base = PlanarLayout(gon = gon, vertex = 3, side =1, radius_method = 'exp', modeType = 'FW')
    base.populate(maxItter = 1, resonatorsOnly = True)   
    baseName = str(gon) + 'gon_3vertex'
    for itt in itts:
        if itt > 1:
            base.itter_generate()
            base.generate_semiduals()
            print itt
        
        nameStr = baseName  + '_' + str(itt)
        test = GeneralLayout(resonators = base.get_all_resonators(), resonatorsOnly = True, modeType = 'FW', name = nameStr, roundDepth = roundDepth)
        
        Hsparse = generate_layout_Hamiltonian(test, roundDepth = roundDepth, t = 1, verbose = False, sparse = True, flags = 0)
        
        almostMaxs = scipy.sparse.linalg.eigsh(Hsparse, sigma = target, return_eigenvectors = False, k = numVals)
        
        lambda_vals[itt-1,: ] = almostMaxs
        sizes[itt-1] = test.coords.shape[0]
    
       
    pickleDict = {}
    pickleDict['itts'] = itts
    pickleDict['lambdas'] = lambda_vals
    pickleDict['target'] = target
    pickleDict['name'] = baseName
    pickleDict['systemSizes'] = sizes
    
    saveName_0 = baseName + '_' + str(maxItt) +  '_layoutLambdaTarget_' + str(target) + '_' +str(numVals) 
    if save:
        saveName = saveName_0 + '.pkl'
        save_path = os.path.join(saveFolder, saveName)
        pickle.dump(pickleDict, open(save_path, 'wb'))
    
    
    fig1 = pylab.figure(1)
    pylab.clf()
    ax = pylab.subplot(1,1,1)
    for ind in range(0, numVals):
        pylab.plot(itts, lambda_vals[:, ind], 'b.-', label = 'sparse')
#    ax.legend(loc = 'lower right')
    pylab.title('$\lambda$_' + str(target))
    pylab.xlabel('itterations')
    
#    ax = pylab.subplot(1,2,2)
#    pylab.plot(itts, lambdaMin_vals, 'r.-', label = 'sparse')
##    pylab.plot(itts_full[2:], lambdaMin_vals_full[2:], color = 'deepskyblue', linestyle = '-', marker = '.', label = 'full')
#    ax.legend(loc = 'upper right')
#    pylab.title('$\lambda_{min}$')
#    pylab.xlabel('itterations')
    
    
    
    pylab.suptitle(saveName_0)
    
    fig1.set_size_inches([5.1,5.1])
    pylab.show()
    
    
    if save:
#        fig_saveName = baseName + '_layoutLambdaExtremaFig_' + str(maxItt) + '.png'
        fig_saveName = saveName_0 +'.png'
        fig_save_path = os.path.join(saveFolder, fig_saveName)
        fig1.savefig(fig_save_path,transparent= False, dpi = 200)
        
    return lambda_vals, itts
def compile_lambda_extrema_gonSequence(maxItt, firstGon = 7, lastGon = 10, degree = 3, roundDepth = 6, save = True, saveFolder = ''):
    lambdaMax_vals = numpy.zeros(lastGon - firstGon + 1)
    lambdaMin_vals = numpy.zeros(lastGon - firstGon + 1)
    
    sizes = numpy.zeros(lastGon - firstGon + 1)


    gons = scipy.arange(firstGon,lastGon+1, 1)
    
      
#    baseName = str(gon) + 'gon_' + str(degree) + 'vertex'
    for ind in range(0, len(gons)):
        gon = gons[ind]
        base = PlanarLayout(gon = gon, vertex = degree, side =1, radius_method = 'exp', modeType = 'FW')
        base.populate(maxItter = maxItt, resonatorsOnly = True) 
        
        nameStr = str(gon) + 'gon_' + str(degree) + 'vertex'  + '_' + str(maxItt)
        test = GeneralLayout(resonators = base.get_all_resonators(), resonatorsOnly = True, modeType = 'FW', name = nameStr, roundDepth = roundDepth)
        
        Hsparse = generate_layout_Hamiltonian(test, roundDepth = roundDepth, t = 1, verbose = False, sparse = True, flags = 0)
        
        almostMaxs = scipy.sparse.linalg.eigsh(Hsparse, sigma = degree, return_eigenvectors = False)
        almostMins = scipy.sparse.linalg.eigsh(Hsparse, sigma = -degree, return_eigenvectors = False)
        
        lambdaMax_vals[ind] = numpy.max(almostMaxs)
        lambdaMin_vals[ind] = numpy.min(almostMins)
        sizes[ind] = test.coords.shape[0]
        
    baseName = str(firstGon) + '_' + str(lastGon) + 'gon_' + str(degree) + 'vertex'
    pickleDict = {}
    pickleDict['gons'] = gons
    pickleDict['lambdaMax'] = lambdaMax_vals
    pickleDict['lambdaMin'] = lambdaMin_vals
    pickleDict['name'] = baseName
    pickleDict['systemSizes'] = sizes
    
    if save:
        saveName = baseName + '_layoutLambdaExtrema_' + str(maxItt) + '.pkl'
        save_path = os.path.join(saveFolder, saveName)
        pickle.dump(pickleDict, open(save_path, 'wb'))
    
    
    fig1 = pylab.figure(1)
    pylab.clf()
    ax = pylab.subplot(1,2,1)
    pylab.plot(gons, lambdaMax_vals, 'b.-', label = 'sparse')
    ax.legend(loc = 'upper right')
    pylab.title('$\lambda_{max}$')
    pylab.xlabel('k')
    
    ax = pylab.subplot(1,2,2)
    pylab.plot(gons, lambdaMin_vals, 'r.-', label = 'sparse')
    ax.legend(loc = 'upper right')
    pylab.title('$\lambda_{min}$')
    pylab.xlabel('k')
    
    pylab.suptitle(baseName)
    
    fig1.set_size_inches([9.7,5.1])
    pylab.show()
    
    if save:
        fig_saveName = baseName + '_layoutLambdaExtremaFig_' + str(maxItt) + '.png'
        fig_save_path = os.path.join(saveFolder, fig_saveName)
        fig1.savefig(fig_save_path,transparent= False, dpi = 200)
        
    return lambdaMax_vals, lambdaMin_vals, gons
Exemplo n.º 5
0
#
#newCell = split_resonators(testEuclidLattice.unitcell.resonators)
##testCell =  UnitCell('split_graphene', resonators = newCell, a1 = testEuclidLattice.unitcell.a1, a2 = testEuclidLattice.unitcell.a2)
#testCell =  UnitCell('graphene_layout', resonators = testEuclidLattice.unitcell.resonators, a1 = testEuclidLattice.unitcell.a1, a2 = testEuclidLattice.unitcell.a2)
#
#parentCell = testEuclidLattice.unitcell
#
#grapheneCell = UnitCell('kagome', a1 = testEuclidLattice.unitcell.a1, a2 = testEuclidLattice.unitcell.a2)
#

############5)
#split kaphene cell
testEuclidLattice = EuclideanLayout(3, 3, lattice_type='kagome', modeType='FW')
resoantors1 = split_resonators(testEuclidLattice.resonators)
splitLattice = GeneralLayout(resoantors1,
                             modeType=testEuclidLattice.modeType,
                             name=testEuclidLattice.lattice_type)

newCell = split_resonators(testEuclidLattice.unitcell.resonators)
#make all the cells that I want
kagomeCell = UnitCell('kagome')  #graphene layout, kagome effective
kapheneCell = kagomeCell.split_cell(
    name='kaphene', splitIn=2)  #split graphene layout, kaphene effective
lineKapheneCell = kapheneCell.line_graph_cell(
    name='lineKaphene',
    resonatorsOnly=False)  #kaphene layout, line kaffene effective

newCell = split_resonators(testEuclidLattice.unitcell.resonators)
splitKapheneLayoutCell = lineKapheneCell.split_cell(
    name='split kaphene layout')
Exemplo n.º 6
0
#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')
Exemplo n.º 7
0
                              modeType='FW',
                              resonatorsOnly=False,
                              initialCell=testCell_auto)

#1) extremal hofman
########split Euclidean, hoffman attemps
##!!!!!!!!needs to be this size for the cell to come out right. DO NOT CHANGE!!!
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, kaphene
resonators2 = split_resonators(resonators1)  #split further
resonators = resonators2
testLattice = GeneralLayout(resonators,
                            modeType=test1.modeType,
                            name='hofmannAttempt')
#sites = [80,81,82, 83,79,78,77,76, 71, 84,85,86,87,114,115, 116, 50, 49, 48, 47, 46, 44, 55,54, 53,52]
sites = [
    80, 81, 83, 79, 78, 77, 76, 71, 50, 49, 48, 47, 46, 44, 55, 54, 53, 52
]
state = numpy.zeros(len(testLattice.SDx))
state[sites] = 0.1
newCell = testLattice.resonators[sites, :]
testCell = UnitCell('extremal_hofmann',
                    resonators=newCell,
                    a1=test1.unitcell.a1,
                    a2=test1.unitcell.a2)

#make all the cells that I want
kagomeCell = UnitCell('kagome')  #graphene layout, kagome effective