Beispiel #1
0
 def test_get_rotation_angle_from_sigma(self):
     true_angle = [12.680383491819821, 167.3196165081802]
     angle = GrainBoundaryGenerator.get_rotation_angle_from_sigma(41, [1, 0, 0], lat_type='o', ratio=[270, 30, 29])
     self.assertArrayAlmostEqual(true_angle, angle)
     close_angle = [36.86989764584403, 143.13010235415598]
     angle = GrainBoundaryGenerator.get_rotation_angle_from_sigma(6, [1, 0, 0], lat_type='o', ratio=[270, 30, 29])
     self.assertArrayAlmostEqual(close_angle, angle)
Beispiel #2
0
    def test_enum_sigma_tet(self):
        true_100 = [5, 37, 41, 13, 3, 15, 39, 25, 17, 29]
        true_331 = [9, 3, 21, 39, 7, 31, 43, 13, 19, 37, 49]
        sigma_100 = list(GrainBoundaryGenerator.enum_sigma_tet(50, [1, 0, 0], [9, 1]).keys())
        sigma_331 = list(GrainBoundaryGenerator.enum_sigma_tet(50, [3, 3, 1], [9, 1]).keys())

        self.assertListEqual(sorted(true_100), sorted(sigma_100))
        self.assertListEqual(sorted(true_331), sorted(sigma_331))
Beispiel #3
0
 def setUpClass(cls):
     warnings.filterwarnings("ignore")
     cls.Cu_conv = Structure.from_file(os.path.join(test_dir,
                                                    "Cu_mp-30_conventional_standard.cif"))
     GB_Cu_conv = GrainBoundaryGenerator(cls.Cu_conv)
     cls.Cu_GB1 = GB_Cu_conv.gb_from_parameters([1, 2, 3], 123.74898859588858,
                                                expand_times=4, vacuum_thickness=1.5,
                                                ab_shift=[0.0, 0.0], plane=[1, 3, 1],
                                                rm_ratio=0.0)
     cls.Cu_GB2 = GB_Cu_conv.gb_from_parameters([1, 2, 3], 123.74898859588858,
                                                expand_times=4, vacuum_thickness=1.5,
                                                ab_shift=[0.2, 0.2], rm_ratio=0.0)
Beispiel #4
0
    def test_enum_sigma_cubic(self):
        true_100 = [5, 13, 17, 25, 29, 37, 41]
        true_110 = [3, 9, 11, 17, 19, 27, 33, 41, 43]
        true_111 = [3, 7, 13, 19, 21, 31, 37, 39, 43, 49]
        sigma_100 = list(GrainBoundaryGenerator.enum_sigma_cubic(50, [1, 0, 0]).keys())
        sigma_110 = list(GrainBoundaryGenerator.enum_sigma_cubic(50, [1, 1, 0]).keys())
        sigma_111 = list(GrainBoundaryGenerator.enum_sigma_cubic(50, [1, 1, 1]).keys())
        sigma_222 = list(GrainBoundaryGenerator.enum_sigma_cubic(50, [2, 2, 2]).keys())
        sigma_888 = list(GrainBoundaryGenerator.enum_sigma_cubic(50, [8, 8, 8]).keys())

        self.assertListEqual(sorted(true_100), sorted(sigma_100))
        self.assertListEqual(sorted(true_110), sorted(sigma_110))
        self.assertListEqual(sorted(true_111), sorted(sigma_111))
        self.assertListEqual(sorted(true_111), sorted(sigma_222))
        self.assertListEqual(sorted(true_111), sorted(sigma_888))
Beispiel #5
0
    def test_enum_sigma_hex(self):
        true_100 = [17, 18, 22, 27, 38, 41]
        true_001 = [7, 13, 19, 31, 37, 43, 49]
        true_210 = [10, 11, 14, 25, 35, 49]
        sigma_100 = list(GrainBoundaryGenerator.enum_sigma_hex(50, [1, 0, 0], [8, 3]).keys())
        sigma_001 = list(GrainBoundaryGenerator.enum_sigma_hex(50, [0, 0, 1], [8, 3]).keys())
        sigma_210 = list(GrainBoundaryGenerator.enum_sigma_hex(50, [2, 1, 0], [8, 3]).keys())
        sigma_420 = list(GrainBoundaryGenerator.enum_sigma_hex(50, [4, 2, 0], [8, 3]).keys())
        sigma_840 = list(GrainBoundaryGenerator.enum_sigma_hex(50, [8, 4, 0], [8, 3]).keys())

        self.assertListEqual(sorted(true_100), sorted(sigma_100))
        self.assertListEqual(sorted(true_001), sorted(sigma_001))
        self.assertListEqual(sorted(true_210), sorted(sigma_210))
        self.assertListEqual(sorted(true_210), sorted(sigma_420))
        self.assertListEqual(sorted(true_210), sorted(sigma_840))
 def test_apply_transformation(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         Li_bulk = Structure.from_spacegroup("Im-3m", Lattice.cubic(2.96771),
                                             ["Li"], [[0, 0, 0]])
         gb_gen_params_s3 = {"rotation_axis": [1, 1, 1], "rotation_angle": 60.0,
                             "expand_times": 2, "vacuum_thickness": 0.0, "normal": True,
                             "ratio": None, "plane": None}
         gbg = GrainBoundaryGenerator(Li_bulk)
         gb_from_generator = gbg.gb_from_parameters(**gb_gen_params_s3)
         gbt_s3 = GrainBoundaryTransformation(**gb_gen_params_s3)
         gb_from_trans = gbt_s3.apply_transformation(Li_bulk)
         self.assertArrayAlmostEqual(gb_from_generator.lattice.matrix,
                                     gb_from_trans.lattice.matrix)
         self.assertArrayAlmostEqual(gb_from_generator.cart_coords,
                                     gb_from_trans.cart_coords)
Beispiel #7
0
 def test_get_trans_mat(self):
     mat1, mat2 = GrainBoundaryGenerator.get_trans_mat([1, 1, 1], 95.55344419565849,
                                                       lat_type='o', ratio=[10, 20, 21],
                                                       surface=[21, 20, 10], normal=True)
     self.assertAlmostEqual(np.dot(mat1[0], [21, 20, 10]), 0)
     self.assertAlmostEqual(np.dot(mat1[1], [21, 20, 10]), 0)
     self.assertAlmostEqual(np.linalg.det(mat1), np.linalg.det(mat2))
     ab_len1 = np.linalg.norm(np.cross(mat1[2], [1, 1, 1]))
     self.assertAlmostEqual(ab_len1, 0)
Beispiel #8
0
 def test_get_trans_mat(self):
     mat1, mat2 = GrainBoundaryGenerator.get_trans_mat([1, 1, 1],
                                                       95.55344419565849,
                                                       lat_type='o',
                                                       ratio=[10, 20, 21],
                                                       surface=[21, 20, 10],
                                                       normal=True)
     self.assertAlmostEqual(np.dot(mat1[0], [21, 20, 10]), 0)
     self.assertAlmostEqual(np.dot(mat1[1], [21, 20, 10]), 0)
     self.assertAlmostEqual(np.linalg.det(mat1), np.linalg.det(mat2))
     ab_len1 = np.linalg.norm(np.cross(mat1[2], [1, 1, 1]))
     self.assertAlmostEqual(ab_len1, 0)
Beispiel #9
0
 def setUpClass(cls):
     warnings.filterwarnings("ignore")
     cls.Cu_prim = Structure.from_file(
         os.path.join(test_dir, "Cu_mp-30_primitive.cif")
     )
     cls.GB_Cu_prim = GrainBoundaryGenerator(cls.Cu_prim)
     cls.Cu_conv = Structure.from_file(
         os.path.join(test_dir, "Cu_mp-30_conventional_standard.cif")
     )
     cls.GB_Cu_conv = GrainBoundaryGenerator(cls.Cu_conv)
     cls.Be = Structure.from_file(
         os.path.join(test_dir, "Be_mp-87_conventional_standard.cif")
     )
     cls.GB_Be = GrainBoundaryGenerator(cls.Be)
     cls.Pa = Structure.from_file(
         os.path.join(test_dir, "Pa_mp-62_conventional_standard.cif")
     )
     cls.GB_Pa = GrainBoundaryGenerator(cls.Pa)
     cls.Br = Structure.from_file(
         os.path.join(test_dir, "Br_mp-23154_conventional_standard.cif")
     )
     cls.GB_Br = GrainBoundaryGenerator(cls.Br)
     cls.Bi = Structure.from_file(
         os.path.join(test_dir, "Bi_mp-23152_primitive.cif")
     )
     cls.GB_Bi = GrainBoundaryGenerator(cls.Bi)
Beispiel #10
0
 def setUpClass(cls):
     warnings.filterwarnings("ignore")
     cls.Cu_conv = Structure.from_file(
         os.path.join(test_dir, "Cu_mp-30_conventional_standard.cif"))
     GB_Cu_conv = GrainBoundaryGenerator(cls.Cu_conv)
     cls.Cu_GB1 = GB_Cu_conv.gb_from_parameters(
         [1, 2, 3],
         123.74898859588858,
         expand_times=4,
         vacuum_thickness=1.5,
         ab_shift=[0.0, 0.0],
         plane=[1, 3, 1],
         rm_ratio=0.0,
     )
     cls.Cu_GB2 = GB_Cu_conv.gb_from_parameters(
         [1, 2, 3],
         123.74898859588858,
         expand_times=4,
         vacuum_thickness=1.5,
         ab_shift=[0.2, 0.2],
         rm_ratio=0.0,
     )
 def test_apply_transformation(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         Li_bulk = Structure.from_spacegroup("Im-3m",
                                             Lattice.cubic(2.96771), ["Li"],
                                             [[0, 0, 0]])
         gb_gen_params_s3 = {
             "rotation_axis": [1, 1, 1],
             "rotation_angle": 60.0,
             "expand_times": 2,
             "vacuum_thickness": 0.0,
             "normal": True,
             "ratio": None,
             "plane": None
         }
         gbg = GrainBoundaryGenerator(Li_bulk)
         gb_from_generator = gbg.gb_from_parameters(**gb_gen_params_s3)
         gbt_s3 = GrainBoundaryTransformation(**gb_gen_params_s3)
         gb_from_trans = gbt_s3.apply_transformation(Li_bulk)
         self.assertArrayAlmostEqual(gb_from_generator.lattice.matrix,
                                     gb_from_trans.lattice.matrix)
         self.assertArrayAlmostEqual(gb_from_generator.cart_coords,
                                     gb_from_trans.cart_coords)
Beispiel #12
0
 def test_apply_transformation(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         Al_bulk = Structure.from_spacegroup("Fm-3m",
                                             Lattice.cubic(2.8575585),
                                             ["Al"], [[0, 0, 0]])
         gb_gen_params_s5 = {
             "rotation_axis": [1, 0, 0],
             "rotation_angle": 53.13010235415599,
             "expand_times": 3,
             "vacuum_thickness": 0.0,
             "normal": True,
             "plane": [0, -1, -3],
             'rm_ratio': 0.6
         }
         gbg = GrainBoundaryGenerator(Al_bulk)
         gb_from_generator = gbg.gb_from_parameters(**gb_gen_params_s5)
         gbt_s5 = GrainBoundaryTransformation(**gb_gen_params_s5)
         gb_from_trans = gbt_s5.apply_transformation(Al_bulk)
         self.assertArrayAlmostEqual(gb_from_generator.lattice.matrix,
                                     gb_from_trans.lattice.matrix)
         self.assertArrayAlmostEqual(gb_from_generator.cart_coords,
                                     gb_from_trans.cart_coords)
Beispiel #13
0
 def test_enum_possible_plane_cubic(self):
     all_plane = GrainBoundaryGenerator.enum_possible_plane_cubic(
         4, [1, 1, 1], 60)
     self.assertEqual(len(all_plane["Twist"]), 1)
     self.assertEqual(len(all_plane["Symmetric tilt"]), 6)
     self.assertEqual(len(all_plane["Normal tilt"]), 12)
Beispiel #14
0
 def test_enum_possible_plane_cubic(self):
     all_plane = GrainBoundaryGenerator.enum_possible_plane_cubic(4, [1, 1, 1], 60)
     self.assertEqual(len(all_plane['Twist']), 1)
     self.assertEqual(len(all_plane['Symmetric tilt']), 6)
     self.assertEqual(len(all_plane['Normal tilt']), 12)
Beispiel #15
0
    def test_enum_sigma_rho(self):
        true_100 = [7, 11, 43, 13, 41, 19, 47, 31]
        sigma_100 = list(GrainBoundaryGenerator.enum_sigma_rho(50, [1, 0, 0], [15, 4]).keys())

        self.assertListEqual(sorted(true_100), sorted(sigma_100))
Beispiel #16
0
    def test_enum_sigma_ort(self):
        true_100 = [41, 37, 39, 5, 15, 17, 13, 3, 25, 29]
        sigma_100 = list(GrainBoundaryGenerator.enum_sigma_ort(50, [1, 0, 0], [270, 30, 29]).keys())

        self.assertListEqual(sorted(true_100), sorted(sigma_100))
Beispiel #17
0
    def test_enum_sigma_ort(self):
        true_100 = [41, 37, 39, 5, 15, 17, 13, 3, 25, 29]
        sigma_100 = list(GrainBoundaryGenerator.enum_sigma_ort(50, [1, 0, 0], [270, 30, 29]).keys())

        self.assertListEqual(sorted(true_100), sorted(sigma_100))
Beispiel #18
0
    def test_enum_sigma_rho(self):
        true_100 = [7, 11, 43, 13, 41, 19, 47, 31]
        sigma_100 = list(GrainBoundaryGenerator.enum_sigma_rho(50, [1, 0, 0], [15, 4]).keys())

        self.assertListEqual(sorted(true_100), sorted(sigma_100))