Esempio n. 1
0
 def test_scattering_vector(self):
     Fe_fcc = Lattice.face_centered_cubic(0.287)  # FCC iron
     hkl = HklPlane(2, 0, 0, Fe_fcc)
     Gc = hkl.scattering_vector()
     self.assertAlmostEqual(np.linalg.norm(Gc),
                            1 / hkl.interplanar_spacing())
     Al_fcc = Lattice.face_centered_cubic(0.405)
     hkl = HklPlane(0, 0, 2, lattice=Al_fcc)
     Gc = hkl.scattering_vector()
     self.assertAlmostEqual(np.linalg.norm(Gc),
                            1 / hkl.interplanar_spacing())
Esempio n. 2
0
 def setUp(self):
     """testing the laue module:"""
     self.ni = Lattice.from_symbol('Ni')
     self.al = Lattice.face_centered_cubic(0.40495)
     self.g4 = Orientation.from_rodrigues(
         [0.0499199, -0.30475322, 0.10396082])
     self.spots = np.array([[76, 211], [77, 281], [86, 435], [90, 563],
                            [112, 128], [151, 459], [151, 639], [161, 543],
                            [170, 325], [176, 248], [189, 70], [190, 375],
                            [213, 670], [250, 167], [294, 54], [310, 153],
                            [323, 262], [358, 444], [360, 507], [369, 163],
                            [378, 535], [384, 86], [402, 555], [442, 139],
                            [444, 224], [452, 565], [476, 292], [496, 88],
                            [501, 547], [514, 166], [522, 525], [531, 433],
                            [536, 494], [559, 264], [581, 57], [625, 168],
                            [663, 607], [679, 69], [686, 363], [694, 240],
                            [703, 315], [728, 437], [728, 518], [743, 609],
                            [756, 128], [786, 413], [789, 271], [790, 534],
                            [791, 205], [818, 123]])
Esempio n. 3
0
    def test_dct_omega_angles(self):
        # test with a BCC Titanium lattice
        lambda_keV = 30
        lambda_nm = 1.2398 / lambda_keV
        a = 0.3306  # lattice parameter in nm
        Ti_bcc = Lattice.cubic(a)
        (h, k, l) = (0, 1, 1)
        hkl = HklPlane(h, k, l, lattice=Ti_bcc)
        o = Orientation.from_euler((103.517, 42.911, 266.452))
        theta = hkl.bragg_angle(lambda_keV, verbose=False)

        gt = o.orientation_matrix(
        )  # our B (here called gt) corresponds to g^{-1} in Poulsen 2004
        A = h * gt[0, 0] + k * gt[1, 0] + l * gt[2, 0]
        B = -h * gt[0, 1] - k * gt[1, 1] - l * gt[2, 1]
        C = -2 * a * np.sin(
            theta
        )**2 / lambda_nm  # the minus sign comes from the main equation
        Delta = 4 * (A**2 + B**2 - C**2)
        self.assertEqual(Delta > 0, True)
        t1 = (B - 0.5 * np.sqrt(Delta)) / (A + C)
        t2 = (B + 0.5 * np.sqrt(Delta)) / (A + C)
        # verifying A cos(w) + B sin(w) = C:'
        for t in (t1, t2):
            x = A * (1 - t**2) / (1 + t**2) + B * 2 * t / (1 + t**2)
            self.assertAlmostEqual(x, C, 2)
        # verifying (A + C) * t**2 - 2 * B * t + (C - A) = 0'
        for t in (t1, t2):
            self.assertAlmostEqual((A + C) * t**2 - 2 * B * t + (C - A), 0.0,
                                   2)
        (w1, w2) = o.dct_omega_angles(hkl, lambda_keV, verbose=False)
        self.assertAlmostEqual(w1, 196.709, 2)
        self.assertAlmostEqual(w2, 28.334, 2)
        # test with an FCC Aluminium-Lithium lattice
        a = 0.40495  # lattice parameter in nm
        Al_fcc = Lattice.face_centered_cubic(a)
        hkl = HklPlane(-1, 1, 1, Al_fcc)
        o = Orientation.from_rodrigues([0.0499, -0.3048, 0.1040])
        w1, w2 = o.dct_omega_angles(hkl, 40, verbose=False)
        self.assertAlmostEqual(w1, 109.2, 1)
        self.assertAlmostEqual(w2, 296.9, 1)
Esempio n. 4
0
lab_frame = axes_actor(1, fontSize=50)
lab_frame.SetCylinderRadius(0.02)
s3d.add(lab_frame)

crystal_frame = axes_actor(0.6, fontSize=50, axisLabels=None)
crystal_frame.SetCylinderRadius(0.05)
collection = vtk.vtkPropCollection()
crystal_frame.GetActors(collection)
for i in range(collection.GetNumberOfItems()):
    collection.GetItemAsObject(i).GetProperty().SetColor(0.0, 0.0, 0.0)
apply_orientation_to_actor(crystal_frame, orientation)
s3d.add(crystal_frame)

a = 1.0
l = Lattice.face_centered_cubic(a)
fcc_lattice = lattice_3d(l, crystal_orientation=orientation)
set_opacity(fcc_lattice, 0.3)
s3d.add(fcc_lattice)

# arrow to show 111 lattice vector
Vc = np.array([a, a, a])
Vs = np.dot(g.T, Vc)
vector = unit_arrow_3d((0., 0., 0.), Vs, make_unit=False)
s3d.add(vector)

# add some text actors
euler_str = 'Crystal Euler angles = (%.1f, %.1f, %.1f)\n' \
            'Vc=[1, 1, 1]\n' \
            'Vs=[%.3f, %.3f, %.3f]' % (phi1, Phi, phi2, Vs[0], Vs[1], Vs[2])
euler_text = text(euler_str, coords=(0.5, 0.05))
Esempio n. 5
0
s3d = Scene3D(display=False, ren_size=(800, 800), name=base_name)

# specify the grain orientation
o1 = Orientation.from_euler(numpy.array([45., 0., 0.]))  # grain 1

# choose slip plane normals and directions to display in grain
n1 = numpy.array([1.0, 1.0, -1.0])
l1 = numpy.array([1.0, 1.0, 2.0])
d1 = '[112]'
n2 = numpy.array([1.0, 1.0, 1.0])
l2 = numpy.array([1.0, 1.0, -2.0])
d2 = '[11-2]'
nld = [[n1, l1, d1], [n2, l2, d2]]

# we use a unit lattice cell to represent the mesh
l_xyz = Lattice.face_centered_cubic(1.0)
g1 = create_mesh_outline_3d_with_planes(l_xyz, o1, nld)
s3d.add(g1)

# add axes actor
axes = axes_actor(0.5, fontSize=40)
s3d.add(axes)

# set up camera
cam = vtk.vtkCamera()
cam.SetViewUp(0, 0, 1)
cam.SetPosition(4.0, -1.5, 1.8)
cam.SetFocalPoint(0.5, 0.5, 0.6)
s3d.set_camera(cam)
s3d.render()