structuretoolkit 0.0.13__tar.gz → 0.0.14__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.
Files changed (51) hide show
  1. structuretoolkit-0.0.14/MANIFEST.in +1 -0
  2. {structuretoolkit-0.0.13/structuretoolkit.egg-info → structuretoolkit-0.0.14}/PKG-INFO +1 -1
  3. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/pyproject.toml +3 -3
  4. structuretoolkit-0.0.14/setup.py +8 -0
  5. structuretoolkit-0.0.14/structuretoolkit/_version.py +21 -0
  6. structuretoolkit-0.0.14/structuretoolkit/analyse/__init__.py +250 -0
  7. structuretoolkit-0.0.14/structuretoolkit/analyse/distance.py +59 -0
  8. structuretoolkit-0.0.14/structuretoolkit/analyse/neighbors.py +1246 -0
  9. structuretoolkit-0.0.14/structuretoolkit/analyse/phonopy.py +42 -0
  10. structuretoolkit-0.0.14/structuretoolkit/analyse/pyscal.py +299 -0
  11. structuretoolkit-0.0.14/structuretoolkit/analyse/spatial.py +641 -0
  12. structuretoolkit-0.0.14/structuretoolkit/analyse/strain.py +246 -0
  13. structuretoolkit-0.0.14/structuretoolkit/analyse/symmetry.py +385 -0
  14. structuretoolkit-0.0.14/structuretoolkit/build/__init__.py +11 -0
  15. structuretoolkit-0.0.14/structuretoolkit/build/aimsgb.py +121 -0
  16. structuretoolkit-0.0.14/structuretoolkit/build/compound.py +209 -0
  17. structuretoolkit-0.0.14/structuretoolkit/build/random.py +107 -0
  18. structuretoolkit-0.0.14/structuretoolkit/build/sqs.py +158 -0
  19. structuretoolkit-0.0.14/structuretoolkit/build/surface.py +163 -0
  20. structuretoolkit-0.0.14/structuretoolkit/common/__init__.py +16 -0
  21. structuretoolkit-0.0.14/structuretoolkit/common/error.py +2 -0
  22. structuretoolkit-0.0.14/structuretoolkit/common/helper.py +216 -0
  23. structuretoolkit-0.0.14/structuretoolkit/common/phonopy.py +36 -0
  24. structuretoolkit-0.0.14/structuretoolkit/common/pymatgen.py +18 -0
  25. structuretoolkit-0.0.14/structuretoolkit/common/pyscal.py +19 -0
  26. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14/structuretoolkit.egg-info}/PKG-INFO +1 -1
  27. structuretoolkit-0.0.14/structuretoolkit.egg-info/SOURCES.txt +44 -0
  28. structuretoolkit-0.0.13/MANIFEST.in +0 -3
  29. structuretoolkit-0.0.13/setup.py +0 -3
  30. structuretoolkit-0.0.13/structuretoolkit/_version.py +0 -716
  31. structuretoolkit-0.0.13/structuretoolkit.egg-info/SOURCES.txt +0 -25
  32. structuretoolkit-0.0.13/versioneer.py +0 -2277
  33. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/LICENSE +0 -0
  34. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/README.md +0 -0
  35. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/setup.cfg +0 -0
  36. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/structuretoolkit/__init__.py +0 -0
  37. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/structuretoolkit/visualize.py +0 -0
  38. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/structuretoolkit.egg-info/dependency_links.txt +0 -0
  39. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/structuretoolkit.egg-info/requires.txt +0 -0
  40. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/structuretoolkit.egg-info/top_level.txt +0 -0
  41. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_aimsgb.py +0 -0
  42. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_analyse.py +0 -0
  43. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_compound.py +0 -0
  44. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_high_index_surface.py +0 -0
  45. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_neighbors.py +0 -0
  46. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_pymatgen.py +0 -0
  47. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_pyscal.py +0 -0
  48. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_pyxtal.py +0 -0
  49. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_strain.py +0 -0
  50. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_symmetry.py +0 -0
  51. {structuretoolkit-0.0.13 → structuretoolkit-0.0.14}/tests/test_visualize.py +0 -0
@@ -0,0 +1 @@
1
+ include LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: structuretoolkit
3
- Version: 0.0.13
3
+ Version: 0.0.14
4
4
  Summary: build, analyse and visualise atomistic structures for materials science
5
5
  Author-email: Jan Janssen <janssen@mpie.de>
6
6
  License: BSD 3-Clause License
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["ase", "matplotlib", "numpy", "setuptools", "scipy"]
2
+ requires = ["ase", "matplotlib", "numpy", "setuptools", "scipy", "versioneer[toml]==0.29"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
@@ -56,8 +56,8 @@ phonopy = [
56
56
  ]
57
57
  pyxtal = ["pyxtal>=0.5.5,<=0.6.1"]
58
58
 
59
- [tool.setuptools]
60
- packages = ["structuretoolkit"]
59
+ [tool.setuptools.packages.find]
60
+ include = ["structuretoolkit*"]
61
61
 
62
62
  [tool.setuptools.dynamic]
63
63
  version = {attr = "structuretoolkit.__version__"}
@@ -0,0 +1,8 @@
1
+ from setuptools import setup
2
+
3
+ import versioneer
4
+
5
+ setup(
6
+ version=versioneer.get_version(),
7
+ cmdclass=versioneer.get_cmdclass(),
8
+ )
@@ -0,0 +1,21 @@
1
+
2
+ # This file was generated by 'versioneer.py' (0.29) from
3
+ # revision-control system data, or from the parent directory name of an
4
+ # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
+ # of this file.
6
+
7
+ import json
8
+
9
+ version_json = '''
10
+ {
11
+ "date": "2023-11-26T23:00:57+0100",
12
+ "dirty": true,
13
+ "error": null,
14
+ "full-revisionid": "985776e9464b45fc318cddad01f767eb3a308f2f",
15
+ "version": "0.0.14"
16
+ }
17
+ ''' # END VERSION_JSON
18
+
19
+
20
+ def get_versions():
21
+ return json.loads(version_json)
@@ -0,0 +1,250 @@
1
+ import numpy as np
2
+
3
+ from structuretoolkit.analyse.distance import find_mic, get_distances_array
4
+ from structuretoolkit.analyse.neighbors import get_neighborhood, get_neighbors
5
+ from structuretoolkit.analyse.phonopy import get_equivalent_atoms
6
+ from structuretoolkit.analyse.pyscal import (
7
+ find_solids,
8
+ get_adaptive_cna_descriptors,
9
+ get_centro_symmetry_descriptors,
10
+ get_diamond_structure_descriptors,
11
+ get_steinhardt_parameters,
12
+ get_voronoi_volumes,
13
+ )
14
+ from structuretoolkit.analyse.spatial import (
15
+ get_average_of_unique_labels,
16
+ get_cluster_positions,
17
+ get_delaunay_neighbors,
18
+ get_interstitials,
19
+ get_layers,
20
+ get_mean_positions,
21
+ get_voronoi_neighbors,
22
+ get_voronoi_vertices,
23
+ )
24
+ from structuretoolkit.analyse.strain import get_strain
25
+
26
+
27
+ def get_symmetry(
28
+ structure, use_magmoms=False, use_elements=True, symprec=1e-5, angle_tolerance=-1.0
29
+ ):
30
+ """
31
+
32
+ Args:
33
+ structure (Atoms): The structure to analyse.
34
+ use_magmoms (bool): Whether to consider magnetic moments (cf.
35
+ get_initial_magnetic_moments())
36
+ use_elements (bool): If False, chemical elements will be ignored
37
+ symprec (float): Symmetry search precision
38
+ angle_tolerance (float): Angle search tolerance
39
+
40
+ Returns:
41
+ symmetry (:class:`structuretoolkit.analyse.symmetry.Symmetry`): Symmetry class
42
+
43
+
44
+ """
45
+ from structuretoolkit.analyse.symmetry import Symmetry
46
+
47
+ return Symmetry(
48
+ structure=structure,
49
+ use_magmoms=use_magmoms,
50
+ use_elements=use_elements,
51
+ symprec=symprec,
52
+ angle_tolerance=angle_tolerance,
53
+ )
54
+
55
+
56
+ def symmetrize_vectors(
57
+ structure,
58
+ vectors,
59
+ use_magmoms=False,
60
+ use_elements=True,
61
+ symprec=1e-5,
62
+ angle_tolerance=-1.0,
63
+ ):
64
+ """
65
+ Symmetrization of natom x 3 vectors according to box symmetries
66
+
67
+ Args:
68
+ structure (Atoms): The structure to analyse.
69
+ vectors (ndarray/list): natom x 3 array to symmetrize
70
+ use_magmoms (bool): Whether to consider magnetic moments (cf.
71
+ get_initial_magnetic_moments())
72
+ use_elements (bool): If False, chemical elements will be ignored
73
+ symprec (float): Symmetry search precision
74
+ angle_tolerance (float): Angle search tolerance
75
+
76
+ Returns:
77
+ (np.ndarray) symmetrized vectors
78
+ """
79
+ from structuretoolkit.analyse.symmetry import Symmetry
80
+
81
+ return Symmetry(
82
+ structure=structure,
83
+ use_magmoms=use_magmoms,
84
+ use_elements=use_elements,
85
+ symprec=symprec,
86
+ angle_tolerance=angle_tolerance,
87
+ ).symmetrize_vectors(vectors=vectors)
88
+
89
+
90
+ def group_points_by_symmetry(
91
+ structure,
92
+ points,
93
+ use_magmoms=False,
94
+ use_elements=True,
95
+ symprec=1e-5,
96
+ angle_tolerance=-1.0,
97
+ ):
98
+ """
99
+ This function classifies the points into groups according to the box symmetry given by
100
+ spglib.
101
+
102
+ Args:
103
+ structure (Atoms): The structure to analyse.
104
+ points: (np.array/list) nx3 array which contains positions
105
+ use_magmoms (bool): Whether to consider magnetic moments (cf.
106
+ get_initial_magnetic_moments())
107
+ use_elements (bool): If False, chemical elements will be ignored
108
+ symprec (float): Symmetry search precision
109
+ angle_tolerance (float): Angle search tolerance
110
+
111
+ Returns: list of arrays containing geometrically equivalent positions
112
+
113
+ It is possible that the original points are not found in the returned list, as the
114
+ positions outsie the box will be projected back to the box.
115
+ """
116
+ from structuretoolkit.analyse.symmetry import Symmetry
117
+
118
+ return Symmetry(
119
+ structure=structure,
120
+ use_magmoms=use_magmoms,
121
+ use_elements=use_elements,
122
+ symprec=symprec,
123
+ angle_tolerance=angle_tolerance,
124
+ ).get_arg_equivalent_sites(points)
125
+
126
+
127
+ def get_equivalent_points(
128
+ structure,
129
+ points,
130
+ use_magmoms=False,
131
+ use_elements=True,
132
+ symprec=1e-5,
133
+ angle_tolerance=-1.0,
134
+ ):
135
+ """
136
+
137
+ Args:
138
+ structure (Atoms): The structure to analyse.
139
+ points (list/ndarray): 3d vector
140
+ use_magmoms (bool): Whether to consider magnetic moments (cf.
141
+ get_initial_magnetic_moments())
142
+ use_elements (bool): If False, chemical elements will be ignored
143
+ symprec (float): Symmetry search precision
144
+ angle_tolerance (float): Angle search tolerance
145
+
146
+ Returns:
147
+ (ndarray): array of equivalent points with respect to box symmetries
148
+ """
149
+ from structuretoolkit.analyse.symmetry import Symmetry
150
+
151
+ return Symmetry(
152
+ structure=structure,
153
+ use_magmoms=use_magmoms,
154
+ use_elements=use_elements,
155
+ symprec=symprec,
156
+ angle_tolerance=angle_tolerance,
157
+ ).get_arg_equivalent_sites(points)
158
+
159
+
160
+ def get_symmetry_dataset(structure, symprec=1e-5, angle_tolerance=-1.0):
161
+ """
162
+
163
+ Args:
164
+ structure (Atoms): The structure to analyse.
165
+ symprec (float): Symmetry search precision
166
+ angle_tolerance (float): Angle search tolerance
167
+
168
+ Returns:
169
+
170
+ https://atztogo.github.io/spglib/python-spglib.html
171
+ """
172
+ from structuretoolkit.analyse.symmetry import Symmetry
173
+
174
+ return Symmetry(
175
+ structure=structure,
176
+ symprec=symprec,
177
+ angle_tolerance=angle_tolerance,
178
+ ).info
179
+
180
+
181
+ def get_spacegroup(structure, symprec=1e-5, angle_tolerance=-1.0):
182
+ """
183
+
184
+ Args:
185
+ structure (Atoms): The structure to analyse.
186
+ symprec (float): Symmetry search precision
187
+ angle_tolerance (float): Angle search tolerance
188
+
189
+ Returns:
190
+
191
+ https://atztogo.github.io/spglib/python-spglib.html
192
+ """
193
+ from structuretoolkit.analyse.symmetry import Symmetry
194
+
195
+ return Symmetry(
196
+ structure=structure,
197
+ symprec=symprec,
198
+ angle_tolerance=angle_tolerance,
199
+ ).spacegroup
200
+
201
+
202
+ def get_primitive_cell(structure, symprec=1e-5, angle_tolerance=-1.0):
203
+ """
204
+
205
+ Args:
206
+ structure (Atoms): The structure to analyse.
207
+ symprec (float): Symmetry search precision
208
+ angle_tolerance (float): Angle search tolerance
209
+
210
+ Returns:
211
+
212
+ """
213
+ from structuretoolkit.analyse.symmetry import Symmetry
214
+
215
+ return Symmetry(
216
+ structure=structure,
217
+ symprec=symprec,
218
+ angle_tolerance=angle_tolerance,
219
+ ).get_primitive_cell(standardize=False)
220
+
221
+
222
+ def get_ir_reciprocal_mesh(
223
+ structure,
224
+ mesh,
225
+ is_shift=np.zeros(3, dtype="intc"),
226
+ is_time_reversal=True,
227
+ symprec=1e-5,
228
+ ):
229
+ """
230
+
231
+ Args:
232
+ structure (Atoms): The structure to analyse.
233
+ mesh:
234
+ is_shift:
235
+ is_time_reversal:
236
+ symprec (float): Symmetry search precision
237
+
238
+ Returns:
239
+
240
+ """
241
+ from structuretoolkit.analyse.symmetry import Symmetry
242
+
243
+ return Symmetry(
244
+ structure=structure,
245
+ symprec=symprec,
246
+ ).get_ir_reciprocal_mesh(
247
+ mesh=mesh,
248
+ is_shift=is_shift,
249
+ is_time_reversal=is_time_reversal,
250
+ )
@@ -0,0 +1,59 @@
1
+ import numpy as np
2
+
3
+
4
+ def get_distances_array(structure, p1=None, p2=None, mic=True, vectors=False):
5
+ """
6
+ Return distance matrix of every position in p1 with every position in
7
+ p2. If p2 is not set, it is assumed that distances between all
8
+ positions in p1 are desired. p2 will be set to p1 in this case. If both
9
+ p1 and p2 are not set, the distances between all atoms in the box are
10
+ returned.
11
+
12
+ Args:
13
+ p1 (numpy.ndarray/list): Nx3 array of positions
14
+ p2 (numpy.ndarray/list): Nx3 array of positions
15
+ mic (bool): minimum image convention
16
+ vectors (bool): return vectors instead of distances
17
+ Returns:
18
+ numpy.ndarray: NxN if vector=False and NxNx3 if vector=True
19
+
20
+ """
21
+ if p1 is None and p2 is not None:
22
+ p1 = p2
23
+ p2 = None
24
+ if p1 is None:
25
+ p1 = structure.positions
26
+ if p2 is None:
27
+ p2 = structure.positions
28
+ p1 = np.asarray(p1)
29
+ p2 = np.asarray(p2)
30
+ diff_relative = (
31
+ p2.reshape(-1, 3)[np.newaxis, :, :] - p1.reshape(-1, 3)[:, np.newaxis, :]
32
+ )
33
+ diff_relative = diff_relative.reshape(p1.shape[:-1] + p2.shape[:-1] + (3,))
34
+ if not mic:
35
+ if vectors:
36
+ return diff_relative
37
+ else:
38
+ return np.linalg.norm(diff_relative, axis=-1)
39
+ return find_mic(structure=structure, v=diff_relative, vectors=vectors)
40
+
41
+
42
+ def find_mic(structure, v, vectors=True):
43
+ """
44
+ Find vectors following minimum image convention (mic). In principle this
45
+ function does the same as ase.geometry.find_mic
46
+
47
+ Args:
48
+ v (list/numpy.ndarray): 3d vector or a list/array of 3d vectors
49
+ vectors (bool): Whether to return vectors (distances are returned if False)
50
+
51
+ Returns: numpy.ndarray of the same shape as input with mic
52
+ """
53
+ if any(structure.pbc):
54
+ v = np.einsum("ji,...j->...i", np.linalg.inv(structure.cell), v)
55
+ v[..., structure.pbc] -= np.rint(v)[..., structure.pbc]
56
+ v = np.einsum("ji,...j->...i", structure.cell, v)
57
+ if vectors:
58
+ return np.asarray(v)
59
+ return np.linalg.norm(v, axis=-1)