Пример #1
0
 def test_rotation_analyser_is_initialised(self):
     reference_points = np.array([[1.0, -1.0, 1.0], [-1.0, -1.0, -1.0],
                                  [1.0, 1.0, -1.0], [-1.0, 1.0, 1.0]])
     ra = RotationAnalyser(reference_points=reference_points)
     self.assertEqual(ra.reference_points.shape, (1, 4, 3))
     np.testing.assert_array_equal(ra.reference_points,
                                   np.array([reference_points]))
Пример #2
0
 def test_rotation_analyser_init_raises_error_for_misformed_reference_points(
         self):
     reference_points = np.array([[[1.0, -1.0, 1.0]],
                                  [[-1.0, -1.0, -1.0], [1.0, 1.0, -1.0],
                                   [-1.0, 1.0, 1.0]]])
     with self.assertRaises(ValueError):
         ra = RotationAnalyser(reference_points=reference_points)
Пример #3
0
 def test_rotation_analyser_is_initialised_with_multiple_reference_geometries(
         self):
     reference_points = np.array([[[1.0, -1.0, 1.0], [-1.0, -1.0, -1.0]],
                                  [[1.0, 1.0, -1.0], [-1.0, 1.0, 1.0]]])
     ra = RotationAnalyser(reference_points=reference_points)
     self.assertEqual(ra.reference_points.shape, (2, 2, 3))
     np.testing.assert_array_equal(ra.reference_points, reference_points)
Пример #4
0
class TestRotationAnalyser(unittest.TestCase):
    def setUp(self):
        reference_points = np.array([[1.0, -1.0, 1.0], [-1.0, -1.0, -1.0],
                                     [1.0, 1.0, -1.0], [-1.0, 1.0, 1.0]])
        all_points = np.array([reference_points, reference_points * (-1.0)])
        self.ra = RotationAnalyser(reference_points=all_points)

    def test_polyhedron_orientation(self):
        mock_polyhedron = Mock(spec=CoordinationPolyhedron)
        mock_polyhedron.abstract_geometry = Mock(spec=AbstractGeometry)
        mock_polyhedron.abstract_geometry.points_wocs_csc = Mock(
            return_value='foo')
        self.ra.discrete_orientation = Mock(return_value='bar')
        orientation = self.ra.polyhedron_orientation(mock_polyhedron)
        self.ra.discrete_orientation.assert_called_once_with('foo')
        self.assertEqual(orientation, 'bar')
Пример #5
0
 def setUp(self):
     reference_points = np.array([[1.0, -1.0, 1.0], [-1.0, -1.0, -1.0],
                                  [1.0, 1.0, -1.0], [-1.0, 1.0, 1.0]])
     all_points = np.array([reference_points, reference_points * (-1.0)])
     self.ra = RotationAnalyser(reference_points=all_points)
trajectory = Trajectory.from_xdatcars(filenames=[
    '1/XDATCAR', '2/XDATCAR', '3/XDATCAR', '4/XDATCAR', '5/XDATCAR'
],
                                      recipes=[ps4_recipe, sns4_recipe],
                                      progress=True,
                                      ncores=4)

reference_points = np.array([[1.0, -1.0, 1.0], [-1.0, -1.0, -1.0],
                             [1.0, 1.0, -1.0], [-1.0, 1.0, 1.0]])
reference_points.shape

all_points = np.array([reference_points, reference_points * (-1)])
all_points.shape

ra = RotationAnalyser(reference_points=all_points)

import math

n = len(trajectory.configurations[0].polyhedra)
# n = 2
all_orientations = []
all_angles = []
all_reference = []
for i in tqdm(range(n)):
    angles = []
    orientations = []
    reference = []
    for c in trajectory.configurations:
        po = ra.polyhedron_orientation(c.polyhedra[i])
        angles.append(po['rotational_distance'])