Exercise-11-checkpoint.ipynb 38.7 KB
 spiasko committed May 20, 2019 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 { "cells": [ { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from matplotlib.patches import Rectangle\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Theoretical background\n", "\n", "$\\Psi_k = \\frac{1}{\\sqrt{N}} \\sum_j e^{(j\\,k\\cdot r_j)} \\, \\phi_j = \\frac{1}{\\sqrt{N}} \\sum_j c_k(r_j) \\, \\phi_j$\n", "\n", "Notation:\n", "$[\\,]_{nm}$ = matrix of dimensions $n\\times m$\n", "\n", "- h = $[\\phi_0]_{nn}$\n", "- t = $[\\phi_{+1}]_{mnn}, \\ m=1$ for first nn hopping\n", "\n", "For first nn:\n", "\n", "- $c(k) = e^{(j\\,k\\cdot R)} \\, ,k=(0,0,0)...(2\\pi,0,0) \\, , R=(1,0,0)$\n", "\n", "- $[h(k)]_{nn} = [h]_{nn} + c(k) \\cdot [t]_{0nn} + (c(k) \\cdot [t]_{0nn})^H$\n", "\n", "- $E(k)_n=eigvalsh([h(k)]_{nn})$" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "def bands(h,t,K):\n", " '''\n", " input:\n", " h = [\\phi_0]_nn\n", " t = [\\phi_1]_mnn \n", " variables:\n", " \n", " '''\n", " kpts = np.linspace(0,K,300)\n", " E = np.zeros((len(kpts),len(h)))\n", " R = [1,0,0]\n", " for k, kpt in enumerate(kpts):\n", " c_k = np.exp(1j*2*np.pi*np.dot(R,[kpt,0,0]))\n", " h_k = h + np.sum(c_k*t,axis=0) + np.conj(np.sum(c_k*t,axis=0))\n", " E[k] = np.linalg.eigvalsh(h_k)\n", " return kpts,E" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def make_ht(e,tau):\n", " dim = e.ndim\n", " if dim>0:\n", " dim = len(e)\n", " h = np.zeros((dim,dim),complex)\n", " t = np.zeros((dim,dim),complex)\n", " h.flat[::dim+1]=e\n", " h.flat[1::dim+1]=tau[0]\n", " h.flat[dim::dim+1]=np.conj(tau[0])\n", " t[-1,0]=tau[1]\n", " else:\n", " h = np.array(e).reshape(1,1)\n", " t = np.array(tau).reshape(1,1)\n", " return h,np.expand_dims(t,0)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def visulize(ax,h,t,replica=5):\n", " \n", " import matplotlib.cm as cm\n", " colors = cm.hot(np.diag(h).real)\n", " colors = np.tile(colors,(replica,1))\n", " \n", " dim = len(h)\n", " if dim>1:\n", " uc = np.arange(dim)*1/abs(h[0,1].real)\n", " colors = cm.hot(np.diag(h).real)\n", " colors = np.tile(colors,(replica,1))\n", " a = 1/abs(t[0,-1,0].real)+1/abs(h[0,1].real)\n", " atoms = [uc[i]+(j*a) for j in range(replica) for i in range(dim)]\n", " else:\n", " uc = 0\n", " a = 1/abs(t[0,-1,0].real)\n", " atoms = [uc+(j*a) for j in range(replica)]\n", " rect = Rectangle((-1/abs(2*t[0,-1,0].real),-0.25),a,0.5,\n", " linewidth=1,edgecolor='r',facecolor='none')\n", " ax.add_patch(rect)\n", " ax.set_ylim((-1,1))\n", " ax.scatter(atoms,np.zeros(dim*5),100,c=colors)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Do not run\n", "\n", "example 0:\n", "\n", " 0.1 0.1 \n", "... | x | x | x | ...\n", " \n", "tau=np.array((0.2)), 0.2 = inter-cell hopping term