def sample(struct, size, rescale=20, nr_processes=1, elec_field=0.0): def pbc_func(unit_cell_coords, orbital_ind): x, y, z = unit_cell_coords return (x % size[0], y % size[1], z), orbital_ind nsite = struct.nsite site_set = siteset(nsite, size) latt = lattice(struct) if os.path.isfile('sample.hdf5'): print('Reading sample ...') sp = tipsi.Sample(latt, site_set, pbc_func, nr_processes=nr_processes, read_from_file='sample.hdf5') print('Read done') else: print('Constructing sample from scratch ...') sp = tipsi.Sample(latt, site_set, pbc_func, nr_processes=nr_processes) hop_dict = SparseHopDict(nsite) hop_dict.dict = struct.hoppings_2to3() sp.add_hop_dict(hop_dict) sp.save() sp.rescale_H(rescale) return sp
def square(width: int, a: float, t: float, periodic: bool) -> tipsi.Sample: vectors = [[a, 0, 0], [0, a, 0]] orbital_coords = [[0, 0, 0]] lattice = tipsi.builder.Lattice(vectors, orbital_coords) site_set = tipsi.builder.SiteSet() for i in range(width): for j in range(width): site_set.add_site((i, j, 0)) hop_dict = tipsi.builder.HopDict() hop_dict.set((1, 0, 0), t) hop_dict.set((0, 1, 0), t) if periodic: def pbc_func(unit_cell_coords, orbital): n0, n1, n2 = unit_cell_coords return (n0 % width, n1 % width, n2), orbital else: pbc_func = tipsi.builder.bc_default sample = tipsi.Sample(lattice, site_set, pbc_func) sample.add_hop_dict(hop_dict) return sample
def sample(struct, rescale=30., nr_processes=1): nsite = len(struct.coords) latt = lattice(struct.coords) site_set = siteset(nsite) if os.path.isfile('sample.hdf5'): sp = tipsi.Sample(latt, site_set, nr_processes=nr_processes, read_from_file='sample.hdf5') else: sp = tipsi.Sample(latt, site_set, nr_processes=nr_processes) t0 = time.time() hop_dict = hopdict(struct, elec_field=elec_field) t1 = time.time() print('hop % s' % (t1-t0)) del struct sp.add_hop_dict(hop_dict) sp.save() sp.rescale_H(rescale) return sp
def carpet(start_width, iteration, lattice_constant, hopping_value): lattice = square_lattice(lattice_constant) sites = carpet_sites(start_width, iteration) sample = tipsi.Sample(lattice, sites, bc_func=lambda p, o: (p, o)) sample.add_hop_dict(carpet_hoppings(hopping_value)) return sample