def test_getFsSquared(self): generator = ReflectionGenerator(self.crystalStructure) hkls = generator.getUniqueHKLs(1.0, 10.0) fsSquared = generator.getFsSquared(hkls) self.assertEqual(len(fsSquared), len(hkls))
def test_getUniqueHKLs(self): generator = ReflectionGenerator(self.crystalStructure) hkls = generator.getUniqueHKLs(1.0, 10.0) self.assertEqual(len(hkls), 9) self.assertTrue(V3D(2, 2, 2) in hkls) self.assertFalse(V3D(1, 0, 0) in hkls)
def _update_distributions_and_weights(self): crystal_structure = CrystalStructure(str(self._unit_cell), str(self._space_group), str(self._atoms)) reflection_generator = ReflectionGenerator(crystal_structure) # Calculate all unique reflections within the specified resolution limits, including structure factors unique_hkls = reflection_generator.getUniqueHKLs(self.d_min, self.d_max) structure_factors = reflection_generator.getFsSquared(unique_hkls) # Calculate multiplicities of the reflections point_group = crystal_structure.getSpaceGroup().getPointGroup() multiplicities = [len(point_group.getEquivalents(hkl)) for hkl in unique_hkls] # Calculate weights as F^2 * multiplicity and normalize so that Sum(weights) = 1 weights = np.array([x * y for x, y in zip(structure_factors, multiplicities)]) self._parameter_lock.acquire() self._peak_weights = weights / sum(weights) d_values = reflection_generator.getDValues(unique_hkls) self._peak_distributions = [partial(np.random.normal, loc=d, scale=self._relative_sigma * d) for d in d_values] self._parameter_lock.release()