def test_positive_intensity(self): """ Test that potential_map raises an error if diffraction intensity is not positive """ aR1, aR2, aR3 = self.crystal.lattice_vectors extent = np.arange(0, 5, 0.1) with suppress_warnings(): plane = plane_mesh(aR3, aR1 + aR2, x1=extent) self.I[0] = -1 with self.assertRaises(ValueError): potmap = potential_map(self.q, self.I, self.crystal, plane)
def test_trivial(self): """ Test that potential_map calculated from zero intensity is zero everywhere """ aR1, aR2, aR3 = self.crystal.lattice_vectors extent = np.arange(0, 10, 0.1) with suppress_warnings(): plane = plane_mesh(aR3, aR1 + aR2, x1=extent) potmap = potential_map(self.q, np.zeros_like(self.I), self.crystal, plane) self.assertTrue(np.allclose(potmap, 0))
def test_shape(self): """ Test that potential_map returns a map with the same shape as the mesh """ aR1, aR2, aR3 = self.crystal.lattice_vectors extent = np.arange(0, 5, 0.1) with suppress_warnings(): plane = plane_mesh(aR3, aR1 + aR2, x1=extent) potmap = potential_map(self.q, self.I, self.crystal, plane) xx, yy, zz = plane for arr in plane: self.assertTupleEqual(potmap.shape, arr.shape)
def test_potential_map_positive_intensity(): """ Test that potential_map raises an error if diffraction intensity is not positive """ crystal = Crystal.from_database("vo2-rutile") q = np.linspace(1, 5, 256) I = powdersim(crystal, q) aR1, aR2, aR3 = crystal.lattice_vectors extent = np.arange(0, 5, 0.1) with suppress_warnings(): plane = plane_mesh(aR3, aR1 + aR2, x1=extent) I[0] = -1 with pytest.raises(ValueError): potmap = potential_map(q, I, crystal, plane)
def test_potential_map_trivial(): """ Test that potential_map calculated from zero intensity is zero everywhere """ crystal = Crystal.from_database("vo2-rutile") q = np.linspace(1, 5, 256) I = powdersim(crystal, q) aR1, aR2, aR3 = crystal.lattice_vectors extent = np.arange(0, 10, 0.1) with suppress_warnings(): plane = plane_mesh(aR3, aR1 + aR2, x1=extent) potmap = potential_map(q, np.zeros_like(I), crystal, plane) assert np.allclose(potmap, 0)
def test_potential_map_shape(): """ Test that potential_map returns a map with the same shape as the mesh """ crystal = Crystal.from_database("vo2-rutile") q = np.linspace(1, 5, 256) I = powdersim(crystal, q) aR1, aR2, aR3 = crystal.lattice_vectors extent = np.arange(0, 5, 0.1) with suppress_warnings(): plane = plane_mesh(aR3, aR1 + aR2, x1=extent) potmap = potential_map(q, I, crystal, plane) xx, yy, zz = plane for arr in plane: assert potmap.shape == arr.shape