コード例 #1
0
            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')
# plt.ylabel('Normalisation-1')
コード例 #2
0
# 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())

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))]