File: octahedron.py

package info (click to toggle)
python-ase 3.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (69 lines) | stat: -rw-r--r-- 2,049 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# fmt: off

"""
Function-like objects that creates cubic clusters.
"""

import numpy as np

from ase.cluster.compounds import L1_2
from ase.cluster.cubic import FaceCenteredCubic


def Octahedron(symbol, length, cutoff=0, latticeconstant=None, alloy=False):
    """
    Returns Face Centered Cubic clusters of the octahedral class depending
    on the choice of cutoff.

    ============================    =======================
    Type                            Condition
    ============================    =======================
    Regular octahedron              cutoff = 0
    Truncated octahedron            cutoff > 0
    Regular truncated octahedron    length = 3 * cutoff + 1
    Cuboctahedron                   length = 2 * cutoff + 1
    ============================    =======================


    Parameters
    ----------
    symbol : str or list
        The chemical symbol or atomic number of the element(s).

    length : int
        Number of atoms on the square edges of the complete octahedron.

    cutoff : int, default 0
        Number of layers cut at each vertex.

    latticeconstant : float, optional
        The lattice constant. If not given, then it is extracted from
        `ase.data`.

    alloy : bool, default False
        If True the L1_2 structure is used.

    """

    # Check length and cutoff
    if length < 1:
        raise ValueError("The length must be at least one.")

    if cutoff < 0 or length < 2 * cutoff + 1:
        raise ValueError(
            "The cutoff must fulfill: > 0 and <= (length - 1) / 2.")

    # Create cluster
    surfaces = [(1, 1, 1), (1, 0, 0)]
    if length % 2 == 0:
        center = np.array([0.5, 0.5, 0.5])
        layers = [length / 2, length - 1 - cutoff]
    else:
        center = np.array([0.0, 0.0, 0.0])
        layers = [(length - 1) / 2, length - 1 - cutoff]

    if not alloy:
        return FaceCenteredCubic(
            symbol, surfaces, layers, latticeconstant, center)
    else:
        return L1_2(symbol, surfaces, layers, latticeconstant, center)