From 45ef3be59da32f830ef6529536c11153754a189d Mon Sep 17 00:00:00 2001 From: ireaml Date: Sun, 24 Dec 2023 20:54:20 +0100 Subject: [PATCH] update Porous tutorial --- docs/tutorials/Porous/Porous.ipynb | 149 ++++++++++++++--------------- 1 file changed, 70 insertions(+), 79 deletions(-) diff --git a/docs/tutorials/Porous/Porous.ipynb b/docs/tutorials/Porous/Porous.ipynb index 18b5b27..a95c3ac 100644 --- a/docs/tutorials/Porous/Porous.ipynb +++ b/docs/tutorials/Porous/Porous.ipynb @@ -47,7 +47,7 @@ "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", + "/tmp/ipykernel_7455/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" ] } @@ -71,54 +71,13 @@ "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)" + "## Look for pore centre points" ] }, { "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", @@ -141,42 +100,78 @@ " \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", + "* 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." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "## 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": "markdown", + "metadata": {}, + "source": [ + "### Read the potential" + ] + }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "LOCPOT already exists\n" + ] + } + ], "source": [ - "cube_origin = [1,1,1]\n", - "travelled = [0,0,0]" + "if os.path.isfile('LOCPOT'):\n", + " print('LOCPOT already exists')\n", + "else:\n", + " os.system('bunzip2 LOCPOT.bz2')" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "216" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" + "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": [ - "int(cube_origin[0]*NGX)" + "# Read the potential from the LOCPOT file\n", + "input_file = 'LOCPOT'\n", + "\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", + "grid_pot, electrons = md.density_2_grid(vasp_pot, NGX, NGY, NGZ)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "cube_origin = [1,1,1]\n", + "travelled = [0,0,0]" ] }, { @@ -190,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -199,13 +194,13 @@ "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" + "1\t 2.3068\t 0.00000\n", + "10\t 2.3068\t 0.00000\n", + "20\t 2.3068\t 0.00000\n", + "40\t 2.3068\t 0.00002\n", + "60\t 2.3067\t 0.00011\n", + "80\t 2.3048\t 0.00115\n", + "100\t 2.2883\t 0.01587\n" ] } ], @@ -215,8 +210,10 @@ "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))" + " cube_potential, cube_var = md.volume_average(\n", + " cube_origin, cube, grid_pot, NGX, NGY, NGZ, travelled=travelled\n", + " )\n", + " print(f\"{d}\\t {cube_potential:.4f}\\t {cube_var:.5f}\")" ] }, { @@ -228,7 +225,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -240,15 +237,9 @@ } ], "source": [ - "print(\"IP: %3.4f eV\" % (2.3068 -- 2.4396 ))" + "vbm = -2.4396 # eV\n", + "print(\"IP: %3.4f eV\" % (2.3068 - vbm))" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -267,7 +258,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.5" } }, "nbformat": 4,