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.data import reference_states as _refstate 

8from ase.cluster.factory import ClusterFactory 

9 

10 

11class SimpleCubicFactory(ClusterFactory): 

12 spacegroup = 221 

13 

14 xtal_name = 'sc' 

15 

16 def get_lattice_constant(self): 

17 "Get the lattice constant of an element with cubic crystal structure." 

18 symmetry = _refstate[self.atomic_numbers[0]]['symmetry'] 

19 if symmetry != self.xtal_name: 

20 raise ValueError("Cannot guess the %s " % (self.xtal_name,) + 

21 "lattice constant of an element with crystal " + 

22 "structure %s." % (symmetry,)) 

23 return _refstate[self.atomic_numbers[0]]['a'] 

24 

25 def set_basis(self): 

26 a = self.lattice_constant 

27 if not isinstance(a, (int, float)): 

28 raise ValueError( 

29 "Improper lattice constant for %s crystal." % 

30 (self.xtal_name,)) 

31 

32 self.lattice_basis = np.array([[a, 0., 0.], 

33 [0., a, 0.], 

34 [0., 0., a]]) 

35 

36 self.resiproc_basis = self.get_resiproc_basis(self.lattice_basis) 

37 

38 

39SimpleCubic = SimpleCubicFactory() 

40 

41 

42class BodyCenteredCubicFactory(SimpleCubicFactory): 

43 spacegroup = 229 

44 

45 xtal_name = 'bcc' 

46 

47 atomic_basis = np.array([[0., 0., 0.], 

48 [.5, .5, .5]]) 

49 

50 

51BodyCenteredCubic = BodyCenteredCubicFactory() 

52 

53 

54class FaceCenteredCubicFactory(SimpleCubicFactory): 

55 spacegroup = 225 

56 

57 xtal_name = 'fcc' 

58 

59 atomic_basis = np.array([[0., 0., 0.], 

60 [0., .5, .5], 

61 [.5, 0., .5], 

62 [.5, .5, 0.]]) 

63 

64 

65FaceCenteredCubic = FaceCenteredCubicFactory()