vaspparser 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2021, Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: vaspparser
3
+ Version: 0.0.1
4
+ Summary: Parser for the Vienna Ab initio Simulation Package (VASP)
5
+ Project-URL: Homepage, https://pyiron.org
6
+ Project-URL: Documentation, https://vaspparser.readthedocs.io
7
+ Project-URL: Repository, https://github.com/pyiron/vaspparser
8
+ Author-email: Jan Janssen <janssen@mpie.de>
9
+ License: BSD 3-Clause License
10
+
11
+ Copyright (c) 2021, Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
12
+ All rights reserved.
13
+
14
+ Redistribution and use in source and binary forms, with or without
15
+ modification, are permitted provided that the following conditions are met:
16
+
17
+ * Redistributions of source code must retain the above copyright notice, this
18
+ list of conditions and the following disclaimer.
19
+
20
+ * Redistributions in binary form must reproduce the above copyright notice,
21
+ this list of conditions and the following disclaimer in the documentation
22
+ and/or other materials provided with the distribution.
23
+
24
+ * Neither the name of the copyright holder nor the names of its
25
+ contributors may be used to endorse or promote products derived from
26
+ this software without specific prior written permission.
27
+
28
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
32
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
+ License-File: LICENSE
39
+ Keywords: pyiron
40
+ Classifier: Development Status :: 5 - Production/Stable
41
+ Classifier: Intended Audience :: Science/Research
42
+ Classifier: License :: OSI Approved :: BSD License
43
+ Classifier: Operating System :: OS Independent
44
+ Classifier: Programming Language :: Python :: 3.9
45
+ Classifier: Programming Language :: Python :: 3.10
46
+ Classifier: Programming Language :: Python :: 3.11
47
+ Classifier: Programming Language :: Python :: 3.12
48
+ Classifier: Programming Language :: Python :: 3.13
49
+ Classifier: Programming Language :: Python :: 3.14
50
+ Classifier: Topic :: Scientific/Engineering :: Physics
51
+ Requires-Python: <3.15,>=3.9
52
+ Requires-Dist: ase<=3.27.0,>=3.23.0
53
+ Requires-Dist: defusedxml<=0.7.1,>=0.7.0
54
+ Requires-Dist: numpy<=2.4.2,>=1.26.0
55
+ Requires-Dist: pandas<=3.0.0,>=2.0.3
56
+ Requires-Dist: scipy<=1.17.0,>=1.11.1
57
+ Provides-Extra: plot
58
+ Requires-Dist: matplotlib==3.10.8; extra == 'plot'
59
+ Description-Content-Type: text/markdown
60
+
61
+ # vaspparser
62
+
63
+ [![Pipeline](https://github.com/pyiron/vaspparser/actions/workflows/pipeline.yml/badge.svg)](https://github.com/pyiron/vaspparser/actions/workflows/pipeline.yml)
64
+ [![codecov](https://codecov.io/gh/pyiron/vaspparser/graph/badge.svg?token=PWWLjnbDJz)](https://codecov.io/gh/pyiron/vaspparser)
65
+
66
+ Parser for the Vienna Ab initio Simulation Package (VASP)
67
+
68
+ ## Installation
69
+ Via pip
70
+ ```
71
+ pip install vaspparser
72
+ ```
73
+
74
+ Via conda
75
+ ```
76
+ conda install -c conda-forge vaspparser
77
+ ```
78
+
79
+ ## Usage
80
+ Parse an directory with VASP output files
81
+ ```python
82
+ from vaspparser.vasp.output import parse_vasp_output
83
+
84
+ output_dict = parse_vasp_output(working_directory="path/to/calculation")
85
+ ```
@@ -0,0 +1,25 @@
1
+ # vaspparser
2
+
3
+ [![Pipeline](https://github.com/pyiron/vaspparser/actions/workflows/pipeline.yml/badge.svg)](https://github.com/pyiron/vaspparser/actions/workflows/pipeline.yml)
4
+ [![codecov](https://codecov.io/gh/pyiron/vaspparser/graph/badge.svg?token=PWWLjnbDJz)](https://codecov.io/gh/pyiron/vaspparser)
5
+
6
+ Parser for the Vienna Ab initio Simulation Package (VASP)
7
+
8
+ ## Installation
9
+ Via pip
10
+ ```
11
+ pip install vaspparser
12
+ ```
13
+
14
+ Via conda
15
+ ```
16
+ conda install -c conda-forge vaspparser
17
+ ```
18
+
19
+ ## Usage
20
+ Parse an directory with VASP output files
21
+ ```python
22
+ from vaspparser.vasp.output import parse_vasp_output
23
+
24
+ output_dict = parse_vasp_output(working_directory="path/to/calculation")
25
+ ```
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["ase", "defusedxml", "matplotlib", "numpy", "pandas", "scipy", "hatchling==1.28.0", "hatch-vcs==0.5.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "vaspparser"
7
+ description = "Parser for the Vienna Ab initio Simulation Package (VASP)"
8
+ authors = [
9
+ { name = "Jan Janssen", email = "janssen@mpie.de" },
10
+ ]
11
+ readme = "README.md"
12
+ license = { file = "LICENSE" }
13
+ keywords = ["pyiron"]
14
+ requires-python = ">=3.9, <3.15"
15
+ classifiers = [
16
+ "Development Status :: 5 - Production/Stable",
17
+ "Topic :: Scientific/Engineering :: Physics",
18
+ "License :: OSI Approved :: BSD License",
19
+ "Intended Audience :: Science/Research",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ ]
28
+ dependencies = [
29
+ "ase>=3.23.0,<=3.27.0",
30
+ "defusedxml>=0.7.0,<=0.7.1",
31
+ "numpy>=1.26.0,<=2.4.2",
32
+ "pandas>=2.0.3,<=3.0.0",
33
+ "scipy>=1.11.1,<=1.17.0",
34
+ ]
35
+ dynamic = ["version"]
36
+
37
+ [project.urls]
38
+ Homepage = "https://pyiron.org"
39
+ Documentation = "https://vaspparser.readthedocs.io"
40
+ Repository = "https://github.com/pyiron/vaspparser"
41
+
42
+ [project.optional-dependencies]
43
+ plot = [
44
+ "matplotlib==3.10.8"
45
+ ]
46
+
47
+ [tool.hatch.build]
48
+ include = [
49
+ "src/vaspparser"
50
+ ]
51
+
52
+ [tool.hatch.build.hooks.vcs]
53
+ version-file = "src/vaspparser/_version.py"
54
+
55
+ [tool.hatch.build.targets.sdist]
56
+ include = [
57
+ "src/vaspparser"
58
+ ]
59
+
60
+ [tool.hatch.build.targets.wheel]
61
+ packages = [
62
+ "src/vaspparser"
63
+ ]
64
+
65
+ [tool.hatch.version]
66
+ source = "vcs"
67
+ path = "src/vaspparser/_version.py"
68
+
69
+ [tool.coverage.run]
70
+ source = ["vaspparser"]
71
+ command_line = "-m unittest discover tests"
@@ -0,0 +1,3 @@
1
+ import vaspparser._version
2
+
3
+ __version__ = vaspparser._version.__version__
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.0.1'
32
+ __version_tuple__ = version_tuple = (0, 0, 1)
33
+
34
+ __commit_id__ = commit_id = None
File without changes
@@ -0,0 +1,149 @@
1
+ # coding: utf-8
2
+ # Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
3
+ # Distributed under the terms of "New BSD License", see the LICENSE file.
4
+
5
+ import os
6
+ import subprocess
7
+
8
+ import numpy as np
9
+
10
+ from vaspparser.vasp.volumetric_data import VaspVolumetricData
11
+
12
+ __author__ = "Sudarsan Surendralal"
13
+ __copyright__ = (
14
+ "Copyright 2021, Max-Planck-Institut für Eisenforschung GmbH - "
15
+ "Computational Materials Design (CM) Department"
16
+ )
17
+ __version__ = "1.0"
18
+ __maintainer__ = "Sudarsan Surendralal"
19
+ __email__ = "surendralal@mpie.de"
20
+ __status__ = "production"
21
+ __date__ = "May 1, 2021"
22
+
23
+
24
+ class Bader:
25
+ """
26
+ Module to apply the Bader charge partitioning scheme to finished DFT jobs. This module is interfaced with the
27
+ `Bader code`_ from the Greame Henkelmann group.
28
+
29
+ .. _Bader code: http://theory.cm.utexas.edu/henkelman/code/bader
30
+ """
31
+
32
+ def __init__(self, structure, working_directory):
33
+ """
34
+ Initialize the Bader module
35
+
36
+ Args:
37
+ job (pyiron_atomistics.dft.job.generic.GenericDFTJob): A DFT job instance (finished/converged job)
38
+ """
39
+ self._working_directory = working_directory
40
+ self._structure = structure
41
+
42
+ def _create_cube_files(self):
43
+ """
44
+ Create CUBE format files of the total and valce charges to be used by the Bader program
45
+ """
46
+ cd_val, cd_total = get_valence_and_total_charge_density(
47
+ working_directory=self._working_directory
48
+ )
49
+ cd_val.write_cube_file(
50
+ filename=os.path.join(self._working_directory, "valence_charge.CUBE")
51
+ )
52
+ cd_total.write_cube_file(
53
+ filename=os.path.join(self._working_directory, "total_charge.CUBE")
54
+ )
55
+
56
+ def compute_bader_charges(self, extra_arguments=None):
57
+ """
58
+ Run Bader analysis on the output from the DFT job
59
+
60
+ Args:
61
+ extra_arguments (str): Extra arguments to the Bader program
62
+
63
+ Returns:
64
+ tuple: Charges and volumes as numpy arrays
65
+
66
+ """
67
+ self._create_cube_files()
68
+ error_code = call_bader(
69
+ foldername=self._working_directory, extra_arguments=extra_arguments
70
+ )
71
+ if error_code > 0:
72
+ self._remove_cube_files()
73
+ raise ValueError("Invoking Bader charge analysis failed!")
74
+ self._remove_cube_files()
75
+ return self._parse_charge_vol()
76
+
77
+ def _remove_cube_files(self):
78
+ """
79
+ Delete created CUBE files
80
+ """
81
+ os.remove(os.path.join(self._working_directory, "valence_charge.CUBE"))
82
+ os.remove(os.path.join(self._working_directory, "total_charge.CUBE"))
83
+
84
+ def _parse_charge_vol(self):
85
+ """
86
+ Parse Bader charges and volumes
87
+
88
+ Returns:
89
+ tuple: charges and volumes
90
+
91
+ """
92
+ filename = os.path.join(self._working_directory, "ACF.dat")
93
+ return parse_charge_vol_file(structure=self._structure, filename=filename)
94
+
95
+
96
+ def call_bader(foldername, extra_arguments=None):
97
+ """
98
+ Call the Bader program inside a given folder
99
+
100
+ Args:
101
+ foldername (str): Folder path
102
+ extra_arguments (str): Extra arguments to the Bader program
103
+
104
+ Returns:
105
+ int: Result from the subprocess call (>0 if an error occurs)
106
+
107
+ """
108
+ if extra_arguments is None:
109
+ extra_arguments = ""
110
+ cmd = "bader valence_charge.CUBE -ref total_charge.CUBE {0}".format(extra_arguments)
111
+ return subprocess.call(cmd, shell=True, cwd=foldername)
112
+
113
+
114
+ def parse_charge_vol_file(structure, filename="ACF.dat"):
115
+ """
116
+ Parse charges and volumes from the output file
117
+
118
+ Args:
119
+ structure (pyiron_atomistics.atomistics.structure.atoms.Atoms): The snapshot to be analyzed
120
+ filename (str): Filename of the output file
121
+
122
+ Returns:
123
+ tuple: charges and volumes
124
+
125
+ """
126
+ with open(filename, errors="ignore") as f:
127
+ lines = f.readlines()
128
+ charges = np.genfromtxt(lines[2:], max_rows=len(structure))[:, 4]
129
+ volumes = np.genfromtxt(lines[2:], max_rows=len(structure))[:, 6]
130
+ return charges, volumes
131
+
132
+
133
+ def get_valence_and_total_charge_density(working_directory):
134
+ """
135
+ Gives the valence and total charge densities
136
+
137
+ Returns:
138
+ tuple: The required charge densities
139
+ """
140
+ cd_core = VaspVolumetricData()
141
+ cd_total = VaspVolumetricData()
142
+ cd_val = VaspVolumetricData()
143
+ if os.path.isfile(working_directory + "/AECCAR0"):
144
+ cd_core.from_file(working_directory + "/AECCAR0")
145
+ cd_val.from_file(working_directory + "/AECCAR2")
146
+ cd_val.atoms = cd_val.atoms
147
+ cd_total.total_data = cd_core.total_data + cd_val.total_data
148
+ cd_total.atoms = cd_val.atoms
149
+ return cd_val, cd_total