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"""Function-like object creating monoclinic lattices. 

2 

3The following lattice creator is defined: 

4 SimpleMonoclinic 

5 BaseCenteredMonoclinic 

6""" 

7 

8from ase.lattice.triclinic import TriclinicFactory 

9import numpy as np 

10 

11 

12class SimpleMonoclinicFactory(TriclinicFactory): 

13 "A factory for creating simple monoclinic lattices." 

14 # The name of the crystal structure in ChemicalElements 

15 xtal_name = "monoclinic" 

16 

17 def make_crystal_basis(self): 

18 """Make the basis matrix for the crystal unit cell and the system 

19 unit cell.""" 

20 # First convert the basis specification to a triclinic one 

21 if isinstance(self.latticeconstant, type({})): 

22 self.latticeconstant['beta'] = 90 

23 self.latticeconstant['gamma'] = 90 

24 else: 

25 if len(self.latticeconstant) == 4: 

26 self.latticeconstant = self.latticeconstant + (90, 90) 

27 else: 

28 raise ValueError( 

29 "Improper lattice constants for monoclinic crystal.") 

30 

31 TriclinicFactory.make_crystal_basis(self) 

32 

33 

34SimpleMonoclinic = SimpleMonoclinicFactory() 

35 

36 

37class BaseCenteredMonoclinicFactory(SimpleMonoclinicFactory): 

38 # The natural basis vectors of the crystal structure 

39 int_basis = np.array([[1, -1, 0], 

40 [1, 1, 0], 

41 [0, 0, 2]]) 

42 basis_factor = 0.5 

43 

44 # Converts the natural basis back to the crystallographic basis 

45 inverse_basis = np.array([[1, 1, 0], 

46 [-1, 1, 0], 

47 [0, 0, 1]]) 

48 inverse_basis_factor = 1.0 

49 

50 

51BaseCenteredMonoclinic = BaseCenteredMonoclinicFactory()