Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudo-Raheel authored Jul 4, 2024
2 parents 87ca273 + 78e38f3 commit 00dc55e
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
micromamba activate venv
cd notebooks
pwd
pytest --ignore=*notest.ipynb --nbmake .
pytest --ignore-glob=*notest.ipynb --nbmake .
3 changes: 1 addition & 2 deletions notebooks/2013-01-01-Basic functionality.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"outputs": [],
"source": [
"# Uncomment the subsequent lines in this cell to install dependencies for Google Colab.\n",
"# !pip install pymatgen==2022.7.19\n",
"from __future__ import annotations"
"# !pip install pymatgen"
]
},
{
Expand Down
6 changes: 2 additions & 4 deletions notebooks/2013-01-01-Ordering Disordered Structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
],
"source": [
"# Let us start by creating a disordered CuAu fcc structure.\n",
"from __future__ import annotations\n",
"\n",
"from pymatgen.core import Lattice, Structure\n",
"\n",
"specie = {\"Cu0+\": 0.5, \"Au0+\": 0.5}\n",
Expand Down Expand Up @@ -233,9 +231,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
20 changes: 8 additions & 12 deletions notebooks/2017-04-14-Inputs and Analysis of VASP runs.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

74 changes: 42 additions & 32 deletions notebooks/2023-12-31-FHI-aims-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"metadata": {},
"outputs": [],
"source": [
"from __future__ import annotations\n",
"\n",
"from pathlib import Path\n",
"from subprocess import check_call\n",
"\n",
Expand All @@ -29,8 +27,7 @@
"# AIMS_CMD should be modified to match your system\n",
"AIMS_CMD = \"aims.x\"\n",
"AIMS_OUTPUT = \"aims.out\"\n",
"AIMS_SD = \"species_dir\"\n",
"AIMS_TEST_DIR = \"../../tests/io/aims/species_directory/light/\""
"AIMS_SD = \"species_dir\""
]
},
{
Expand Down Expand Up @@ -87,22 +84,7 @@
"execution_count": 5,
"id": "4",
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "Species file for Si not found.",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[5], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m work_dir\u001b[38;5;241m.\u001b[39mmkdir(exist_ok\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m 5\u001b[0m geo_in\u001b[38;5;241m.\u001b[39mwrite_file(work_dir, overwrite\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m----> 6\u001b[0m \u001b[43mcont_in\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mwrite_file\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstructure\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mwork_dir\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moverwrite\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/miniconda3/envs/mavrl/lib/python3.11/site-packages/pymatgen/io/aims/inputs.py:583\u001b[0m, in \u001b[0;36mAimsControlIn.write_file\u001b[0;34m(self, structure, directory, verbose_header, overwrite)\u001b[0m\n\u001b[1;32m 578\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(structure, Structure) \u001b[38;5;129;01mand\u001b[39;00m (\n\u001b[1;32m 579\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mk_grid\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parameters \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mk_grid_density\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parameters\n\u001b[1;32m 580\u001b[0m ):\n\u001b[1;32m 581\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mk-grid must be defined for periodic systems\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 583\u001b[0m content \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_content\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstructure\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mverbose_header\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 585\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdirectory\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/control.in\u001b[39m\u001b[38;5;124m\"\u001b[39m, mode\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m file:\n\u001b[1;32m 586\u001b[0m file\u001b[38;5;241m.\u001b[39mwrite(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m#\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;250m \u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;250m \u001b[39m\u001b[38;5;241m72\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/miniconda3/envs/mavrl/lib/python3.11/site-packages/pymatgen/io/aims/inputs.py:548\u001b[0m, in \u001b[0;36mAimsControlIn.get_content\u001b[0;34m(self, structure, verbose_header, directory)\u001b[0m\n\u001b[1;32m 546\u001b[0m content \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m lim \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 547\u001b[0m species_dir \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parameters\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mspecies_dir\u001b[39m\u001b[38;5;124m\"\u001b[39m, os\u001b[38;5;241m.\u001b[39menviron\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAIMS_SPECIES_DIR\u001b[39m\u001b[38;5;124m\"\u001b[39m))\n\u001b[0;32m--> 548\u001b[0m content \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_species_block\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstructure\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mspecies_dir\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 550\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m content\n",
"File \u001b[0;32m~/miniconda3/envs/mavrl/lib/python3.11/site-packages/pymatgen/io/aims/inputs.py:618\u001b[0m, in \u001b[0;36mAimsControlIn.get_species_block\u001b[0;34m(self, structure, species_dir)\u001b[0m\n\u001b[1;32m 616\u001b[0m block \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(sf\u001b[38;5;241m.\u001b[39mreadlines())\n\u001b[1;32m 617\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 618\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSpecies file for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00msp\u001b[38;5;241m.\u001b[39msymbol\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m not found.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 620\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m block\n",
"\u001b[0;31mValueError\u001b[0m: Species file for Si not found."
]
}
],
"outputs": [],
"source": [
"# Write the input files\n",
"work_dir = Path.cwd() / \"workdir/\"\n",
Expand All @@ -114,33 +96,61 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"# Run the calculation\n",
"with open(f\"{work_dir}/{AIMS_OUTPUT}\", \"w\") as outfile:\n",
" aims_run = check_call([AIMS_CMD], cwd=work_dir, stdout=outfile)"
"# with open(f\"{work_dir}/{AIMS_OUTPUT}\", \"w\") as outfile:\n",
"# aims_run = check_call([AIMS_CMD], cwd=work_dir, stdout=outfile)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "6",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Full Formula (Si8)\n",
"Reduced Formula: Si\n",
"abc : 5.630352 5.630352 5.630352\n",
"angles: 90.000000 90.000000 90.000000\n",
"pbc : True True True\n",
"Sites (8)\n",
" # SP a b c force\n",
"--- ---- --------- ----- ----- -------------------------------------------------\n",
" 0 Si -0.498224 0.5 0.5 [-1.10236868e-01 5.39644191e-08 4.70492367e-07]\n",
" 1 Si 0.5 0 -0 [-1.83812467e-02 3.53891730e-08 4.63693170e-07]\n",
" 2 Si 0 0.5 -0 [4.67871056e-03 3.57565863e-08 4.65599333e-07]\n",
" 3 Si 0 0 0.5 [4.67870957e-03 4.34255894e-08 4.38675279e-07]\n",
" 4 Si -0.25 -0.25 -0.25 [0.02997323 0.01705022 0.01704979]\n",
" 5 Si -0.25 0.25 0.25 [ 0.02997324 -0.0170503 -0.01705073]\n",
" 6 Si 0.25 -0.25 0.25 [ 0.02965711 -0.0165611 0.0165606 ]\n",
" 7 Si 0.25 0.25 -0.25 [ 0.02965711 0.01656101 -0.0165615 ]\n"
]
}
],
"source": [
"# Read the aims output file and the final relaxed geometry\n",
"outputs = AimsOutput.from_outfile(f\"{work_dir}/{AIMS_OUTPUT}\")\n",
"relaxed_structure = AimsGeometryIn.from_file(f\"{work_dir}/geometry.in.next_step\")\n",
"outputs = AimsOutput.from_outfile(f\"{work_dir}/aims.out.gz\")\n",
"relaxed_structure = AimsGeometryIn.from_file(f\"{work_dir}/geometry.in\")\n",
"\n",
"# Check the results\n",
"assert outputs.get_results_for_image(-1).lattice == relaxed_structure.structure.lattice\n",
"assert_allclose(outputs.get_results_for_image(-1).frac_coords, relaxed_structure.structure.frac_coords)\n",
"assert_allclose(outputs.get_results_for_image(-1).properties[\"stress\"], outputs.stress)\n",
"assert_allclose(outputs.get_results_for_image(-1).site_properties[\"force\"], outputs.forces)"
"print(outputs.get_results_for_image(-1))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1aadaebf-f797-4733-8180-fc1850fa1069",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -159,7 +169,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
40 changes: 20 additions & 20 deletions notebooks/Al-band/KPOINTS
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,49 @@ Reciprocal
0.5000000000000001 0.25 0.7500000000000001 1 W
0.5000000000000001 0.25 0.7500000000000001 1 W
0.4886363636363637 0.2613636363636364 0.7500000000000001 1
0.4772727272727273 0.27272727272727276 0.75 1
0.465909090909091 0.2840909090909091 0.7500000000000001 1
0.47727272727272735 0.27272727272727276 0.75 1
0.46590909090909105 0.2840909090909091 0.7500000000000001 1
0.45454545454545464 0.29545454545454547 0.7500000000000001 1
0.4431818181818183 0.3068181818181819 0.7500000000000001 1
0.4318181818181819 0.31818181818181823 0.7500000000000001 1
0.4204545454545455 0.3295454545454546 0.7500000000000001 1
0.4090909090909091 0.34090909090909094 0.75 1
0.40909090909090917 0.34090909090909094 0.75 1
0.3977272727272728 0.35227272727272735 0.7500000000000001 1
0.38636363636363646 0.3636363636363637 0.7500000000000001 1
0.37500000000000006 0.3750000000000001 0.7500000000000001 1 K
0.37500000000000006 0.3750000000000001 0.7500000000000001 1 K
0.3750000000000001 0.3750000000000001 0.7500000000000001 1 K
0.3750000000000001 0.3750000000000001 0.7500000000000001 1 K
0.3636363636363637 0.3636363636363637 0.7272727272727274 1
0.35227272727272735 0.35227272727272735 0.7045454545454546 1
0.34090909090909094 0.34090909090909094 0.6818181818181819 1
0.32954545454545464 0.32954545454545464 0.6590909090909093 1
0.31818181818181823 0.3181818181818183 0.6363636363636365 1
0.3181818181818183 0.3181818181818183 0.6363636363636365 1
0.3068181818181819 0.3068181818181819 0.6136363636363638 1
0.2954545454545455 0.2954545454545455 0.5909090909090909 1
0.28409090909090917 0.28409090909090917 0.5681818181818182 1
0.2727272727272728 0.2727272727272729 0.5454545454545455 1
0.26136363636363646 0.26136363636363646 0.5227272727272728 1
0.2500000000000001 0.2500000000000001 0.5000000000000001 1
0.2386363636363637 0.23863636363636373 0.4772727272727274 1
0.22727272727272732 0.22727272727272735 0.45454545454545464 1
0.21590909090909094 0.21590909090909097 0.4318181818181819 1
0.22727272727272735 0.22727272727272735 0.45454545454545464 1
0.21590909090909097 0.21590909090909097 0.4318181818181819 1
0.2045454545454546 0.2045454545454546 0.40909090909090917 1
0.19318181818181823 0.19318181818181823 0.38636363636363646 1
0.18181818181818185 0.18181818181818185 0.3636363636363637 1
0.1704545454545455 0.17045454545454553 0.340909090909091 1
0.17045454545454553 0.17045454545454553 0.340909090909091 1
0.1590909090909091 0.15909090909090912 0.3181818181818182 1
0.14772727272727276 0.14772727272727276 0.29545454545454547 1
0.1363636363636364 0.1363636363636364 0.27272727272727276 1
0.12500000000000006 0.12500000000000006 0.25000000000000006 1
0.11363636363636363 0.11363636363636363 0.22727272727272724 1
0.10227272727272728 0.10227272727272729 0.20454545454545456 1
0.10227272727272729 0.10227272727272729 0.20454545454545456 1
0.09090909090909094 0.09090909090909095 0.18181818181818188 1
0.07954545454545456 0.07954545454545457 0.15909090909090912 1
0.07954545454545457 0.07954545454545457 0.15909090909090912 1
0.0681818181818182 0.0681818181818182 0.13636363636363638 1
0.056818181818181816 0.056818181818181816 0.11363636363636362 1
0.045454545454545435 0.04545454545454544 0.09090909090909087 1
0.03409090909090914 0.03409090909090914 0.06818181818181826 1
0.022727272727272683 0.022727272727272683 0.045454545454545366 1
0.011363636363636376 0.011363636363636378 0.022727272727272752 1
0.011363636363636378 0.011363636363636378 0.022727272727272752 1
0.0 0.0 0.0 1 \Gamma
0.0 0.0 0.0 1 \Gamma
0.01851851851851852 0.01851851851851852 0.01851851851851852 1
Expand Down Expand Up @@ -130,7 +130,7 @@ Reciprocal
0.5125000000000002 0.47500000000000014 0.5125000000000002 1
0.5187500000000002 0.4625000000000001 0.51875 1
0.5250000000000001 0.45000000000000007 0.5250000000000001 1
0.5312500000000001 0.4375000000000001 0.5312500000000001 1
0.5312500000000002 0.4375000000000001 0.5312500000000001 1
0.5375000000000002 0.4250000000000001 0.5375000000000001 1
0.5437500000000001 0.4125000000000001 0.5437500000000001 1
0.5500000000000002 0.40000000000000013 0.5500000000000002 1
Expand Down Expand Up @@ -160,7 +160,7 @@ Reciprocal
0.5000000000000001 0.25 0.7500000000000001 1 W
0.5000000000000001 0.25 0.7500000000000001 1 W
0.5000000000000001 0.2613636363636364 0.7386363636363636 1
0.5 0.27272727272727276 0.7272727272727273 1
0.5000000000000001 0.27272727272727276 0.7272727272727273 1
0.5000000000000001 0.2840909090909091 0.7159090909090909 1
0.5000000000000001 0.2954545454545455 0.7045454545454546 1
0.5000000000000001 0.3068181818181819 0.6931818181818182 1
Expand All @@ -173,7 +173,7 @@ Reciprocal
0.5000000000000001 0.3863636363636364 0.6136363636363636 1
0.5000000000000001 0.39772727272727276 0.6022727272727273 1
0.5000000000000001 0.4090909090909091 0.5909090909090909 1
0.5 0.42045454545454547 0.5795454545454545 1
0.5000000000000001 0.42045454545454547 0.5795454545454545 1
0.5000000000000001 0.4318181818181819 0.5681818181818182 1
0.5000000000000001 0.44318181818181823 0.556818181818182 1
0.5000000000000001 0.4545454545454546 0.5454545454545455 1
Expand All @@ -187,21 +187,21 @@ Reciprocal
0.4812500000000001 0.4812500000000001 0.5375000000000001 1
0.4750000000000001 0.4750000000000001 0.5500000000000002 1
0.4687500000000001 0.4687500000000001 0.5625 1
0.46250000000000013 0.4625000000000001 0.5750000000000001 1
0.4562500000000001 0.45625000000000016 0.5875 1
0.4625000000000002 0.4625000000000001 0.5750000000000001 1
0.45625000000000016 0.45625000000000016 0.5875 1
0.4500000000000001 0.4500000000000001 0.6000000000000001 1
0.44375000000000014 0.4437500000000001 0.6125 1
0.4375000000000001 0.4375000000000001 0.625 1
0.4312500000000001 0.43125000000000013 0.6375000000000001 1
0.4250000000000001 0.4250000000000001 0.65 1
0.4187500000000001 0.4187500000000001 0.6625 1
0.4187500000000002 0.4187500000000001 0.6625 1
0.41250000000000014 0.4125000000000001 0.675 1
0.40625000000000006 0.4062500000000001 0.6875 1
0.4062500000000001 0.4062500000000001 0.6875 1
0.4000000000000001 0.4000000000000001 0.7000000000000001 1
0.3937500000000001 0.3937500000000001 0.7125 1
0.38750000000000007 0.3875000000000001 0.7250000000000001 1
0.38125000000000014 0.38125000000000014 0.7375000000000002 1
0.37500000000000006 0.3750000000000001 0.7500000000000001 1 K
0.3750000000000001 0.3750000000000001 0.7500000000000001 1 K
0.6250000000000002 0.2500000000000001 0.6250000000000001 1 U
0.6136363636363638 0.22727272727272738 0.6136363636363638 1
0.6022727272727274 0.2045454545454546 0.6022727272727273 1
Expand Down
27 changes: 0 additions & 27 deletions notebooks/Al-relax.cif

This file was deleted.

File renamed without changes.
Binary file added notebooks/species_dir/14_Si_default.gz
Binary file not shown.
Binary file added notebooks/workdir/aims.out.gz
Binary file not shown.
Loading

0 comments on commit 00dc55e

Please sign in to comment.