diff --git a/src/pymatgen/analysis/interfaces/coherent_interfaces.py b/src/pymatgen/analysis/interfaces/coherent_interfaces.py index de58e9d58b5..c189511337b 100644 --- a/src/pymatgen/analysis/interfaces/coherent_interfaces.py +++ b/src/pymatgen/analysis/interfaces/coherent_interfaces.py @@ -32,7 +32,7 @@ def __init__( film_miller: tuple[int, int, int], substrate_miller: tuple[int, int, int], zslgen: ZSLGenerator | None = None, - termination_ftol: float = 0.25, + termination_ftol: float | tuple[float, float] = 0.25, label_index: bool = False, # necessary to add index to termination filter_out_sym_slabs: bool = True, ): @@ -43,7 +43,8 @@ def __init__( film_miller (tuple[int, int, int]): miller index for the film layer substrate_miller (tuple[int, int, int]): miller index for the substrate layer zslgen (ZSLGenerator | None): BiDirectionalZSL if you want custom lattice matching tolerances for coherency. - termination_ftol (float): tolerance to distinguish different terminating atomic planes. + termination_ftol (float | tuple[float, float]): tolerances (film, substrate) to distinguish + different terminating atomic planes. label_index (bool): If True add an extra index at the beginning of the termination label. filter_out_sym_slabs (bool): If True filter out identical slabs with different terminations. This might need to be set as False to find more non-identical terminations because slab @@ -133,24 +134,33 @@ def _find_terminations(self): reorient_lattice=False, # This is necessary to not screw up the lattice ) - film_slabs = film_sg.get_slabs(ftol=self.termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs) - sub_slabs = sub_sg.get_slabs(ftol=self.termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs) + if isinstance(self.termination_ftol, tuple): + self.film_termination_ftol, self.substrate_termination_ftol = self.termination_ftol + else: + self.film_termination_ftol = self.substrate_termination_ftol = self.termination_ftol + + film_slabs = film_sg.get_slabs(ftol=self.film_termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs) + sub_slabs = sub_sg.get_slabs( + ftol=self.substrate_termination_ftol, filter_out_sym_slabs=self.filter_out_sym_slabs + ) film_shifts = [slab.shift for slab in film_slabs] if self.label_index: film_terminations = [ - label_termination(slab, self.termination_ftol, t_idx) for t_idx, slab in enumerate(film_slabs, start=1) + label_termination(slab, self.film_termination_ftol, t_idx) + for t_idx, slab in enumerate(film_slabs, start=1) ] else: - film_terminations = [label_termination(slab, self.termination_ftol) for slab in film_slabs] + film_terminations = [label_termination(slab, self.film_termination_ftol) for slab in film_slabs] sub_shifts = [slab.shift for slab in sub_slabs] if self.label_index: sub_terminations = [ - label_termination(slab, self.termination_ftol, t_idx) for t_idx, slab in enumerate(sub_slabs, start=1) + label_termination(slab, self.substrate_termination_ftol, t_idx) + for t_idx, slab in enumerate(sub_slabs, start=1) ] else: - sub_terminations = [label_termination(slab, self.termination_ftol) for slab in sub_slabs] + sub_terminations = [label_termination(slab, self.substrate_termination_ftol) for slab in sub_slabs] self._terminations = { (film_label, sub_label): (film_shift, sub_shift) diff --git a/tests/analysis/interfaces/test_coherent_interface.py b/tests/analysis/interfaces/test_coherent_interface.py index 9f578f30c32..4cb5a113bf1 100644 --- a/tests/analysis/interfaces/test_coherent_interface.py +++ b/tests/analysis/interfaces/test_coherent_interface.py @@ -59,7 +59,7 @@ def setup_method(self): def test_termination_searching(self): sub_analyzer = SubstrateAnalyzer() matches = list(sub_analyzer.calculate(substrate=self.substrate, film=self.film)) - cib = CoherentInterfaceBuilder( + cib1 = CoherentInterfaceBuilder( film_structure=self.film, substrate_structure=self.substrate, film_miller=matches[0].film_miller, @@ -69,9 +69,24 @@ def test_termination_searching(self): label_index=True, filter_out_sym_slabs=False, ) - assert cib.terminations == [ + cib2 = CoherentInterfaceBuilder( + film_structure=self.film, + substrate_structure=self.substrate, + film_miller=matches[0].film_miller, + substrate_miller=matches[0].substrate_miller, + zslgen=sub_analyzer, + termination_ftol=(2, 0.1), + label_index=True, + filter_out_sym_slabs=False, + ) + assert cib1.terminations == [ ("1_Ge_P4/mmm_1", "1_Si_P4/mmm_1"), ("1_Ge_P4/mmm_1", "2_Si_P4/mmm_1"), ("2_Ge_P4/mmm_1", "1_Si_P4/mmm_1"), ("2_Ge_P4/mmm_1", "2_Si_P4/mmm_1"), - ], "termination results wrong" + ], "cib1 termination results wrong" + + assert cib2.terminations == [ + ("1_Ge_C2/m_2", "1_Si_P4/mmm_1"), + ("1_Ge_C2/m_2", "2_Si_P4/mmm_1"), + ], "cib2 termination results wrong"