Skip to content

Commit

Permalink
update Porous tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
ireaml committed Dec 24, 2023
1 parent cc06459 commit 45ef3be
Showing 1 changed file with 70 additions and 79 deletions.
149 changes: 70 additions & 79 deletions docs/tutorials/Porous/Porous.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Expand All @@ -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",
Expand All @@ -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]"
]
},
{
Expand All @@ -190,7 +185,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 17,
"metadata": {},
"outputs": [
{
Expand All @@ -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"
]
}
],
Expand All @@ -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}\")"
]
},
{
Expand All @@ -228,7 +225,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -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": {
Expand All @@ -267,7 +258,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 45ef3be

Please sign in to comment.