Esempio n. 1
0
def facepole_goniometricangles(facepole, unitcell):
    """
    Return the goniometric angles (:math:`\\phi` and :math:`\\rho`)
    for a face pole of a given unit cell.
    
    :type facepole: :class:`vectors.Vector3D`
    
    :type unitcell: :class:`unitcell.UnitCell`
    
    :return: (:math:`\\phi`, :math:`\\rho`)
    :rtype: :class:`tuple`
    
    **References**
    
      Example 2.20 from Mathematical Crystallography
    
    """
    b = matrices.inverse(matrices.transpose(unitcell.cartesianmatrix))

    # Change basis of face pole (reciprocal basis) into the cartesian basis
    s_c = b * facepole

    # Normalize r_c to have a unit length
    s_c.normalize()

    # Find phi and rho
    rho = acos(s_c[2])
    phi = atan2(s_c[0], s_c[1])

    return phi, rho
Esempio n. 2
0
    def testcartesianmatrix(self):
        alpha = 93.11 / 180.0 * pi
        beta = 115.91 / 180.0 * pi
        gamma = 91.26 / 180.0 * pi
        L = unitcell.create_triclinic_unitcell(8.173, 12.869, 14.165, alpha,
                                               beta, gamma)

        cartesianmatrix = L.cartesianmatrix
        expected_cartesianmatrix = matrices.Matrix3D(
            [7.3513, -0.65437, 0.0], [0.0, 12.8333, 0.0],
            [-3.5716, -0.69886, 14.165])
        self.assertTrue(
            matrices.almostequal(cartesianmatrix, expected_cartesianmatrix, 2))

        # Identity G = A^T A
        g = matrices.transpose(cartesianmatrix) * cartesianmatrix
        self.assertTrue(matrices.almostequal(g, L.metricalmatrix, 4))
Esempio n. 3
0
    def testcartesianmatrix(self):
        alpha = 93.11 / 180.0 * pi
        beta = 115.91 / 180.0 * pi
        gamma = 91.26 / 180.0 * pi
        L = unitcell.create_triclinic_unitcell(8.173, 12.869, 14.165,
                                               alpha, beta, gamma)

        cartesianmatrix = L.cartesianmatrix
        expected_cartesianmatrix = matrices.Matrix3D([7.3513, -0.65437, 0.0],
                                                     [0.0, 12.8333, 0.0],
                                                     [-3.5716, -0.69886, 14.165])
        self.assertTrue(matrices.almostequal(cartesianmatrix,
                                             expected_cartesianmatrix, 2))

        # Identity G = A^T A
        g = matrices.transpose(cartesianmatrix) * cartesianmatrix
        self.assertTrue(matrices.almostequal(g, L.metricalmatrix, 4))
Esempio n. 4
0
def interplanarangle(plane1, plane2, unitcell):
    """
    Return the interplanar angle between *plane1* and *plane2* of a unit cell.
    
    :type plane1: :class:`plane.Plane`
    
    :type plane2: :class:`plane.Plane`
    
    :arg unitcell: unit cell of *plane1* and *plane2*
    :type unitcell: :class:`unitcell.UnitCell`
    
    :return: angle between *plane1* and *plane2* in radians
    :rtype: :class:`float`
    
    """
    b = matrices.inverse(matrices.transpose(unitcell.cartesianmatrix))

    plane1_c = b * plane1
    plane2_c = b * plane2

    return vectors.angle(plane1_c, plane2_c)
Esempio n. 5
0
 def testtranspose(self):
     expected_m1_transpose = matrices.Matrix3D(1, 0, 5, 2, 1, 6, 3, 4, 0)
     m1_transpose = matrices.transpose(self.m1)
     self.assertEqual(expected_m1_transpose, m1_transpose)
Esempio n. 6
0
 def testtranspose(self):
     m1 = copy.deepcopy(self.m1)
     m1.transpose()
     self.assertEqual(m1, matrices.transpose(self.m1))
Esempio n. 7
0
 def testtranspose(self):
     expected_m1_transpose = matrices.Matrix3D(1, 0, 5, 2, 1, 6, 3, 4, 0)
     m1_transpose = matrices.transpose(self.m1)
     self.assertEqual(expected_m1_transpose, m1_transpose)
Esempio n. 8
0
 def testtranspose(self):
     m1 = copy.deepcopy(self.m1)
     m1.transpose()
     self.assertEqual(m1, matrices.transpose(self.m1))