Coverage for /builds/kinetik161/ase/ase/cluster/cubic.py: 92.86%
28 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"""
2Function-like objects that creates cubic clusters.
3"""
5import numpy as np
7from ase.cluster.factory import ClusterFactory
8from ase.data import reference_states as _refstate
11class SimpleCubicFactory(ClusterFactory):
12 spacegroup = 221
14 xtal_name = 'sc'
16 def get_lattice_constant(self):
17 "Get the lattice constant of an element with cubic crystal structure."
18 symmetry = _refstate[self.atomic_numbers[0]]['symmetry']
19 if symmetry != self.xtal_name:
20 raise ValueError(f"Cannot guess the {self.xtal_name} " +
21 "lattice constant of an element with crystal " +
22 f"structure {symmetry}.")
23 return _refstate[self.atomic_numbers[0]]['a']
25 def set_basis(self):
26 a = self.lattice_constant
27 if not isinstance(a, (int, float)):
28 raise ValueError(
29 f"Improper lattice constant for {self.xtal_name} crystal.")
31 self.lattice_basis = np.array([[a, 0., 0.],
32 [0., a, 0.],
33 [0., 0., a]])
35 self.resiproc_basis = self.get_resiproc_basis(self.lattice_basis)
38SimpleCubic = SimpleCubicFactory()
41class BodyCenteredCubicFactory(SimpleCubicFactory):
42 spacegroup = 229
44 xtal_name = 'bcc'
46 atomic_basis = np.array([[0., 0., 0.],
47 [.5, .5, .5]])
50BodyCenteredCubic = BodyCenteredCubicFactory()
53class FaceCenteredCubicFactory(SimpleCubicFactory):
54 spacegroup = 225
56 xtal_name = 'fcc'
58 atomic_basis = np.array([[0., 0., 0.],
59 [0., .5, .5],
60 [.5, 0., .5],
61 [.5, .5, 0.]])
64FaceCenteredCubic = FaceCenteredCubicFactory()