Beispiel #1
0
    def calc_cherns_vary_glatparam(self,
                                   glatparam,
                                   paramV,
                                   reverse=False,
                                   verbose=False,
                                   save_png=True):
        """For a single Lattice instance, vary a GyroLattice parameter and compute the chern index for each value.
        When supplied, a single gyro_lattice instance is required for each physical lattice, but each new glat
        (same lattice, different lp) will be appended to self.gyro_collection.gyro_lattices when lp is updated

        Parameters
        ----------
        glatparam : str key for lp dictionary
            the string specifier for the parameter to change FOR THE SAME LATTICE, for each value in paramV
        paramV : list or 1d numpy array
            the values to assign to glat.lp[glatparam] for each chern calculation
        reverse : bool
            reverse the order of paramV in which to compute
        verbose : bool
            print intermediate output
        """
        # prepare xy locations as fraction of system size
        print 'Looping over all networks in the gyro collection. ' + \
              'For each one, cycling through glat lpparams in paramV..'
        print('--> glats to do:',
              [key for key in self.gyro_collection.gyro_lattices])
        glatstodo = [key for key in self.gyro_collection.gyro_lattices]
        for glat in glatstodo:
            print '\n\nchern_collection: Getting cherns for GyroLattice ', glat, '...'
            print ' of name ', glat.lp['meshfn']
            print 'Removing cpmeshfn from cp...'
            self.cp.pop('cpmeshfn', None)

            proj = None
            print 'paramV = ', paramV
            if reverse:
                paramtodo = paramV[::-1]
            else:
                paramtodo = paramV

            lp_master = copy.deepcopy(glat.lp)
            lat = copy.deepcopy(glat.lattice)
            for val in paramtodo:
                cp = copy.deepcopy(self.cp)
                lp = copy.deepcopy(lp_master)
                lp[glatparam] = val
                print 'glatparam = ', glatparam
                # print 'lp[OmKspec]=', lp['OmKspec']
                glat = gyro_lattice_class.GyroLattice(lat, lp)
                print 'kchern_gyro_collection: glat.Omg = ', glat.Omg

                # This should not be necessary since appended in self.add_chern()
                # self.gyro_collection.gyro_lattices.append(glat)

                # Simply add the one chern to the collection
                self.add_chern(glat, cp=cp, verbose=verbose, save_png=save_png)

        return self.cherns
Beispiel #2
0
    def ensure_all_gyro_lattices(self):
        """Ensure that all gyro lattices called for by self.meshfns are loaded.
        """
        # todo: add the ability to change glat.lp parameters (like Omk) at function call-- specify as list of lp's or as single lp
        print 'Ensuring all gyro lattices...'
        for ii in range(len(self.meshfns)):
            meshfn = self.meshfns[ii]
            if isinstance(meshfn, list):
                try:
                    meshfn = meshfn[0]
                except IndexError:
                    print 'self.meshfns = ', self.meshfns
                    print 'meshfn = ', meshfn
                    raise IndexError('list index out of range')
            print 'Ensuring ', meshfn
            try:
                self.gyro_lattices[ii]
                append_glat = False
            except IndexError:
                append_glat = True

            try:
                # Check if lp['meshfn'] of gyro_lattice matches meshfn
                self.gyro_lattices[ii].lp['meshfn']
                # print('Already have gyro_lattice defined for ii='+str(ii)+': ', test)
            except IndexError:
                lp = le.load_params(dio.prepdir(meshfn), 'lattice_params')
                lat = lattice_class.Lattice(lp=lp)
                lat.load(meshfn=meshfn)
                lp['Omk'] = -1.0
                lp['Omg'] = -1.0
                if append_glat:
                    self.gyro_lattices.append(
                        gyro_lattice_class.GyroLattice(lat, lp))
                else:
                    self.gyro_lattices[ii] = gyro_lattice_class.GyroLattice(
                        lat, lp)

                glat = gyro_lattice_class.GyroLattice(
                    lat, self.gyro_lattices[ii].lp)
                self.gyro_lattices[ii] = glat
    'periodic_strip': False,
    'alph': alph,
    'origin': np.array([0., 0.]),
    'thres': 0.0,
    'spreading_time': 0.30,
    'spreading_dt': 0.001,
    'kicksz': -1.0,
    'aratio': 0.0,
}

# Collate botts for one lattice with a gyro_lattice parameter that varies between instances of that lattice
meshfn = le.find_meshfn(lp)
lp['meshfn'] = meshfn
lat = lattice_class.Lattice(lp)
lat.load()
glat = gyro_lattice_class.GyroLattice(lat, lp)
glat.load()
gc = gyro_collection.GyroCollection()
gc.add_gyro_lattice(glat)
print 'Creating bott collection from single-lattice gyro_collection...'
kcoll = BottGyroCollection(gc, cp=cp)

# get the paramV from the available configurations on the hard disk
searchstr = lp['rootdir'] + 'networks/' + lt + '/' + lt + \
            '_square_periodicBC_delta0p667_phi0p000_perd*_{0:06d}'.format(NH) +\
            '_x_' + '{0:06d}'.format(NV) + '_xy.txt'
xystr = glob.glob(searchstr)
datadir
paramV = sf.string_sequence_to_numpy_array(args.paramV, dtype=args.paramVdtype)
kcoll.calc_botts_vary_glatparam(args.glatparam,
                                paramV,
Beispiel #4
0
    lattice.save(skip_polygons=args.skip_polygons, check=lp['check'])

    if args.nice_plot:
        print 'Saving nice BW plot...'
        lattice.plot_BW_lat(meshfn=dio.prepdir(lattice.lp['meshfn']))

    infodir = lattice.lp['meshfn'] + '/'
    if args.bondL_histogram:
        print 'Creating bond length histogram...'
        lattice.bond_length_histogram(fig=None,
                                      ax=None,
                                      outdir=infodir,
                                      check=args.check)

    glp = {'Omk': -1.0, 'Omg': -1.0}
    gyrolat = gyro_lattice_class.GyroLattice(lattice, glp)

    if not args.skip_gyroDOS:
        print '\n\nPerforming gyro DOS ...'
        gyrolat.save_eigval_eigvect()
        if args.DOSmovie:
            gyrolat.save_DOSmovie()
    if args.massDOS:
        print 'Performing mass DOS...'
        masslat = mass_lattice_class.mass_lattice(lattice.xy, lattice.NL,
                                                  lattice.KL, [1., 0.], 'mass')
        masslat.save_eigval_eigvect(infodir)
        # if args.DOSmovie:
        #     masslat.save_DOSmovie()
    if args.varN and lattice.lp['LL'][0] * 0.17 > 6:
        print 'Performing number variance...'