示例#1
0
    def fromHDF5(cls, store, dataset):
        from CDTK.SpaceGroups import space_groups
        from CDTK.Crystal import UnitCell
        space_group = space_groups[dataset.attrs['space_group']]
        cell = UnitCell(dataset.attrs['a'],
                        dataset.attrs['b'],
                        dataset.attrs['c'],
                        dataset.attrs['alpha'],
                        dataset.attrs['beta'],
                        dataset.attrs['gamma'])
        self = cls(ReflectionSet(cell, space_group))
        self._reflections = dataset[...]
        try:
            self._absences = dataset.attrs['systematic_absences']
        except KeyError:
            self._absences = np.zeros((0,), dtype=self._dtype)

        r1, r2, r3 = cell.reciprocalBasisVectors()
        sv = self._reflections['h'][:, np.newaxis]*r1.array + \
             self._reflections['k'][:, np.newaxis]*r2.array + \
             self._reflections['l'][:, np.newaxis]*r3.array
        sva = self._absences['h'][:, np.newaxis]*r1.array + \
              self._absences['k'][:, np.newaxis]*r2.array + \
              self._absences['l'][:, np.newaxis]*r3.array
        s = np.concatenate([np.sqrt(np.sum(sv**2, axis=1)),
                            np.sqrt(np.sum(sva**2, axis=1))])
        self.s_min = s.min()
        self.s_max = s.max()
        return self
示例#2
0
 def test_geometry(self):
     for params, rb, sg in datasets:
         cell1 = UnitCell(*params)
         basis = cell1.basisVectors()
         reciprocal_basis = cell1.reciprocalBasisVectors()
         for i in range(3):
             self.assert_((reciprocal_basis[i]-rb[i]).length()
                          < 1.e-6)
         for i in range(3):
             for j in range(3):
                 p = basis[i]*reciprocal_basis[j]
                 if i == j:
                     self.assertAlmostEqual(p, 1., 10)
                 else:
                     self.assertAlmostEqual(p, 0., 10)
         cell2 = UnitCell(*tuple(basis))
         self.assertAlmostEqual(cell1.a, cell2.a, 5)
         self.assertAlmostEqual(cell1.b, cell2.b, 5)
         self.assertAlmostEqual(cell1.c, cell2.c, 5)
         self.assertAlmostEqual(cell1.alpha, cell2.alpha, 5)
         self.assertAlmostEqual(cell1.beta, cell2.beta, 5)
         self.assertAlmostEqual(cell1.gamma, cell2.gamma, 5)