File: octahedron.py

package info (click to toggle)
python-ase 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,192 kB
  • ctags: 8,112
  • sloc: python: 93,375; sh: 99; makefile: 94
file content (56 lines) | stat: -rw-r--r-- 1,804 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
"""
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: The chemical symbol or atomic number of the element(s).

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

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

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

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

    # Check length and cutoff
    if length < 2:
        raise ValueError("The length must be greater than 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)