File: monoclinic.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 (46 lines) | stat: -rw-r--r-- 1,631 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
45
46
"""Function-like object creating monoclinic lattices.

The following lattice creator is defined:
    SimpleMonoclinic
    BaseCenteredMonoclinic
"""

from ase.lattice.triclinic import TriclinicFactory
import numpy as np


class SimpleMonoclinicFactory(TriclinicFactory):
    "A factory for creating simple monoclinic lattices."
    # The name of the crystal structure in ChemicalElements
    xtal_name = "monoclinic"

    def make_crystal_basis(self):
        "Make the basis matrix for the crystal unit cell and the system unit cell."
        # First convert the basis specification to a triclinic one
        if isinstance(self.latticeconstant, type({})):
            self.latticeconstant['beta'] = 90
            self.latticeconstant['gamma'] = 90
        else:
            if len(self.latticeconstant) == 4:
                self.latticeconstant = self.latticeconstant + (90,90)
            else:
                raise ValueError("Improper lattice constants for monoclinic crystal.")

        TriclinicFactory.make_crystal_basis(self)
        
SimpleMonoclinic = SimpleMonoclinicFactory()

class BaseCenteredMonoclinicFactory(SimpleMonoclinicFactory):
    # The natural basis vectors of the crystal structure
    int_basis = np.array([[1, -1, 0],
                          [1, 1, 0],
                          [0, 0, 2]])
    basis_factor = 0.5

    # Converts the natural basis back to the crystallographic basis
    inverse_basis = np.array([[1, 1, 0],
                              [-1, 1, 0],
                              [0, 0, 1]])
    inverse_basis_factor = 1.0

BaseCenteredMonoclinic = BaseCenteredMonoclinicFactory()