dt, lim1=((0, x_length), (0, max(np.real(psi_x)))), lim2=((ks[0], ks[N - 1]), (0, 30))) a.make_fig() t_list = [] norm_x = [] expec_x = [] expec_xs = [] expec_k = [] for i in range(Ns): if i != 0: sch.evolve_t(step, dt) t_list.append(sch.t) norm_x.append(sch.norm_x() - 1) expec_x.append(sch.expectation_x()) expec_xs.append(np.sqrt(sch.expectation_x_square() - expec_x[i]**2)) expec_k.append(sch.expectation_k()) # x_pos_list = [x_pos(j, x0, k_initial, hbar=hbar, m=m) for j in t_list] # xdiff = [np.abs(expec_x[n] - x_pos_list[n]) for n in range(len(expec_x))] # popt1, pcov = curve_fit(func, t_list, x_pos_list) # print("Expected x :", popt1) # # popt2, pcov = curve_fit(func, t_list, expec_x) # print("Calculated x :", popt2) # # plt.plot(t_list, norm_x, linestyle='none', marker='x') # plt.title('Normalistaion of wavefunction over time')
hbar = 1 m = 1 omega = 0.01 sigma = np.sqrt(hbar / (2 * m * omega)) # Defining Wavefunction psi = wave_init(x, sigma, x0-50) V_x = harmonic_potential(x, m, omega, x0) #V_x = np.zeros(N) # Defining k dk = dx / (2 * np.pi) k = fftfreq(N, dk) ks = fftshift(k) # Defining time steps t = 0 dt = 5 step = 1 sch = Schrodinger(x, psi, V_x, k, hbar, m, t) print(sch.norm_x()) x_limits = ((x[0],x[N-1]), (0, 0.16)) k_limits = ((-5, 5), (0, max(abs(sch.psi_k)+0.5))) a = Animate(sch, V_x, step, dt, lim1=x_limits, lim2=k_limitsq) a.make_fig()