{ "cells": [ { "cell_type": "markdown", "id": "dcc94f22-3be1-4cd9-9f1c-e61f7e03a1f5", "metadata": {}, "source": "# Simulation Codes" }, { "cell_type": "markdown", "id": "5ffec124-6252-4965-9267-cc771c79570f", "metadata": {}, "source": "## ASE\nAt the current stage the majority of simulation codes are interfaced using the [Atomic Simulation Environment (ASE)](https://wiki.fysik.dtu.dk/ase/).\nThe limitation of the ASE based interfaces is that the simulation codes are only used to calculate energies, forces and\nstresses, while more complex computations like structure optimization or molecular dynamics are implemented in python." }, { "cell_type": "markdown", "id": "ece0e223-3b49-41d7-99ab-e0518ef01c2b", "metadata": {}, "source": "### Abinit\n[Abinit](https://www.abinit.org) - Plane wave density functional theory:" }, { "cell_type": "code", "execution_count": 1, "id": "59904794-1beb-43f5-b6e2-f79404ca8b46", "metadata": { "tags": [], "trusted": false }, "outputs": [], "source": [ "import os\n", "\n", "from ase.calculators.abinit import Abinit, AbinitProfile\n", "from ase.units import Ry\n", "from atomistics.calculators import evaluate_with_ase\n", "\n", "result_dict = evaluate_with_ase(\n", " task_dict={},\n", " ase_calculator=Abinit(\n", " nbands=32,\n", " ecut=10 * Ry,\n", " kpts=(3, 3, 3),\n", " toldfe=1.0e-2,\n", " profile=AbinitProfile(\n", " command=\"abinit\",\n", " pp_paths=os.path.join(os.environ[\"CONDA_PREFIX\"], \"share/abinit/LDA_FHI\"),\n", " ),\n", " ),\n", ")" ] }, { "cell_type": "markdown", "id": "53687acd-cc66-470c-b88b-c4a2a7f4182c", "metadata": {}, "source": "The full documentation of the corresponding interface is available on the [Atomic Simulation Environment](https://wiki.fysik.dtu.dk/ase/ase/calculators/abinit.html)\nwebsite. " }, { "cell_type": "markdown", "id": "a765a024-fc04-4add-b6c2-eef026e4dbd2", "metadata": {}, "source": "### EMT\n[EMT](https://wiki.fysik.dtu.dk/ase/ase/calculators/emt.html) - Effective medium theory: " }, { "cell_type": "code", "execution_count": 2, "id": "a7467756-1366-42c2-b595-e8c7893437ab", "metadata": { "tags": [], "trusted": false }, "outputs": [], "source": [ "from ase.calculators.emt import EMT\n", "from atomistics.calculators import evaluate_with_ase\n", "\n", "result_dict = evaluate_with_ase(task_dict={}, ase_calculator=EMT())" ] }, { "cell_type": "markdown", "id": "e635174f-be67-462f-a3aa-1d3103c31d97", "metadata": {}, "source": "The full documentation of the corresponding interface is available on the [Atomic Simulation Environment](https://wiki.fysik.dtu.dk/ase/ase/calculators/emt.html)\nwebsite. " }, { "cell_type": "markdown", "id": "af758cea-e4ad-475e-8fcc-2afbf497334d", "metadata": {}, "source": "### GPAW\n[GPAW](https://wiki.fysik.dtu.dk/gpaw/) - Density functional theory Python code based on the projector-augmented wave \nmethod:" }, { "cell_type": "code", "execution_count": 3, "id": "10a942f6-b4c0-4710-856f-e736a643ce17", "metadata": { "tags": [], "trusted": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": "\n ___ ___ ___ _ _ _ \n | | |_ | | | | \n | | | | | . | | | | \n |__ | _|___|_____| 24.1.0\n |___|_| \n\nUser: jovyan@jupyter-pyiron-2datomistics-2djetdbyfr\nDate: Wed May 1 22:47:22 2024\nArch: x86_64\nPid: 754\nCWD: /home/jovyan\nPython: 3.10.12\ngpaw: /srv/conda/envs/notebook/lib/python3.10/site-packages/gpaw\n_gpaw: /srv/conda/envs/notebook/lib/python3.10/site-packages/\n _gpaw.cpython-310-x86_64-linux-gnu.so\nase: /srv/conda/envs/notebook/lib/python3.10/site-packages/ase (version 3.22.1)\nnumpy: /srv/conda/envs/notebook/lib/python3.10/site-packages/numpy (version 1.26.4)\nscipy: /srv/conda/envs/notebook/lib/python3.10/site-packages/scipy (version 1.13.0)\nlibxc: 6.2.2\nunits: Angstrom and eV\ncores: 1\nOpenMP: True\nOMP_NUM_THREADS: 1\n\nInput parameters:\n kpts: [3 3 3]\n mode: {ecut: 300.0,\n name: pw}\n xc: PBE\n\nMemory usage: 142.86 MiB\nDate: Wed May 1 22:47:22 2024\n" }, { "name": "stderr", "output_type": "stream", "text": "[jupyter-pyiron-2datomistics-2djetdbyfr:00754] mca_base_component_repository_open: unable to open mca_btl_openib: librdmacm.so.1: cannot open shared object file: No such file or directory (ignored)\n" } ], "source": [ "from gpaw import GPAW, PW\n", "from atomistics.calculators import evaluate_with_ase\n", "\n", "result_dict = evaluate_with_ase(\n", " task_dict={}, ase_calculator=GPAW(xc=\"PBE\", mode=PW(300), kpts=(3, 3, 3))\n", ")" ] }, { "cell_type": "markdown", "id": "a38a03dd-630c-4bff-a256-d0380da29db1", "metadata": {}, "source": "The full documentation of the corresponding interface is available on the [GPAW](https://wiki.fysik.dtu.dk/gpaw/)\nwebsite." }, { "cell_type": "markdown", "id": "f8a20ee4-153d-4c0b-b89f-a3ac64cfbcbc", "metadata": {}, "source": "### Quantum Espresso \n[Quantum Espresso](https://www.quantum-espresso.org) - Integrated suite of Open-Source computer codes for \nelectronic-structure calculations:" }, { "cell_type": "code", "execution_count": 4, "id": "40b9384e-02a0-41d8-adff-ad4dd6316a21", "metadata": { "tags": [], "trusted": false }, "outputs": [], "source": [ "from ase.calculators.espresso import Espresso, EspressoProfile\n", "from atomistics.calculators import evaluate_with_ase\n", "\n", "result_dict = evaluate_with_ase(\n", " task_dict={},\n", " ase_calculator=Espresso(\n", " pseudopotentials={\"Al\": \"Al.pbe-n-kjpaw_psl.1.0.0.UPF\"},\n", " tstress=True,\n", " tprnfor=True,\n", " kpts=(3, 3, 3),\n", " profile=EspressoProfile(\n", " command=\"pw.x\",\n", " pseudo_dir=\"tests/static/qe\",\n", " ),\n", " ),\n", ")" ] }, { "cell_type": "markdown", "id": "c7f74b95-e161-4ee6-8a9b-58c11ba3ca47", "metadata": {}, "source": "The full documentation of the corresponding interface is available on the [Atomic Simulation Environment](https://wiki.fysik.dtu.dk/ase/ase/calculators/espresso.html)\nwebsite. " }, { "cell_type": "markdown", "id": "cdc1c88c-62f8-4af1-a135-9266ba1ab1ee", "metadata": {}, "source": "### Siesta\n[Siesta](https://siesta-project.org) - Electronic structure calculations and ab initio molecular dynamics:" }, { "cell_type": "code", "execution_count": 5, "id": "5fa73a10-043f-4b46-a162-3f1da7399cba", "metadata": { "tags": [], "trusted": false }, "outputs": [], "source": [ "import os\n", "from ase.calculators.siesta import Siesta\n", "from ase.units import Ry\n", "from atomistics.calculators import evaluate_with_ase\n", "\n", "result_dict = evaluate_with_ase(\n", " task_dict={},\n", " ase_calculator=Siesta(\n", " label=\"siesta\",\n", " xc=\"PBE\",\n", " mesh_cutoff=200 * Ry,\n", " energy_shift=0.01 * Ry,\n", " basis_set=\"DZ\",\n", " kpts=(5, 5, 5),\n", " fdf_arguments={\"DM.MixingWeight\": 0.1, \"MaxSCFIterations\": 100},\n", " pseudo_path=os.path.abspath(\"tests/static/siesta\"),\n", " pseudo_qualifier=\"\",\n", " ),\n", ")" ] }, { "cell_type": "markdown", "id": "ed3bba6d-8fd9-4d26-8f0d-437fb5559397", "metadata": {}, "source": "The full documentation of the corresponding interface is available on the [Atomic Simulation Environment](https://wiki.fysik.dtu.dk/ase/ase/calculators/siesta.html)\nwebsite." }, { "cell_type": "markdown", "id": "0c09855c-80ca-4fb9-9f66-458b8d145e59", "metadata": {}, "source": "## LAMMPS\n[LAMMPS](https://www.lammps.org) - Molecular Dynamics:" }, { "cell_type": "code", "execution_count": 6, "id": "a95e1c9c-1ad1-4765-aa13-790db6971dab", "metadata": { "tags": [], "trusted": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": "/srv/conda/envs/notebook/lib/python3.10/site-packages/atomistics/calculators/lammps/potential.py:299: SettingWithCopyWarning: \nA value is trying to be set on a copy of a slice from a DataFrame.\nTry using .loc[row_indexer,col_indexer] = value instead\n\nSee the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n df_pot[\"Config\"] = config_lst\n" } ], "source": [ "from ase.build import bulk\n", "from atomistics.calculators import evaluate_with_lammpslib, get_potential_by_name\n", "\n", "structure = bulk(\"Al\", cubic=True)\n", "potential_dataframe = get_potential_by_name(\n", " potential_name=\"1999--Mishin-Y--Al--LAMMPS--ipr1\", resource_path=\"static/lammps\"\n", ")\n", "\n", "result_dict = evaluate_with_lammpslib(\n", " task_dict={},\n", " potential_dataframe=potential_dataframe,\n", ")" ] }, { "cell_type": "markdown", "id": "ed5732c4-4221-4081-83d8-2c1df793d8b7", "metadata": {}, "source": "The [LAMMPS](https://www.lammps.org) interface is based on the [pylammpsmpi](https://github.com/pyiron/pylammpsmpi)\npackage which couples a [LAMMPS](https://www.lammps.org) instance which is parallelized via the Message Passing Interface\n(MPI) with a serial python process or jupyter notebook. The challenging part about molecular dynamics simulation is \nidentifying a suitable interatomic potential. \n\nTo address this challenge the `atomistics` package is leveraging the [NIST database of interatomic potentials](https://www.ctcms.nist.gov/potentials). \nIt is recommended to install this database `iprpy-data` via the `conda` package manager, then the `resource_path` is\nautomatically set to `${CONDA_PREFIX}/share/iprpy`. Alternatively, the `resource_path` can be specified manually as an\noptional parameter of the `get_potential_by_name()` function.\n\nIn addition, the `get_potential_dataframe(structure)` function which takes an `ase.atoms.Atoms` object as input can be\nused to query the [NIST database of interatomic potentials](https://www.ctcms.nist.gov/potentials) for potentials, which\ninclude the interatomic interactions required to simulate the atomic structure defined by the `ase.atoms.Atoms` object. \nIt returns a `pandas.DataFrame` with all the available potentials and the `resource_path` can again be specified as \noptional parameter.\n\nFinally, another option to specify the interatomic potential for a LAMMPS simulation is by defining the `potential_dataframe`\ndirectly: " }, { "cell_type": "code", "execution_count": 7, "id": "4ab54444-0d8b-42dd-8a97-c0743598a7bd", "metadata": { "tags": [], "trusted": false }, "outputs": [], "source": [ "import pandas\n", "\n", "potential_dataframe = pandas.DataFrame(\n", " {\n", " \"Config\": [\n", " [\"pair_style morse/smooth/linear 9.0\", \"pair_coeff * * 0.5 1.8 2.95\"]\n", " ],\n", " \"Filename\": [[]],\n", " \"Model\": [\"Morse\"],\n", " \"Name\": [\"Morse\"],\n", " \"Species\": [[\"Al\"]],\n", " }\n", ")" ] }, { "cell_type": "markdown", "id": "0fbec738-da33-44bf-ab6f-b222f1d56186", "metadata": {}, "source": "## Quantum Espresso\n[Quantum Espresso](https://www.quantum-espresso.org) - Integrated suite of Open-Source computer codes for \nelectronic-structure calculations:" }, { "cell_type": "markdown", "id": "1e7fe91e-424e-46c6-b1de-632ae9333b77", "metadata": { "tags": [] }, "source": "```\nfrom atomistics.calculators import evaluate_with_qe\n\nresult_dict = evaluate_with_qe(\n task_dict={},\n calculation_name=\"espresso\",\n working_directory=\".\",\n kpts=(3, 3, 3),\n pseudopotentials={\n \"Al\": \"Al.pbe-n-kjpaw_psl.1.0.0.UPF\"\n },\n tstress=True,\n tprnfor=True,\n ecutwfc=40.0, # kinetic energy cutoff (Ry) for wavefunctions\n conv_thr=1e-06, # Convergence threshold for selfconsistency\n diagonalization='david', \n electron_maxstep=100, # maximum number of iterations in a scf step. \n nstep=200, # number of molecular-dynamics or structural optimization steps performed in this run.\n etot_conv_thr=1e-4, # Convergence threshold on total energy (a.u) for ionic minimization\n forc_conv_thr=1e-3, # Convergence threshold on forces (a.u) for ionic minimization\n smearing='gaussian', # ordinary Gaussian spreading (Default)\n)\n```" }, { "cell_type": "markdown", "id": "727f824e-97a2-42ae-94f2-b8080c023e24", "metadata": {}, "source": "This secondary interface for [Quantum Espresso](https://www.quantum-espresso.org) is based on the input writer from the\n[Atomic Simulation Environment (ASE)](https://wiki.fysik.dtu.dk/ase/) and the output is parsed using the [pwtools](https://elcorto.github.io/pwtools/).\nThe executable can be set using the `ASE_ESPRESSO_COMMAND` environment variable:" }, { "cell_type": "markdown", "id": "b840f3d2-a7b3-42d6-8401-e350dc905c2f", "metadata": {}, "source": "```\nexport ASE_ESPRESSO_COMMAND=\"pw.x -in PREFIX.pwi > PREFIX.pwo\"\n```" }, { "cell_type": "markdown", "id": "54ee1c7b-a829-49b9-8746-d57496b339e6", "metadata": { "tags": [] }, "source": "The full list of possible keyword arguments is available in the [Quantum Espresso Documentation](https://www.quantum-espresso.org/Doc/INPUT_PW.html).\nFinally, the [Standard solid-state pseudopotentials (SSSP)](https://www.materialscloud.org/discover/sssp/table/efficiency) \nfor quantum espresso are distributed via the materials cloud." } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.14" } }, "nbformat": 4, "nbformat_minor": 5 }