Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculate and plot energy band #3

Open
kaiqi-wang opened this issue Apr 22, 2023 · 3 comments
Open

calculate and plot energy band #3

kaiqi-wang opened this issue Apr 22, 2023 · 3 comments

Comments

@kaiqi-wang
Copy link

Dear zeying,
I use MagneticKP-python version to print Hamiltonian , and run the example in the file of /MagneticKP-main/MagneticKP-python/doc/html/index.html. I also want to know how to use this Hamiltonian to calculate and plot energy band ?

@zhangzeyingvv
Copy link
Owner

Hi kaiqi, You can use the matplotlib module to plot the band structure, Here is a simple example to plot the energy band structure of 2x2 model

import matplotlib.pyplot as plt

C_0_0 = 1
C_2_1 = 2

def matrix(kx):
    return np.array([
        [C_0_0, -C_2_1 * kx],
        [-C_2_1 * kx, C_0_0]
    ])

# Define the range of kx values
kx_range = np.linspace(-10, 10, 1000)

# Calculate the eigenvalues for each kx value
eigenvalues = [np.linalg.eigvals(matrix(kx_val)) for kx_val in kx_range]

# Unpack the eigenvalues into separate arrays
eval1, eval2 = zip(*eigenvalues)

# Plot the eigenvalues
plt.plot(kx_range, eval1, label="Eigenvalue 1")
plt.plot(kx_range, eval2, label="Eigenvalue 2")
plt.xlabel("kx")
plt.ylabel("Eigenvalues")
plt.legend()
plt.show()

Or you can use the Mathematica version of MagneticKP, and plot the band structure by bandManipulate and bandplot functions.

@kaiqi-wang
Copy link
Author

Thank you very much ~ Is there a WeChat or QQ communication group? I would like to apply to join.

@zhangzeyingvv
Copy link
Owner

Yes! You can scan this QR code:
2309273d95bc4b2d2c001b35010cce2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants