File: octahedron.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (67 lines) | stat: -rw-r--r-- 2,046 bytes parent folder | download | duplicates (2)
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
"""
Function-like objects that creates cubic clusters.
"""

import numpy as np

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


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: string or sequence of int
        The chemical symbol or atomic number of the element(s).

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

    cutoff (optional): int
        Number of layers cut at each vertex.

    latticeconstant (optional): float
        The lattice constant. If not given,
        then it is extracted form ase.data.

    alloy (optional): bool
        If true the L1_2 structure is used. Default is False.

    """

    # 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)