Coverage for /builds/kinetik161/ase/ase/lattice/monoclinic.py: 63.16%
19 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1"""Function-like object creating monoclinic lattices.
3The following lattice creator is defined:
4 SimpleMonoclinic
5 BaseCenteredMonoclinic
6"""
8import numpy as np
10from ase.lattice.triclinic import TriclinicFactory
13class SimpleMonoclinicFactory(TriclinicFactory):
14 "A factory for creating simple monoclinic lattices."
15 # The name of the crystal structure in ChemicalElements
16 xtal_name = "monoclinic"
18 def make_crystal_basis(self):
19 """Make the basis matrix for the crystal unit cell and the system
20 unit cell."""
21 # First convert the basis specification to a triclinic one
22 if isinstance(self.latticeconstant, type({})):
23 self.latticeconstant['beta'] = 90
24 self.latticeconstant['gamma'] = 90
25 else:
26 if len(self.latticeconstant) == 4:
27 self.latticeconstant = self.latticeconstant + (90, 90)
28 else:
29 raise ValueError(
30 "Improper lattice constants for monoclinic crystal.")
32 TriclinicFactory.make_crystal_basis(self)
35SimpleMonoclinic = SimpleMonoclinicFactory()
38class BaseCenteredMonoclinicFactory(SimpleMonoclinicFactory):
39 # The natural basis vectors of the crystal structure
40 int_basis = np.array([[1, -1, 0],
41 [1, 1, 0],
42 [0, 0, 2]])
43 basis_factor = 0.5
45 # Converts the natural basis back to the crystallographic basis
46 inverse_basis = np.array([[1, 1, 0],
47 [-1, 1, 0],
48 [0, 0, 1]])
49 inverse_basis_factor = 1.0
52BaseCenteredMonoclinic = BaseCenteredMonoclinicFactory()