File: tetragonal.py

package info (click to toggle)
python-ase 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,192 kB
  • ctags: 8,112
  • sloc: python: 93,375; sh: 99; makefile: 94
file content (44 lines) | stat: -rw-r--r-- 1,452 bytes parent folder | download | duplicates (3)
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
"""Function-like objects creating tetragonal lattices.

The following lattice creators are defined:
    SimleTetragonal
    CenteredTetragonal
"""

from ase.lattice.orthorhombic import (SimpleOrthorhombicFactory,
                                      BodyCenteredOrthorhombicFactory)


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()