Example #1
0
def test_axis_angle_from_rotation_matrix():
    for angle in np.linspace(0.0, 2 * np.pi, np.pi / 4):
        for rmatrix in (Rx, Ry, Rz):
            rot_axis, rot_angle = \
                axis_angle_from_rotation_matrix(rmatrix(angle))
            assert_true(
                np.allclose(rotation_matrix(angle=rot_angle, axis=rot_axis),
                            rmatrix(angle)))
Example #2
0
def test_axis_angle_from_rotation_matrix():
    for angle in np.linspace(0.0, 2 * np.pi, np.pi / 4):
        for rmatrix in (Rx, Ry, Rz):
            rot_axis, rot_angle = \
                axis_angle_from_rotation_matrix(rmatrix(angle))
            assert_true(np.allclose(rotation_matrix(angle=rot_angle,
                                                    axis=rot_axis),
                                    rmatrix(angle)))
Example #3
0
    def rotate(self,
               angle=None,
               axis=None,
               anchor_point=None,
               rot_point=None,
               from_vector=None,
               to_vector=None,
               degrees=False,
               transform_matrix=None,
               verbose=False,
               **kwargs):
        """Rotate unit cell.

        Parameters
        ----------
        angle : float
        axis : :class:`~sknano.core.math.Vector`, optional
        anchor_point : :class:`~sknano.core.math.Point`, optional
        rot_point : :class:`~sknano.core.math.Point`, optional
        from_vector, to_vector : :class:`~sknano.core.math.Vector`, optional
        degrees : bool, optional
        transform_matrix : :class:`~numpy:numpy.ndarray`

        See Also
        --------
        core.math.rotate

        """
        if self.nd == 2:
            axis = 'z'
        if transform_matrix is None:
            transform_matrix = \
                np.asmatrix(
                    rotation_matrix(angle=angle, axis=axis,
                                    anchor_point=anchor_point,
                                    rot_point=rot_point,
                                    from_vector=from_vector,
                                    to_vector=to_vector, degrees=degrees,
                                    verbose=verbose, **kwargs))
            # print('transform_matrix: {}'.format(transform_matrix))

            # transform_matrix = \
            #     transformation_matrix(angle=angle, axis=axis,
            #                           anchor_point=anchor_point,
            #                           rot_point=rot_point,
            #                           from_vector=from_vector,
            #                           to_vector=to_vector, degrees=degrees,
            #                           verbose=verbose, **kwargs)

        self.orientation_matrix = \
            transform_matrix * self.orientation_matrix
Example #4
0
def test20():
    a = np.sqrt(3) * aCC
    orientation_matrix = rotation_matrix(angle=-np.pi / 6, axis=zhat)
    dlattice = Crystal3DLattice(a=a,
                                b=a,
                                c=2 * r_CC_vdw,
                                alpha=90,
                                beta=90,
                                gamma=120,
                                orientation_matrix=orientation_matrix)
    rlattice = \
        Reciprocal3DLattice(a_star=dlattice.reciprocal_lattice.a_star,
                            b_star=dlattice.reciprocal_lattice.b_star,
                            c_star=dlattice.reciprocal_lattice.c_star,
                            alpha_star=dlattice.reciprocal_lattice.alpha_star,
                            beta_star=dlattice.reciprocal_lattice.beta_star,
                            gamma_star=dlattice.reciprocal_lattice.gamma_star)

    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
        dlattice.reciprocal_lattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))

    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
        rlattice.reciprocal_lattice.matrix))
    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
        dlattice.reciprocal_lattice.matrix))

    pmg_rlattice = \
        pmg.Lattice.from_parameters(dlattice.reciprocal_lattice.a_star,
                                    dlattice.reciprocal_lattice.b_star,
                                    dlattice.reciprocal_lattice.c_star,
                                    dlattice.reciprocal_lattice.alpha_star,
                                    dlattice.reciprocal_lattice.beta_star,
                                    dlattice.reciprocal_lattice.gamma_star)

    print('\npmg_rlattice.matrix:\n{}'.format(pmg_rlattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))
    print('\npmg_rlattice.reciprocal_lattice.matrix:\n{}'.format(
        pmg_rlattice.reciprocal_lattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
        rlattice.reciprocal_lattice.matrix))

    assert_true(np.allclose(rlattice.matrix, pmg_rlattice.matrix))
    assert_true(
        np.allclose(dlattice.reciprocal_lattice.matrix, pmg_rlattice.matrix))
    assert_true(np.allclose(rlattice.matrix, pmg_rlattice.matrix))
Example #5
0
    def rotate(self, **kwargs):
        """Rotate `Atom` vectors.

        Parameters
        ----------
        angle : float
        axis : :class:`~sknano.core.math.Vector`, optional
        anchor_point : :class:`~sknano.core.math.Point`, optional
        rot_point : :class:`~sknano.core.math.Point`, optional
        from_vector, to_vector : :class:`~sknano.core.math.Vector`, optional
        degrees : bool, optional
        transform_matrix : :class:`~numpy:numpy.ndarray`

        """
        if kwargs.get('transform_matrix', None) is None:
            kwargs['transform_matrix'] = rotation_matrix(**kwargs)
        [atom.rotate(**kwargs) for atom in self]
def test20():
    a = np.sqrt(3) * aCC
    orientation_matrix = rotation_matrix(angle=-np.pi / 6, axis=zhat)
    dlattice = Crystal3DLattice(a=a, b=a, c=2 * r_CC_vdw,
                                alpha=90, beta=90, gamma=120,
                                orientation_matrix=orientation_matrix)
    rlattice = \
        Reciprocal3DLattice(a_star=dlattice.reciprocal_lattice.a_star,
                            b_star=dlattice.reciprocal_lattice.b_star,
                            c_star=dlattice.reciprocal_lattice.c_star,
                            alpha_star=dlattice.reciprocal_lattice.alpha_star,
                            beta_star=dlattice.reciprocal_lattice.beta_star,
                            gamma_star=dlattice.reciprocal_lattice.gamma_star)

    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
          dlattice.reciprocal_lattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))

    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
          rlattice.reciprocal_lattice.matrix))
    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
          dlattice.reciprocal_lattice.matrix))

    pmg_rlattice = \
        pmg.Lattice.from_parameters(dlattice.reciprocal_lattice.a_star,
                                    dlattice.reciprocal_lattice.b_star,
                                    dlattice.reciprocal_lattice.c_star,
                                    dlattice.reciprocal_lattice.alpha_star,
                                    dlattice.reciprocal_lattice.beta_star,
                                    dlattice.reciprocal_lattice.gamma_star)

    print('\npmg_rlattice.matrix:\n{}'.format(pmg_rlattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))
    print('\npmg_rlattice.reciprocal_lattice.matrix:\n{}'.format(
          pmg_rlattice.reciprocal_lattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
          rlattice.reciprocal_lattice.matrix))

    assert_true(np.allclose(rlattice.matrix,
                            pmg_rlattice.matrix))
    assert_true(np.allclose(dlattice.reciprocal_lattice.matrix,
                            pmg_rlattice.matrix))
    assert_true(np.allclose(rlattice.matrix,
                            pmg_rlattice.matrix))
Example #7
0
    def rotate(self, angle=None, axis=None, anchor_point=None,
               rot_point=None, from_vector=None, to_vector=None, degrees=False,
               transform_matrix=None, verbose=False, **kwargs):
        """Rotate unit cell.

        Parameters
        ----------
        angle : float
        axis : :class:`~sknano.core.math.Vector`, optional
        anchor_point : :class:`~sknano.core.math.Point`, optional
        rot_point : :class:`~sknano.core.math.Point`, optional
        from_vector, to_vector : :class:`~sknano.core.math.Vector`, optional
        degrees : bool, optional
        transform_matrix : :class:`~numpy:numpy.ndarray`

        See Also
        --------
        core.math.rotate

        """
        if self.nd == 2:
            axis = 'z'
        if transform_matrix is None:
            transform_matrix = \
                np.asmatrix(
                    rotation_matrix(angle=angle, axis=axis,
                                    anchor_point=anchor_point,
                                    rot_point=rot_point,
                                    from_vector=from_vector,
                                    to_vector=to_vector, degrees=degrees,
                                    verbose=verbose, **kwargs))
            # print('transform_matrix: {}'.format(transform_matrix))

            # transform_matrix = \
            #     transformation_matrix(angle=angle, axis=axis,
            #                           anchor_point=anchor_point,
            #                           rot_point=rot_point,
            #                           from_vector=from_vector,
            #                           to_vector=to_vector, degrees=degrees,
            #                           verbose=verbose, **kwargs)

        self.orientation_matrix = \
            transform_matrix * self.orientation_matrix
def test1():
    dlattice = Crystal2DLattice(a=4.0, b=8.0, gamma=120)
    orientation_matrix = rotation_matrix(angle=np.pi/6, axis=zhat)
    rlattice = \
        Reciprocal2DLattice(a_star=dlattice.reciprocal_lattice.a_star,
                            b_star=dlattice.reciprocal_lattice.b_star,
                            gamma_star=dlattice.reciprocal_lattice.gamma_star,
                            orientation_matrix=orientation_matrix)
    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))

    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
          dlattice.reciprocal_lattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
          rlattice.reciprocal_lattice.matrix))

    assert_true(np.allclose(dlattice.matrix,
                            rlattice.reciprocal_lattice.matrix))
    assert_true(np.allclose(dlattice.reciprocal_lattice.matrix,
                            rlattice.matrix))
Example #9
0
def test1():
    dlattice = Crystal2DLattice(a=4.0, b=8.0, gamma=120)
    orientation_matrix = rotation_matrix(angle=np.pi / 6, axis=zhat)
    rlattice = \
        Reciprocal2DLattice(a_star=dlattice.reciprocal_lattice.a_star,
                            b_star=dlattice.reciprocal_lattice.b_star,
                            gamma_star=dlattice.reciprocal_lattice.gamma_star,
                            orientation_matrix=orientation_matrix)
    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))

    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
        dlattice.reciprocal_lattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
        rlattice.reciprocal_lattice.matrix))

    assert_true(
        np.allclose(dlattice.matrix, rlattice.reciprocal_lattice.matrix))
    assert_true(
        np.allclose(dlattice.reciprocal_lattice.matrix, rlattice.matrix))
Example #10
0
def test_rotation_matrix():
    assert_true(np.allclose(rotation_matrix(angle=np.pi/2),
                            np.array([[0.0, -1.0], [1.0, 0.0]])))

    sqrt2 = np.sqrt(2)
    assert_true(np.allclose(rotation_matrix(angle=np.pi/4),
                            np.array([[1 / sqrt2, -1 / sqrt2],
                                      [1 / sqrt2, 1 / sqrt2]])))

    sqrt3 = np.sqrt(3)
    assert_true(np.allclose(
        rotation_matrix(angle=np.pi/2, axis=Vector(np.ones(3))),
        np.array([[1 / 3, 1 / 3 - 1 / sqrt3, 1 / 3 + 1 / sqrt3],
                  [1 / 3 + 1 / sqrt3, 1 / 3, 1 / 3 - 1 / sqrt3],
                  [1 / 3 - 1 / sqrt3, 1 / 3 + 1 / sqrt3, 1 / 3]])))

    [[assert_true(np.allclose(
        Rmat(angle=angle), rotation_matrix(angle=angle, axis=axis)))
        for angle in np.linspace(0.0, 2 * np.pi, np.pi / 4)]
        for Rmat, axis in zip((Rx, Ry, Rz), ('x', 'y', 'z'))]

    assert_true(np.allclose(rotation_matrix(angle=np.pi / 2),
                            rotation_matrix(from_vector=[1, 0],
                                            to_vector=[0, 1])))

    assert_true(np.allclose(rotation_matrix(angle=-np.pi / 2),
                            rotation_matrix(from_vector=[0, 1],
                                            to_vector=[1, 0])))

    assert_true(np.allclose(
        rotation_matrix(angle=np.pi / 2, axis=[0, 0, 1]),
        rotation_matrix(from_vector=[1, 0, 0], to_vector=[0, 1, 0])))

    assert_true(np.allclose(
        rotation_matrix(angle=-np.pi / 2, axis=[0, 0, 1]),
        rotation_matrix(from_vector=[0, 1, 0], to_vector=[1, 0, 0])))
def test11():
    a = np.sqrt(3) * aCC
    dlattice = Crystal3DLattice(a=a, b=a, c=2 * r_CC_vdw,
                                alpha=90, beta=90, gamma=120)

    orientation_matrix = rotation_matrix(angle=np.pi / 6, axis=zhat)
    rlattice = \
        Reciprocal3DLattice(a_star=dlattice.reciprocal_lattice.a_star,
                            b_star=dlattice.reciprocal_lattice.b_star,
                            c_star=dlattice.reciprocal_lattice.c_star,
                            alpha_star=dlattice.reciprocal_lattice.alpha_star,
                            beta_star=dlattice.reciprocal_lattice.beta_star,
                            gamma_star=dlattice.reciprocal_lattice.gamma_star,
                            orientation_matrix=orientation_matrix)

    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
          dlattice.reciprocal_lattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))

    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
          rlattice.reciprocal_lattice.matrix))

    # assert_equal(dlattice.reciprocal_lattice, rlattice)
    assert_true(np.allclose(dlattice.reciprocal_lattice.matrix,
                            rlattice.matrix))
    assert_true(np.allclose(dlattice.matrix,
                            rlattice.reciprocal_lattice.matrix))

    # print('\n{}'.format(np.linalg.inv(dlattice.matrix)))
    # print(np.linalg.inv(dlattice.matrix) * dlattice.matrix)
    # print(np.linalg.inv(dlattice.matrix).T)
    # print(dlattice.reciprocal_lattice.matrix)
    # print(dlattice.reciprocal_lattice.b1)
    # print(dlattice.reciprocal_lattice.b2)
    # print(dlattice.reciprocal_lattice.b3)
    # print(rlattice.matrix)
    # print(rlattice.b1)
    # print(rlattice.b2)
    # print(rlattice.b3)

    assert_equal(dlattice.reciprocal_lattice, rlattice)
    assert_equal(dlattice.reciprocal_lattice.b1, rlattice.b1)
    assert_equal(dlattice.reciprocal_lattice.b2, rlattice.b2)
    assert_equal(dlattice.reciprocal_lattice.b3, rlattice.b3)

    assert_true(np.allclose(dlattice.reciprocal_lattice.matrix,
                            rlattice.matrix))
    assert_true(np.allclose(dlattice.reciprocal_lattice.metric_tensor,
                            rlattice.metric_tensor))

    pmg_dlattice = pmg.Lattice(dlattice.matrix)
    print('\npmg_dlattice.matrix:\n{}'.format(pmg_dlattice.matrix))
    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\npmg_dlattice.reciprocal_lattice.matrix:\n{}'.format(
          pmg_dlattice.reciprocal_lattice.matrix))
    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
          dlattice.reciprocal_lattice.matrix))
    assert_true(np.allclose(dlattice.a, pmg_dlattice.a))
    assert_true(np.allclose(dlattice.b, pmg_dlattice.b))
    assert_true(np.allclose(dlattice.c, pmg_dlattice.c))
    assert_true(np.allclose(np.asarray(dlattice.a1), pmg_dlattice.matrix[0]))
    assert_true(np.allclose(np.asarray(dlattice.a2), pmg_dlattice.matrix[1]))
    assert_true(np.allclose(np.asarray(dlattice.a3), pmg_dlattice.matrix[2]))

    assert_true(np.allclose(dlattice.matrix, pmg_dlattice.matrix))

    assert_true(np.allclose(dlattice.ortho_matrix.T,
                            pmg.Lattice(dlattice.ortho_matrix.T).matrix))

    assert_true(np.allclose(pmg.Lattice(dlattice.matrix).metric_tensor,
                            dlattice.metric_tensor))
    assert_true(np.allclose(pmg.Lattice(dlattice.ortho_matrix.T).metric_tensor,
                            dlattice.metric_tensor))
    assert_true(np.allclose(pmg.Lattice(dlattice.matrix).matrix,
                            dlattice.matrix))
    assert_true(np.allclose(pmg.Lattice(dlattice.ortho_matrix.T).matrix,
                            dlattice.matrix))

    # print('latt_from_inv_latt_matrix_transpose:\n{}\n'.format(
    #       latt_from_inv_latt_matrix_transpose.matrix))

    # print('rlattice.reciprocal_lattice.matrix:\n{}'.format(
    #       rlattice.reciprocal_lattice.matrix))

    assert_true(np.allclose(pmg.Lattice(dlattice.matrix).matrix,
                            rlattice.reciprocal_lattice.matrix))

    # print('rlattice.reciprocal_lattice.matrix:\n{}'.format(
    #       rlattice.reciprocal_lattice.matrix))
    # print('pmg.Lattice(np.linalg.inv(dlattice.matrix).T).'
    #       'reciprocal_lattice_crystallographic.matrix:\n{}'
    #       .format(pmg.Lattice(np.linalg.inv(dlattice.matrix).T)
    #               .reciprocal_lattice_crystallographic.matrix))
    # print('pmg.Lattice.from_parameters(...):\n{}\n'.format(
    #       rezero_array(pmg.Lattice.from_parameters(
    #                    dlattice.reciprocal_lattice.a_star,
    #                    dlattice.reciprocal_lattice.b_star,
    #                    dlattice.reciprocal_lattice.c_star,
    #                    dlattice.reciprocal_lattice.alpha_star,
    #                    dlattice.reciprocal_lattice.beta_star,
    #                    dlattice.reciprocal_lattice.gamma_star)
    #                    .reciprocal_lattice_crystallographic.matrix)))

    # print('dlattice.ortho_matrix:\n{}'.format(dlattice.ortho_matrix))
    # print('np.linalg.inv(dlattice.matrix).T:\n{}'.format(np.linalg.inv(
    #       dlattice.matrix).T))
    # print('rlattice.reciprocal_lattice.ortho_matrix:\n{}'
    #       .format(rlattice.reciprocal_lattice.ortho_matrix))
    # print('rlattice.reciprocal_lattice.ortho_matrix:\n{}\n'.
    #       format(rlattice.reciprocal_lattice.ortho_matrix))

    # print('dlattice.reciprocal_lattice.ortho_matrix:\n{}'.format(
    #       dlattice.reciprocal_lattice.ortho_matrix))
    # print('rlattice.ortho_matrix:\n{}'.format(
    #       rlattice.ortho_matrix))
    # print('rlattice.ortho_matrix:\n{}\n'.format(
    #       rlattice.ortho_matrix))

    assert_true(np.allclose(dlattice.ortho_matrix,
                            rlattice.reciprocal_lattice.
                            ortho_matrix))
    assert_true(np.allclose(dlattice.reciprocal_lattice.ortho_matrix,
                            rlattice.ortho_matrix))
    assert_equal(dlattice, rlattice.reciprocal_lattice)
    assert_equal(dlattice.reciprocal_lattice, rlattice)

    print(dlattice.matrix * rlattice.matrix.T)
    assert_true(np.allclose(dlattice.matrix * rlattice.matrix.T,
                np.eye(3)))
Example #12
0
def test_rotation_matrix():
    assert_true(
        np.allclose(rotation_matrix(angle=np.pi / 2),
                    np.array([[0.0, -1.0], [1.0, 0.0]])))

    sqrt2 = np.sqrt(2)
    assert_true(
        np.allclose(
            rotation_matrix(angle=np.pi / 4),
            np.array([[1 / sqrt2, -1 / sqrt2], [1 / sqrt2, 1 / sqrt2]])))

    sqrt3 = np.sqrt(3)
    assert_true(
        np.allclose(
            rotation_matrix(angle=np.pi / 2, axis=Vector(np.ones(3))),
            np.array([[1 / 3, 1 / 3 - 1 / sqrt3, 1 / 3 + 1 / sqrt3],
                      [1 / 3 + 1 / sqrt3, 1 / 3, 1 / 3 - 1 / sqrt3],
                      [1 / 3 - 1 / sqrt3, 1 / 3 + 1 / sqrt3, 1 / 3]])))

    [[
        assert_true(
            np.allclose(Rmat(angle=angle),
                        rotation_matrix(angle=angle, axis=axis)))
        for angle in np.linspace(0.0, 2 * np.pi, np.pi / 4)
    ] for Rmat, axis in zip((Rx, Ry, Rz), ('x', 'y', 'z'))]

    assert_true(
        np.allclose(rotation_matrix(angle=np.pi / 2),
                    rotation_matrix(from_vector=[1, 0], to_vector=[0, 1])))

    assert_true(
        np.allclose(rotation_matrix(angle=-np.pi / 2),
                    rotation_matrix(from_vector=[0, 1], to_vector=[1, 0])))

    assert_true(
        np.allclose(
            rotation_matrix(angle=np.pi / 2, axis=[0, 0, 1]),
            rotation_matrix(from_vector=[1, 0, 0], to_vector=[0, 1, 0])))

    assert_true(
        np.allclose(
            rotation_matrix(angle=-np.pi / 2, axis=[0, 0, 1]),
            rotation_matrix(from_vector=[0, 1, 0], to_vector=[1, 0, 0])))
Example #13
0
def test11():
    a = np.sqrt(3) * aCC
    dlattice = Crystal3DLattice(a=a,
                                b=a,
                                c=2 * r_CC_vdw,
                                alpha=90,
                                beta=90,
                                gamma=120)

    orientation_matrix = rotation_matrix(angle=np.pi / 6, axis=zhat)
    rlattice = \
        Reciprocal3DLattice(a_star=dlattice.reciprocal_lattice.a_star,
                            b_star=dlattice.reciprocal_lattice.b_star,
                            c_star=dlattice.reciprocal_lattice.c_star,
                            alpha_star=dlattice.reciprocal_lattice.alpha_star,
                            beta_star=dlattice.reciprocal_lattice.beta_star,
                            gamma_star=dlattice.reciprocal_lattice.gamma_star,
                            orientation_matrix=orientation_matrix)

    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
        dlattice.reciprocal_lattice.matrix))
    print('\nrlattice.matrix:\n{}'.format(rlattice.matrix))

    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\nrlattice.reciprocal_lattice.matrix:\n{}'.format(
        rlattice.reciprocal_lattice.matrix))

    # assert_equal(dlattice.reciprocal_lattice, rlattice)
    assert_true(
        np.allclose(dlattice.reciprocal_lattice.matrix, rlattice.matrix))
    assert_true(
        np.allclose(dlattice.matrix, rlattice.reciprocal_lattice.matrix))

    # print('\n{}'.format(np.linalg.inv(dlattice.matrix)))
    # print(np.linalg.inv(dlattice.matrix) * dlattice.matrix)
    # print(np.linalg.inv(dlattice.matrix).T)
    # print(dlattice.reciprocal_lattice.matrix)
    # print(dlattice.reciprocal_lattice.b1)
    # print(dlattice.reciprocal_lattice.b2)
    # print(dlattice.reciprocal_lattice.b3)
    # print(rlattice.matrix)
    # print(rlattice.b1)
    # print(rlattice.b2)
    # print(rlattice.b3)

    assert_equal(dlattice.reciprocal_lattice, rlattice)
    assert_equal(dlattice.reciprocal_lattice.b1, rlattice.b1)
    assert_equal(dlattice.reciprocal_lattice.b2, rlattice.b2)
    assert_equal(dlattice.reciprocal_lattice.b3, rlattice.b3)

    assert_true(
        np.allclose(dlattice.reciprocal_lattice.matrix, rlattice.matrix))
    assert_true(
        np.allclose(dlattice.reciprocal_lattice.metric_tensor,
                    rlattice.metric_tensor))

    pmg_dlattice = pmg.Lattice(dlattice.matrix)
    print('\npmg_dlattice.matrix:\n{}'.format(pmg_dlattice.matrix))
    print('\ndlattice.matrix:\n{}'.format(dlattice.matrix))
    print('\npmg_dlattice.reciprocal_lattice.matrix:\n{}'.format(
        pmg_dlattice.reciprocal_lattice.matrix))
    print('\ndlattice.reciprocal_lattice.matrix:\n{}'.format(
        dlattice.reciprocal_lattice.matrix))
    assert_true(np.allclose(dlattice.a, pmg_dlattice.a))
    assert_true(np.allclose(dlattice.b, pmg_dlattice.b))
    assert_true(np.allclose(dlattice.c, pmg_dlattice.c))
    assert_true(np.allclose(np.asarray(dlattice.a1), pmg_dlattice.matrix[0]))
    assert_true(np.allclose(np.asarray(dlattice.a2), pmg_dlattice.matrix[1]))
    assert_true(np.allclose(np.asarray(dlattice.a3), pmg_dlattice.matrix[2]))

    assert_true(np.allclose(dlattice.matrix, pmg_dlattice.matrix))

    assert_true(
        np.allclose(dlattice.ortho_matrix.T,
                    pmg.Lattice(dlattice.ortho_matrix.T).matrix))

    assert_true(
        np.allclose(
            pmg.Lattice(dlattice.matrix).metric_tensor,
            dlattice.metric_tensor))
    assert_true(
        np.allclose(
            pmg.Lattice(dlattice.ortho_matrix.T).metric_tensor,
            dlattice.metric_tensor))
    assert_true(
        np.allclose(pmg.Lattice(dlattice.matrix).matrix, dlattice.matrix))
    assert_true(
        np.allclose(
            pmg.Lattice(dlattice.ortho_matrix.T).matrix, dlattice.matrix))

    # print('latt_from_inv_latt_matrix_transpose:\n{}\n'.format(
    #       latt_from_inv_latt_matrix_transpose.matrix))

    # print('rlattice.reciprocal_lattice.matrix:\n{}'.format(
    #       rlattice.reciprocal_lattice.matrix))

    assert_true(
        np.allclose(
            pmg.Lattice(dlattice.matrix).matrix,
            rlattice.reciprocal_lattice.matrix))

    # print('rlattice.reciprocal_lattice.matrix:\n{}'.format(
    #       rlattice.reciprocal_lattice.matrix))
    # print('pmg.Lattice(np.linalg.inv(dlattice.matrix).T).'
    #       'reciprocal_lattice_crystallographic.matrix:\n{}'
    #       .format(pmg.Lattice(np.linalg.inv(dlattice.matrix).T)
    #               .reciprocal_lattice_crystallographic.matrix))
    # print('pmg.Lattice.from_parameters(...):\n{}\n'.format(
    #       rezero_array(pmg.Lattice.from_parameters(
    #                    dlattice.reciprocal_lattice.a_star,
    #                    dlattice.reciprocal_lattice.b_star,
    #                    dlattice.reciprocal_lattice.c_star,
    #                    dlattice.reciprocal_lattice.alpha_star,
    #                    dlattice.reciprocal_lattice.beta_star,
    #                    dlattice.reciprocal_lattice.gamma_star)
    #                    .reciprocal_lattice_crystallographic.matrix)))

    # print('dlattice.ortho_matrix:\n{}'.format(dlattice.ortho_matrix))
    # print('np.linalg.inv(dlattice.matrix).T:\n{}'.format(np.linalg.inv(
    #       dlattice.matrix).T))
    # print('rlattice.reciprocal_lattice.ortho_matrix:\n{}'
    #       .format(rlattice.reciprocal_lattice.ortho_matrix))
    # print('rlattice.reciprocal_lattice.ortho_matrix:\n{}\n'.
    #       format(rlattice.reciprocal_lattice.ortho_matrix))

    # print('dlattice.reciprocal_lattice.ortho_matrix:\n{}'.format(
    #       dlattice.reciprocal_lattice.ortho_matrix))
    # print('rlattice.ortho_matrix:\n{}'.format(
    #       rlattice.ortho_matrix))
    # print('rlattice.ortho_matrix:\n{}\n'.format(
    #       rlattice.ortho_matrix))

    assert_true(
        np.allclose(dlattice.ortho_matrix,
                    rlattice.reciprocal_lattice.ortho_matrix))
    assert_true(
        np.allclose(dlattice.reciprocal_lattice.ortho_matrix,
                    rlattice.ortho_matrix))
    assert_equal(dlattice, rlattice.reciprocal_lattice)
    assert_equal(dlattice.reciprocal_lattice, rlattice)

    print(dlattice.matrix * rlattice.matrix.T)
    assert_true(np.allclose(dlattice.matrix * rlattice.matrix.T, np.eye(3)))