Example #1
0
def test_root_surf():
    from ase.build import fcc111
    from ase.build import bcc111
    from ase.build import hcp0001
    from ase.build import fcc111_root
    from ase.build import bcc111_root
    from ase.build import hcp0001_root
    from ase.build import root_surface
    from ase.build import root_surface_analysis

    # Manually checked set of roots for FCC111
    fcc111_21_set = set([1, 3, 4, 7, 9, 12, 13, 16, 19, 21])

    # Keep pairs for testing
    bulk_root = ((fcc111, fcc111_root), (bcc111, bcc111_root), (hcp0001,
                                                                hcp0001_root))

    for bulk, root_surf in bulk_root:
        prim = bulk("H", (1, 1, 2), a=1)

        # Check valid roots up to root 21 (the 10th root cell)
        assert fcc111_21_set == root_surface_analysis(prim, 21)

        # Use internal function
        internal_func_atoms = root_surface(prim, 7)

        # Remake using surface function
        helper_func_atoms = root_surf("H", 7, (1, 1, 2), a=1)

        # Right number of atoms
        assert len(internal_func_atoms) == 14
        assert len(helper_func_atoms) == 14
        assert (internal_func_atoms.cell == helper_func_atoms.cell).all()

    # Try bad root
    with pytest.raises(ValueError):
        fcc111_root("H", 5, (1, 1, 2), a=1)
Example #2
0
def test_root_surf():
    from ase.build import fcc111
    from ase.build import bcc111
    from ase.build import hcp0001
    from ase.build import fcc111_root
    from ase.build import root_surface
    from ase.build import root_surface_analysis

    # Make samples of primitive cell
    prim_fcc111 = fcc111("H", (1, 1, 2), a=1)
    prim_bcc111 = bcc111("H", (1, 1, 2), a=1)
    prim_hcp0001 = hcp0001("H", (1, 1, 2), a=1)

    # Check valid roots up to root 21 (the 10th root cell)
    valid_fcc111 = root_surface_analysis(prim_fcc111, 21)
    valid_bcc111 = root_surface_analysis(prim_bcc111, 21)
    valid_hcp0001 = root_surface_analysis(prim_hcp0001, 21)

    # These should have different positions, but the same
    # cell geometry.
    assert valid_fcc111 == valid_bcc111 == valid_hcp0001

    # Make an easy sample to check code errors
    atoms1 = root_surface(prim_fcc111, 7)

    # Ensure the valid roots are the roots are valid against
    # a set of manually checked roots for this system
    assert valid_fcc111 == [1.0, 3.0, 4.0, 7.0, 9.0,
                            12.0, 13.0, 16.0, 19.0, 21.0]

    # Remake easy sample using surface function
    atoms2 = fcc111_root("H", 7, (1, 1, 2), a=1)

    # Right number of atoms
    assert len(atoms1) == len(atoms2) == 14

    # Same positions
    assert (atoms1.positions == atoms2.positions).all()

    # Same cell
    assert (atoms1.cell == atoms2.cell).all()
Example #3
0
def slabgen(termination, size, adsorbate, position):
    if termination == '100':
        prim = fcc100('Cu',
                      a=3.6302862146117354,
                      size=(1, 1, 5),
                      vacuum=15,
                      orthogonal=True,
                      periodic=True)
    elif termination == '111':
        prim = fcc111_root('Cu',
                           root=3,
                           a=3.6302862146117354,
                           size=(1, 1, 5),
                           vacuum=15)

    super = make_supercell(prim, size)
    add_adsorbate(slab=super,
                  adsorbate=adsorbate,
                  height=ads_height,
                  position=position)
    constr = FixAtoms(
        indices=[atom.index for atom in super if atom.position[2] < 19])
    super.set_constraint(constr)
    return super
Example #4
0
prim_hcp0001 = hcp0001("H", (1, 1, 2), a=1)

# Check valid roots up to root 21 (the 10th root cell)
valid_fcc111 = root_surface_analysis(prim_fcc111, 21)
valid_bcc111 = root_surface_analysis(prim_bcc111, 21)
valid_hcp0001 = root_surface_analysis(prim_hcp0001, 21)

# These should have different positions, but the same
# cell geometry.
assert valid_fcc111 == valid_bcc111 == valid_hcp0001

# Make an easy sample to check code errors
atoms1 = root_surface(prim_fcc111, 7)

# Ensure the valid roots are the roots are valid against
# a set of manually checked roots for this system
assert valid_fcc111 == [1.0, 3.0, 4.0, 7.0, 9.0,
                        12.0, 13.0, 16.0, 19.0, 21.0]

# Remake easy sample using surface function
atoms2 = fcc111_root("H", 7, (1, 1, 2), a=1)

# Right number of atoms
assert len(atoms1) == len(atoms2) == 14

# Same positions
assert (atoms1.positions == atoms2.positions).all()

# Same cell
assert (atoms1._cell == atoms2._cell).all()
Example #5
0
prim_hcp0001 = hcp0001("H", (1, 1, 2), a=1)

# Check valid roots up to root 21 (the 10th root cell)
valid_fcc111 = root_surface_analysis(prim_fcc111, 21)
valid_bcc111 = root_surface_analysis(prim_bcc111, 21)
valid_hcp0001 = root_surface_analysis(prim_hcp0001, 21)

# These should have different positions, but the same
# cell geometry.
assert valid_fcc111 == valid_bcc111 == valid_hcp0001

# Make an easy sample to check code errors
atoms1 = root_surface(prim_fcc111, 7)

# Ensure the valid roots are the roots are valid against
# a set of manually checked roots for this system
assert valid_fcc111 == [1.0, 3.0, 4.0, 7.0, 9.0,
                        12.0, 13.0, 16.0, 19.0, 21.0]

# Remake easy sample using surface function
atoms2 = fcc111_root("H", 7, (1, 1, 2), a=1)

# Right number of atoms
assert len(atoms1) == len(atoms2) == 14

# Same positions
assert (atoms1.positions == atoms2.positions).all()

# Same cell
assert (atoms1.cell == atoms2.cell).all()