From 10e67c50234baf886aadc4d051339f94ea60bf5f Mon Sep 17 00:00:00 2001
From: Anton Akhmerov <anton.akhmerov@gmail.com>
Date: Thu, 22 Mar 2018 22:21:18 +0100
Subject: [PATCH] add numerical DOS plots

---
 code/band_structures.py | 23 ++++++++++++++
 lecture_3.md            | 69 ++++++-----------------------------------
 2 files changed, 32 insertions(+), 60 deletions(-)

diff --git a/code/band_structures.py b/code/band_structures.py
index 90297282..1da3bc8a 100644
--- a/code/band_structures.py
+++ b/code/band_structures.py
@@ -118,6 +118,25 @@ def phonons_1d_2masses():
         draw_classic_axes(ax, xlabeloffset=.2)
         pyplot.savefig('phonons6.svg')
 
+def DOS_finite_phonon_chain(n, output_name):
+    rhs = 2 * np.eye(n) - np.eye(n, k=1) - np.eye(n, k=-1)
+    rhs[0, 0] -= 1
+    rhs[-1, -1] -= 1
+    pyplot.figure()
+    pyplot.hist(np.sqrt(np.abs(np.linalg.eigvalsh(rhs))), bins=30)
+    pyplot.xlabel("$\omega$")
+    pyplot.ylabel("Number of levels")
+    pyplot.savefig(output_name)
+
+
+def DOS_finite_electron_chain(n, output_name):
+    rhs = - np.eye(n, k=1) - np.eye(n, k=-1)
+    pyplot.figure()
+    pyplot.hist(np.linalg.eigvalsh(rhs), bins=30)
+    pyplot.xlabel("$E$")
+    pyplot.ylabel("Number of levels")
+    pyplot.savefig(output_name)
+
 
 def main():
     os.chdir('figures')
@@ -126,6 +145,10 @@ def main():
     phonons_1d_2masses()
     meff_1d_tb()
     tight_binding_1d()
+    DOS_finite_phonon_chain(3, 3_phonons.svg)
+    DOS_finite_phonon_chain(300, 300_phonons.svg)
+    DOS_finite_electron_chain(3, 3_electrons.svg)
+    DOS_finite_electron_chain(300, 300_electrons.svg)
 
 if __name__ == "__main__":
     main()
diff --git a/lecture_3.md b/lecture_3.md
index 4d7a2d94..11b488eb 100644
--- a/lecture_3.md
+++ b/lecture_3.md
@@ -261,74 +261,23 @@ $$
 
 Diagonalizing large matrices is unwieldy, but let's try and check it numerically to see if we notice a trend.
 
+Eigenfrequencies of 3 atoms: `[0.0 1.0 1.732050]`
 
-```python
-%matplotlib inline
-import numpy as np
-from matplotlib import pyplot
+![](figures/3_phonons.svg)
 
-# Phonons
-rhs = np.array([[1, -1, 0], [-1, 2, -1], [0, -1, 1]])
-print("Eigenfrequencies of 3 atoms:", np.sqrt(np.linalg.eigvalsh(rhs)))
-pyplot.hist(np.sqrt(np.linalg.eigvalsh(rhs)), bins=30)
-pyplot.show()
+Energies of 3 orbitals: `[-1.41421356 0.0  1.41421356]`
 
-# Electrons
+![](figures/3_electrons.svg)
 
-rhs = np.array([[0, -1, 0], [-1, 0, -1], [0, -1, 0]])
-print("Energies of 3 orbitals:", np.linalg.eigvalsh(rhs))
-pyplot.hist(np.linalg.eigvalsh(rhs), bins=30);
-```
+### From 3 atoms to 300
 
-    Eigenfrequencies of 3 atoms: [6.26502485e-09 1.00000000e+00 1.73205081e+00]
+Frequencies of many phonons:
 
+![](figures/300_phonons.svg)
 
+Energies of many electrons:
 
-![png](lecture_3_files/lecture_3_14_1.png)
-
-
-    Energies of 3 orbitals: [-1.41421356e+00 -8.06646416e-17  1.41421356e+00]
-
-
-
-![png](lecture_3_files/lecture_3_14_3.png)
-
-
-### From 3 atoms to 100
-
-
-```python
-n = 100
-
-# Phonons
-rhs = 2 * np.eye(100) - np.eye(100, k=1) - np.eye(100, k=-1)
-rhs[0, 0] -= 1
-rhs[-1, -1] -= 1
-print('Frequencies of many phonons')
-pyplot.hist(np.sqrt(np.abs(np.linalg.eigvalsh(rhs))), bins=30)
-pyplot.show()
-
-
-# Electrons
-
-rhs = - np.eye(100, k=1) - np.eye(100, k=-1)
-print("Energies of many electrons")
-pyplot.hist(np.linalg.eigvalsh(rhs), bins=30);
-```
-
-    Frequencies of many phonons
-
-
-
-![png](lecture_3_files/lecture_3_16_1.png)
-
-
-    Energies of many electrons
-
-
-
-![png](lecture_3_files/lecture_3_16_3.png)
-
+![](figures/300_electrons.svg)
 
 ## Summary
 
-- 
GitLab