Coverage for /builds/ase/ase/ase/lattice/tetragonal.py: 55.56%
18 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
1# fmt: off
3"""Function-like objects creating tetragonal lattices.
5The following lattice creators are defined:
6 SimleTetragonal
7 CenteredTetragonal
8"""
10from ase.lattice.orthorhombic import (
11 BodyCenteredOrthorhombicFactory,
12 SimpleOrthorhombicFactory,
13)
16class _Tetragonalize:
17 "A mixin class for implementing tetragonal crystals as orthorhombic ones."
19 # The name of the crystal structure in ChemicalElements
20 xtal_name = "tetragonal"
22 def make_crystal_basis(self):
23 lattice = self.latticeconstant
24 if isinstance(lattice, type({})):
25 lattice['b/a'] = 1.0
26 else:
27 if len(lattice) == 2:
28 lattice = (lattice[0], lattice[0], lattice[1])
29 else:
30 raise ValueError(
31 'Improper lattice constants for tetragonal crystal.')
32 self.latticeconstant = lattice
33 self.orthobase.make_crystal_basis(self)
36class SimpleTetragonalFactory(_Tetragonalize, SimpleOrthorhombicFactory):
37 "A factory for creating simple tetragonal lattices."
38 orthobase = SimpleOrthorhombicFactory
41SimpleTetragonal = SimpleTetragonalFactory()
44class CenteredTetragonalFactory(_Tetragonalize,
45 BodyCenteredOrthorhombicFactory):
46 "A factory for creating centered tetragonal lattices."
47 orthobase = BodyCenteredOrthorhombicFactory
50CenteredTetragonal = CenteredTetragonalFactory()