kim-tools 0.3.3__py3-none-any.whl → 0.3.5__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.3.3"
1
+ __version__ = "0.3.5"
2
2
 
3
3
  from .aflow_util import *
4
4
  from .aflow_util import __all__ as aflow_all
kim_tools/ase/core.py CHANGED
@@ -208,7 +208,7 @@ def randomize_positions(atoms, pert_amp, seed=None):
208
208
 
209
209
 
210
210
  ################################################################################
211
- def get_isolated_energy_per_atom(model: Union[str, Calculator], symbol):
211
+ def get_isolated_energy_per_atom(model: Union[str, Calculator], symbol: str) -> float:
212
212
  """
213
213
  Construct a non-periodic cell containing a single atom and compute its energy.
214
214
 
@@ -237,23 +237,16 @@ def get_isolated_energy_per_atom(model: Union[str, Calculator], symbol):
237
237
  f"or an ASE Calculator. Instead got an object of type {type(model)}."
238
238
  )
239
239
  single_atom.calc = calc
240
- try:
241
- energy_per_atom = single_atom.get_potential_energy()
242
- except Exception as e:
243
- msg = (
244
- "Energy evaluation for isolated atom raised the following error:\n"
245
- f"{repr(e)}\nAssuming zero isolated atom energy."
246
- )
247
- logger.warning(msg)
248
- print(msg)
249
- energy_per_atom = 0.0
250
- finally:
240
+ energy_per_atom = single_atom.get_potential_energy()
241
+ # if we are attaching an existing LAMMPS calculator to an atoms object,
242
+ # we can't delete it. Only do so if we are making a new one from a KIM ID.
243
+ if isinstance(model, str):
251
244
  if hasattr(calc, "clean"):
252
245
  calc.clean()
253
246
  if hasattr(calc, "__del__"):
254
247
  calc.__del__()
255
- del single_atom
256
- return energy_per_atom
248
+ del single_atom
249
+ return energy_per_atom
257
250
 
258
251
 
259
252
  ################################################################################
@@ -66,6 +66,7 @@ from ..aflow_util import (
66
66
  prototype_labels_are_equivalent,
67
67
  )
68
68
  from ..aflow_util.core import AFLOW_EXECUTABLE
69
+ from ..ase import get_isolated_energy_per_atom
69
70
  from ..kimunits import convert_list, convert_units
70
71
  from ..symmetry_util import (
71
72
  cartesian_rotation_is_in_point_group,
@@ -490,6 +491,13 @@ class KIMTestDriver(ABC):
490
491
  the Test Driver
491
492
  """
492
493
 
494
+ class NonKIMModelError(Exception):
495
+ """
496
+ Raised when a KIM model name is requested but is absent. This is important
497
+ to handle to inform users that they are trying to run a Test Driver that
498
+ requires a KIM model (e.g. a LAMMPS TD) with a non-KIM Calculator
499
+ """
500
+
493
501
  def __init__(self, model: Union[str, Calculator]) -> None:
494
502
  """
495
503
  Args:
@@ -690,7 +698,13 @@ class KIMTestDriver(ABC):
690
698
  """
691
699
  Get the KIM model name, if present
692
700
  """
693
- return self.__kim_model_name
701
+ if self.__kim_model_name is not None:
702
+ return self.__kim_model_name
703
+ else:
704
+ raise self.NonKIMModelError(
705
+ "A KIM model name is being requested, but the Test Driver "
706
+ "is being run with a non-KIM calculator."
707
+ )
694
708
 
695
709
  @property
696
710
  def property_instances(self) -> Dict:
@@ -733,6 +747,23 @@ class KIMTestDriver(ABC):
733
747
  self.__output_property_instances, f
734
748
  ) # serialize the dictionary to string first
735
749
 
750
+ def get_isolated_energy_per_atom(self, symbol: str) -> float:
751
+ """
752
+ Construct a non-periodic cell containing a single atom and compute its energy.
753
+
754
+ Args
755
+ symbol:
756
+ The chemical species
757
+
758
+ Returns:
759
+ The isolated energy of a single atom
760
+ """
761
+ try:
762
+ model = self.kim_model_name
763
+ except self.NonKIMModelError:
764
+ model = self._calc
765
+ return get_isolated_energy_per_atom(model=model, symbol=symbol)
766
+
736
767
 
737
768
  def _add_common_crystal_genome_keys_to_current_property_instance(
738
769
  property_instances: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kim-tools
3
- Version: 0.3.3
3
+ Version: 0.3.5
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>, Philipp Hoellmer <ph2484@nyu.edu>, Guanming Zhang <gz2241@nyu.edu>, Tom Egg <tje3676@nyu.edu>
6
6
  Maintainer-email: ilia Nikiforov <nikif002@umn.edu>
@@ -32,7 +32,7 @@ Dynamic: license-file
32
32
 
33
33
  # kim-tools
34
34
 
35
- ![testing](https://github.com/openkim/kim-tools/actions/workflows/testing.yml/badge.svg)
35
+ [![Testing](https://github.com/openkim/kim-tools/actions/workflows/testing.yml/badge.svg)](https://github.com/openkim/kim-tools/actions/workflows/testing.yml)
36
36
  [![docs](https://app.readthedocs.org/projects/kim-tools/badge/?version=latest)](https://kim-tools.readthedocs.io/en/latest/)
37
37
  [![PyPI](https://img.shields.io/pypi/v/kim-tools.svg)](https://pypi.org/project/kim-tools/)
38
38
 
@@ -1,4 +1,4 @@
1
- kim_tools/__init__.py,sha256=pnnfC__2WcTkgaE8RZU5AfDIx6PQOR9Dst7oBvYsMYI,433
1
+ kim_tools/__init__.py,sha256=y8h76B1TbTZ5GZBpVnnyhzD06UpiOrAN5xffFW2TfLI,433
2
2
  kim_tools/kimunits.py,sha256=jOxBv9gRVhxPE6ygAIUxOzCAfPI6tT6sBaF_FNl9m-M,5387
3
3
  kim_tools/aflow_util/__init__.py,sha256=lJnQ8fZCma80QVRQeKvY4MQ87oCWu-9KATV3dKJfpDc,80
4
4
  kim_tools/aflow_util/core.py,sha256=zi69wMcgkcYBTKbc-OvKlMIzUtgphO57yBA8LB7_5wc,77484
@@ -2002,7 +2002,7 @@ kim_tools/aflow_util/aflow_prototype_encyclopedia/data/A_tP4_129_ac-001/info.jso
2002
2002
  kim_tools/aflow_util/aflow_prototype_encyclopedia/data/A_tP4_136_f-001/info.json,sha256=5_xlFGOov7VoFwzhp7JtltRnWiAFfgpwF5qc3kMSAjQ,1278
2003
2003
  kim_tools/aflow_util/aflow_prototype_encyclopedia/data/A_tP50_134_a2m2n-001/info.json,sha256=K601zsKLpvPLIaK17bEiNGIQJYJDvIby1lIJ3P9Ze6E,1258
2004
2004
  kim_tools/ase/__init__.py,sha256=1i6ko5tNr0VZC3T7hoEzq4fnSU0DdxNpxXcSaWMcJWc,76
2005
- kim_tools/ase/core.py,sha256=KRtcNYcJLlP-WiEMOOmR-DhYw5IN5MoOCtKWJJzRkhM,31313
2005
+ kim_tools/ase/core.py,sha256=odRuHQGZl-pcRtkdYvG31_3kW6nt3qwHdKvAOJ-ifwM,31207
2006
2006
  kim_tools/symmetry_util/__init__.py,sha256=uu-ZSUDUTe2P81rkAS3tXverx31s_uZ3wL4SD_dn5aI,86
2007
2007
  kim_tools/symmetry_util/core.py,sha256=HfDy1CwNWUZIkb4cs3ebUDgWjtt4jRSkBKgGEnlkjuI,30888
2008
2008
  kim_tools/symmetry_util/data/possible_primitive_shifts.json,sha256=4OVNgn3NnykgGlYiAcecERmVWiIZFrmP2LZI3ml_Sh0,25010
@@ -2012,11 +2012,11 @@ kim_tools/symmetry_util/data/wyck_pos_xform_under_normalizer.json,sha256=6g1YuYh
2012
2012
  kim_tools/symmetry_util/data/wyckoff_multiplicities.json,sha256=qG2RPBd_-ejDIfz-E4ZhkHyRpIboxRy7oiXkdDf5Eg8,32270
2013
2013
  kim_tools/symmetry_util/data/wyckoff_sets.json,sha256=f5ZpHKDHo6_JWki1b7KUGoYLlhU-44Qikw_-PtbLssw,9248
2014
2014
  kim_tools/test_driver/__init__.py,sha256=KOiceeZNqkfrgZ66CiRiUdniceDrCmmDXQkOw0wXaCQ,92
2015
- kim_tools/test_driver/core.py,sha256=r4hiZcV-PkWcOo0uEqfqeP1-YGGpPepaAjmR4LJog0w,89208
2015
+ kim_tools/test_driver/core.py,sha256=8FbOhQRu38zX48CBgFgMrB2tLLSXUsbrXl9dYx5CVHw,90320
2016
2016
  kim_tools/vc/__init__.py,sha256=zXjhxXCKVMLBMXXWYG3if7VOpBnsFrn_RjVpnohDm5c,74
2017
2017
  kim_tools/vc/core.py,sha256=BIjzEExnQAL2S90a_npptRm3ACqAo4fZBtvTDBMWMdw,13963
2018
- kim_tools-0.3.3.dist-info/licenses/LICENSE.CDDL,sha256=I2luEED_SHjuZ01B4rYG-AF_135amL24JpHvZ1Jhqe8,16373
2019
- kim_tools-0.3.3.dist-info/METADATA,sha256=d5yobjRNvHpCLftHbue8GmC0xsvD8FSOpCksGnRoxC8,1962
2020
- kim_tools-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2021
- kim_tools-0.3.3.dist-info/top_level.txt,sha256=w_YCpJ5ERigj9te74ln7k64tqj1VumOzM_s9dsalIWY,10
2022
- kim_tools-0.3.3.dist-info/RECORD,,
2018
+ kim_tools-0.3.5.dist-info/licenses/LICENSE.CDDL,sha256=I2luEED_SHjuZ01B4rYG-AF_135amL24JpHvZ1Jhqe8,16373
2019
+ kim_tools-0.3.5.dist-info/METADATA,sha256=YHR8cikv3dJ0DLWxltEXkNyDbHFJMMT5hullZnEvYvs,2032
2020
+ kim_tools-0.3.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2021
+ kim_tools-0.3.5.dist-info/top_level.txt,sha256=w_YCpJ5ERigj9te74ln7k64tqj1VumOzM_s9dsalIWY,10
2022
+ kim_tools-0.3.5.dist-info/RECORD,,