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 comparrison(sch, Nstep, dt): t_l, x_s, y_s, xs_s, ys_s = sch.expectationVals(Nstep, dt) t_l, xh, yh, xhs, yhs = hellerValues(Nstep, dt, derivsDt, args) widx = np.sqrt(xhs - xh**2) widy = np.sqrt(yhs - yh**2) tool = PlotTools() tool.expectationValuesComparrison(t_l, x_s, y_s, xs_s, ys_s, xh, yh, widx, widy)
def runSch(psi): sch = Schrodinger2D(x, y, psi, V, args) # sch.evolvet(Nstep, dt) t_list, x_av, y_av, xs_av, ys_av = sch.expectationVals(Nstep, dt) psif = sch.psi_x tool = PlotTools() tool.compareInit(psi, psif, xlen / 2, k_lim) fig, ax = tool.expectationValues(t_list, x_av, y_av, xs_av, ys_av, show=False) fig.suptitle(f"Schrodinger") fig.tight_layout(rect=[0, 0.03, 1, 0.95]) # plt.savefig("HO") plt.show()
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 runSim(psi, V): sch = Schrodinger2D(x, y, psi, V, args) # sch.evolvet(Nstep, dt) t_list, x_av, y_av, xs_av, ys_av = sch.expectationVals(Nstep, dt) psif = sch.psi_x t_l, xh_av, yh_av, xhs_av, yhs_av = hellerValues(Nstep, dt, derivsdt, args) tool = PlotTools() # tool.compareInit(psi, psif, xlen, k_lim) # tool.expectationValues(t_list, x_av, y_av, xs_av, ys_av) # tool.expectationValues(t_list, xh_av, yh_av, xhs_av, yhs_av) xh_wid = np.sqrt(xhs_av - xh_av ** 2) yh_wid = np.sqrt(yhs_av - yh_av ** 2) fig, ax = tool.expectationValuesComparrison(t_list, x_av, y_av, xs_av, ys_av, xh_av, yh_av, xh_wid, yh_wid, show=False) fig.suptitle(f"$Schrodinger - Heller Comparison,\omega_x={w1} ,\omega_y={w2}$") ax[0, 0].lines[0].set_label("Split-Step") ax[0, 0].lines[1].set_label("Heller") ax[0, 0].legend() fig.tight_layout(rect=[0, 0.03, 1, 0.95]) # plt.savefig("HO") plt.show()
def freeAnimate(Nstep, dt): sch = Schrodinger2D(x, y, psi, V, args) tool = PlotTools() tool.animation2D(sch, Nstep, dt, args, xlen / 2, k_lim)
def expectation(sch, Nstep, dt): t_list, x_av, y_av, xs_av, ys_av = sch.expectationVals(Nstep, dt) tool = PlotTools() tool.expectationValues(t_list, x_av, y_av, xs_av, ys_av)
# tool = PlotTools() # tool.animateRing(sch, Nstep, dt, args, xlen / 2, k_lim, rp,save="Test") ############ Animate correct width # ax0 = 1j * m*w/2 # ay0 = 1j * m*w/2 # # init = [x0, y0, vx0, vy0, ax0, ay0, lam, g0] # V = ring2D(X, Y, args) # psi = hellerGaussian2D(X, Y, init, args) # sch = Schrodinger2D(x, y, psi, V, args) # # Nstep=1 # tool = PlotTools() # tool.animateRing(sch, Nstep, dt, args, xlen / 2, k_lim, rp,save="Test") ########### Animate Off Centre x0 = x0 - 7 ax0 = 1j * m * w / 2 ay0 = 1j * m * w / 2 init = [x0, y0, vx0, vy0, ax0, ay0, lam, g0] init = [x0, y0, vx0, vy0, ax0, ay0, lam, g0] V = ring2D(X, Y, args) psi = hellerGaussian2D(X, Y, init, args) sch = Schrodinger2D(x, y, psi, V, args) Nstep = 1 tool = PlotTools() # tool.animateRing(sch, Nstep, dt, args, xlen / 2, k_lim, rp,save="Ring Off Centre") tool.animateRing(sch, Nstep, dt, args, xlen / 2, k_lim, rp)
r0 = 0.5 * 10**(-5) x0 = 0.5 * (r0 + np.sqrt(r0**2 + 4 * (vy0**2 / w**2))) init = [x0, y0, vx0, vy0, ax0, ay0, lam, g0] args = (m, hbar, w, r0) psi_init = hellerGaussian2D(X, Y, init, args) V = ring2D(X, Y, args) # fig, ax = plt.subplots() # ax.imshow(V) # plt.show() sch = Schrodinger2D(x, y, psi_init, V, args) tool = PlotTools() # t_list, x_av, y_av, xs_av, ys_av = sch.expectationVals(Nstep, dt) # tool.expectationValues(t_list,x_av,y_av,xs_av,ys_av) tool.animation2D(sch, 1, 0.0001, args, xlim / 2, k_lim, save="Realistic_values") ############# Scaled Values # m_s = m # T_s = 2 * np.pi / w
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")
# plt.show() #######Compare Inital and Final theta = np.linspace(-np.pi, np.pi, N) thetax = x0 * np.cos(theta) thetay = x0 * np.sin(theta) thetadup = (thetax, thetay) # sch = Schrodinger2D(x, y, psi, V, args) # sch.evolvet(Nstep, dt) # np.savez_compressed("psi_tilt",psi=sch.psi_x,time=sch.t) loaded = np.load("psi_tilt.npz") psif = loaded["psi"] tool = PlotTools() tool.compareInit(psi, psif, xlen / 2, k_lim, other=thetadup) ######## Tilt investigation loaded = np.load("psi_tilt.npz") psif = loaded["psi"] psifs = np.real(psif * np.conjugate(psif)) X, Y = np.meshgrid(x, y) KX, KY = np.meshgrid(k_arr, k_arr) x_expect = simps(simps(X * psifs, x), y) y_expect = simps(simps(Y * psifs, y), x) xs_expect = simps(simps(X**2 * psifs, x), y) ys_expect = simps(simps(Y**2 * psifs, y), x)
T_tot = 4 * np.pi / w Nstep = 500 dt = T_tot / Nstep V = ring2D(X, Y, args) psi = hellerGaussian2D(X, Y, init, args) ##### Animate Ring Spreadding psis = np.real(psi * np.conjugate(psi)) # fig, ax = plt.subplots() # ax.imshow(psis[::-1]) # plt.show() sch = Schrodinger2D(x, y, psi, V, args) # freeAnimate(1,3) tool = PlotTools() # tool.animateRing(sch, 1, dt, args, xlen / 2, k_lim, r0, save="Test") tool.animateRing(sch, 1, dt, args, xlen / 2, k_lim, r0) ########## Changing with over time t = 0 T_tot = 2 * np.pi / w Nstep = 50 dt = T_tot / Nstep sch = Schrodinger2D(x, y, psi, V, args) theta = np.linspace(-np.pi, np.pi, N) squared = np.real(sch.psi_x * np.conjugate(sch.psi_x)) psi_x = squared[:, xN]