1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
# fmt: off
"""Function-like objects creating tetragonal lattices.
The following lattice creators are defined:
SimleTetragonal
CenteredTetragonal
"""
from ase.lattice.orthorhombic import (
BodyCenteredOrthorhombicFactory,
SimpleOrthorhombicFactory,
)
class _Tetragonalize:
"A mixin class for implementing tetragonal crystals as orthorhombic ones."
# The name of the crystal structure in ChemicalElements
xtal_name = "tetragonal"
def make_crystal_basis(self):
lattice = self.latticeconstant
if isinstance(lattice, type({})):
lattice['b/a'] = 1.0
else:
if len(lattice) == 2:
lattice = (lattice[0], lattice[0], lattice[1])
else:
raise ValueError(
'Improper lattice constants for tetragonal crystal.')
self.latticeconstant = lattice
self.orthobase.make_crystal_basis(self)
class SimpleTetragonalFactory(_Tetragonalize, SimpleOrthorhombicFactory):
"A factory for creating simple tetragonal lattices."
orthobase = SimpleOrthorhombicFactory
SimpleTetragonal = SimpleTetragonalFactory()
class CenteredTetragonalFactory(_Tetragonalize,
BodyCenteredOrthorhombicFactory):
"A factory for creating centered tetragonal lattices."
orthobase = BodyCenteredOrthorhombicFactory
CenteredTetragonal = CenteredTetragonalFactory()
|