Exemple #1
0
x = np.linspace(0, 1, 2**10)
t = np.linspace(0, 4 / (np.pi), 2**13)

# Wave package constants
x0 = 0.5
sigma = 0.1
k0 = 100

# Normalize the custom wave function and get the cn's
fun = np.exp(-1 / 2 * (x - x0)**2 / sigma**2) * np.exp(-1j * k0 * x)

A = 1 / np.sqrt(np.trapz(np.abs(fun)**2, x=x))

fun = A * fun

cn = getcn(x, fun)

# Check normalization

f = np.abs(Psi(cn, x, t[0]))**2
integral = np.trapz(f, x=x)

if integral == 1:
    print("Wave function is normalized")
else:
    print("Wave function is not normalized. Integral is " + str(integral))

f = []

# Calculate the function for all times
for i in range(0, len(t)):
t = np.linspace(0, 1 / (np.pi), 2**10)

# Wave package constants
x0 = 0.75
sigma = 0.1
k0 = 100

# Normalize the custom wave function and get the cn's
fun = np.exp(-1 / 2 * (x - x0)**2 / sigma**2) * np.exp(-1j * k0 * x) + np.exp(
    -1 / 2 * (x - (1 - x0))**2 / sigma**2) * np.exp(-1j * (-k0) * x)

A = 1 / np.sqrt(np.trapz(np.abs(fun)**2, x=x))

fun = A * fun

cn = getcn(x, fun, epsilon=10**-6)

# Check normalization

f = np.abs(Psi(cn, x, t[0]))**2
integral = np.trapz(f, x=x)

if integral == 1:
    print("Wave function is normalized")
else:
    print("Wave function is not normalized. Integral is " + str(integral))

f = []

# Calculate the function for all times
for i in range(0, len(t)):