Exemplo n.º 1
0
    def test_surface(self):
        """Test the helper surface generator."""
        slab = surface('Pd', size=(2, 2, 4), vacuum=10)

        # Slab should have 16 Pd atoms
        assert (len(slab) == 16)

        correct_connectivity = np.array(
            [[0, 2, 2, 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
             [2, 0, 2, 2, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
             [2, 2, 0, 2, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
             [2, 2, 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
             [0, 1, 1, 1, 0, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0],
             [1, 0, 1, 1, 2, 0, 2, 2, 1, 1, 0, 1, 0, 0, 0, 0],
             [1, 1, 0, 1, 2, 2, 0, 2, 1, 0, 1, 1, 0, 0, 0, 0],
             [1, 1, 1, 0, 2, 2, 2, 0, 0, 1, 1, 1, 0, 0, 0, 0],
             [0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 1, 1, 1, 0],
             [0, 0, 0, 0, 1, 1, 0, 1, 2, 0, 2, 2, 1, 1, 0, 1],
             [0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 2, 1, 0, 1, 1],
             [0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 1],
             [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2],
             [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 2, 0, 2, 2],
             [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 0, 2],
             [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0]])
        assert_array_equal(slab.connectivity, correct_connectivity)

        correct_surf_atoms = np.array([12, 13, 14, 15])
        assert_array_equal(slab.get_surface_atoms(), correct_surf_atoms)

        # Test the ability to pass an atoms object
        atoms = bulk('Pd', cubic=True)
        slab = surface(atoms, size=(2, 2, 4), vacuum=10)
Exemplo n.º 2
0
    def test_nonlocal_fingerprinting(self):
        """Test the non-local fingerprint example"""
        atoms = bulk('Pd', cubic=True)
        atoms[3].symbol = 'Pt'

        slab = surface('Al', size=(2, 2, 3), a=3.8, vacuum=10)

        images = [atoms, slab]

        parameters = [
            'atomic_number',
            'atomic_radius',
            'atomic_volume',
        ]

        operations = [
            'periodic_convolution',
            ['periodic_convolution', {'d': 1}]
        ]

        fp = Fingerprinter(images)
        fingerprints = fp.get_fp(parameters, operations)

        truth = np.array([
            [12432.0, 7.562800000000001, 320.44, 136896.0, 90.7488, 3844.8],
            [2028.0, 24.53879999999999, 1200.0, 20280.0, 245.388, 12000.0]])

        np.testing.assert_allclose(fingerprints, truth)
Exemplo n.º 3
0
    def test_surface(self):
        """Test catkit.build.surface generator."""
        slab = surface('Pd', size=(2, 2, 4), vacuum=10)

        # Slab should have 16 Pd atoms
        assert (len(slab) == 16)
        degree = slab.degree

        test_degree = np.array(
            [9, 9, 9, 9, 12, 12, 12, 12, 12, 12, 12, 12, 9, 9, 9, 9])

        assert_array_equal(degree, test_degree)

        correct_surf_atoms = np.array([12, 13, 14, 15])
        assert_array_equal(slab.get_surface_atoms(), correct_surf_atoms)

        # Test the ability to pass an atoms object
        atoms = bulk('Pd', cubic=True)
        slab = surface(atoms, size=(2, 2, 4), vacuum=10)

        # Test orthogonalization search
        slab = surface(atoms, size=(1, 4), vacuum=10)
Exemplo n.º 4
0
    def test_surface_examples(self):
        """Test surface construction examples."""
        atoms = bulk('Pd', 'fcc', a=4, cubic=True)
        atoms[3].symbol = 'Cu'

        gen = SlabGenerator(
            atoms, miller_index=(2, 1, 1), layers=6, fixed=5, vacuum=4)

        terminations = gen.get_unique_terminations()
        assert (len(terminations) == 2)

        for i, t in enumerate(terminations):
            slab = gen.get_slab(iterm=i)
            assert (len(slab) == 16)

        atoms = surface('Pd', size=(3, 3), miller=(1, 1, 1), vacuum=4)
        con_matrix = atoms.connectivity

        test_con_matrix = np.array([
            [0, 3, 3, 1, 1, 1, 0, 0, 0],
            [3, 0, 3, 1, 1, 1, 0, 0, 0],
            [3, 3, 0, 1, 1, 1, 0, 0, 0],
            [1, 1, 1, 0, 3, 3, 1, 1, 1],
            [1, 1, 1, 3, 0, 3, 1, 1, 1],
            [1, 1, 1, 3, 3, 0, 1, 1, 1],
            [0, 0, 0, 1, 1, 1, 0, 3, 3],
            [0, 0, 0, 1, 1, 1, 3, 0, 3],
            [0, 0, 0, 1, 1, 1, 3, 3, 0]])

        np.testing.assert_allclose(con_matrix, test_con_matrix)

        test_surf_atoms = np.array([6, 7, 8])
        np.testing.assert_allclose(atoms.get_surface_atoms(), test_surf_atoms)

        atoms = bulk('Pd', 'fcc', a=5, cubic=True)
        atoms[3].symbol = 'Cu'

        gen = SlabGenerator(
            atoms, miller_index=(1, 1, 1), layers=3, layer_type='trim',
            fixed=2, vacuum=10)

        atoms = gen.get_slab()
        coordinates, connectivity = gen.adsorption_sites(atoms)

        test_connectivity = np.array([1, 1, 2, 2, 2, 3, 3, 3, 3])
        np.testing.assert_allclose(connectivity, test_connectivity)