Coverage for ase/lattice/tetragonal.py: 55.56%
18 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-27 15:21 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-27 15:21 +0000
1"""Function-like objects creating tetragonal lattices.
3The following lattice creators are defined:
4 SimleTetragonal
5 CenteredTetragonal
6"""
8from ase.lattice.orthorhombic import (
9 BodyCenteredOrthorhombicFactory,
10 SimpleOrthorhombicFactory,
11)
14class _Tetragonalize:
15 "A mixin class for implementing tetragonal crystals as orthorhombic ones."
17 # The name of the crystal structure in ChemicalElements
18 xtal_name = 'tetragonal'
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 )
31 self.latticeconstant = lattice
32 self.orthobase.make_crystal_basis(self)
35class SimpleTetragonalFactory(_Tetragonalize, SimpleOrthorhombicFactory):
36 "A factory for creating simple tetragonal lattices."
38 orthobase = SimpleOrthorhombicFactory
41SimpleTetragonal = SimpleTetragonalFactory()
44class CenteredTetragonalFactory(
45 _Tetragonalize, BodyCenteredOrthorhombicFactory
46):
47 "A factory for creating centered tetragonal lattices."
49 orthobase = BodyCenteredOrthorhombicFactory
52CenteredTetragonal = CenteredTetragonalFactory()