{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Ionisation potential of a porous material\n", "\n", "In this example we use `MacroDensity` with `VASP` to align the energy levels of a porous material.\n", "\n", "The procedure involves one DFT calculaion, yielding different important values:\n", "\n", "* $\\epsilon_{vbm}$ - the valence band maximum\n", "* $V_{vac}$ - the vacuum potential\n", "\n", "The ionisation potential ($IP$) is then obtained from:\n", "\n", "$IP = V_{vac} - \\epsilon_{vbm}$\n", "\n", "The difference to a bulk calculation is that here the material itself has a vacuum within it. This allows us to sample the vacuum level from the vacuum region, as explained in [this paper](http://pubs.acs.org/doi/abs/10.1021/ja4110073).\n", "\n", "## Our system \n", "\n", "We will demonstrate this procedure for the porous system ZIF-8.\n", "\n", "![](./zif8.png)\n", "\n", "## Procedure\n", "\n", "1. Optimise the structure\n", "2. Calculate the electronic structure at your chosen level of theory, adding the `LVHAR` flag to the `INCAR` file:\n", "\n", " ``LVHAR = .TRUE. # This generates a LOCPOT file with the potential`` \n", " \n", "3. Locate the centre of the largest pore - do this \"by eye\" first\n", "4. Plot the potential in that plane, so see if it plateaus\n", "5. Plot a profile of the potential across the pore, again to see the plateau\n", "6. Sample the potential from the pore centre" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_13766/391802285.py:7: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses\n", " import imp\n" ] } ], "source": [ "%matplotlib inline\n", "%load_ext autoreload\n", "%autoreload 2\n", "\n", "import sys\n", "sys.path.append('../../')\n", "import imp\n", "import macrodensity as md\n", "import math\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import os" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read the potential" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "if os.path.isfile('LOCPOT'):\n", " print('LOCPOT already exists')\n", "else:\n", " os.system('bunzip2 LOCPOT.bz2')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Reading header information...\n", "Reading 3D data using Pandas...\n", "Average of the potential = 1.9559870102655787e-14\n" ] } ], "source": [ "input_file = 'LOCPOT'\n", "\n", "#=== No need to edit below\n", "vasp_pot, NGX, NGY, NGZ, Lattice = md.read_vasp_density(input_file)\n", "vector_a,vector_b,vector_c,av,bv,cv = md.matrix_2_abc(Lattice)\n", "resolution_x = vector_a/NGX\n", "resolution_y = vector_b/NGY\n", "resolution_z = vector_c/NGZ\n", "grid_pot, electrons = md.density_2_grid(vasp_pot, NGX, NGY, NGZ)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Look for pore centre points\n", "\n", "* For this we will use `VESTA`.\n", " * Open the LOCPOT in `VESTA`.\n", " * Expand to 2x2x2 cell, by choosing the Boundary option on the left hand side.\n", " * Look for a pore centre - [1,1,1] is at a pore centre here.\n", " * Now draw a lattice plane through that point.\n", " * Choose Edit > Lattice Planes.\n", " * Click New.\n", " * Put in the Miller index (e.g. 1,1,1).\n", " * Move the plane up and down using the d parameter, until it passes through the point you think is the centre.\n", " * It should look like the picture below.\n", "![](./111.png)\n", "\n", "* Now we look at a contour plot of this plane to see if we are at a plateau.\n", " * Utiltiy > 2D Data Display.\n", " * Click Slice and enter the same parameters as in the 3D view.\n", " * Now choose contours to play with the settings\n", " * Z(max) and Z(min) tell you the potential max and min.\n", " * Set contour max = Z(max) and contour min = 0 and the interval to 0.1.\n", " * With some playing with the General settings, you can get something like this:\n", " \n", "![](./plane.png)\n", "\n", "* We can see the [1,1,1], at the centre of the picture is a maximum and is a plateau, so we can now use it for sampling.\n", "\n", "## Sampling the potential\n", "\n", "* We now set the point to sample at [1,1,1]\n", "* We must also set the travelled parameter, for this type of analysis it is always [0,0,0]." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "cube_origin = [1,1,1]\n", "travelled = [0,0,0]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "216" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "int(cube_origin[0]*NGX)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* We want to try a range of sampling area sizes and analyse how this affects the potential.\n", "* We also want low variance (plateau condidtions).\n", "* Ideally we should have as large an area as possible, with low (< 1e-5) variance." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Dimension Potential Variance\n", "--------------------------------\n", " 1 2.3068 0.000000\n", " 10 2.3068 0.000001\n", " 20 2.3068 0.000003\n", " 40 2.3068 0.000019\n", " 60 2.3067 0.000108\n", " 80 2.3048 0.001151\n", " 100 2.2883 0.015872\n" ] } ], "source": [ "dim = [1, 10, 20, 40, 60, 80, 100]\n", "print(\"Dimension Potential Variance\")\n", "print(\"--------------------------------\")\n", "for d in dim:\n", " cube = [d, d, d]\n", " cube_potential, cube_var = md.volume_average(cube_origin, cube,grid_pot, NGX, NGY, NGZ, travelled=travelled)\n", " print(\" %3i %10.4f %10.6f\"%(d, cube_potential, cube_var))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So we take the potential value of `2.3068`. For the VBM value, we take it from the `OUTCAR` file (VBM: -2.4396 eV)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "IP: 4.7464 eV\n" ] } ], "source": [ "print(\"IP: %3.4f eV\" % (2.3068 -- 2.4396 ))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 2 }