Error while get_slabs() is symmetrizing the surface

Hello,
I’m following a tutorial to generate the surface slab model:
https://matgenb.materialsvirtuallab.org/2017/04/03/Slab-generation-and-Wulff-shape.html

But, the error occurs when the code attempts to symmetrize the slab while it generates the Ni(111) surface.
When I tried the same procedure with different materials (or structures), the same error occurs.
Any comments would be appreciated!

I used the following script:
from pymatgen.core.structure import Structure
from pymatgen.core.surface import Lattice, SlabGenerator, generate_all_slabs
lattice = Lattice.cubic(3.508)
Ni = Structure(
lattice,
[“Ni”, “Ni”, “Ni”, “Ni”],
[[0, 0, 0], [0, 0.5, 0], [0.5, 0, 0], [0, 0, 0.5]],
)
slabgen = SlabGenerator(Ni, (1, 1, 1), 10, 10)
slabs = slabgen.get_slabs()

Error:
AttributeError Traceback (most recent call last)
Input In [13], in <cell line: 38>()
32 Ni = Structure(
33 lattice,
34 [“Ni”, “Ni”, “Ni”, “Ni”],
35 [[0, 0, 0], [0, 0.5, 0], [0.5, 0, 0], [0, 0, 0.5]],
36 )
37 slabgen = SlabGenerator(Ni, (1, 1, 1), 10, 10)
—> 38 slabs = slabgen.get_slabs()

File C:\ProgramData\Miniconda3\envs\screening\lib\site-packages\pymatgen\core\surface.py:1150, in SlabGenerator.get_slabs(self, bonds, ftol, tol, max_broken_bonds, symmetrize, repair)
1147 m = StructureMatcher(ltol=tol, stol=tol, primitive_cell=False, scale=False)
1149 new_slabs = []
→ 1150 for g in m.group_structures(slabs):
1151 # For each unique termination, symmetrize the
1152 # surfaces by removing sites from the bottom.
1153 if symmetrize:
1154 slabs = self.nonstoichiometric_symmetrized_slab(g[0])

File C:\ProgramData\Miniconda3\envs\screening\lib\site-packages\pymatgen\analysis\structure_matcher.py:848, in StructureMatcher.group_structures(self, s_list, anonymous)
843 else:
844 inds = filter(
845 lambda i: self.fit(refs, unmatched[i][1], skip_structure_reduction=True),
846 list(range(len(unmatched))),
847 )
→ 848 inds = list(inds)
849 matches.extend([unmatched[i][0] for i in inds])
850 unmatched = [unmatched[i] for i in range(len(unmatched)) if i not in inds]

File C:\ProgramData\Miniconda3\envs\screening\lib\site-packages\pymatgen\analysis\structure_matcher.py:845, in StructureMatcher.group_structures..(i)
839 inds = filter(
840 lambda i: self.fit_anonymous(refs, unmatched[i][1], skip_structure_reduction=True),
841 list(range(len(unmatched))),
842 )
843 else:
844 inds = filter(
→ 845 lambda i: self.fit(refs, unmatched[i][1], skip_structure_reduction=True),
846 list(range(len(unmatched))),
847 )
848 inds = list(inds)
849 matches.extend([unmatched[i][0] for i in inds])

File C:\ProgramData\Miniconda3\envs\screening\lib\site-packages\pymatgen\analysis\structure_matcher.py:609, in StructureMatcher.fit(self, struct1, struct2, symmetric, skip_structure_reduction)
605 if not symmetric:
606 struct1, struct2, fu, s1_supercell = self._preprocess(
607 struct1, struct2, skip_structure_reduction=skip_structure_reduction
608 )
→ 609 match = self._match(struct1, struct2, fu, s1_supercell, break_on_match=True)
610 if match is None:
611 return False

File C:\ProgramData\Miniconda3\envs\screening\lib\site-packages\pymatgen\analysis\structure_matcher.py:709, in StructureMatcher._match(self, struct1, struct2, fu, s1_supercell, use_rms, break_on_match)
707 ratio = fu if s1_supercell else 1 / fu
708 if len(struct1) * ratio >= len(struct2):
→ 709 return self._strict_match(
710 struct1,
711 struct2,
712 fu,
713 s1_supercell=s1_supercell,
714 break_on_match=break_on_match,
715 use_rms=use_rms,
716 )
717 return self._strict_match(
718 struct2,
719 struct1,
(…)
723 use_rms=use_rms,
724 )

File C:\ProgramData\Miniconda3\envs\screening\lib\site-packages\pymatgen\analysis\structure_matcher.py:760, in StructureMatcher._strict_match(self, struct1, struct2, fu, s1_supercell, use_rms, break_on_match)
757 if (not self._subset) and mask.shape[1] != mask.shape[0]:
758 return None
→ 760 if LinearAssignment(mask).min_cost > 0: # pylint: disable=E1101
761 return None
763 best_match = None

File pymatgen\optimization\linear_assignment.pyx:72, in pymatgen.optimization.linear_assignment.LinearAssignment.init()

File C:\ProgramData\Miniconda3\envs\screening\lib\site-packages\numpy_init_.py:284, in getattr(attr)
281 from .testing import Tester
282 return Tester
→ 284 raise AttributeError("module {!r} has no attribute "
285 “{!r}”.format(name, attr))

AttributeError: module ‘numpy’ has no attribute ‘int’

Hey @Soonho,

The snippet you posted is working fine for me. I suspect that your numpy installation might be the issue here.