Example #1
0
    def test_matrix_notation_search(self):
        """Test the matrix notation algorithm."""
        atoms = bulk('Pd', 'fcc', cubic=True)
        gen = SlabGenerator(atoms, miller_index=(1, 1, 1), layers=6)

        gen.get_slab(size=1)
        gen.get_slab(size=[[1, 0], [0, 1]])
Example #2
0
    def test_terminations(self):
        """Test termination finding on fcc(211)."""
        atoms = bulk('Pd', 'fcc', a=4, cubic=True)
        atoms[3].symbol = 'Cu'

        gen = SlabGenerator(atoms, miller_index=(2, 1, 1), layers=8, vacuum=4)

        gen.get_slab(iterm=1)
Example #3
0
def test_adsorption_examples():
    atoms = bulk('Pd', 'fcc', a=5, cubic=True)
    atoms[3].symbol = 'Cu'

    gen = SlabGenerator(atoms, miller_index=(1, 1, 1), layers=3, vacuum=4)

    atoms = gen.get_slab(primitive=True)
    atoms.set_surface_atoms([8, 9, 10, 11])

    sites = AdsorptionSites(atoms)
    sites.plot('./Pd3Cu-adsorption-sites.png')

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

    gen = SlabGenerator(atoms, miller_index=(3, 2, 1), layers=13, vacuum=5)

    atoms = gen.get_slab(primitive=True)

    top, _ = gen.get_voronoi_surface_atoms(atoms)
    atoms.set_surface_atoms(top)
    sites = AdsorptionSites(atoms)

    coordinates = sites.get_coordinates()
    assert (len(coordinates) == 56)
    connectivity = sites.get_connectivity()
    test_connectivity = np.array([
        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
        3, 3, 3, 3, 3, 3, 4, 4
    ])
    np.testing.assert_allclose(connectivity, test_connectivity)

    topology = sites.get_topology()
    assert (len(topology) == 56)

    periodic = sites.get_periodic_sites()
    symmetric = sites.get_symmetric_sites()
    print(periodic)
    np.testing.assert_allclose(symmetric, periodic)

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

    gen = SlabGenerator(atoms, miller_index=(2, 1, 1), layers=10, vacuum=5)

    atoms = gen.get_slab(primitive=True)

    top, _ = gen.get_voronoi_surface_atoms(atoms, attach_graph=False)
    atoms.set_surface_atoms(top)
    sites = AdsorptionSites(atoms)

    coordinates = sites.get_coordinates()
    vectors = sites.get_adsorption_vectors(unique=False)
    assert (len(vectors) == 32)
Example #4
0
    def test_adsorption_examples(self):
        """Test adsorption structure examples."""
        atoms = bulk('Pd', 'fcc', a=5, cubic=True)
        atoms[3].symbol = 'Cu'

        gen = SlabGenerator(atoms, miller_index=(1, 1, 1), layer_type='trim',
                            layers=3, vacuum=4)

        atoms = gen.get_slab()

        sites = AdsorptionSites(atoms)
        sites.plot('./Pd3Cu-adsorption-sites.png')

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

        gen = SlabGenerator(atoms, miller_index=(3, 2, 1), layers=8, vacuum=5)

        atoms = gen.get_slab()
        sites = AdsorptionSites(atoms)

        coordinates = sites.get_coordinates()
        assert (len(coordinates) == 56)
        connectivity = sites.get_connectivity()
        test_connectivity = np.array([
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
            2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4])
        np.testing.assert_allclose(connectivity, test_connectivity)

        topology = sites.get_topology()
        assert (len(topology) == 56)

        periodic = sites.get_periodic_sites()
        symmetric = sites.get_symmetric_sites()
        np.testing.assert_allclose(symmetric, periodic)

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

        gen = SlabGenerator(atoms, miller_index=(2, 1, 1), layers=8, vacuum=5)

        atoms = gen.get_slab()
        sites = AdsorptionSites(atoms)

        coordinates = sites.get_coordinates()
        vectors = sites.get_adsorption_vectors(unique=False)
        assert (len(vectors) == 32)
Example #5
0
def cut_slab_catkit(
    bulk,
    facet,
    slab_thickness=6,
    vacuum=8.,
    ):
    """Cut slab from bulk using CatKit.

    Args:
        bulk:
        facet:
    """
    # | - cut_slab_catkit
    gen = SlabGenerator_catkit(
        bulk,
        miller_index=facet,
        layers=slab_thickness,
        vacuum=vacuum,
        fixed=2,
        layer_type='ang',
        # attach_graph=True,
        standardize_bulk=False,
        tol=1e-8
        )

    terminations = gen.get_unique_terminations()

    images = []
    for i, t in enumerate(terminations):
        images += [gen.get_slab(iterm=i, size=1)]

    # view(images)

    return(images)
Example #6
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)
Example #7
0
def test_surface_generator():
    atoms = bulk('Pd', 'fcc', a=4, cubic=True)

    # A variety of slab tests
    gen = SlabGenerator(atoms, miller_index=(1, 0, 0), layers=6, vacuum=4)

    gen = SlabGenerator(atoms, miller_index=(1, 1, 0), layers=6, vacuum=4)

    gen = SlabGenerator(atoms, miller_index=(0, 0, 1), layers=6, vacuum=4)

    # Test automatic termination finding
    atoms = bulk('Pd', 'fcc', a=4, cubic=True)
    atoms[3].symbol = 'Cu'

    gen = SlabGenerator(atoms, miller_index=(2, 1, 1), min_width=10, vacuum=4)

    gen.get_slab(iterm=1)
def get_struct(symbol='Ag2Au2', adsorbate='OH', SB_symbol='L10', a=4, c=3):
    """It returns the structure generated with catkit
       using the keyword given."""
    size = (1, 1)
    layers = 3
    miller = (1, 1, 1)
    vacuum = 10
    get_height = dict([('C', 1.0), ('O', 1.0), ('N', 1.0), ('S', 1.0),
                       ('H', 1.0)])
    if adsorbate in ['CH', 'OH', 'NH', 'SH']:
        tags = [-1, -2]
        n_atoms = 14
    elif adsorbate in ['CH2', 'OH2']:
        tags = [-1, -2, -2]
        n_atoms = 15
    elif adsorbate == 'CH3':
        tags = [-1, -2, -2, -2]
        n_atoms = 16
    else:
        tags = [-1]
        n_atoms = 13
    data = np.load('bulk_data.npy')[()]

    if '2' in symbol:
        m1, m2, _ = symbol.split('2')
        b = bulk(m1, cubic=True, crystalstructure='fcc', a=a, c=c)
        b[2].symbol = m2
        b[3].symbol = m2
    elif '3' in symbol:
        m1, m2 = symbol.split('3')
        b = bulk(m1, cubic=True, crystalstructure='fcc', a=a, c=c)
        b[3].symbol = m2
    else:
        b = bulk(symbol, cubic=True, crystalstructure='fcc', a=a, c=c)

    gen = SlabGenerator(b,
                        miller_index=miller,
                        vacuum=vacuum,
                        layers=layers,
                        fixed=2,
                        layer_type='trim',
                        standardize_bulk=False,
                        primitive=False)

    terminations = gen.get_unique_terminations()
    if len(terminations) > 1:
        raise IncosistencyError('There are more than one temrination.')

    slab = gen.get_slab(size=size, iterm=-1)
    mm = {'Fe': 3, 'Ni': 1, 'Co': 1, 'Mn': 1}
    slab.set_initial_magnetic_moments(
        [mm.get(i, 0) for i in slab.get_chemical_symbols()])

    adsorbate = molecule(adsorbate)[0]
    adsorbate.set_tags(tags)
    builder = Builder(slab)
    structures = builder.add_adsorbate(adsorbate, index=-1)
    return structures
Example #9
0
def create_slab_from_bulk_tmp(atoms=None, facet=None):
    """
    """
    #| - create_slab_from_bulk
    # SG = SlabGenerator(
    #     atoms, facet, 20, vacuum=15,
    #     fixed=None, layer_type='ang',
    #     attach_graph=True,
    #     standardize_bulk=True,
    #     primitive=True, tol=1e-03)

    SG = SlabGenerator(
        atoms,
        facet,

        20,
        vacuum=15,
        fixed=None,
        layer_type="sym",
        attach_graph=True,
        standardize_bulk=True,
        primitive=True,
        tol=1e-03,
        )

    # print("TEMP", "SlabGenerator:", SlabGenerator)

    slab_i = SG.get_slab()
    slab_i.set_pbc([True, True, True])


    # #############################################
    # Write slab to file ##########################
    directory = "out_data"
    if not os.path.exists(directory):
        os.makedirs(directory)

    assert False, "Fix os.makedirs"

    # TEMP write to file
    path_i = os.path.join("out_data", "temp.cif")
    slab_i.write(path_i)

    # Rereading the structure file to get it back into ase format
    slab_i = io.read(path_i)
    # data_dict_i["slab_0"] = slab_i

    return(slab_i)
Example #10
0
def create_slab_from_bulk(atoms=None, facet=None, layers=20):
    """Create slab from bulk atoms object and facet.

    Args:
        atoms (ASE atoms object): ASE atoms object of bulk structure.
        facet (str): Facet cut
        layers (int): Number of layers
    """
    #| - create_slab_from_bulk
    SG = SlabGenerator(
        atoms,
        facet,
        layers,
        vacuum=15,
        # atoms, facet, 20, vacuum=15,
        fixed=None,
        layer_type='ang',
        attach_graph=True,
        standardize_bulk=True,
        primitive=True,
        tol=1e-03)

    # print("TEMP", "SlabGenerator:", SlabGenerator)

    slab_i = SG.get_slab()
    slab_i.set_pbc([True, True, True])

    # #############################################
    # Write slab to file ##########################
    # directory = "out_data"
    directory = os.path.join(os.environ["PROJ_irox_oer"],
                             "workflow/creating_slabs", "out_data")
    # assert False, "Fix os.makedirs"
    if not os.path.exists(directory):
        os.makedirs(directory)

    path_i = os.path.join("out_data", "temp.cif")
    slab_i.write(path_i)

    # Rereading the structure file to get it back into ase format
    slab_i = io.read(path_i)
    # data_dict_i["slab_0"] = slab_i

    return (slab_i)
Example #11
0
def test_surface_examples():
    atoms = bulk('Pd', 'fcc', a=4, cubic=True)
    atoms[3].symbol = 'Cu'

    gen = SlabGenerator(atoms,
                        miller_index=(2, 1, 1),
                        layers=9,
                        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) == 18)

    atoms = bulk('Pd', 'hcp', a=3, cubic=True)

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

    atoms = gen.get_slab()
    con_matrix = gen.get_graph_from_bulk(atoms, attach=True)

    test_con_matrix = np.array(
        [[0.0, 2.0, 2.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [2.0, 0.0, 2.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [2.0, 2.0, 0.0, 2.0, 2.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0],
         [2.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0],
         [1.0, 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 2.0, 1.0, 0.0, 0.0, 0.0],
         [0.0, 1.0, 2.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 1.0, 0.0, 0.0],
         [0.0, 0.0, 1.0, 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 2.0, 1.0, 0.0],
         [0.0, 0.0, 0.0, 1.0, 2.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 1.0],
         [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 2.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 2.0, 2.0, 0.0, 2.0, 2.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 2.0, 0.0, 2.0],
         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 2.0, 2.0, 0.0]])

    np.testing.assert_allclose(con_matrix, test_con_matrix)

    # We can identify both top and bottom sites.
    top, bottom = gen.get_voronoi_surface_atoms(atoms)
    atoms.set_surface_atoms(top)

    test_surf_atoms = np.array([8, 9, 10, 11])
    np.testing.assert_allclose(top, 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,
                        fixed=2,
                        vacuum=10)

    atoms = gen.get_slab(primitive=True)
    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)
Example #12
0
bare = []
coordinates = []
connectivity = []

Cu_N_ads = {}

for idx, term in enumerate(terminations):
    gen = SlabGenerator(atoms_bulk,
                        miller_index=miller_indices[idx],
                        layers=layers[idx],
                        fixed=fixed[idx],
                        vacuum=10,
                        standardize_bulk=True,
                        layer_type="trim")

    prim = gen.get_slab()
    supercell = prim.repeat(sizes[idx])
    #print(supercell.get_cell())
    primitive.append(prim)
    bare.append(supercell)
    coords_tmp, connect_tmp = gen.adsorption_sites(prim)
    coordinates.append(coords_tmp)
    connectivity.append(connect_tmp)

    list_ads = next_ads(bare[-1], [1, 1], primitive[-1].get_cell(),
                        coordinates[-1])
    Cu_N_ads.update({term: {'1N': list_ads}})
    print("Termination (" + term +
          ") 1N Adsorption: %d structures" % len(Cu_N_ads[term]['1N']))

# Data structure
Example #13
0
def get_struct(symbol='Ag2Au2',
               adsorbate='C',
               site='hollow',
               site_type='Ag_Ag_Au|FCC',
               SB_symbol='L10'):
    """It returns the structure generated with catkit
       using the keyword given."""
    size = (1, 1)
    layers = 3
    miller = (1, 1, 1)
    vacuum = 10
    get_height = dict([('C', 1.0), ('O', 1.0), ('N', 1.0), ('S', 1.0),
                       ('H', 1.0)])
    if adsorbate in ['CH', 'OH', 'NH', 'SH']:
        tags = [-1, -2]
        n_atoms = 14
    elif adsorbate in ['CH2', 'OH2']:
        tags = [-1, -2, -2]
        n_atoms = 15
    elif adsorbate == 'CH3':
        tags = [-1, -2, -2, -2]
        n_atoms = 16
    else:
        tags = [-1]
        n_atoms = 13
    data = np.load('bulk_data.npy')[()]

    try:
        a = data[symbol]['a']
        c = data[symbol]['c']
    except KeyError:
        if '2' in symbol:
            m1, m2, _ = symbol.split('2')
            try:
                a = data[m1 + '2' + m2 + '2']['a']
                c = data[m1 + '2' + m2 + '2']['c']
            except KeyError:
                a = data[m2 + '2' + m1 + '2']['a']
                c = data[m2 + '2' + m1 + '2']['c']

    if '2' in symbol:
        m1, m2, _ = symbol.split('2')
        name = m1 + '2' + m2 + '2'
        b = Atoms(name,
                  scaled_positions=[(0, 0, 0), (0.5, 0.5, 0), (0.5, 0, 0.5),
                                    (0, 0.5, 0.5)],
                  cell=[a, a, c],
                  pbc=True)
        b.set_pbc((1, 1, 1))
    elif '3' in symbol:
        m1, m2 = symbol.split('3')
        b = bulk(m1, cubic=True, crystalstructure='fcc', a=a, c=c)
        b[3].symbol = m2
    else:
        b = bulk(symbol, cubic=True, crystalstructure='fcc', a=a, c=c)

    gen = SlabGenerator(b,
                        miller_index=miller,
                        vacuum=vacuum,
                        layers=layers,
                        fixed=2,
                        layer_type='trim',
                        standardize_bulk=False,
                        primitive=False)

    terminations = gen.get_unique_terminations()
    if len(terminations) > 1:
        raise IncosistencyError('There are more than one temrination.')

    slab = gen.get_slab(size=size, iterm=-1)
    mm = {'Fe': 3, 'Ni': 1, 'Co': 1, 'Mn': 1}
    slab.set_initial_magnetic_moments(
        [mm.get(i, 0) for i in slab.get_chemical_symbols()])
    ads_slab = slab.copy()
    coords, conn = gen.adsorption_sites(slab)
    if site == 'top':
        si = 1
    if site == 'bridge':
        si = 2
    if site == 'hollow':
        si = 3

    adsorbate = molecule(adsorbate)[0]
    adsorbate.set_tags(tags)
    builder = Builder(slab)
    structures = builder.add_adsorbate(adsorbate, index=-1)
    ads_slab = None
    for struct in structures:
        connectivity = struct.connectivity
        connectivity = connectivity[~(connectivity == 0).all(1)]
        if n_atoms == 13:
            ads_conn = np.array(connectivity[:, -1]).reshape(n_atoms).sum()
            ads_site = [
                i
                for i, j in zip(struct.get_chemical_symbols(),
                                np.array(connectivity[:, -1]).reshape(n_atoms))
                if j == 1
            ]
        if n_atoms == 14:
            ads_conn = np.array(connectivity[:, -2]).reshape(n_atoms).sum() - 1
            ads_site = [
                i for i, j in zip(
                    struct.get_chemical_symbols(),
                    np.array(connectivity[:, -2]).reshape(n_atoms)[:13])
                if j == 1
            ]
        if n_atoms == 15:
            ads_conn = np.array(connectivity[:, -3]).reshape(n_atoms).sum() - 2
            ads_site = [
                i for i, j in zip(
                    struct.get_chemical_symbols(),
                    np.array(connectivity[:, -3]).reshape(n_atoms)[:13])
                if j == 1
            ]
        if n_atoms == 16:
            ads_conn = np.array(connectivity[:, -4]).reshape(n_atoms).sum() - 3
            ads_site = [
                i for i, j in zip(
                    struct.get_chemical_symbols(),
                    np.array(connectivity[:, -4]).reshape(n_atoms)[:13])
                if j == 1
            ]

        if si != ads_conn:
            continue
        if SB_symbol == 'A1':
            if si == 1 or si == 2:
                ads_slab = struct
            else:
                if get_under_hollow(struct[:13]) == site_type.split('|')[1]:
                    ads_slab = struct
        else:
            if si == 1:
                if ads_site[0] == site_type:
                    ads_slab = struct
            elif si == 3:
                hol = get_under_hollow(struct[:13])
                a, b = site_type.split('|')
                a = a.split('_')
                if Counter(ads_site) == Counter(a) and b == hol:
                    ads_slab = struct
            else:
                if SB_symbol == 'L10':
                    if '|' not in site_type:
                        if len(set(ads_site)) == 1:
                            if ads_site[0] == site_type:
                                ads_slab = struct
                    else:
                        if not len(set(ads_site)) == 2:
                            continue
                        if get_under_bridge(
                                struct[:13]) == site_type.split('|')[1]:
                            ads_slab = struct
                else:
                    if '|' in site_type and len(set(ads_site)) == 1:
                        if get_under_bridge(
                                struct[:13]) == site_type.split('|')[1]:
                            ads_slab = struct
                    else:
                        ads_slab = struct

    return slab, ads_slab
Example #14
0
from catkit.gen.surface import SlabGenerator
from ase.build import bulk
from ase.visualize import view
from ase import Atom, Atoms
import numpy as np

atoms_bulk = bulk(name='Cu', crystalstructure='fcc', a=3.6302862146117354, cubic=True)
gen = SlabGenerator(atoms_bulk,
                    miller_index = (2,1,0),
                    layers = 8,
                    fixed = 4,
                    vacuum = 10,
                    standardize_bulk = True,
                    layer_type = "trim")

primitive = gen.get_slab()
#supercell = primitive.repeat(2,3)
supercell_1 = gen.get_slab( size=2 )
supercell_2 = gen.get_slab( size=(2,2) )
supercell_3 = gen.get_slab( size=np.array([[2,0],[0,2]]))
view(primitive)
view(supercell_3)
Example #15
0
#calc = Vasp(encut=400,
#            ismear=2,
#            sigma=0.2,
#            gga='PE',
#            xc='PBE')
#label = "CarbonMonoxide"

#co2 = copy.deepcopy(co)
#calc2 = Vasp2(label=label,
#              encut=400,
#              ismear=2,
#              sigma=0.2,
#              gga='PE',
#              xc='PBE')

#co.set_calculator(calc)
#co.get_potential_energy()

atoms_bulk = bulk(name='Cu',
                  crystalstructure='fcc',
                  a=3.6302862146117354,
                  cubic=True)
gen = SlabGenerator(atoms_bulk,
                    miller_index=[2, 1, 0],
                    layers=8,
                    fixed=4,
                    vacuum=10,
                    standardize_bulk=True,
                    layer_type="trim")
bare = gen.get_slab(size=[2, 2])
view(bare)