Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2Function-like objects that creates cubic clusters. 

3""" 

4 

5import numpy as np 

6 

7from ase.cluster.cubic import FaceCenteredCubic 

8from ase.cluster.compounds import L1_2 

9 

10 

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. 

15 

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 ============================ ======================= 

24 

25 

26 Parameters: 

27 

28 symbol: string or sequence of int 

29 The chemical symbol or atomic number of the element(s). 

30 

31 length: int 

32 Number of atoms on the square edges of the complete octahedron. 

33 

34 cutoff (optional): int 

35 Number of layers cut at each vertex. 

36 

37 latticeconstant (optional): float 

38 The lattice constant. If not given, 

39 then it is extracted form ase.data. 

40 

41 alloy (optional): bool 

42 If true the L1_2 structure is used. Default is False. 

43 

44 """ 

45 

46 # Check length and cutoff 

47 if length < 1: 

48 raise ValueError("The length must be at least one.") 

49 

50 if cutoff < 0 or length < 2 * cutoff + 1: 

51 raise ValueError( 

52 "The cutoff must fulfill: > 0 and <= (length - 1) / 2.") 

53 

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] 

62 

63 if not alloy: 

64 return FaceCenteredCubic( 

65 symbol, surfaces, layers, latticeconstant, center) 

66 else: 

67 return L1_2(symbol, surfaces, layers, latticeconstant, center)