-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6709dd0
commit 445ff0d
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
contoh_081.py | ||
PDP Kuantum | ||
SHSH <[email protected]> | ||
23/12/23 | ||
""" | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
plt.style.use("bmh") | ||
|
||
def atur_profil_energi_potensial(x, L, V0): | ||
V = np.zeros_like(x) | ||
V[(x > L / 3) & (x < 2 * L / 3)] = V0 | ||
return V | ||
|
||
def atur_hamiltonian(jml_titik, dx, V): | ||
H = np.zeros((jml_titik, jml_titik)) | ||
H[np.diag_indices(jml_titik)] = 2 / dx**2 + V | ||
H[np.arange(1, jml_titik), np.arange(0, jml_titik - 1)] = -1 / dx**2 | ||
H[np.arange(0, jml_titik - 1), np.arange(1, jml_titik)] = -1 / dx**2 | ||
return H | ||
|
||
def main(): | ||
# Konstanta | ||
h_bar = 1.0 # Konstanta Planck tereduksi | ||
m = 1.0 # Massa partikel | ||
L = 10.0 # Lebar sumur potensial | ||
V0 = 50.0 # Tinggi penghalang potensial | ||
jml_titik = 500 # Jumlah titik spasial | ||
dx = L / (jml_titik - 1) # Ukuran langkah spasial | ||
|
||
# Diskritisasi koordinat spasial | ||
x = np.linspace(0, L, jml_titik) | ||
|
||
# Atur profil energi potensial | ||
V = atur_profil_energi_potensial(x, L, V0) | ||
|
||
# Atur matriks Hamiltonian | ||
H = atur_hamiltonian(jml_titik, dx, V) | ||
|
||
# Hitung eigenvalues dan eigenvectors | ||
eigenvalues, eigenvectors = np.linalg.eigh(H) | ||
|
||
# Plot energi potensial dan beberapa fungsi gelombang pertama | ||
plt.plot(x, V, label='Energi Potensial') | ||
for i in range(3): | ||
plt.plot(x, eigenvalues[i] + eigenvectors[:, i], label=f'Mode Eigen {i+1}') | ||
|
||
plt.xlabel('$x$', fontsize=16) | ||
plt.ylabel('Energi / Fungsi Gelombang', fontsize=16) | ||
plt.legend() | ||
plt.savefig("../gambar/gambar082.png", dpi=250) | ||
|
||
if __name__ == "__main__": | ||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.