From de35cd1a13c541bd0a68d1eff742e138f9dab865 Mon Sep 17 00:00:00 2001 From: Nick Papior Date: Thu, 29 Aug 2024 12:28:08 +0200 Subject: [PATCH] fixed notebooks and amended another change Signed-off-by: Nick Papior --- S_01/run.ipynb | 11 ++++++----- S_02/run.ipynb | 43 +++++++++++++++++++++++++------------------ tutorial.ipynb | 4 ++-- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/S_01/run.ipynb b/S_01/run.ipynb index 2a3bc3d..27c9607 100644 --- a/S_01/run.ipynb +++ b/S_01/run.ipynb @@ -9,6 +9,7 @@ "import sisl\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "\n", "%matplotlib inline" ] }, @@ -58,7 +59,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Read Hamiltonians using two different methods\n" + "# Read Hamiltonians using two different methods" ] }, { @@ -99,12 +100,12 @@ "\n", "# Plot band-structures\n", "band.set_parent()\n", - "eigs = band.eigh()\n", + "eigs = band.apply.ndarray.eigh()\n", "ax.plot(lk, eigs)\n", " \n", "# You need to create the TB Hamiltonian, see e.g. TB_01\n", "band.set_parent()\n", - "eigs = band.eigh()\n", + "eigs = band.apply.ndarray.eigh()\n", "ax.plot(lk, eigs, '--')" ] }, @@ -118,7 +119,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -132,7 +133,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/S_02/run.ipynb b/S_02/run.ipynb index f2502cf..7cb75f5 100644 --- a/S_02/run.ipynb +++ b/S_02/run.ipynb @@ -9,6 +9,7 @@ "import sisl\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "\n", "%matplotlib inline" ] }, @@ -38,8 +39,8 @@ "outputs": [], "source": [ "graphene = sisl.geom.graphene(1.44)\n", - "graphene.write('STRUCT.fdf')\n", - "graphene.write('STRUCT.xyz')" + "graphene.write(\"STRUCT.fdf\")\n", + "graphene.write(\"STRUCT.xyz\")" ] }, { @@ -55,7 +56,8 @@ "metadata": {}, "outputs": [], "source": [ - "open('PDOS.fdf', 'w').write(\"\"\"\n", + "open(\"PDOS.fdf\", \"w\").write(\n", + " \"\"\"\n", "# K-point sampling\n", "%block PDOS.kgrid.MonkhorstPack\n", " 63 0 0\n", @@ -70,7 +72,8 @@ "%block Projected.DensityOfStates\n", "-20.00 15.00 0.200 3500 eV\n", "%endblock\n", - "\"\"\");" + "\"\"\"\n", + ")" ] }, { @@ -99,7 +102,7 @@ "metadata": {}, "outputs": [], "source": [ - "geometry, E, PDOS = sisl.get_sile('siesta.PDOS.xml').read_data()" + "geometry, E, PDOS = sisl.get_sile(\"siesta.PDOS.xml\").read_data()" ] }, { @@ -108,7 +111,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Examine output by printing shapes and geometry\n" + "# Examine output by printing shapes and geometry" ] }, { @@ -123,16 +126,20 @@ "3. Figure out which orbital contributes to the Dirac cone by plotting the PDOS for all orbitals\n", "4. Read in the Hamiltonian (as done in [S 1](../S_01/run.ipynb)) and create a Monkhorst-Pack grid as the one in Siesta input. Use this snippet to calculate the PDOS using `sisl`\n", "\n", - " mp = sisl.MonkhorstPack(H, [nx, ny, 1])\n", - " def wrap_multiple(eigenstate):\n", - " DOS = eigenstate.DOS(E)\n" - " PDOS = eigenstate.PDOS(E)\n" - " return sisl.oplist([DOS, PDOS])\n", - " DOS, PDOS = mp.apply.average.eigenstate(wrap=wrap_multiple, eta=True)\n", + " ```python\n", + " mp = sisl.MonkhorstPack(H, [nx, ny, 1])\n", + " def wrap_multiple(eigenstate):\n", + " DOS = eigenstate.DOS(E)\n", + " PDOS = eigenstate.PDOS(E)\n", + " return sisl.oplist([DOS, PDOS])\n", + " DOS, PDOS = mp.apply.average.eigenstate(wrap=wrap_multiple, eta=True)\n", + " \n", + " ```\n", "\n", " Search the API documentation for the `MonkhorstPack.apply.average` method and figure out what it does. Note, there are other `MonkhorstPack.apply.*` methods - these are all extremely useful when calculating many quantities of data in a Brillouin-zone object.\n", - "5. Compare the Siesta PDOS with sisl PDOS, why are they different? \n", - " *HINT*: $\\sigma$. Check the API for the `PDOS` method in the Siesta manual (https://siesta-project.org/SIESTA_MATERIAL/Docs/Manuals/siesta-4.1.5.pdf)." + "5. Ensure that the `DOS` and the summed `PDOS` (use Eq. 2) are equivalent.\n", + "6. Compare the Siesta PDOS with sisl PDOS, why are they different? \n", + " *HINT*: $\\sigma$. Check the API for the `PDOS` method in the Siesta manual, provided via this tutorial (`../siesta.pdf`)." ] }, { @@ -141,9 +148,9 @@ "metadata": {}, "outputs": [], "source": [ - "plt.plot(E, PDOS.sum(0), label='DOS')\n", - "plt.xlabel(r'$E - E_F$ [eV]')\n", - "plt.ylabel(r'DOS [1/eV]')\n", + "plt.plot(E, PDOS.sum(0), label=\"DOS\")\n", + "plt.xlabel(r\"$E - E_F$ [eV]\")\n", + "plt.ylabel(r\"DOS [1/eV]\")\n", "\n", "# Add more plots for individual PDOS\n", "\n", @@ -169,7 +176,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/tutorial.ipynb b/tutorial.ipynb index 97336a9..3f178d5 100644 --- a/tutorial.ipynb +++ b/tutorial.ipynb @@ -233,7 +233,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -247,7 +247,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.11.7" } }, "nbformat": 4,