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_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. 3
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. 4
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