Skip to content

Commit

Permalink
implemented full set of internal shifts
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-nikiforov-umn committed Feb 9, 2025
1 parent 9d25b13 commit 3fe2bb9
Show file tree
Hide file tree
Showing 10 changed files with 6,956 additions and 48 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
*.pyc
*.egg-info
*.egg
*scratch*

# PyPI-specific dirs
dist/
build/
dist-old/

# test stuff
*.log
*.log*
/tests/*.out*
/tests/*.err*
/tests/__pycache__/
/tests/*/__pycache__/
/tests/output/
/tests/output*/
26 changes: 15 additions & 11 deletions kim_tools/aflow_util/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from sympy import parse_expr,matrix2numpy,linear_eq_to_matrix,Symbol
from dataclasses import dataclass
from ..symmetry_util import are_in_same_wyckoff_set, space_group_numbers_are_enantiomorphic, \
WYCK_POS_XFORM_UNDER_NORMALIZER, WYCKOFF_MULTIPLICITIES, CENTERING_DIVISORS, C_CENTERED_ORTHORHOMBIC_GROUPS, A_CENTERED_ORTHORHOMBIC_GROUPS
WYCK_POS_XFORM_UNDER_NORMALIZER, WYCKOFF_MULTIPLICITIES, CENTERING_DIVISORS, C_CENTERED_ORTHORHOMBIC_GROUPS, A_CENTERED_ORTHORHOMBIC_GROUPS, \
POSSIBLE_PRIMITIVE_SHIFTS
from operator import attrgetter
from math import cos, acos, sqrt, radians, degrees
import logging
Expand Down Expand Up @@ -53,6 +54,14 @@
"AFLOW"
]

CENTROSYMMETRIC_SPACE_GROUPS_WITH_MORE_THAN_ONE_SETTING = (
48 , 50 , 59 , 68 , 70 ,
85 , 86 , 88 , 125 , 126 ,
129 , 130 , 133 , 134 , 137 ,
138 , 141 , 142 , 201 , 203 ,
222 , 224 , 227 , 228)


class incorrectNumAtomsException(Exception):
"""
Raised when the number of atoms in the atoms object or in the WYCCAR returned by aflow --sgdata does not match the number of atoms in the Pearson symbol of the prototype label
Expand Down Expand Up @@ -1200,7 +1209,6 @@ def solve_for_prototype_params(self, atoms: Atoms, equation_set_list: List[Equiv

if not prototype_labels_are_equivalent(prototype_label,prototype_label_detected):
logger.info(f'Redetected prototype label {prototype_label_detected} does not match nominal {prototype_label}, probably due to rounding.')
return None

# I believe we want the negative of the origin shift from atoms_rebuilt to atoms, because
# the origin shift is the last operation to happen, so it will be in the "atoms" frame
Expand All @@ -1215,18 +1223,15 @@ def solve_for_prototype_params(self, atoms: Atoms, equation_set_list: List[Equiv
# to a high-symmetry origin first
atoms_shifted = atoms.copy()
atoms_shifted.translate(-origin_shift)
logger.info(f'Shifting atoms by an initial shift {-origin_shift}')
logger.info(f'Shifting atoms by an initial cartesian shift {-origin_shift}')

# It's possible that the mapping between the rebuilt cell and the original cell included an internal translation.
# So we have to search over all of these as well to ensure the original equations match
internal_cartesian_translations = self.get_unique_internal_cartesian_translations_from_atoms(atoms_shifted)
space_group_number = get_space_group_number_from_prototype(prototype_label)

for internal_translation in internal_cartesian_translations:

for prim_shift in POSSIBLE_PRIMITIVE_SHIFTS[space_group_number]:
atoms_shifted = atoms.copy()
atoms_shifted.translate(-origin_shift)
atoms_shifted.translate(internal_translation)
logger.info(f'Shifting atoms by internal translation {internal_translation}')
atoms_shifted.translate(prim_shift@atoms_shifted.cell)
logger.info(f'Shifting atoms by internal fractional translation {prim_shift}')

atoms_shifted.wrap()

Expand All @@ -1235,7 +1240,6 @@ def solve_for_prototype_params(self, atoms: Atoms, equation_set_list: List[Equiv
if len(position_set_list) != len(equation_set_list):
raise inconsistentWyckoffException('Number of equivalent positions detected in Atoms object did not match the number of equivalent equations given')

space_group_number = get_space_group_number_from_prototype(prototype_label)
free_params_dict = {}
position_set_matched_list = [False]*len(position_set_list)

Expand Down
Loading

0 comments on commit 3fe2bb9

Please sign in to comment.