Skip to content

Commit 445ff0d

Browse files
committed
tambah kuantum
1 parent 6709dd0 commit 445ff0d

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

bab8/contoh_082.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
contoh_081.py
5+
6+
PDP Kuantum
7+
8+
9+
23/12/23
10+
"""
11+
12+
import numpy as np
13+
import matplotlib.pyplot as plt
14+
plt.style.use("bmh")
15+
16+
def atur_profil_energi_potensial(x, L, V0):
17+
V = np.zeros_like(x)
18+
V[(x > L / 3) & (x < 2 * L / 3)] = V0
19+
return V
20+
21+
def atur_hamiltonian(jml_titik, dx, V):
22+
H = np.zeros((jml_titik, jml_titik))
23+
H[np.diag_indices(jml_titik)] = 2 / dx**2 + V
24+
H[np.arange(1, jml_titik), np.arange(0, jml_titik - 1)] = -1 / dx**2
25+
H[np.arange(0, jml_titik - 1), np.arange(1, jml_titik)] = -1 / dx**2
26+
return H
27+
28+
def main():
29+
# Konstanta
30+
h_bar = 1.0 # Konstanta Planck tereduksi
31+
m = 1.0 # Massa partikel
32+
L = 10.0 # Lebar sumur potensial
33+
V0 = 50.0 # Tinggi penghalang potensial
34+
jml_titik = 500 # Jumlah titik spasial
35+
dx = L / (jml_titik - 1) # Ukuran langkah spasial
36+
37+
# Diskritisasi koordinat spasial
38+
x = np.linspace(0, L, jml_titik)
39+
40+
# Atur profil energi potensial
41+
V = atur_profil_energi_potensial(x, L, V0)
42+
43+
# Atur matriks Hamiltonian
44+
H = atur_hamiltonian(jml_titik, dx, V)
45+
46+
# Hitung eigenvalues dan eigenvectors
47+
eigenvalues, eigenvectors = np.linalg.eigh(H)
48+
49+
# Plot energi potensial dan beberapa fungsi gelombang pertama
50+
plt.plot(x, V, label='Energi Potensial')
51+
for i in range(3):
52+
plt.plot(x, eigenvalues[i] + eigenvectors[:, i], label=f'Mode Eigen {i+1}')
53+
54+
plt.xlabel('$x$', fontsize=16)
55+
plt.ylabel('Energi / Fungsi Gelombang', fontsize=16)
56+
plt.legend()
57+
plt.savefig("../gambar/gambar082.png", dpi=250)
58+
59+
if __name__ == "__main__":
60+
main()

gambar/gambar082.png

92.6 KB
Loading

0 commit comments

Comments
 (0)