matid 2.0.0.dev0__tar.gz → 2.0.0.dev1__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 (49) hide show
  1. {matid-2.0.0.dev0/matid.egg-info → matid-2.0.0.dev1}/PKG-INFO +1 -1
  2. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/clustering/sbc.py +35 -18
  3. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/ext/geometry.cpp +57 -35
  4. {matid-2.0.0.dev0 → matid-2.0.0.dev1/matid.egg-info}/PKG-INFO +1 -1
  5. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/pyproject.toml +1 -1
  6. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/LICENSE +0 -0
  7. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/MANIFEST.in +0 -0
  8. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/README.md +0 -0
  9. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/__init__.py +0 -0
  10. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/classification/__init__.py +0 -0
  11. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/classification/classifications.py +0 -0
  12. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/classification/classifier.py +0 -0
  13. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/clustering/__init__.py +0 -0
  14. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/clustering/cluster.py +0 -0
  15. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/core/__init__.py +0 -0
  16. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/core/distances.py +0 -0
  17. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/core/lattice.py +0 -0
  18. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/core/linkedunits.py +0 -0
  19. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/core/periodicfinder.py +0 -0
  20. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/core/system.py +0 -0
  21. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/data/__init__.py +0 -0
  22. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/data/alphabet_data.py +0 -0
  23. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/data/constants.py +0 -0
  24. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/data/element_data.py +0 -0
  25. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/data/symmetry_data.py +0 -0
  26. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/ext/celllist.cpp +0 -0
  27. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/ext/ext.cpp +0 -0
  28. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/geometry/__init__.py +0 -0
  29. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/geometry/geometry.py +0 -0
  30. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/symmetry/__init__.py +0 -0
  31. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/symmetry/symmetryanalyzer.py +0 -0
  32. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/symmetry/wyckoffset.py +0 -0
  33. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/__init__.py +0 -0
  34. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/exceptions.py +0 -0
  35. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/segfault_protect.py +0 -0
  36. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/surfacegenerator.py +0 -0
  37. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/symmetry_info_generation/generate_symmetry_info.py +0 -0
  38. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/symmetry_info_generation/query_continuous_translations.py +0 -0
  39. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/symmetry_info_generation/query_conventional_transform_info.py +0 -0
  40. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/symmetry_info_generation/query_normalizers.py +0 -0
  41. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/symmetry_info_generation/query_space_group_info.py +0 -0
  42. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid/utils/symmetry_info_generation/query_wyckoff_sets.py +0 -0
  43. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid.egg-info/SOURCES.txt +0 -0
  44. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid.egg-info/dependency_links.txt +0 -0
  45. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid.egg-info/requires.txt +0 -0
  46. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/matid.egg-info/top_level.txt +0 -0
  47. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/requirements.txt +0 -0
  48. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/setup.cfg +0 -0
  49. {matid-2.0.0.dev0 → matid-2.0.0.dev1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: matid
3
- Version: 2.0.0.dev0
3
+ Version: 2.0.0.dev1
4
4
  Summary: MatID is a Python package for identifying and analyzing atomistic systems based on their structure.
5
5
  Author: Lauri Himanen
6
6
  License: Apache License
@@ -1,6 +1,7 @@
1
1
  from collections import defaultdict
2
2
 
3
3
  import numpy as np
4
+ import ase.geometry
4
5
 
5
6
  import matid.geometry
6
7
  from matid.clustering.cluster import Cluster
@@ -231,25 +232,41 @@ class SBC:
231
232
  # Copy the system to avoid mutating the original
232
233
  system_copy = system.copy()
233
234
 
234
- # If cell has not been set, or it has zero volume AND periodic boundary
235
- # conditions are not used, a dummy cell is created so that the rest of
236
- # the code that uses scaled positions works correctly.
237
- cell = system_copy.get_cell()
238
- if (not cell or cell.volume == 0) and not any(system_copy.get_pbc()):
239
- positions = system_copy.get_positions()
240
- max_pos = positions.max(axis=0) + 1
241
- min_pos = positions.min(axis=0) - 1
242
- dummy_cell = max_pos - min_pos
243
- system_copy.set_cell(dummy_cell)
244
- system_copy.center()
235
+ # Here we ensure that the system has three valid basis vectors which
236
+ # when forming a unit cell contain all of the atoms in the system. This
237
+ # is to ensure that the code that requires scaled positions works
238
+ # correctly.
239
+ pbc = system_copy.get_pbc()
240
+ basis = system_copy.get_cell()
241
+ requires_completion = False
242
+ for i in range(3):
243
+ if not basis[i, :].any():
244
+ if not pbc[i]:
245
+ requires_completion = True
246
+ else:
247
+ raise ValueError(
248
+ "Cannot process system with zero-volume cell and periodic boundaries."
249
+ )
250
+ if requires_completion:
251
+ system_copy.set_cell(ase.geometry.complete_cell(basis))
252
+ if not all(pbc):
253
+ scaled_positions = system_copy.get_scaled_positions()
254
+ new_cell = system_copy.get_cell()
255
+ scale_cell = False
256
+ for i in range(3):
257
+ if not pbc[i]:
258
+ i_pos = scaled_positions[:, i]
259
+ max_pos = i_pos.max()
260
+ min_pos = i_pos.min()
261
+ if max_pos > 1 or min_pos < 0:
262
+ scale_cell = True
263
+ new_cell[i, :] *= (max_pos - min_pos) + 1
264
+ if scale_cell:
265
+ system_copy.set_cell(new_cell)
266
+ system_copy.center()
267
+
245
268
  # Positions are wrapped
246
- else:
247
- try:
248
- system_copy.wrap()
249
- except Exception:
250
- raise ValueError(
251
- "Cannot process system with zero-volume cell and periodic boundaries."
252
- )
269
+ system_copy.wrap()
253
270
 
254
271
  atomic_numbers = system.get_atomic_numbers()
255
272
  radii = matid.geometry.get_radii(radii, atomic_numbers)
@@ -58,45 +58,67 @@ ExtendedSystem extend_system(
58
58
  vector<double> a = {cell_u(0, 0), cell_u(0, 1), cell_u(0, 2)};
59
59
  vector<double> b = {cell_u(1, 0), cell_u(1, 1), cell_u(1, 2)};
60
60
  vector<double> c = {cell_u(2, 0), cell_u(2, 1), cell_u(2, 2)};
61
+ vector<double> lengths = {norm(a), norm(b), norm(c)};
62
+ int n_empty = int(lengths[0] == 0) + int(lengths[1] == 0) + int(lengths[2] == 0);
63
+ vector<int> n_copies_axis(3, 0);
64
+
65
+ // If one basis vectors is missing, we need to create a dummy third vector
66
+ if (n_empty <= 1) {
67
+ if (lengths[0] == 0 && lengths[1] != 0 && lengths[2] != 0) {
68
+ a = cross(b, c);
69
+ } else if (lengths[1] == 0 && lengths[0] != 0 && lengths[2] != 0) {
70
+ b = cross(a, c);
71
+ } else if (lengths[2] == 0 && lengths[0] != 0 && lengths[1] != 0) {
72
+ c = cross(a, b);
73
+ }
74
+ vector<double> p1 = cross(b, c);
75
+ vector<double> p2 = cross(c, a);
76
+ vector<double> p3 = cross(a, b);
77
+
78
+ // Projections of basis vectors onto perpendicular vectors.
79
+ double p1_coeff = dot(a, p1) / dot(p1, p1);
80
+ double p2_coeff = dot(b, p2) / dot(p2, p2);
81
+ double p3_coeff = dot(c, p3) / dot(p3, p3);
82
+ for(double &x : p1) { x *= p1_coeff; }
83
+ for(double &x : p2) { x *= p2_coeff; }
84
+ for(double &x : p3) { x *= p3_coeff; }
85
+ vector<vector<double>> vectors = {p1, p2, p3};
86
+
87
+ // Figure out how many copies to take per basis vector. Determined by how
88
+ // many perpendicular projections fit into the cutoff distance.
89
+ for (int i=0; i < 3; ++i) {
90
+ if (pbc_u(i) && lengths[i]) {
91
+ double length = norm(vectors[i]);
92
+ double factor = cutoff/length;
93
+ int multiplier = (int)ceil(factor);
94
+ n_copies_axis[i] = multiplier;
95
+ }
96
+ }
97
+ // When two basis vectors are missing, only the remaining non-zero direction
98
+ // needs to be extended.
99
+ } else if (n_empty == 2) {
100
+ for (int i=0; i < 3; ++i) {
101
+ if (pbc_u(i) && lengths[i]) {
102
+ double factor = cutoff / lengths[i];
103
+ int multiplier = (int)ceil(factor);
104
+ n_copies_axis[i] = multiplier;
105
+ }
106
+ }
107
+ }
61
108
 
62
- vector<double> p1 = cross(b, c);
63
- vector<double> p2 = cross(c, a);
64
- vector<double> p3 = cross(a, b);
65
-
66
- // Projections of basis vectors onto perpendicular vectors.
67
- double p1_coeff = dot(a, p1) / dot(p1, p1);
68
- double p2_coeff = dot(b, p2) / dot(p2, p2);
69
- double p3_coeff = dot(c, p3) / dot(p3, p3);
70
- for(double &x : p1) { x *= p1_coeff; }
71
- for(double &x : p2) { x *= p2_coeff; }
72
- for(double &x : p3) { x *= p3_coeff; }
73
- vector<vector<double>> vectors = {p1, p2, p3};
74
-
75
- // Figure out how many copies to take per basis vector. Determined by how
76
- // many perpendicular projections fit into the cutoff distance.
77
- vector<int> n_copies_axis(3);
109
+ // Store multipliers explicitly into a list in an order that keeps the
110
+ // original system in the same place both in space and in index.
78
111
  vector<vector<int>> multipliers;
79
112
  for (int i=0; i < 3; ++i) {
80
- if (pbc_u(i)) {
81
- double length = norm(vectors[i]);
82
- double factor = cutoff/length;
83
- int multiplier = (int)ceil(factor);
84
- n_copies_axis[i] = multiplier;
85
-
86
- // Store multipliers explicitly into a list in an order that keeps the
87
- // original system in the same place both in space and in index.
88
- vector<int> multiples;
89
- for (int j=0; j < multiplier + 1; ++j) {
90
- multiples.push_back(j);
91
- }
92
- for (int j=-multiplier; j < 0; ++j) {
93
- multiples.push_back(j);
94
- }
95
- multipliers.push_back(multiples);
96
- } else {
97
- n_copies_axis[i] = 0;
98
- multipliers.push_back(vector<int>{0});
113
+ int multiplier = n_copies_axis[i];
114
+ vector<int> multiples;
115
+ for (int j=0; j < multiplier + 1; ++j) {
116
+ multiples.push_back(j);
117
+ }
118
+ for (int j=-multiplier; j < 0; ++j) {
119
+ multiples.push_back(j);
99
120
  }
121
+ multipliers.push_back(multiples);
100
122
  }
101
123
 
102
124
  // Calculate the extended system positions.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: matid
3
- Version: 2.0.0.dev0
3
+ Version: 2.0.0.dev1
4
4
  Summary: MatID is a Python package for identifying and analyzing atomistic systems based on their structure.
5
5
  Author: Lauri Himanen
6
6
  License: Apache License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = 'matid'
7
- version = '2.0.0.dev0'
7
+ version = '2.0.0.dev1'
8
8
  description = 'MatID is a Python package for identifying and analyzing atomistic systems based on their structure.'
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Lauri Himanen" }]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes