def runHel(): hel = Heller2D(Nstep, dt, init, derivsDt) tl, hel_arr = hel.rk4(args) # tool = PlotTools2D(tl, hel_arr, xlen / 2, xlen / 2, N) # tool.animation2D(args) tool = PlotTools() tool.hellerAnimation(Nstep, X, Y, tl, hel_arr, args, xlen / 2)
def runComp(psi, V): sch = Schrodinger2D(x, y, psi, V, args) hel = Heller2D(Nstep, dt, init, derivsDt) tl, hel_arr = hel.rk4(args) tool = PlotTools() tool.animateComparrison(sch, Nstep, tl, hel_arr, args, xlen / 2, k_lim, full=False,rp=x0,save="Test") tool.animateComparrison(sch, Nstep, tl, hel_arr, args, xlen / 2, k_lim, full=False, rp=x0)
def hellerValues(N_step, dt, func, args): hel = Heller2D(N_step, dt, init, func) tl, hel_arr = hel.rk4(args) t_list = [i * dt for i in range(N_step)] xh_av = np.zeros(N_step) yh_av = np.zeros(N_step) xhs_av = np.zeros(N_step) yhs_av = np.zeros(N_step) for n, v in enumerate(tl): psi_h = hellerGaussian2D(X, Y, hel_arr[:, n], args) psi_hs = np.real(psi_h * np.conjugate(psi_h)) xh_av[n] = simps(simps(X * psi_hs, x), y) yh_av[n] = simps(simps(Y * psi_hs, y), x) xhs_av[n] = simps(simps(X ** 2 * psi_hs, x), y) yhs_av[n] = simps(simps(Y ** 2 * psi_hs, y), x) return t_list, xh_av, yh_av, xhs_av, yhs_av
def derivsDt(t, current, args, eta, dt): m, hbar = args xt, yt, vxt, vyt, axt, ayt, lamt, gt = current xn = vxt * dt yn = vyt * dt vxn = 0 * dt vyn = 0 * dt axn = (-2 * axt**2 / m - 0.5 * lamt**2 / m) * dt ayn = (-2 * ayt**2 / m - 0.5 * lamt**2 / m) * dt lamn = (-2 * (axt + ayt) * lamt / m) * dt gn = (1j * hbar * axt / m + 1j * hbar * ayt / m + 0.5 * m * vxt**2 + 0.5 * m * vyt**2) * dt return xn, yn, vxn, vyn, axn, ayn, lamn, gn sch = Schrodinger2D(x, y, psi, V, args) hel = Heller2D(N_step, dt, init, derivsDt) tl, hel_arr = hel.rk4(args) tool = PlotTools() tool.animateComparrison(sch, N_step, tl, hel_arr, args, len / 2, k_lim, full=False, rp=x0, save="Test")
args = (m, hbar) #######Initial Plot # X, Y = np.meshgrid(x, y) # psi = hellerGaussian2D(X, Y, init, args=args) # Z = np.real(psi*np.conjugate(psi)) # # fig, ax = plt.subplots() # data = ax.imshow(Z, extent=[-lim, lim, -lim, lim], cmap="gist_heat") # cb = fig.colorbar(data) # plt.show() ########Simulation # n = 1000 # dt = 0.001 tf = 2 * m * sigx * sigy / hbar n = 1000 dt = tf / n Hel = Heller2D(n, dt, init, derivsDt) tl, var_arr = Hel.rk4(args) # print(var_arr[:,0]) Plot = PlotTools2D(tl, var_arr, lim, lim, n_point) # Plot.animation2D(args) # Plot.plot2D(var_arr[:, 0], args) # Plot.plot2D(var_arr[:, -1], args) Plot.animation2D(args, save="Spread_3")