pynabi


Namepynabi JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryA package to easily create Abinit input files
upload_time2023-08-05 13:43:04
maintainer
docs_urlNone
authorFederico Guglielmi
requires_python>=3.11
licenseMIT License Copyright (c) 2023 Federico Guglielmi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords abinit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PynAbi

Python package to easily create [Abinit](https://www.abinit.org/) input files.

```cmd
pip install pynabi
```

## Example

```python
from pynabi import createAbi, DataSet, AbIn, AbOut
from pynabi.kspace import CriticalPointsOf, BZ, SymmetricGrid, UsualKShifts, Path
from pynabi.calculation import ToleranceOn, EnergyCutoff, MaxSteps, SCFMixing, NonSelfConsistentCalc
from pynabi.crystal import Atom, FluoriteLike
from pynabi.occupation import OccupationPerBand
from pynabi.units import eV, nm

# create manually an atom -> Atom(<Z>, <pseudo potential name>)
# or using sensible defaults as follows
Zr = Atom.of("Zr")  # Z=40 and pseudos located at "Zr.psp8"
Oxy = Atom.of("O")  # Z=8 and pseudos located at "O.psp8"

# base dataset with common variables
base = DataSet(
    AbOut("./scf/scf"),                             # prefix for output files
    AbIn().PseudoPotentials("./pseudos/PBE-SR"),    # folder with pseudo potentials

    FluoriteLike(Zr, Oxy, 0.5135*nm),               # creates AtomBasis and Lattice of a crystal like fluorite
                                                    # with lattice constant 0.5135nm

    SymmetricGrid(BZ.Irreducible, UsualKShifts.FCC) # easily define kptopt, ngkpt, nshiftk, kpt
        .ofMonkhorstPack(4),

    SCFMixing(density=True).Pulay(10),              # scf cycle with Pulay mixing of the density 
                                                    # based on the last 10 iteration

    ToleranceOn.EnergyDifference(1e-6),             # expressively define the tolerance
    MaxSteps(30)                                    # nstep
)

# set the default energy unit in eV (from now on)
eV.setAsReference()

# datasets to see the convergenge as a function of energy
sets = [DataSet(EnergyCutoff(8.0 + i*0.25)) for i in range(0,17)]

# final non-self-consistent round to find bands 
bands = DataSet(
    NonSelfConsistentCalc(),
    ToleranceOn.WavefunctionSquaredResidual(1e-12),
    AbIn().ElectronDensity(sets[-1]),                   # get the electron density from the last dataset
    OccupationPerBand(2.0, repeat=8),                   # same number of bands (max 8) for each k point
    Path.auto(10, "GXWKGLUWLK", CriticalPointsOf.FCC)   # easily define a path in the k-space   
)

with open("./out.txt", 'w') as f:
    f.write(createAbi(base, *sets, bands))
```

<details>
<summary><b>Output</b></summary>

```txt
ndtset 18

# Atoms definition
ntypat 2
znucl 40 8
pseudos "Zr.psp8, O.psp8"

# Common DataSet
natom 3
typat 1 2 2
xred 0 0 0   0.3333333333333333 0.3333333333333333 0.3333333333333333   0.6666666666666666 0.6666666666666666 0.6666666666666666
outdata_prefix "./scf/scf"
pp_dirpath "./pseudos/PBE-SR"
scalecart 0.5135 0.5135 0.5135 nm
rprim 0.5 0.5 0.0   0.0 0.5 0.5   0.5 0.0 0.5
kptopt 1
nshiftk 4
shiftk 0.5 0.5 0.5 0.5 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.5
ngkpt 4 4 4
iscf 17
npulayit 10
toldfe 1e-06
nstep 30

# DataSet 1
ecut1 8.0 eV

# DataSet 2
ecut2 8.25 eV

# DataSet 3
ecut3 8.5 eV

# DataSet 4
ecut4 8.75 eV

# DataSet 5
ecut5 9.0 eV

# DataSet 6
ecut6 9.25 eV

# DataSet 7
ecut7 9.5 eV

# DataSet 8
ecut8 9.75 eV

# DataSet 9
ecut9 10.0 eV

# DataSet 10
ecut10 10.25 eV

# DataSet 11
ecut11 10.5 eV

# DataSet 12
ecut12 10.75 eV

# DataSet 13
ecut13 11.0 eV

# DataSet 14
ecut14 11.25 eV

# DataSet 15
ecut15 11.5 eV

# DataSet 16
ecut16 11.75 eV

# DataSet 17
ecut17 12.0 eV

# DataSet 18
iscf18 -2
tolwfr18 1e-12
getden18 17
occopt18 0
occ18 8*2.0
band18 8
kptopt18 -9
kptbounds18 0 0 0  0.0 0.5 0.5  0.25 0.75 0.5  0.375 0.75 0.375  0 0 0  0.5 0.5 0.5  0.25 0.625 0.625  0.25 0.75 0.5  0.5 0.5 0.5  0.375 0.75 0.375
ndivsm18 10
```

</details>

## Features

 - Multi dataset support
 - Helper functions for common crystal structures (caesium chloride, rock-salt, fluorite, zincblende, wurtzite, nickeline, HCP)
 - Registered critical points of and methodsto create lattices of CUB, BCC, FCC, HEX, TET, BCT, ORC, ORCC
 - Smooth experience in defining the k-points
 - Handy management of [file handling variables](https://docs.abinit.org/variables/files/)
 - Almost full covarage of [basic input variables](https://docs.abinit.org/variables/basic/) (missing nbandhf, symrel, tnons, wvl_hgrid)
 - Partial coverage of [ground state variables](https://docs.abinit.org/variables/gstate/)
 - Partial coverage of [relaxation variables](https://docs.abinit.org/variables/rlx/)
 - _More to come..._

## Why PynAbi over pure Abinit files?

If you're a very experienced Abinit user who knows its variables and their possible values (and associated meaning), then this package probably isn't for you.
For all other users, on top of all the aforementioned features, here's a list of reasons why you could find PynAbi useful:

 1. You have all the power of coding to generate Abinit instructions, e.g. reusability, loops to generate datasets programmatically
 2. It provides some useful presets and helper functions/methods that allows you to skip to the fun part of the simulation
 3. Under the hood, it checks for the validity of variable values *before* starting Abinit
 4. It makes use of expressive declarations and definition, leading to readable and comprehensible istructions
 5. If you're using a code editor (with autocompletition), you'll get suggetions of all the possible options in a more natural language 

Some prior knowledge of Abinit (and DFT in general) is nonetheless needed to fully understand what actually is to be simulated: this package only provides a handier way to generate the required files.

## Documentation

Although currently severely incomplete, a wiki is available on the [GitHub repository Wiki](https://github.com/Fedesky25/pynabi/wiki). Ideally a wiki for this package shouldn't be needed if your editor has some autocompletition: the aim is to document every class and function with a detailed description taken from the relevant parts of ABINIT documentation. 

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pynabi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "abinit",
    "author": "Federico Guglielmi",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/fb/d3/3b303924d549460a8c0a71268bb28e5895d4e17cbe3ff3c8fe044a40714b/pynabi-0.1.2.tar.gz",
    "platform": null,
    "description": "# PynAbi\n\nPython package to easily create [Abinit](https://www.abinit.org/) input files.\n\n```cmd\npip install pynabi\n```\n\n## Example\n\n```python\nfrom pynabi import createAbi, DataSet, AbIn, AbOut\nfrom pynabi.kspace import CriticalPointsOf, BZ, SymmetricGrid, UsualKShifts, Path\nfrom pynabi.calculation import ToleranceOn, EnergyCutoff, MaxSteps, SCFMixing, NonSelfConsistentCalc\nfrom pynabi.crystal import Atom, FluoriteLike\nfrom pynabi.occupation import OccupationPerBand\nfrom pynabi.units import eV, nm\n\n# create manually an atom -> Atom(<Z>, <pseudo potential name>)\n# or using sensible defaults as follows\nZr = Atom.of(\"Zr\")  # Z=40 and pseudos located at \"Zr.psp8\"\nOxy = Atom.of(\"O\")  # Z=8 and pseudos located at \"O.psp8\"\n\n# base dataset with common variables\nbase = DataSet(\n    AbOut(\"./scf/scf\"),                             # prefix for output files\n    AbIn().PseudoPotentials(\"./pseudos/PBE-SR\"),    # folder with pseudo potentials\n\n    FluoriteLike(Zr, Oxy, 0.5135*nm),               # creates AtomBasis and Lattice of a crystal like fluorite\n                                                    # with lattice constant 0.5135nm\n\n    SymmetricGrid(BZ.Irreducible, UsualKShifts.FCC) # easily define kptopt, ngkpt, nshiftk, kpt\n        .ofMonkhorstPack(4),\n\n    SCFMixing(density=True).Pulay(10),              # scf cycle with Pulay mixing of the density \n                                                    # based on the last 10 iteration\n\n    ToleranceOn.EnergyDifference(1e-6),             # expressively define the tolerance\n    MaxSteps(30)                                    # nstep\n)\n\n# set the default energy unit in eV (from now on)\neV.setAsReference()\n\n# datasets to see the convergenge as a function of energy\nsets = [DataSet(EnergyCutoff(8.0 + i*0.25)) for i in range(0,17)]\n\n# final non-self-consistent round to find bands \nbands = DataSet(\n    NonSelfConsistentCalc(),\n    ToleranceOn.WavefunctionSquaredResidual(1e-12),\n    AbIn().ElectronDensity(sets[-1]),                   # get the electron density from the last dataset\n    OccupationPerBand(2.0, repeat=8),                   # same number of bands (max 8) for each k point\n    Path.auto(10, \"GXWKGLUWLK\", CriticalPointsOf.FCC)   # easily define a path in the k-space   \n)\n\nwith open(\"./out.txt\", 'w') as f:\n    f.write(createAbi(base, *sets, bands))\n```\n\n<details>\n<summary><b>Output</b></summary>\n\n```txt\nndtset 18\n\n# Atoms definition\nntypat 2\nznucl 40 8\npseudos \"Zr.psp8, O.psp8\"\n\n# Common DataSet\nnatom 3\ntypat 1 2 2\nxred 0 0 0   0.3333333333333333 0.3333333333333333 0.3333333333333333   0.6666666666666666 0.6666666666666666 0.6666666666666666\noutdata_prefix \"./scf/scf\"\npp_dirpath \"./pseudos/PBE-SR\"\nscalecart 0.5135 0.5135 0.5135 nm\nrprim 0.5 0.5 0.0   0.0 0.5 0.5   0.5 0.0 0.5\nkptopt 1\nnshiftk 4\nshiftk 0.5 0.5 0.5 0.5 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.5\nngkpt 4 4 4\niscf 17\nnpulayit 10\ntoldfe 1e-06\nnstep 30\n\n# DataSet 1\necut1 8.0 eV\n\n# DataSet 2\necut2 8.25 eV\n\n# DataSet 3\necut3 8.5 eV\n\n# DataSet 4\necut4 8.75 eV\n\n# DataSet 5\necut5 9.0 eV\n\n# DataSet 6\necut6 9.25 eV\n\n# DataSet 7\necut7 9.5 eV\n\n# DataSet 8\necut8 9.75 eV\n\n# DataSet 9\necut9 10.0 eV\n\n# DataSet 10\necut10 10.25 eV\n\n# DataSet 11\necut11 10.5 eV\n\n# DataSet 12\necut12 10.75 eV\n\n# DataSet 13\necut13 11.0 eV\n\n# DataSet 14\necut14 11.25 eV\n\n# DataSet 15\necut15 11.5 eV\n\n# DataSet 16\necut16 11.75 eV\n\n# DataSet 17\necut17 12.0 eV\n\n# DataSet 18\niscf18 -2\ntolwfr18 1e-12\ngetden18 17\noccopt18 0\nocc18 8*2.0\nband18 8\nkptopt18 -9\nkptbounds18 0 0 0  0.0 0.5 0.5  0.25 0.75 0.5  0.375 0.75 0.375  0 0 0  0.5 0.5 0.5  0.25 0.625 0.625  0.25 0.75 0.5  0.5 0.5 0.5  0.375 0.75 0.375\nndivsm18 10\n```\n\n</details>\n\n## Features\n\n - Multi dataset support\n - Helper functions for common crystal structures (caesium chloride, rock-salt, fluorite, zincblende, wurtzite, nickeline, HCP)\n - Registered critical points of and methodsto create lattices of CUB, BCC, FCC, HEX, TET, BCT, ORC, ORCC\n - Smooth experience in defining the k-points\n - Handy management of [file handling variables](https://docs.abinit.org/variables/files/)\n - Almost full covarage of [basic input variables](https://docs.abinit.org/variables/basic/) (missing nbandhf, symrel, tnons, wvl_hgrid)\n - Partial coverage of [ground state variables](https://docs.abinit.org/variables/gstate/)\n - Partial coverage of [relaxation variables](https://docs.abinit.org/variables/rlx/)\n - _More to come..._\n\n## Why PynAbi over pure Abinit files?\n\nIf you're a very experienced Abinit user who knows its variables and their possible values (and associated meaning), then this package probably isn't for you.\nFor all other users, on top of all the aforementioned features, here's a list of reasons why you could find PynAbi useful:\n\n 1. You have all the power of coding to generate Abinit instructions, e.g. reusability, loops to generate datasets programmatically\n 2. It provides some useful presets and helper functions/methods that allows you to skip to the fun part of the simulation\n 3. Under the hood, it checks for the validity of variable values *before* starting Abinit\n 4. It makes use of expressive declarations and definition, leading to readable and comprehensible istructions\n 5. If you're using a code editor (with autocompletition), you'll get suggetions of all the possible options in a more natural language \n\nSome prior knowledge of Abinit (and DFT in general) is nonetheless needed to fully understand what actually is to be simulated: this package only provides a handier way to generate the required files.\n\n## Documentation\n\nAlthough currently severely incomplete, a wiki is available on the [GitHub repository Wiki](https://github.com/Fedesky25/pynabi/wiki). Ideally a wiki for this package shouldn't be needed if your editor has some autocompletition: the aim is to document every class and function with a detailed description taken from the relevant parts of ABINIT documentation. \n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Federico Guglielmi  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A package to easily create Abinit input files",
    "version": "0.1.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/Fedesky25/pynabi/issues",
        "Changelog": "https://github.com/Fedesky25/pynabi/blob/master/CHANGELOG.md",
        "Documentation": "https://github.com/Fedesky25/pynabi/wiki",
        "Homepage": "https://github.com/Fedesky25/pynabi",
        "Repository": "https://github.com/Fedesky25/pynabi.git"
    },
    "split_keywords": [
        "abinit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6a0a8576023ce87990ec26bbeec68cc955c272a045d4b8c0fdfc50eeb32e94b",
                "md5": "08c2c1d1302a3e1056e79a8d67b65721",
                "sha256": "d47903b7e36abd0718d92695f0bb0e88cc9e0d8109a4a4663e6dbec6aea54785"
            },
            "downloads": -1,
            "filename": "pynabi-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "08c2c1d1302a3e1056e79a8d67b65721",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 29072,
            "upload_time": "2023-08-05T13:43:03",
            "upload_time_iso_8601": "2023-08-05T13:43:03.243484Z",
            "url": "https://files.pythonhosted.org/packages/d6/a0/a8576023ce87990ec26bbeec68cc955c272a045d4b8c0fdfc50eeb32e94b/pynabi-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fbd33b303924d549460a8c0a71268bb28e5895d4e17cbe3ff3c8fe044a40714b",
                "md5": "c829f2b052c57934e548b2ae1bbc2533",
                "sha256": "f0d5c0447be1fd7f018c4626b19bc77a598be8793aa247fbe3fc8efd24a386a2"
            },
            "downloads": -1,
            "filename": "pynabi-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c829f2b052c57934e548b2ae1bbc2533",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 28456,
            "upload_time": "2023-08-05T13:43:04",
            "upload_time_iso_8601": "2023-08-05T13:43:04.717493Z",
            "url": "https://files.pythonhosted.org/packages/fb/d3/3b303924d549460a8c0a71268bb28e5895d4e17cbe3ff3c8fe044a40714b/pynabi-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-05 13:43:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Fedesky25",
    "github_project": "pynabi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pynabi"
}
        
Elapsed time: 0.47117s