Coverage for /builds/debichem-team/python-ase/ase/lattice/tetragonal.py: 55.56%

18 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2025-03-06 04:00 +0000

1"""Function-like objects creating tetragonal lattices. 

2 

3The following lattice creators are defined: 

4 SimleTetragonal 

5 CenteredTetragonal 

6""" 

7 

8from ase.lattice.orthorhombic import ( 

9 BodyCenteredOrthorhombicFactory, 

10 SimpleOrthorhombicFactory, 

11) 

12 

13 

14class _Tetragonalize: 

15 "A mixin class for implementing tetragonal crystals as orthorhombic ones." 

16 

17 # The name of the crystal structure in ChemicalElements 

18 xtal_name = "tetragonal" 

19 

20 def make_crystal_basis(self): 

21 lattice = self.latticeconstant 

22 if isinstance(lattice, type({})): 

23 lattice['b/a'] = 1.0 

24 else: 

25 if len(lattice) == 2: 

26 lattice = (lattice[0], lattice[0], lattice[1]) 

27 else: 

28 raise ValueError( 

29 'Improper lattice constants for tetragonal crystal.') 

30 self.latticeconstant = lattice 

31 self.orthobase.make_crystal_basis(self) 

32 

33 

34class SimpleTetragonalFactory(_Tetragonalize, SimpleOrthorhombicFactory): 

35 "A factory for creating simple tetragonal lattices." 

36 orthobase = SimpleOrthorhombicFactory 

37 

38 

39SimpleTetragonal = SimpleTetragonalFactory() 

40 

41 

42class CenteredTetragonalFactory(_Tetragonalize, 

43 BodyCenteredOrthorhombicFactory): 

44 "A factory for creating centered tetragonal lattices." 

45 orthobase = BodyCenteredOrthorhombicFactory 

46 

47 

48CenteredTetragonal = CenteredTetragonalFactory()