Esempio n. 1
0
 def test_as_dict_and_from_dict(self):
     d1 = self.Cu_GB1.as_dict()
     d2 = self.Cu_GB2.as_dict()
     Cu_GB1_new = GrainBoundary.from_dict(d1)
     Cu_GB2_new = GrainBoundary.from_dict(d2)
     self.assertAlmostEqual(Cu_GB1_new.sigma, self.Cu_GB1.sigma)
     self.assertAlmostEqual(Cu_GB1_new.rotation_angle,
                            self.Cu_GB1.rotation_angle)
     self.assertListEqual(Cu_GB1_new.rotation_axis,
                          self.Cu_GB1.rotation_axis)
     self.assertListEqual(Cu_GB1_new.gb_plane, self.Cu_GB1.gb_plane)
     self.assertArrayAlmostEqual(Cu_GB1_new.init_cell.lattice.matrix,
                                 self.Cu_GB1.init_cell.lattice.matrix)
     self.assertArrayAlmostEqual(
         Cu_GB1_new.oriented_unit_cell.lattice.matrix,
         self.Cu_GB1.oriented_unit_cell.lattice.matrix,
     )
     self.assertArrayAlmostEqual(Cu_GB1_new.lattice.matrix,
                                 self.Cu_GB1.lattice.matrix)
     self.assertAlmostEqual(Cu_GB2_new.sigma, self.Cu_GB2.sigma)
     self.assertAlmostEqual(Cu_GB2_new.rotation_angle,
                            self.Cu_GB2.rotation_angle)
     self.assertListEqual(Cu_GB2_new.rotation_axis,
                          self.Cu_GB2.rotation_axis)
     self.assertListEqual(Cu_GB2_new.gb_plane, self.Cu_GB2.gb_plane)
     self.assertArrayAlmostEqual(Cu_GB2_new.init_cell.lattice.matrix,
                                 self.Cu_GB2.init_cell.lattice.matrix)
     self.assertArrayAlmostEqual(
         Cu_GB2_new.oriented_unit_cell.lattice.matrix,
         self.Cu_GB2.oriented_unit_cell.lattice.matrix,
     )
     self.assertArrayAlmostEqual(Cu_GB2_new.lattice.matrix,
                                 self.Cu_GB2.lattice.matrix)
Esempio n. 2
0
 def test_as_dict_and_from_dict(self):
     d1 = self.Cu_GB1.as_dict()
     d2 = self.Cu_GB2.as_dict()
     Cu_GB1_new = GrainBoundary.from_dict(d1)
     Cu_GB2_new = GrainBoundary.from_dict(d2)
     self.assertAlmostEqual(Cu_GB1_new.sigma, self.Cu_GB1.sigma)
     self.assertAlmostEqual(Cu_GB1_new.rotation_angle, self.Cu_GB1.rotation_angle)
     self.assertListEqual(Cu_GB1_new.rotation_axis, self.Cu_GB1.rotation_axis)
     self.assertListEqual(Cu_GB1_new.gb_plane, self.Cu_GB1.gb_plane)
     self.assertArrayAlmostEqual(Cu_GB1_new.init_cell.lattice.matrix,
                                 self.Cu_GB1.init_cell.lattice.matrix)
     self.assertArrayAlmostEqual(Cu_GB1_new.oriented_unit_cell.lattice.matrix,
                                 self.Cu_GB1.oriented_unit_cell.lattice.matrix)
     self.assertArrayAlmostEqual(Cu_GB1_new.lattice.matrix,
                                 self.Cu_GB1.lattice.matrix)
     self.assertAlmostEqual(Cu_GB2_new.sigma, self.Cu_GB2.sigma)
     self.assertAlmostEqual(Cu_GB2_new.rotation_angle, self.Cu_GB2.rotation_angle)
     self.assertListEqual(Cu_GB2_new.rotation_axis, self.Cu_GB2.rotation_axis)
     self.assertListEqual(Cu_GB2_new.gb_plane, self.Cu_GB2.gb_plane)
     self.assertArrayAlmostEqual(Cu_GB2_new.init_cell.lattice.matrix,
                                 self.Cu_GB2.init_cell.lattice.matrix)
     self.assertArrayAlmostEqual(Cu_GB2_new.oriented_unit_cell.lattice.matrix,
                                 self.Cu_GB2.oriented_unit_cell.lattice.matrix)
     self.assertArrayAlmostEqual(Cu_GB2_new.lattice.matrix,
                                 self.Cu_GB2.lattice.matrix)