From c608809edf3a2e40769ea4656f542d3c5780ef3e Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Mon, 4 Apr 2022 08:27:29 +0200 Subject: [PATCH] Final: Fix task 4.3 except for some TODOs and comments --- ...l - Tight-binding propagation method.ipynb | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/Final/Final - Tight-binding propagation method.ipynb b/Final/Final - Tight-binding propagation method.ipynb index dcaf652..afa6e8c 100644 --- a/Final/Final - Tight-binding propagation method.ipynb +++ b/Final/Final - Tight-binding propagation method.ipynb @@ -1339,6 +1339,7 @@ " # And that indeed t[0] = 0*tau = 0.\n", " assert np.allclose(t[0], 0)\n", " \n", + " # TODO: What should the dtype be, should it be complex?\n", " c = np.zeros(t.shape + c0.shape, dtype=c0.dtype)\n", " c[0] = c0\n", " \n", @@ -1440,16 +1441,7 @@ "task": false } }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/tmp/ipykernel_2000248/327551893.py:14: ComplexWarning: Casting complex values to real discards the imaginary part\n", - " c[j] = U@c[j - 1]\n" - ] - } - ], + "outputs": [], "source": [ "n = 100\n", "# TODO: Should one be able to pass a through everything?\n", @@ -1460,15 +1452,18 @@ "\n", "H = TBHamiltonian(n, sigma)\n", "U = getU_exact(tau, H)\n", - "#c0 = np.zeros(n, dtype=np.complex128)\n", - "c0 = np.zeros(n)\n", + "# TODO: Is c0 complex?\n", + "c0 = np.zeros(n, dtype=np.complex128)\n", + "#c0 = np.zeros(n)\n", "c0[n//2] = 1\n", "\n", "c = timePropagate(U, c0, t)\n", "xi = atomic_positions(n, a)\n", - "psi = c@atomic_basis(x, xi, sigma).T\n", - "\n", - "x = np.linspace(-1, 11, 150)" + "x = np.linspace(-1, 101, 150)\n", + "# TODO: Does real-space wavefunction mean that it should be real or\n", + "# that we take the real part?\n", + "psi = np.real(c@atomic_basis(x, xi, sigma).T)\n", + "\n" ] }, { @@ -1477,6 +1472,8 @@ "metadata": {}, "outputs": [], "source": [ + "psi\n", + "\n", "# This cell can be deleted!\n", "x = np.linspace(-1, 11, 150)\n", "xi = atomic_positions(n, a)\n", @@ -1488,8 +1485,8 @@ "#print(psi)\n", "psi.shape\n", "#psi[t][x]\n", - "plt.plot(x, psi[30])\n", - "print(psi[2].shape, x.shape)" + "plt.plot(x, psi[20])\n", + "print(psi[100].shape, x.shape)" ] }, { @@ -1521,8 +1518,8 @@ "# create a figure for the animation\n", "fig = plt.figure()\n", "plt.grid(True)\n", - "plt.xlim(-1, 11) # fix x limits\n", - "plt.ylim(-1e-6, 1e-6) # fix y limits\n", + "plt.xlim(-1, 101) # fix x limits\n", + "plt.ylim(-.5, .6) # fix y limits\n", "plt.xlabel('$x$')\n", "plt.ylabel('$\\\\psi(t, x)$')\n", "\n",