def build_kagper_hucent(lp): """Build a hyperuniform centroidal lattice with some density of kagomization (kagper = kagome percolation) Parameters ---------- lp : dict lattice parameters dictionary """ xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten = build_hucentroid( lp) # Select some fraction of vertices (which are points) --> xypick gives Nkag of the vertices (xy) Nkag = round(lp['percolation_density'] * len(xy)) ind_shuffled = np.random.permutation(np.arange(len(xy))) xypick = np.sort(ind_shuffled[0:Nkag]) xy, BL = blf.decorate_kagome_elements(xy, BL, xypick, viewmethod=lp['viewmethod'], check=lp['check']) NL, KL = le.BL2NLandKL(BL) if (BL < 0).any(): print 'Creating periodic boundary vector dictionary for kagper_hucent network...' PV = np.array([]) PVxydict = le.BL2PVxydict(BL, xy, PV) PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL) # If the meshfn going to overwrite a previous realization? mfok = le.meshfn_is_used(le.build_meshfn(lp)[0]) while mfok: lp['subconf'] += 1 mfok = le.meshfn_is_used(le.build_meshfn(lp)[0]) lattice_exten = 'kagper_hucent' + lattice_exten[10:] + \ '_perd' + sf.float2pstr(lp['percolation_density'], ndigits=2) + \ '_r' + '{0:02d}'.format(int(lp['subconf'])) return xy, NL, KL, BL, PVx, PVy, PVxydict, LVUC, BBox, LL, LV, UC, lattice_exten, lp
title += r' $V \pm \sigma = $' + sf.float2pstr( lp['pin']) + r'$\pm$' + sf.float2pstr(lp['V0_pin_gauss']) else: title += r' $V = $' + str(int(lp['pin'])) chern.get_haldane_chern(check=args.check, title=title) if args.contributions: # Calc chern number for specified network try: meshfn = le.find_meshfn(lp) lp['meshfn'] = meshfn lat = lattice_class.Lattice(lp) lat.load() except RuntimeError: print '\n\n Could not find lattice --> creating it!' meshfn, trash = le.build_meshfn(lp) lp['meshfn'] = meshfn lat = lattice_class.Lattice(lp) lat.build() lat.save() hlat = haldane_lattice_class.HaldaneLattice(lat, lp) hlat.load() print '\n\n\nhaldane_chern_class: ', hlat.lattice.lp, '\n' chern = HaldaneChern(hlat, cp=cp) if args.title == '': title = None else: title = eval("r'" + args.title.replace('_', ' ') + "'") chern.calc_haldane_chern(contributions=True, title=title) chern.save_chern()
def build_kagome_randomcent(lp): """Build uniformly random point set, and construct voronoized network from that. lp : dict lattice parameters dictionary """ NH = lp['NH'] NV = lp['NV'] LL = (NH, NV) if lp['periodicBC']: xx = np.random.uniform(low=-NH * 0.5, high=NH * 0.5, size=NH * NV) yy = np.random.uniform(low=-NV * 0.5, high=NV * 0.5, size=NH * NV) xy = np.dstack((xx, yy))[0] xy, NL, KL, BL, PVxydict = \ kagomecentroid_periodic_network_from_pts(xy, LL, BBox='auto', check=lp['check']) PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL) # check that all points are inside BBox shapedict = {lp['shape']: [NH, NV]} keep = argcrop_lattice_to_polygon(shapedict, xy, check=lp['check']) if len(np.where(keep)[0]) != len(xy): raise RuntimeError('Some points were spuriously outside the allowed BBox.') polygon = auto_polygon(lp['shape'], NH, NV, eps=0.00) perstr = '_periodic' else: xx = np.random.uniform(low=-NH * 0.5 - 10, high=NH * 0.5 + 10, size=(NH + 20) * (NV + 20)) yy = np.random.uniform(low=-NV * 0.5 - 10, high=NV * 0.5 + 10, size=(NH + 20) * (NV + 20)) xy = np.dstack((xx, yy))[0] xy, NL, KL, BL = kagomecentroid_lattice_from_pts(xy, polygon=None, trimbound=False, check=lp['check']) # Crop to polygon shapedict = {lp['shape']: [NH, NV]} keep = argcrop_lattice_to_polygon(shapedict, xy, check=lp['check']) xy, NL, KL, BL = le.remove_pts(keep, xy, BL, NN='min') polygon = auto_polygon(lp['shape'], NH, NV, eps=0.00) PVxydict = {} PVx = [] PVy = [] perstr = '' # If the meshfn going to overwrite a previous realization? mfok = le.meshfn_is_used(le.build_meshfn(lp)[0]) print 'mfok = ', mfok while mfok: lp['conf'] += 1 mfok = le.meshfn_is_used(le.build_meshfn(lp)[0]) lattice_exten = lp['LatticeTop'] + '_' + lp['shape'] + perstr + '_r' + '{0:02d}'.format(int(lp['conf'])) # Rescale so that median bond length is unity bL = le.bond_length_list(xy, BL, NL=NL, KL=KL, PVx=PVx, PVy=PVy) scale = 1. / np.median(bL) xy *= scale polygon *= scale LL = (LL[0] * scale, LL[1] * scale) if lp['periodicBC']: PVx *= scale PVy *= scale PVxydict.update((key, val * scale) for key, val in PVxydict.items()) LVUC = 'none' LV = 'none' UC = 'none' BBox = polygon PVx, PVy = le.PVxydict2PVxPVy(PVxydict, NL) return xy, NL, KL, BL, PVxydict, PVx, PVy, LL, LVUC, LV, UC, BBox, lattice_exten