示例#1
0
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)):
    f.append(Psi(cn, x, t[i]))

# Calculate the momentum spectrum
p = np.linspace(-200, 200, 2**10)
示例#2
0
def animate(i):
  line.set_data(x, np.abs(Psi(cn, x, t[i])))
  annotation.xy = (Ex[i], -1)
  annotation.set_position((Ex[i], -0.7))
  title.set_text("t = " + str(t[i]))
  return line, annotation, title # We have to return all the objects we change
def animate(i):
    line.set_data(x, np.abs(Psi(cn, x, t[i])))
    annotation.xy = (Ex[i], -1)
    annotation.set_position((Ex[i], -0.7))
    return line, annotation
示例#4
0
x = np.linspace(0, 1, 256)
t = np.linspace(0, 4/(np.pi), 256)

# Normalize the custom wave function and get the cn's
fun = x**3 * (1 - 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))

# Compute <x> and <x^2>

Ex = np.zeros(t.shape)
Ex2 = np.zeros(t.shape)

for i in range(0, len(t)):
  Ex[i] = np.trapz(x*(np.abs(Psi(cn, x, t[i]))**2), x = x)
  Ex2[i] = np.trapz(x**2*np.abs(Psi(cn, x, t[i]))**2, x = x)
# 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))

plt.plot(energy(np.arange(len(cn))), np.abs(cn)**2, 'ro')
#plt.title("Energy spectrum")
plt.xlabel(r"$E_n$")
plt.ylabel(r"$| c_n |^2$")
#plt.show()
plt.savefig("ISW_wavePackageEnergySpectrum.png")