# Generate a real space monkhorst pack lattice mp_moire = bandcalc.generate_monkhorst_pack_raw(m, 100) moire_potential_pointwise = bandcalc.calc_moire_potential(mp_moire, GM, Vj) results = {"CPU": [], "GPU": []} ######################## ###### Comparison ###### ######################## shells = [1, 2] #, 4, 8, 10, 12, 14, 16] for shell in shells: print(f"Shells: {shell}") # Complete reciprocal moire lattice rec_moire_lattice = bandcalc.generate_lattice_by_shell(rec_m, shell) size = len(rec_moire_lattice) #### CPU #### cpu_fun = ray.remote(calc_moire_potential_reciprocal) print("CPU calculating...") start = time.time() calc_potential_matrix(rec_moire_lattice, False, cpu_fun, mp_moire, moire_potential_pointwise, False) results["CPU"].append([size, time.time() - start]) print("Done.") #### GPU ####
shells = args.shells a = lattice_constants["MoS2"] * 1e9 N = 1000 mass = 0.35 * physical_constants["electron mass"][0] # Reciprocal lattice vectors b1 = np.array([2 * np.pi / (np.sqrt(3) * a), 2 * np.pi / a]) b2 = np.array([2 * np.pi / (np.sqrt(3) * a), -2 * np.pi / a]) b = np.vstack([b1, b2]) # Reciprocal moire basis vectors rec_m = b - bandcalc.rotate_lattice(b, angle) # Complete reciprocal moire lattice rec_moire_lattice = bandcalc.generate_lattice_by_shell(rec_m, shells) # Real space moire basis vectors m = bandcalc.generate_reciprocal_lattice_basis(rec_m) # Real space moire lattice vectors moire_lattice = bandcalc.generate_lattice_by_shell(m, shells) if potential == "MoS2": # Moire potential coefficients V = 6.6 * 1e-3 * np.exp(-1j * 94 * np.pi / 180) # in eV Vj = np.array([V if i % 2 else np.conjugate(V) for i in range(1, 7)]) potential_matrix = bandcalc.calc_potential_matrix_from_coeffs( rec_moire_lattice, Vj) elif potential == "off": potential_matrix = bandcalc.calc_potential_matrix(rec_moire_lattice)
import bandcalc # Constants a = 1 N = 1000 m_e = 0.42*bandcalc.constants.physical_constants["electron mass"][0] m_h = 0.34*bandcalc.constants.physical_constants["electron mass"][0] m = m_e+m_h # Reciprocal lattice vectors b1 = np.array([2*np.pi/a, 0, 0]) b2 = np.array([0, 2*np.pi/a, 0]) b3 = np.array([0, 0, 2*np.pi/a]) b = np.vstack([b1, b2, b3]) lattice = bandcalc.generate_lattice_by_shell(b, 2) # k path points = np.array([[0, 0, 0], # Gamma [0, np.pi/a, 0], # X [np.pi/a, np.pi/a, 0], # M [0, 0, 0], # Gamma [np.pi/a, np.pi/a, np.pi/a]]) # R k_names = [r"$\Gamma$", r"X", r"M", r"$\Gamma$", r"R"] path = bandcalc.generate_k_path(points, N) # Calculate band structure potential_matrix = bandcalc.calc_potential_matrix(lattice) hamiltonian = bandcalc.calc_hamiltonian(lattice, potential_matrix, m) bandstructure, prefix = bandcalc.get_unit_prefix( bandcalc.calc_bandstructure(path, hamiltonian))
# Reciprocal moire lattice vectors G = bandcalc.generate_twisted_lattice_by_shell(b, b, angle, 1) GT = G[0] GB = G[1] GM = GT - GB GM = np.array(sorted(GM, key=lambda x: np.abs(x.view(complex))))[1:] GM = np.array(sorted(GM, key=lambda x: np.angle(x.view(complex)))) # Real space grid size = np.linspace(-10, 10, 100) grid = np.meshgrid(size, size) # Results fig, ax = plt.subplots() moire_potential = bandcalc.calc_moire_potential_on_grid(grid, GM, Vj) contour = bandcalc.plot_moire_potential(ax, grid, moire_potential, alpha=0.4) twisted_lattice = bandcalc.generate_twisted_lattice_by_shell(a, a, angle, 15) bandcalc.plot_lattice(ax, twisted_lattice[0], "r.") bandcalc.plot_lattice(ax, twisted_lattice[1], "b.") moire_lattice = bandcalc.generate_lattice_by_shell(m, 1) bandcalc.plot_lattice(ax, moire_lattice, "ko") ax.axis("scaled") ax.set_xlim([size.min(), size.max()]) ax.set_ylim([size.min(), size.max()]) plt.colorbar(contour, label=r"$\Delta(\mathbf{r})$ in meV") plt.show()
temperature = config["general"].getfloat("temperature") filling = config["general"].getfloat("filling") system_str = f"{material_system.replace('/', '_')}_{stacking}_stacking_{particle_type}" with open(f"bandcalc/examples/hubbard/wannier_pickle/moire_vector_lengths_{system_str}.pickle", "rb") as f: m_lens = pickle.load(f) res = [] for angle in np.linspace(1, 3, num=10): # Reciprocal moire basis vectors rec_m = b1-bc.rotate_lattice(b2, angle) # Complete reciprocal moire lattice rec_moire_lattice = bc.generate_lattice_by_shell(rec_m, shells) # Real space moire basis vectors m = bc.generate_reciprocal_lattice_basis(rec_m) # Real space moire lattice vectors moire_lattice = bc.generate_lattice_by_shell(m, 2) # Moire potential coefficients Vj = np.array([V if i%2 else np.conjugate(V) for i in range(1, 7)]) potential_matrix = bc.calc_potential_matrix_from_coeffs(rec_moire_lattice, Vj) k_points = bc.generate_monkhorst_pack_set(rec_m, 40) ## Calculate the band structure # The bandstructure is slightly different from the bandstructure in the
mode = args.mode a = lattice_constants["MoS2"]*1e9 N = 1000 mass = 0.35*physical_constants["electron mass"][0] # Reciprocal lattice vectors b1 = np.array([2*np.pi/(np.sqrt(3)*a), 2*np.pi/a]) b2 = np.array([2*np.pi/(np.sqrt(3)*a), -2*np.pi/a]) b = np.vstack([b1, b2]) # Reciprocal moire basis vectors rec_m = b-bandcalc.rotate_lattice(b, angle) # Complete reciprocal moire lattice rec_moire_lattice = bandcalc.generate_lattice_by_shell(rec_m, shells) # Real space moire basis vectors m = bandcalc.generate_reciprocal_lattice_basis(rec_m) if potential == "MoS2": # Moire potential coefficients V = 6.6*1e-3*np.exp(-1j*94*np.pi/180) # in eV Vj = np.array([V if i%2 else np.conjugate(V) for i in range(1, 7)]) potential_matrix = bandcalc.calc_potential_matrix_from_coeffs(rec_moire_lattice, Vj) elif potential == "off": potential_matrix = bandcalc.calc_potential_matrix(rec_moire_lattice) ## Calculate eigenstates for every k point in the MBZ k_points = bandcalc.generate_monkhorst_pack_set(rec_m, 20).astype(np.float32) hamiltonian = bandcalc.calc_hamiltonian(rec_moire_lattice, potential_matrix, mass)