Coverage for /builds/ase/ase/ase/lattice/monoclinic.py : 63.16%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Function-like object creating monoclinic lattices.
3The following lattice creator is defined:
4 SimpleMonoclinic
5 BaseCenteredMonoclinic
6"""
8from ase.lattice.triclinic import TriclinicFactory
9import numpy as np
12class SimpleMonoclinicFactory(TriclinicFactory):
13 "A factory for creating simple monoclinic lattices."
14 # The name of the crystal structure in ChemicalElements
15 xtal_name = "monoclinic"
17 def make_crystal_basis(self):
18 """Make the basis matrix for the crystal unit cell and the system
19 unit cell."""
20 # First convert the basis specification to a triclinic one
21 if isinstance(self.latticeconstant, type({})):
22 self.latticeconstant['beta'] = 90
23 self.latticeconstant['gamma'] = 90
24 else:
25 if len(self.latticeconstant) == 4:
26 self.latticeconstant = self.latticeconstant + (90, 90)
27 else:
28 raise ValueError(
29 "Improper lattice constants for monoclinic crystal.")
31 TriclinicFactory.make_crystal_basis(self)
34SimpleMonoclinic = SimpleMonoclinicFactory()
37class BaseCenteredMonoclinicFactory(SimpleMonoclinicFactory):
38 # The natural basis vectors of the crystal structure
39 int_basis = np.array([[1, -1, 0],
40 [1, 1, 0],
41 [0, 0, 2]])
42 basis_factor = 0.5
44 # Converts the natural basis back to the crystallographic basis
45 inverse_basis = np.array([[1, 1, 0],
46 [-1, 1, 0],
47 [0, 0, 1]])
48 inverse_basis_factor = 1.0
51BaseCenteredMonoclinic = BaseCenteredMonoclinicFactory()