kim-tools 0.3.2__py3-none-any.whl → 0.3.3__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.2"
1
+ __version__ = "0.3.3"
2
2
 
3
3
  from .aflow_util import *
4
4
  from .aflow_util import __all__ as aflow_all
@@ -552,12 +552,32 @@ def find_species_permutation_between_prototype_labels(
552
552
  # Disassemble prototype_label_1
553
553
  stoich_reduced_list_1 = get_stoich_reduced_list_from_prototype(prototype_label_1)
554
554
  pearson_1 = get_pearson_symbol_from_prototype(prototype_label_1)
555
- space_group_1 = str(get_space_group_number_from_prototype(prototype_label_1))
555
+ space_group_1 = get_space_group_number_from_prototype(prototype_label_1)
556
+ space_group_1_str = str(space_group_1)
556
557
  species_wyckoff_sections_1 = prototype_label_1.split("-")[0].split("_")[3:]
557
558
 
558
559
  nspecies = len(stoich_reduced_list_1)
559
560
  assert nspecies == len(species_wyckoff_sections_1)
560
561
 
562
+ # For crystals with many species, it takes forever to loop through all permutations,
563
+ # so do some basic checks first to reject
564
+ stoich_reduced_list_2 = get_stoich_reduced_list_from_prototype(prototype_label_2)
565
+ pearson_2 = get_pearson_symbol_from_prototype(prototype_label_2)
566
+ space_group_2 = get_space_group_number_from_prototype(prototype_label_2)
567
+ if (
568
+ len(stoich_reduced_list_1) != len(stoich_reduced_list_2)
569
+ or sum(stoich_reduced_list_1) != sum(stoich_reduced_list_2)
570
+ or pearson_1 != pearson_2
571
+ ):
572
+ return None
573
+
574
+ if allow_enantiomorph:
575
+ if not space_group_numbers_are_enantiomorphic(space_group_1, space_group_2):
576
+ return None
577
+ else:
578
+ if space_group_1 != space_group_2:
579
+ return None
580
+
561
581
  permutation_candidates = permutations(tuple(range(nspecies)))
562
582
  for permutation in permutation_candidates:
563
583
  # Permute the species
@@ -573,13 +593,14 @@ def find_species_permutation_between_prototype_labels(
573
593
  prototype_label_1_permuted_list = [
574
594
  abstract_formula_1_permuted,
575
595
  pearson_1,
576
- space_group_1,
596
+ space_group_1_str,
577
597
  ] + species_wyckoff_sections_1_permuted
578
598
  prototype_label_1_permuted = "_".join(prototype_label_1_permuted_list)
579
599
  if prototype_labels_are_equivalent(
580
600
  prototype_label_1=prototype_label_1_permuted,
581
601
  prototype_label_2=prototype_label_2,
582
602
  allow_enantiomorph=allow_enantiomorph,
603
+ log=log,
583
604
  ):
584
605
  return permutation
585
606
  return None
@@ -618,6 +639,23 @@ def read_shortnames(
618
639
  with open(info_file) as f:
619
640
  info = json.load(f)
620
641
  shortnames[libproto] = info["title"]
642
+
643
+ ##################################################
644
+ # CUSTOM MODIFICATIONS TO SHORTNAME DICT
645
+ ##################################################
646
+ # For some reason, CsCl is AB_cP2_221_a_b-002,
647
+ # while AB_cP2_221_a_b-001 is Ammonium Nitrate,
648
+ # where the atoms represent molecular ions
649
+ shortnames.pop("AB_cP2_221_a_b-001")
650
+
651
+ # I am making an executive decision to include
652
+ # only one identical cubic prototype with no
653
+ # free parameters. Here I am choosing to keep
654
+ # 'A7B_cF32_225_ad_b-001': 'Ca₇Ge Structure'
655
+ # and remove
656
+ # 'AB7_cF32_225_a_bd-001': '𝐿1ₐ (disputed CuPt₃ Structure)'
657
+ shortnames.pop("AB7_cF32_225_a_bd-001")
658
+
621
659
  return shortnames
622
660
 
623
661
 
kim_tools/ase/core.py CHANGED
@@ -32,13 +32,20 @@ Helper routines for KIM Tests and Verification Checks
32
32
  """
33
33
 
34
34
  import itertools
35
+ import logging
35
36
  import random
37
+ from typing import Union
36
38
 
37
39
  import numpy as np
38
40
  from ase import Atoms
41
+ from ase.calculators.calculator import Calculator
39
42
  from ase.calculators.kim.kim import KIM
40
43
  from ase.data import chemical_symbols
41
44
 
45
+ logger = logging.getLogger(__name__)
46
+ logging.basicConfig(filename="kim-tools.log", level=logging.INFO, force=True)
47
+
48
+
42
49
  __all__ = [
43
50
  "KIMASEError",
44
51
  "atom_outside_cell_along_nonperiodic_dim",
@@ -201,9 +208,18 @@ def randomize_positions(atoms, pert_amp, seed=None):
201
208
 
202
209
 
203
210
  ################################################################################
204
- def get_isolated_energy_per_atom(model, symbol):
211
+ def get_isolated_energy_per_atom(model: Union[str, Calculator], symbol):
205
212
  """
206
213
  Construct a non-periodic cell containing a single atom and compute its energy.
214
+
215
+ Args:
216
+ model:
217
+ A KIM model ID or an ASE calculator for computing the energy
218
+ symbol:
219
+ The chemical species
220
+
221
+ Returns:
222
+ The isolated energy of a single atom
207
223
  """
208
224
  single_atom = Atoms(
209
225
  symbol,
@@ -211,15 +227,33 @@ def get_isolated_energy_per_atom(model, symbol):
211
227
  cell=(20, 20, 20),
212
228
  pbc=(False, False, False),
213
229
  )
214
- calc = KIM(model)
230
+ if isinstance(model, str):
231
+ calc = KIM(model)
232
+ elif isinstance(model, Calculator):
233
+ calc = model
234
+ else:
235
+ raise KIMASEError(
236
+ "`model` argument must be a string indicating a KIM model "
237
+ f"or an ASE Calculator. Instead got an object of type {type(model)}."
238
+ )
215
239
  single_atom.calc = calc
216
- energy_per_atom = single_atom.get_potential_energy()
217
- if hasattr(calc, "clean"):
218
- calc.clean()
219
- if hasattr(calc, "__del__"):
220
- calc.__del__()
221
- del single_atom
222
- return energy_per_atom
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:
251
+ if hasattr(calc, "clean"):
252
+ calc.clean()
253
+ if hasattr(calc, "__del__"):
254
+ calc.__del__()
255
+ del single_atom
256
+ return energy_per_atom
223
257
 
224
258
 
225
259
  ################################################################################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kim-tools
3
- Version: 0.3.2
3
+ Version: 0.3.3
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>
@@ -1,7 +1,7 @@
1
- kim_tools/__init__.py,sha256=AhAW6unNWB_4jaiwxb0_XxUKtCv1rwG3CNqLk4aqqso,433
1
+ kim_tools/__init__.py,sha256=pnnfC__2WcTkgaE8RZU5AfDIx6PQOR9Dst7oBvYsMYI,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
- kim_tools/aflow_util/core.py,sha256=CsqN6MNVXE4QFrM0SxWhahTwu_gTeUXITk7ZMXLXfv0,75954
4
+ kim_tools/aflow_util/core.py,sha256=zi69wMcgkcYBTKbc-OvKlMIzUtgphO57yBA8LB7_5wc,77484
5
5
  kim_tools/aflow_util/aflow_prototype_encyclopedia/data/A108B24C11D24_cP334_222_h4i_i_bf_i-001/info.json,sha256=IsFiO9X2Ko7yoq2QkDurUVP7k1BE4WFgblu7oxl6iZs,2013
6
6
  kim_tools/aflow_util/aflow_prototype_encyclopedia/data/A10B11_tI84_139_dehim_eh2n-001/info.json,sha256=f1EdtouuSL2y9NNw40Rvz2J9ZZcsqQBcyEmlHj6XoW8,1186
7
7
  kim_tools/aflow_util/aflow_prototype_encyclopedia/data/A10B2C_hP39_171_5c_c_a-001/info.json,sha256=vD1xjZKWShL0E6XNsSlmIhilGcGNefl56oQDLQlHO1M,1596
@@ -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=d6eOu_HSxVr-ae0TSEbY4HKdePxhNu3yv8NN9VDl-BA,30256
2005
+ kim_tools/ase/core.py,sha256=KRtcNYcJLlP-WiEMOOmR-DhYw5IN5MoOCtKWJJzRkhM,31313
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
@@ -2015,8 +2015,8 @@ kim_tools/test_driver/__init__.py,sha256=KOiceeZNqkfrgZ66CiRiUdniceDrCmmDXQkOw0w
2015
2015
  kim_tools/test_driver/core.py,sha256=r4hiZcV-PkWcOo0uEqfqeP1-YGGpPepaAjmR4LJog0w,89208
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.2.dist-info/licenses/LICENSE.CDDL,sha256=I2luEED_SHjuZ01B4rYG-AF_135amL24JpHvZ1Jhqe8,16373
2019
- kim_tools-0.3.2.dist-info/METADATA,sha256=EAQFkPk6S0svLhGMBstoSj4Kk9vdzbIDATWefRyb8zE,1962
2020
- kim_tools-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2021
- kim_tools-0.3.2.dist-info/top_level.txt,sha256=w_YCpJ5ERigj9te74ln7k64tqj1VumOzM_s9dsalIWY,10
2022
- kim_tools-0.3.2.dist-info/RECORD,,
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,,