{ "cells": [ { "cell_type": "markdown", "id": "ebe73de1", "metadata": {}, "source": [ "# Quick Start - Command Line\n", "While we strongly recommend PyBigDFT as the way to drive BigDFT calculations, you may nonetheless want to run calculations from the command line. If you have installed from source, you should make sure you have setup the proper environment variables using the following command:\n", "```\n", "source install/bin/bigdftvars.sh\n", "```" ] }, { "cell_type": "markdown", "id": "3b8741aa", "metadata": {}, "source": [ "## Input File\n", "Input files are in the [yaml](https://yaml.org) format. A simple example is:" ] }, { "cell_type": "code", "execution_count": 1, "id": "733edff7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dft: {hgrids: 0.3, ixc: LDA}\r\n", "kpt:\r\n", " method: mpgrid\r\n", " ngkpt: [2, 2, 2]\r\n", "posinp:\r\n", " cell: [2.867, 2.867, 2.867]\r\n", " positions:\r\n", " - Fe: [0.0, 0.0, 0.0]\r\n", " units: angstroem\r\n" ] } ], "source": [ "!cat cmd_work/psys.yaml" ] }, { "cell_type": "markdown", "id": "d379f002", "metadata": {}, "source": [ "To use more exotic exchange and correlation potentials, you will need to:\n", "\n", "1. Lookup the XC code on the website of [libxc](https://tddft.org/programs/libxc/functionals/), and prepend a minus sign before the exchange and correlation code.\n", "2. Copy the pseudopotentials you wish to use to the calculation directory with the name `psppar.ELEMENT`. We have included some in `bigdft/utils/PSPfiles/`." ] }, { "cell_type": "code", "execution_count": 2, "id": "fea961d5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dft: \r\n", " hgrids: 0.3\r\n", " ixc: -109134 # PW91\r\n", "kpt:\r\n", " method: mpgrid\r\n", " ngkpt: [2, 2, 2]\r\n", "posinp:\r\n", " cell: [2.867, 2.867, 2.867]\r\n", " positions:\r\n", " - Fe: [0.0, 0.0, 0.0]\r\n", " units: angstroem\r\n" ] } ], "source": [ "!cat pspwork/psys.yaml" ] }, { "cell_type": "code", "execution_count": 3, "id": "bac17270", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Goedecker pseudopotential for Fe\r\n", " 26 16 070301 zatom,zion,pspdat\r\n", "10 11 2 2 2001 0 pspcod,pspxc,lmax,lloc,mmax,r2well\r\n", " 0.36000000 2 6.75678916 -0.22883251 rloc nloc c1 c2\r\n", " 3 nnonloc\r\n", " 0.27826303 2 0.62950570 7.91313242 rs ns hs11 hs12\r\n", " -10.21581002 hs22\r\n", " 0.25138338 2 -7.93213293 7.69707888 rp np hp11 hp12\r\n", " -9.10730654 hp22\r\n", " 0.09786820 0.08070002 kp11 kp12\r\n", " -0.09548555 kp22\r\n", " 0.22285578 1 -12.38579937 rd nd hd11\r\n", " 0.01036288 kd11\r\n" ] } ], "source": [ "!cat pspwork/psppar.Fe" ] }, { "cell_type": "markdown", "id": "136bcc9e", "metadata": {}, "source": [ "## Running the Code\n", "To run the code, use a line like this:" ] }, { "cell_type": "code", "execution_count": 4, "id": "dc328104", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " log of the run will be written in logfile: ./log-psys.yaml\r\n" ] } ], "source": [ "!cd cmd_work ; $BIGDFT_ROOT/bigdft -n psys ; cd .." ] }, { "cell_type": "markdown", "id": "0ee82574", "metadata": {}, "source": [ "Notice the `-n` option gives the name of the input file. If nothing is given, bigdft will look for `default.yaml`. \n", "\n", "The skip command will check if the calculation has completed, and if so will immediately exit." ] }, { "cell_type": "code", "execution_count": 5, "id": "85e4cf55", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Run already performed, found final file: forces_psys.yaml\r\n", " Memory Consumption Report:\r\n", " Tot. No. of Allocations: 0\r\n", " Tot. No. of Deallocations: 0\r\n", " Remaining Memory (B): 0\r\n", " Memory occupation:\r\n", " Peak Value (MB): 0.000\r\n", " for the array: null\r\n", " in the routine: null\r\n", " Memory Peak of process: unknown\r\n", " Walltime since initialization: 00:00:00.272820000\r\n", " Max No. of dictionaries used: 1119 #( 1044 still in use)\r\n", " Number of dictionary folders allocated: 1\r\n" ] } ], "source": [ "!cd cmd_work ; $BIGDFT_ROOT/bigdft -n psys -s yes ; cd .." ] }, { "cell_type": "markdown", "id": "5a7c4a5d", "metadata": {}, "source": [ "## Results\n", "The following files are produced by a calculation." ] }, { "cell_type": "code", "execution_count": 6, "id": "c5a05bbb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "cmd_work/forces_psys.yaml cmd_work/psys_minimal.yaml\r\n", "cmd_work/log-psys.yaml cmd_work/time-psys.yaml\r\n", "cmd_work/psys.yaml\r\n" ] } ], "source": [ "!ls cmd_work/*psys*" ] }, { "cell_type": "markdown", "id": "9c534b3b", "metadata": {}, "source": [ "The log file contains the essential calculation information in a `yaml` format." ] }, { "cell_type": "code", "execution_count": 7, "id": "2498cc0a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Energy (Hartree) : -2.05484837694368423E+01\r\n" ] } ], "source": [ "!grep \"Energy (Hartree)\" cmd_work/log-psys.yaml" ] }, { "cell_type": "markdown", "id": "b4ab755f", "metadata": {}, "source": [ "The log file contains a list of all input variables and their values, not just the ones you set. They have comments beside them. This can be useful when trying to find out how to modify the calculation. For example, what was the spin of the calculation?" ] }, { "cell_type": "code", "execution_count": 8, "id": "35ab6565", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " nspin : 1 # Spin polarization treatment\r\n" ] } ], "source": [ "!grep \"nspin\" cmd_work/log-psys.yaml" ] }, { "cell_type": "markdown", "id": "31cd495c", "metadata": {}, "source": [ "In the case of geometry optimization, each step can be found in the same logfile." ] }, { "cell_type": "code", "execution_count": 9, "id": "ff5fc88f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dft: {hgrids: 0.35, ixc: PBE}\r\n", "geopt: {\"method\": SQNM}\r\n", "posinp:\r\n", " cell: [.inf, .inf, .inf]\r\n", " positions:\r\n", " - H: [0.0, 0.0, 0.0]\r\n", " - H: [0.0, 0.0, 0.741]\r\n", " - He: [5.292, 0.0, 0.0]\r\n", " units: angstroem\r\n" ] } ], "source": [ "!cat cmd_work/geom.yaml" ] }, { "cell_type": "code", "execution_count": 10, "id": "efd6119b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " log of the run will be written in logfile: ./log-geom.yaml\r\n" ] } ], "source": [ "!cd cmd_work ; $BIGDFT_ROOT/bigdft -n geom -s yes ; cd .." ] }, { "cell_type": "markdown", "id": "95b4139f", "metadata": {}, "source": [ "The details of the geometry optimization procedure are also available in the data directory." ] }, { "cell_type": "code", "execution_count": 11, "id": "d241b864", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "geopt.mon posout_0002.yaml posout_0005.yaml posout_0008.yaml\r\n", "posout_0000.yaml posout_0003.yaml posout_0006.yaml posout_0009.yaml\r\n", "posout_0001.yaml posout_0004.yaml posout_0007.yaml time-geom.yaml\r\n" ] } ], "source": [ "!ls cmd_work/data-geom" ] }, { "cell_type": "code", "execution_count": 12, "id": "a306e56a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " #-------------- Geopt file opened, name: ./data-geom/geopt.mon, timestamp: 2022-07-29 15:26:53.157\r\n", "# COUNT IT GEOPT_METHOD ENERGY DIFF FMAX FNRM FRAC*FLUC FLUC ADD. INFO\r\n", " 0 0 GEOPT_SQNM 0.00000000000000E+00 0.00E+00 6.497E-03 9.18E-03 0.00E+00 0.00E+00 beta=1.00E+00 dim=000 maxd=0.0E+00 dsplr=0.00000E+00 dsplp=0.00000E+00\r\n", " 1 1 GEOPT_SQNM -4.05551003369715E+00 -4.06E+00 1.758E-03 2.54E-03 5.45E-04 5.45E-04 beta=1.00E+00 dim=000 maxd=6.5E-03 dsplr=9.17854E-03 dsplp=9.17854E-03\r\n", " 2 2 GEOPT_SQNM -4.05551478890277E+00 -4.76E-06 6.313E-04 7.75E-04 5.42E-04 5.42E-04 beta=1.10E+00 dim=001 maxd=2.4E-03 dsplr=1.26091E-02 dsplp=1.26091E-02\r\n", " 3 3 GEOPT_SQNM -4.05552404700316E+00 -9.26E-06 5.266E-04 8.33E-04 5.05E-04 5.05E-04 beta=1.21E+00 dim=002 maxd=1.1E-02 dsplr=2.63921E-02 dsplp=2.63921E-02\r\n", " 4 4 GEOPT_SQNM -4.05552808416222E+00 -4.04E-06 7.414E-05 1.11E-04 4.20E-04 4.20E-04 beta=1.33E+00 dim=002 maxd=2.0E-02 dsplr=5.13985E-02 dsplp=5.13985E-02\r\n", " 5 5 GEOPT_SQNM -4.05553137818127E+00 -3.29E-06 8.332E-06 1.13E-05 3.48E-04 3.48E-04 beta=1.13E+00 dim=002 maxd=3.4E-03 dsplr=5.55781E-02 dsplp=5.55781E-02\r\n", " 6 6 GEOPT_SQNM -4.05553064847653E+00 7.30E-07 6.759E-06 9.24E-06 2.91E-04 2.91E-04 beta=1.24E+00 dim=002 maxd=4.0E-04 dsplr=5.60659E-02 dsplp=5.60659E-02\r\n", " 7 7 GEOPT_SQNM -4.05553065682987E+00 -8.35E-09 7.833E-06 1.01E-05 2.46E-04 2.46E-04 beta=1.06E+00 dim=002 maxd=2.7E-04 dsplr=5.63927E-02 dsplp=5.63927E-02\r\n", " 8 8 GEOPT_SQNM -4.05553138514531E+00 -7.28E-07 3.377E-06 4.35E-06 2.09E-04 2.09E-04 beta=1.16E+00 dim=002 maxd=4.0E-04 dsplr=5.68876E-02 dsplp=5.68876E-02\r\n", " 9 9 GEOPT_SQNM -4.05553138634947E+00 -1.20E-09 3.719E-06 4.61E-06 1.80E-04 1.80E-04 beta=1.00E+00 dim=002 maxd=1.2E-04 dsplr=5.70406E-02 dsplp=5.70406E-02\r\n", "SQNM converged at iteration 9. Needed bigdft calls: 9\r\n" ] } ], "source": [ "!cat cmd_work/data-geom/geopt.mon" ] }, { "cell_type": "markdown", "id": "8cb0731e", "metadata": {}, "source": [ "## Profiles\n", "A number of profiles are available which can be useful for more advanced calculations. For example, the `linear` profile for O(N) calculations or the `mixing` profile can be imported for difficult to converge systems." ] }, { "cell_type": "code", "execution_count": 13, "id": "0372bc99", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dft: {hgrids: 0.3, ixc: LDA}\r\n", "kpt:\r\n", " method: mpgrid\r\n", " ngkpt: [2, 2, 2]\r\n", "posinp:\r\n", " cell: [2.867, 2.867, 2.867]\r\n", " positions:\r\n", " - Fe: [0.0, 0.0, 0.0]\r\n", " units: angstroem\r\n", "import: \"mixing\"\r\n" ] } ], "source": [ "!cat cmd_work/*mixing*" ] }, { "cell_type": "code", "execution_count": 14, "id": "8a0edc4b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " log of the run will be written in logfile: ./log-mixing.yaml\r\n" ] } ], "source": [ "!cd cmd_work ; $BIGDFT_ROOT/bigdft -n mixing -s yes ; cd .." ] }, { "cell_type": "markdown", "id": "0f4a0440", "metadata": {}, "source": [ "Full details are available in `bigdft/src/input_variables_definition.yaml`" ] }, { "cell_type": "markdown", "id": "50089b82", "metadata": {}, "source": [ "## PyBigDFT Compatability\n", "All of these calculations are compatabile with the PyBigDFT approach. For example, we can build a Logfile manually:" ] }, { "cell_type": "code", "execution_count": 15, "id": "d03fec1e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-20.548483769436842\n" ] } ], "source": [ "from BigDFT.Logfiles import Logfile\n", "from os.path import join\n", "\n", "log = Logfile(join(\"cmd_work\", \"log-psys.yaml\"))\n", "print(log.energy)" ] }, { "cell_type": "markdown", "id": "55dd90f2", "metadata": {}, "source": [ "And even get access to the system." ] }, { "cell_type": "code", "execution_count": 17, "id": "f1c116fc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ATOM:0\n", "Fe [0.0, 0.0, 0.0]\n" ] } ], "source": [ "from BigDFT.Systems import system_from_log\n", "sys = system_from_log(log)\n", "for fragid, frag in sys.items():\n", " print(fragid)\n", " for at in frag:\n", " print(at.sym, at.get_position())" ] } ], "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.5" } }, "nbformat": 4, "nbformat_minor": 5 }