# 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()
for i in range(7): ## Calculate the wannier function R = 1 / 3 * (moire_lattice[5] + moire_lattice[3] + moire_lattice[6]).astype(np.float32) r = 5 * bandcalc.generate_monkhorst_pack_set(m, 80) wannier_function = bandcalc.calc_wannier_function_gpu(hamiltonian, k_points, rec_moire_lattice, r, R, band_index=i) ## Plot the results bandcalc.plot_bandstructure(ax[i, 0], np.real(bandstructure), k_names, "k", alpha=0.3) ax[i, 0].plot(np.real(sorted_bandstructure)[:, i], "k", lw=2) ax[i, 1].tricontourf(r[:, 0], r[:, 1], np.abs(wannier_function), alpha=0.8) lat = bandcalc.generate_lattice_by_shell(m, 3) bandcalc.plot_lattice(ax[i, 1], lat, "ko") ax[i, 1].plot(R[0], R[1], "ro") for num, vec in enumerate(moire_lattice): ax[i, 1].text(vec[0] + 0.2, vec[1], num, color="#999") plt.tight_layout() plt.savefig("wannier_all_bands.pdf")
energies, prefix = bandcalc.get_unit_prefix( np.sort( np.linalg.eigvals( bandcalc.calc_hamiltonian(rec_moire_lattice, potential_matrix, m)(k_point)))) energy_slice = energies[energy_level - 5 if energy_level - 5 > -1 else None:energy_level + 5 if energy_level + 5 < len(energies) else None] energy = np.real(energies[energy_level]) #np.save("wavefunction_moire_{}deg_energy_level_{}_shells_8.npy".format(angle, energy_level), wavefunction) # Plot the results fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(11, 5)) bandcalc.plot_lattice(axs[0], rec_moire_lattice, "ko") axs[0].text(0.05, 0.95, f"{angle}°", transform=axs[0].transAxes, va="top", bbox={ "fc": "white", "alpha": 0.2 }) axs[0].set_xlabel(r"nm$^{-1}$") axs[0].set_ylabel(r"nm$^{-1}$") bandcalc.plot_moire_potential(axs[1], grid, moire_potential,
# Real space moire potential moire_potential = bandcalc.calc_moire_potential_on_grid(grid, GM, Vj) # Reciprocal space moire potential mp_moire = bandcalc.generate_monkhorst_pack_set(m, 100) moire_potential_pointwise = bandcalc.calc_moire_potential(mp_moire, GM, Vj) rec_moire_potential = bandcalc.calc_moire_potential_reciprocal_on_grid( mp_moire, grid_r, moire_potential_pointwise) # Results fig, axs = plt.subplots(nrows=2, ncols=2) contour = bandcalc.plot_moire_potential(axs[0,0], grid, np.real(moire_potential), alpha=0.4) moire_lattice = bandcalc.generate_lattice_by_shell(m, 2) bandcalc.plot_lattice(axs[0,0], moire_lattice, "ko") vor_m = Voronoi(moire_lattice) voronoi_plot_2d(vor_m, axs[0,0], show_points=False, show_vertices=False) bandcalc.plot_lattice(axs[0,0], mp_moire, "b,", alpha=0.4) rec_moire_lattice = bandcalc.generate_lattice_by_shell(rec_m, 3) axs[0,0].axis("scaled") axs[0,0].set_xlim([size.min(), size.max()]) axs[0,0].set_ylim([size.min(), size.max()]) for i, ax in enumerate(axs.ravel()[1:]): bandcalc.plot_lattice(ax, rec_moire_lattice, "ko") fun = [np.real, np.imag, np.abs][i] title = ["real", "imaginary", "absolute"][i] rec_contour = bandcalc.plot_moire_potential(ax, grid_r,
[0, 4 * np.pi / (3 * a)], # K [0, 0], # Gamma [2 * np.pi / (np.sqrt(3) * a), 0], # M [2 * np.pi / (np.sqrt(3) * a), -2 * np.pi / (3 * a)] ]) # K k_names = [r"K", r"$\Gamma$", r"M", r"K"] path = bandcalc.generate_k_path(points, N) # Calculate Brillouin zones vor = Voronoi(lattice) # 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)) # Plots fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(11, 5)) bandcalc.plot_lattice(ax[0], lattice, "ko") bandcalc.plot_k_path(ax[0], path, "r") voronoi_plot_2d(vor, ax[0], show_points=False, show_vertices=False) bandcalc.plot_bandstructure(ax[1], bandstructure, k_names, "k") ax[1].set_ylabel(r"$E - \hbar\Omega_0$ in {}eV".format(prefix)) ax[1].set_ylim([0, 4]) plt.tight_layout() plt.show()
import matplotlib.pyplot as plt from scipy.spatial import Voronoi, voronoi_plot_2d #pylint: disable=E0611 import bandcalc # Constants a = 1 N = 1000 # 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]) lattice = bandcalc.generate_lattice_by_shell(b, 1) # Monkhorst-Pack lattice mp_lattice = bandcalc.generate_monkhorst_pack_set(b, 10) # Results fig, ax = plt.subplots() vor = Voronoi(lattice) voronoi_plot_2d(vor, ax, show_points=False, show_vertices=False) bandcalc.plot_lattice(ax, lattice, "ko", alpha=0.3) bandcalc.plot_lattice(ax, mp_lattice, "k.") ax.set_xlim([lattice[:, 0].min() - 2, lattice[:, 0].max() + 2]) ax.set_ylim([lattice[:, 1].min() - 2, lattice[:, 1].max() + 2]) plt.show()
# Real space moire lattice vectors moire_lattice = bandcalc.generate_lattice_by_shell(m, shells) # Wannier functions should be centered around potential minima potential_shift = np.array([m[0, 0], m[0, 1]*1/3]) print(f"Potential shift: {potential_shift}") R0 = potential_shift R1 = m[0]+potential_shift R2 = 2*m[0]+potential_shift ## Calculate the wannier function R = R0 r = 4*bandcalc.generate_monkhorst_pack_set(m, 80)#+R wannier_function = bandcalc.calc_wannier_function_gpu( hamiltonian, k_points, rec_moire_lattice, r, R, band_index=energy_level) ## Plot the results if mode == "3d": bandcalc.plot_trisurface_3d(r[:,0], r[:,1], np.abs(wannier_function)) elif mode == "2d": fig, ax = plt.subplots() contour = ax.tricontourf(r[:,0], r[:,1], np.abs(wannier_function), alpha=0.8) bandcalc.plot_lattice(ax, bandcalc.generate_lattice_by_shell(m, 4), "k.") ax.plot(R[0], R[1], "ro") ax.set_xlabel("nm") ax.set_ylabel("nm") plt.colorbar(mappable=contour) plt.show()