Coverage for /builds/kinetik161/ase/ase/lattice/tetragonal.py: 55.56%
18 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"""Function-like objects creating tetragonal lattices.
3The following lattice creators are defined:
4 SimleTetragonal
5 CenteredTetragonal
6"""
8from ase.lattice.orthorhombic import (BodyCenteredOrthorhombicFactory,
9 SimpleOrthorhombicFactory)
12class _Tetragonalize:
13 "A mixin class for implementing tetragonal crystals as orthorhombic ones."
15 # The name of the crystal structure in ChemicalElements
16 xtal_name = "tetragonal"
18 def make_crystal_basis(self):
19 lattice = self.latticeconstant
20 if isinstance(lattice, type({})):
21 lattice['b/a'] = 1.0
22 else:
23 if len(lattice) == 2:
24 lattice = (lattice[0], lattice[0], lattice[1])
25 else:
26 raise ValueError(
27 'Improper lattice constants for tetragonal crystal.')
28 self.latticeconstant = lattice
29 self.orthobase.make_crystal_basis(self)
32class SimpleTetragonalFactory(_Tetragonalize, SimpleOrthorhombicFactory):
33 "A factory for creating simple tetragonal lattices."
34 orthobase = SimpleOrthorhombicFactory
37SimpleTetragonal = SimpleTetragonalFactory()
40class CenteredTetragonalFactory(_Tetragonalize,
41 BodyCenteredOrthorhombicFactory):
42 "A factory for creating centered tetragonal lattices."
43 orthobase = BodyCenteredOrthorhombicFactory
46CenteredTetragonal = CenteredTetragonalFactory()