コード例 #1
0
def detector2reciprocal_lattice(
    sample_tilt: float,
    detector_tilt: float,
    lattice: Lattice,
    rotation: Rotation,
) -> np.ndarray:
    """Rotation U_Kstar from detector to reciprocal crystal lattice
    frame Kstar.

    Parameters
    ----------
    sample_tilt
        Sample tilt in degrees.
    detector_tilt
        Detector tilt in degrees.
    lattice
        Crystal lattice.
    rotation
        Unit cell rotation from the sample frame S.

    Returns
    -------
    np.ndarray
    """
    # Rotation U_S to align the detector frame D with the sample frame S
    _detector2sample = detector2sample(sample_tilt, detector_tilt)

    # Rotation U_O from S to the Cartesian crystal frame C
    sample2cartesian = rotation.to_matrix()

    # Rotation U_A from C to the reciprocal crystal lattice frame Kstar
    structure_matrix = get_direct_structure_matrix(lattice)
    cartesian2reciprocal = np.linalg.inv(structure_matrix).T

    return cartesian2reciprocal.dot(sample2cartesian).dot(_detector2sample)
コード例 #2
0
 def test_direct_structure_matrix(self, lattice, desired_matrix):
     assert np.allclose(
         get_direct_structure_matrix(lattice), desired_matrix, atol=1e-3
     )