Esempio n. 1
0
 def test_tetragonal_direction2(self):
     ZrO2 = Lattice.tetragonal(0.364, 0.527)
     d = HklDirection(1, 1, 1, ZrO2)
     target = np.array([1., 1., 1.448])
     target /= np.linalg.norm(target)
     self.assertAlmostEqual(d.direction()[0], target[0], 4)
     self.assertAlmostEqual(d.direction()[1], target[1], 4)
     self.assertAlmostEqual(d.direction()[2], target[2], 4)
Esempio n. 2
0
 def test_4indices_representation(self):
     u, v, w = HklDirection.four_to_three_indices(2, -1, -1, 0)
     self.assertEqual(u, 1)
     self.assertEqual(v, 0)
     self.assertEqual(w, 0)
     U, V, T, W = HklDirection.three_to_four_indices(2, 1, 0)
     self.assertEqual(U, 1)
     self.assertEqual(V, 0)
     self.assertEqual(T, -1)
     self.assertEqual(W, 0)
Esempio n. 3
0
 def test_angle_with_directions(self):
     (a, b, c) = (1.022, 0.596, 0.481)
     olivine = Lattice.orthorhombic(a, b, c)
     (h1, k1, l1) = (1., 1., 1.)
     (h2, k2, l2) = (3., 3., 2.)
     d1 = HklDirection(h1, k1, l1, olivine)
     d2 = HklDirection(h2, k2, l2, olivine)
     # compare with formula in orthorhombic lattice, angle must be 6.589 degrees
     angle = np.arccos(
         ((h1 * h2 * a**2) + (k1 * k2 * b**2) + (l1 * l2 * c**2)) /
         (np.sqrt(a**2 * h1**2 + b**2 * k1**2 + c**2 * l1**2) *
          np.sqrt(a**2 * h2**2 + b**2 * k2**2 + c**2 * l2**2)))
     self.assertAlmostEqual(d1.angle_with_direction(d2), angle)
Esempio n. 4
0
 def test_angle_between_directions(self):
     d111 = HklDirection(1, 1, 1)
     d110 = HklDirection(1, 1, 0)
     d100 = HklDirection(1, 0, 0)
     dm111 = HklDirection(-1, 1, 1)
     self.assertAlmostEqual(
         d100.angle_with_direction(d110) * 180 / np.pi, 45.0)
     self.assertAlmostEqual(
         d111.angle_with_direction(d110) * 180 / np.pi, 35.26, 2)
     self.assertAlmostEqual(
         d111.angle_with_direction(dm111) * 180 / np.pi, 70.528, 2)
Esempio n. 5
0
 def test_angle_zone(self):
     """Verify the angle between X and a particular zone axis expressed
     in (X, Y, Z), given a crystal orientation."""
     # euler angles in degrees
     phi1 = 89.4
     phi = 92.0
     phi2 = 86.8
     orientation = Orientation.from_euler([phi1, phi, phi2])
     gt = orientation.orientation_matrix().transpose()
     # zone axis
     uvw = HklDirection(1, 0, 5, self.ni)
     ZA = gt.dot(uvw.direction())
     if ZA[0] < 0:
         ZA *= -1  # make sur the ZA vector is going forward
     psi0 = np.arccos(np.dot(ZA, np.array([1., 0., 0.])))
     self.assertAlmostEqual(psi0 * 180 / np.pi, 9.2922, 3)
Esempio n. 6
0
def zone_axis_list(angle,
                   orientation,
                   lattice,
                   max_miller=5,
                   Xu=np.array([1., 0., 0.]),
                   verbose=False):
    """
    This function allows to get easily the Miller indices of zone axis present in a pattern.

    :param float list angle: the angle max or the zone axis angle range admissible around the detector center.
    :param orientation: The orientation of the crystal lattice.
    :param lattice: The corresponding crystal lattice, instance of Lattice.
    :param int max_miller: Maximal value allowed of Miller indices direction.
    :param array Xu: The unit vector of the incident X-ray beam (default along the X-axis).
    :param bool verbose: activate verbose mode (default False).
    :return: A list of HklDirection instance of all zone axis in the angle range.
    """
    ZA_list = []
    if len(angle) == 1:
        angle_max = angle[0] * np.pi / 180.
        angle_min = 0.
    if len(angle) == 2:
        angle_max = max(angle) * np.pi / 180.
        angle_min = min(angle) * np.pi / 180.
        print("Get the indices of directions between [%d, %d] degrees" %
              (min(angle), max(angle)))
    indices = range(-max_miller, max_miller + 1)
    for h in indices:
        for k in indices:
            for l in indices:
                if h == k == l == 0:  # skip (0, 0, 0)
                    continue
                uvw = HklDirection(h, k, l, lattice)
                # compute the direction in the lab frame
                ZA = np.dot(orientation.orientation_matrix().transpose(),
                            uvw.direction())
                psi = np.arccos(np.dot(ZA, Xu))
                if angle_min < psi < angle_max:
                    if verbose == True:
                        print(
                            'found zone axis [%d%d%d] at %.1f deg from incident beam'
                            % (h, k, l, (psi * 180 / pi)))
                    ZA_list.append(
                        uvw
                    )  #zones axis list which are inferior with max angle
    ZA_list = HklObject.skip_higher_order(ZA_list)
    return ZA_list
Esempio n. 7
0
 def test_tetragonal_direction(self):
     bct = Lattice.body_centered_tetragonal(0.28, 0.40)
     d111 = HklDirection(1, 1, 1, bct)
     d110 = HklDirection(1, 1, 0, bct)
     self.assertAlmostEqual(d111.direction()[0], 0.49746834, 5)
     self.assertAlmostEqual(d111.direction()[1], 0.49746834, 5)
     self.assertAlmostEqual(d111.direction()[2], 0.71066905, 5)
     self.assertAlmostEqual(d110.direction()[0], 0.707106781, 5)
     self.assertAlmostEqual(d110.direction()[1], 0.707106781, 5)
     self.assertAlmostEqual(d110.direction()[2], 0.0, 5)
Esempio n. 8
0
 def test_SchimdFactor(self):
     o = Orientation.from_euler([0., 0., 0.])
     ss = SlipSystem(HklPlane(1, 1, 1), HklDirection(0, 1, -1))
     self.assertAlmostEqual(o.schmid_factor(ss), 0.4082, 4)
Esempio n. 9
0
 def test_skip_higher_order(self):
     uvw = HklDirection(3, 3, 1)
     hkl_planes = uvw.find_planes_in_zone(max_miller=3)
     self.assertEqual(len(hkl_planes), 18)
     hkl_planes2 = HklObject.skip_higher_order(hkl_planes)
     self.assertEqual(len(hkl_planes2), 7)