Skip to content

Commit

Permalink
fix structure_to_abivars() for non-hexagonal structures
Browse files Browse the repository at this point in the history
not calling structure.lattice.is_hexagonal()
  • Loading branch information
janosh committed Jan 17, 2024
1 parent f202b79 commit 8b893ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pymatgen/core/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ def is_hexagonal(self, hex_angle_tol: float = 5, hex_length_tol: float = 0.01) -
angles = self.angles
right_angles = [i for i in range(3) if abs(angles[i] - 90) < hex_angle_tol]
hex_angles = [
i for i in range(3) if abs(angles[i] - 60) < hex_angle_tol or abs(angles[i] - 120) < hex_angle_tol
idx for idx in range(3) if abs(angles[idx] - 60) < hex_angle_tol or abs(angles[idx] - 120) < hex_angle_tol
]

return (
Expand Down
14 changes: 7 additions & 7 deletions pymatgen/io/abinit/abiobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def structure_to_abivars(

if enforce_order:
znucl_type = enforce_znucl
typat = enforce_typat or []
typat = enforce_typat or [] # or [] added for mypy
else:
types_of_specie = species_by_znucl(structure)

Expand Down Expand Up @@ -255,11 +255,11 @@ def structure_to_abivars(
}

# Add info on the lattice.
# Should we use (rprim, acell) or (angdeg, acell) to specify the lattice?
# Should we use (rprim, acell) or (ang_deg, acell) to specify the lattice?
geo_mode = kwargs.pop("geomode", "rprim")
if geo_mode == "automatic":
geo_mode = "rprim"
if structure.lattice.is_hexagonal: # or structure.lattice.is_rhombohedral
if structure.lattice.is_hexagonal(): # or structure.lattice.is_rhombohedral
geo_mode = "angdeg"
ang_deg = structure.lattice.angles
# Here one could polish a bit the numerical values if they are not exact.
Expand All @@ -283,15 +283,15 @@ def structure_to_abivars(
return dct


def contract(s):
def contract(string):
"""
assert contract("1 1 1 2 2 3") == "3*1 2*2 1*3"
assert contract("1 1 3 2 3") == "2*1 1*3 1*2 1*3"
"""
if not s:
return s
if not string:
return string

tokens = s.split()
tokens = string.split()
old = tokens[0]
count = [[1, old]]

Expand Down

0 comments on commit 8b893ef

Please sign in to comment.