-
Notifications
You must be signed in to change notification settings - Fork 3
/
TDSE_functions.py
40 lines (27 loc) · 926 Bytes
/
TDSE_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from TDSE_constants import *
from typing import Callable
def square_well(x=None) -> int:
return 0
def harmonic_oscillator(x: float, m: float = m_e, w: float = 3e15) -> float:
return 0.5 * m * w**2 * x**2
def double_well(x: float, x1: float = L / 4, v0: float = 6e-17) -> float:
return v0 * (x**2 / x1**2 - 1) ** 2
# Discretized Hamiltonian
def get_Hamiltonian(potential: Callable, P: int = P):
"""
Returns the discretized Hamiltonian given the <potential> function and
<P> number of spatial intervals.
"""
delta = L / P
A = -(hbar**2) / (2 * m_e * delta**2)
H = np.zeros((P, P))
for i in range(P):
for j in range(P):
if i == j:
B = potential((i + 1) * delta - L / 2) - 2 * A
H[i][j] = B
elif j == i - 1 or j == i + 1:
H[i][j] = A
else:
H[i][j] = 0
return H