Coverage for /builds/ase/ase/ase/cluster/octahedron.py: 82.35%
17 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
1# fmt: off
3"""
4Function-like objects that creates cubic clusters.
5"""
7import numpy as np
9from ase.cluster.compounds import L1_2
10from ase.cluster.cubic import FaceCenteredCubic
13def Octahedron(symbol, length, cutoff=0, latticeconstant=None, alloy=False):
14 """
15 Returns Face Centered Cubic clusters of the octahedral class depending
16 on the choice of cutoff.
18 ============================ =======================
19 Type Condition
20 ============================ =======================
21 Regular octahedron cutoff = 0
22 Truncated octahedron cutoff > 0
23 Regular truncated octahedron length = 3 * cutoff + 1
24 Cuboctahedron length = 2 * cutoff + 1
25 ============================ =======================
28 Parameters
29 ----------
30 symbol : str or list
31 The chemical symbol or atomic number of the element(s).
33 length : int
34 Number of atoms on the square edges of the complete octahedron.
36 cutoff : int, default 0
37 Number of layers cut at each vertex.
39 latticeconstant : float, optional
40 The lattice constant. If not given, then it is extracted from
41 `ase.data`.
43 alloy : bool, default False
44 If True the L1_2 structure is used.
46 """
48 # Check length and cutoff
49 if length < 1:
50 raise ValueError("The length must be at least one.")
52 if cutoff < 0 or length < 2 * cutoff + 1:
53 raise ValueError(
54 "The cutoff must fulfill: > 0 and <= (length - 1) / 2.")
56 # Create cluster
57 surfaces = [(1, 1, 1), (1, 0, 0)]
58 if length % 2 == 0:
59 center = np.array([0.5, 0.5, 0.5])
60 layers = [length / 2, length - 1 - cutoff]
61 else:
62 center = np.array([0.0, 0.0, 0.0])
63 layers = [(length - 1) / 2, length - 1 - cutoff]
65 if not alloy:
66 return FaceCenteredCubic(
67 symbol, surfaces, layers, latticeconstant, center)
68 else:
69 return L1_2(symbol, surfaces, layers, latticeconstant, center)