diff --git a/tests/core/test_surface.py b/tests/core/test_surface.py index f910efdfa03..9b5b00fc00c 100644 --- a/tests/core/test_surface.py +++ b/tests/core/test_surface.py @@ -25,7 +25,7 @@ from pymatgen.symmetry.groups import SpaceGroup from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest from pytest import approx - +from pymatgen.analysis.interfaces import CoherentInterfaceBuilder, SubstrateAnalyzer class TestSlab(PymatgenTest): def setUp(self): @@ -689,7 +689,7 @@ def test_previous_reconstructions(self): assert any(len(match.group_structures([struct, slab])) == 1 for slab in slabs) -class MillerIndexFinderTests(PymatgenTest): +class TestMillerIndexFinder(PymatgenTest): def setUp(self): self.cscl = Structure.from_spacegroup("Pm-3m", Lattice.cubic(4.2), ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]]) self.Fe = Structure.from_spacegroup("Im-3m", Lattice.cubic(2.82), ["Fe"], [[0, 0, 0]]) @@ -846,3 +846,41 @@ def test_miller_index_from_sites(self): s3 = np.array([1.1595, 0.66943764, 0.9065]) hkl = miller_index_from_sites(matrix, [s1, s2, s3]) assert hkl == (2, -1, 0) + +class TestCoherentInterfaceBuilder(unittest.TestCase): + + def setUp(self): + #build substrate & film structure + basis = [[0, 0, 0], [0.25, 0.25, 0.25]] + self.substrate = Structure( + Lattice.cubic(a=5.431), + ["Si", "Si"], + basis) + self.film = substrate = Structure( + Lattice.cubic(a=5.658), + ["Ge", "Ge"], + basis) + + def test_termination_searching(self): + sub_analyzer = SubstrateAnalyzer() + matches = list(sub_analyzer.calculate(substrate = self.substrate, film = self.film)) + cib = 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=1e-4,label_index=True,\ + filting_out_sym_slabs=False) + self.assertTrue(cib.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; the correct list should be: +[('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')]. +""") + +if __name__ == "__main__": + unittest.main()