kim-tools 0.2.0b0__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
kim_tools/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.0b0"
1
+ __version__ = "0.2.1"
2
2
 
3
3
  from .aflow_util import *
4
4
  from .aflow_util import __all__ as aflow_all
@@ -719,6 +719,11 @@ class AFLOW:
719
719
 
720
720
  """
721
721
 
722
+ class AFLOWNotFoundException(Exception):
723
+ """
724
+ Raised when the AFLOW executable is not found
725
+ """
726
+
722
727
  class ChangedSymmetryException(Exception):
723
728
  """
724
729
  Raised when an unexpected symmetry change is detected
@@ -744,6 +749,15 @@ class AFLOW:
744
749
  np: Sets :attr:`np`
745
750
  """
746
751
  self.aflow_executable = aflow_executable
752
+
753
+ try:
754
+ subprocess.check_output(["aflow", "--proto=A_cF4_225_a"])
755
+ except Exception:
756
+ raise self.AFLOWNotFoundException(
757
+ "Failed to run an AFLOW test command. It is likely "
758
+ "that the AFLOW executable was not found."
759
+ )
760
+
747
761
  self.np = np
748
762
  if aflow_work_dir != "" and not aflow_work_dir.endswith("/"):
749
763
  self.aflow_work_dir = aflow_work_dir + "/"
kim_tools/kimunits.py CHANGED
@@ -24,6 +24,19 @@ _units_output_expression = re.compile(
24
24
  )
25
25
 
26
26
 
27
+ def check_units_util():
28
+ """
29
+ Check that units util can be found
30
+ """
31
+ try:
32
+ subprocess.check_output(["units", "--help"])
33
+ except Exception:
34
+ raise UnitConversion(
35
+ "Failed to run a 'units' test command. It is likely "
36
+ "that the 'units' executable was not found."
37
+ )
38
+
39
+
27
40
  def linear_fit(x, y):
28
41
  """
29
42
  Perform a linear fit between x,y, returning the average error for each data
@@ -55,6 +68,7 @@ def islinear(unit, to_unit=None):
55
68
 
56
69
  def convert_units(from_value, from_unit, wanted_unit=None, suppress_unit=False):
57
70
  """Works with 'units' utility"""
71
+ check_units_util()
58
72
  from_sign = from_value < 0
59
73
  from_value = str(abs(from_value))
60
74
  from_unit = str(from_unit)
@@ -131,6 +131,42 @@ def cartesian_to_fractional_itc_rotation_from_ase_cell(
131
131
  return np.transpose(cell_arr @ cart_rot_arr @ np.linalg.inv(cell_arr))
132
132
 
133
133
 
134
+ def fractional_to_cartesian_itc_rotation_from_ase_cell(
135
+ frac_rot: ArrayLike, cell: ArrayLike
136
+ ) -> ArrayLike:
137
+ """
138
+ Convert fractional to Cartesian rotation. Read the arguments and returns carefully,
139
+ as there is some unfortunate mixing of row and columns because of the different
140
+ conventions of the ITC and ASE and other simulation packages
141
+
142
+ Args:
143
+ frac_rot:
144
+ The fractional rotation in ITC convention, i.e. for left-multiplying column
145
+ vectors. Here the distinction with a matrix's transpose DOES matter, because
146
+ the fractional coordinate system is not orthonormal.
147
+ cell:
148
+ The cell of the crystal, with each row being a cartesian vector
149
+ representing a lattice vector. This is consistent with most simulation
150
+ packages, but transposed from the ITC
151
+
152
+ Returns:
153
+ Cartesian rotation. It is assumed that this is for left-multiplying column
154
+ vectors, although in cases where we don't care if we're working with the
155
+ rotation or its inverse (e.g. when checking whether or not it's in the
156
+ point group), this doesn't matter due to orthogonality
157
+ """
158
+
159
+ cell_arr = np.asarray(cell)
160
+ frac_rot_arr = np.asarray(frac_rot)
161
+
162
+ if not ((cell_arr.shape == (3, 3)) and (frac_rot_arr.shape == (3, 3))):
163
+ raise IncorrectCrystallographyException(
164
+ "Either the rotation matrix or the cell provided were not 3x3 matrices"
165
+ )
166
+
167
+ return np.transpose(np.linalg.inv(cell_arr) @ frac_rot_arr @ cell_arr)
168
+
169
+
134
170
  def cartesian_rotation_is_in_point_group(
135
171
  cart_rot: ArrayLike, sgnum: Union[int, str], cell: ArrayLike
136
172
  ) -> bool:
@@ -1218,7 +1218,9 @@ class SingleCrystalTestDriver(KIMTestDriver):
1218
1218
  print(f"\nNOTE: {msg}\n")
1219
1219
  logger.info(msg)
1220
1220
 
1221
- def _update_nominal_parameter_values(self, atoms: Atoms) -> None:
1221
+ def _update_nominal_parameter_values(
1222
+ self, atoms: Atoms, max_resid: float = 1e-5
1223
+ ) -> None:
1222
1224
  """
1223
1225
  Update the nominal parameter values of the nominal crystal structure from the
1224
1226
  provided :class:`~ase.Atoms` object. It is assumed that the crystallographic
@@ -1246,6 +1248,9 @@ class SingleCrystalTestDriver(KIMTestDriver):
1246
1248
 
1247
1249
  Args:
1248
1250
  atoms: Structure to analyze to get the new parameter values
1251
+ max_resid:
1252
+ Maximum residual allowed when attempting to match the fractional
1253
+ positions of the atoms to the crystallographic equations
1249
1254
 
1250
1255
  Raises:
1251
1256
  AFLOW.FailedToMatchException:
@@ -1259,8 +1264,11 @@ class SingleCrystalTestDriver(KIMTestDriver):
1259
1264
 
1260
1265
  try:
1261
1266
  aflow_parameter_values = AFLOW().solve_for_params_of_known_prototype(
1262
- atoms,
1263
- self.__nominal_crystal_structure_npt["prototype-label"]["source-value"],
1267
+ atoms=atoms,
1268
+ prototype_label=self.__nominal_crystal_structure_npt["prototype-label"][
1269
+ "source-value"
1270
+ ],
1271
+ max_resid=max_resid,
1264
1272
  )
1265
1273
  except (AFLOW.FailedToMatchException, AFLOW.ChangedSymmetryException) as e:
1266
1274
  raise type(e)(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kim-tools
3
- Version: 0.2.0b0
3
+ Version: 0.2.1
4
4
  Summary: Base classes and helper routines for writing KIM Tests
5
5
  Author-email: ilia Nikiforov <nikif002@umn.edu>, Ellad Tadmor <tadmor@umn.edu>, Claire Waters <bwaters@umn.edu>, "Daniel S. Karls" <karl0100umn@gmail.com>, Matt Bierbaum <matt.bierbaum@gmail.com>, Eric Fuemmeler <efuemmel@umn.edu>
6
6
  Maintainer-email: ilia Nikiforov <nikif002@umn.edu>
@@ -1,12 +1,12 @@
1
- kim_tools/__init__.py,sha256=_IDKtgO7O3TeqoIhOaAUUqV2IEv5Suk3PPsYokbtI7Q,435
2
- kim_tools/kimunits.py,sha256=kR5VMTurQnbPOHcWF1XN-mjY9FXRAdWI8hA-RZHhrek,5036
1
+ kim_tools/__init__.py,sha256=-dcfQfnIcs043nxVvh5sJHOkRySpNLwUf_MxHxwH2B4,433
2
+ kim_tools/kimunits.py,sha256=jOxBv9gRVhxPE6ygAIUxOzCAfPI6tT6sBaF_FNl9m-M,5387
3
3
  kim_tools/aflow_util/__init__.py,sha256=lJnQ8fZCma80QVRQeKvY4MQ87oCWu-9KATV3dKJfpDc,80
4
- kim_tools/aflow_util/core.py,sha256=Xqjh2Xwf4-e-98FMJ8RfRXsTdx2NeWeZXwrPP0xkvwM,71847
4
+ kim_tools/aflow_util/core.py,sha256=-UOiEHHA_3Bcvl49OIwnlQCl0ddN2KWdmNEZ2M9MlW4,72271
5
5
  kim_tools/aflow_util/data/README_PROTO.TXT,sha256=bTpcd8GHOkpcQn6YUZzqKhiTytwSDpkgu4boeoogT38,447851
6
6
  kim_tools/ase/__init__.py,sha256=1i6ko5tNr0VZC3T7hoEzq4fnSU0DdxNpxXcSaWMcJWc,76
7
7
  kim_tools/ase/core.py,sha256=d6eOu_HSxVr-ae0TSEbY4HKdePxhNu3yv8NN9VDl-BA,30256
8
8
  kim_tools/symmetry_util/__init__.py,sha256=uu-ZSUDUTe2P81rkAS3tXverx31s_uZ3wL4SD_dn5aI,86
9
- kim_tools/symmetry_util/core.py,sha256=eQV6gBVlLzGz3LvbRhD1H64uOooyRWTFxU346jSUbE4,20083
9
+ kim_tools/symmetry_util/core.py,sha256=VTYH1MRADraJVc6SBfFHZweWI_WZgCViSKM4MazF7KY,21634
10
10
  kim_tools/symmetry_util/data/possible_primitive_shifts.json,sha256=4OVNgn3NnykgGlYiAcecERmVWiIZFrmP2LZI3ml_Sh0,25010
11
11
  kim_tools/symmetry_util/data/primitive_GENPOS_ops.json,sha256=FDu4H4PosOpK9yKwOPy3SxbH7xLMOmZfKZ4ItKPMjoQ,224498
12
12
  kim_tools/symmetry_util/data/space_groups_for_each_bravais_lattice.json,sha256=wSNu6d5pH72lJ6Zj5MZ64qzwS_6Fn5WOs0ts7E9uPC4,2507
@@ -14,11 +14,11 @@ kim_tools/symmetry_util/data/wyck_pos_xform_under_normalizer.json,sha256=6g1YuYh
14
14
  kim_tools/symmetry_util/data/wyckoff_multiplicities.json,sha256=qG2RPBd_-ejDIfz-E4ZhkHyRpIboxRy7oiXkdDf5Eg8,32270
15
15
  kim_tools/symmetry_util/data/wyckoff_sets.json,sha256=f5ZpHKDHo6_JWki1b7KUGoYLlhU-44Qikw_-PtbLssw,9248
16
16
  kim_tools/test_driver/__init__.py,sha256=KOiceeZNqkfrgZ66CiRiUdniceDrCmmDXQkOw0wXaCQ,92
17
- kim_tools/test_driver/core.py,sha256=YFLwqV6bBAxRzoinAB3cH86z90fQqENwhMcjyzrJxPM,78225
17
+ kim_tools/test_driver/core.py,sha256=7l_fnLXNYNLuROY3b1vbqIA_715acaBbQGjS3PXdXB8,78538
18
18
  kim_tools/vc/__init__.py,sha256=zXjhxXCKVMLBMXXWYG3if7VOpBnsFrn_RjVpnohDm5c,74
19
19
  kim_tools/vc/core.py,sha256=BIjzEExnQAL2S90a_npptRm3ACqAo4fZBtvTDBMWMdw,13963
20
- kim_tools-0.2.0b0.dist-info/licenses/LICENSE.CDDL,sha256=I2luEED_SHjuZ01B4rYG-AF_135amL24JpHvZ1Jhqe8,16373
21
- kim_tools-0.2.0b0.dist-info/METADATA,sha256=feOdrstYpWjnu0VzAeNU0_zTWgsSM7yBZfs0RkD7fbA,1462
22
- kim_tools-0.2.0b0.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
23
- kim_tools-0.2.0b0.dist-info/top_level.txt,sha256=w_YCpJ5ERigj9te74ln7k64tqj1VumOzM_s9dsalIWY,10
24
- kim_tools-0.2.0b0.dist-info/RECORD,,
20
+ kim_tools-0.2.1.dist-info/licenses/LICENSE.CDDL,sha256=I2luEED_SHjuZ01B4rYG-AF_135amL24JpHvZ1Jhqe8,16373
21
+ kim_tools-0.2.1.dist-info/METADATA,sha256=kQVhy8AzLH5-Oa8s0NEPdzgVnmjkfKBLMcOgKL2u02g,1460
22
+ kim_tools-0.2.1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
23
+ kim_tools-0.2.1.dist-info/top_level.txt,sha256=w_YCpJ5ERigj9te74ln7k64tqj1VumOzM_s9dsalIWY,10
24
+ kim_tools-0.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5