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