def run(Ns, step, dt, acc, c): args = (m, omega, acc, x0, c) v = harmonic_potential(x, t, args=args) sch = Schrodinger(x, psi_x, v, k, hbar=hbar, m=m, t=0, args=args) for i in range(Ns): sch.evolve_t(N_steps=step, dt=dt) return sch.expectation_x()
def run(acc): t = 0 psi_x = gauss_init(x, k_initial, x0=0, d=d) V_x = gaussbox(x, w, L, x0=xb, A=Amp, a=acc) sch = Schrodinger(x, psi_x, V_x, k, hbar=hbar, m=m, t=t) t_list = [] x_list = [] for i in range(Ns): sch.evolve_t(N_steps=step, dt=dt) t_list.append(sch.t) x_list.append(sch.expectation_x()) dat = list(zip(t_list, x_list)) # np.savetxt("GBox_{}.txt".format(a), dat) return dat
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') # plt.xlabel('Time')
# a = Animate(sch, V_x, step, dt, lim1=((0, x_length), (0, max(np.real(psi_x)))), # lim2=((ks[0], ks[N-1]), (0, 1))) # a.make_fig() t_list = [] norm_x = [] expec_x = [] expec_xs = [] expec_k = [] for i in range(int(Ns / 2)): 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() - sch.expectation_x()**2)) expec_k.append(sch.expectation_k()) sch.momentum_kick(-2 * k_initial) for i in range(int(Ns / 2)): 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() - sch.expectation_x()**2)) expec_k.append(sch.expectation_k())