Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions diffsims/crystallography/reciprocal_lattice_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,21 +503,6 @@ def scattering_parameter(self):

return 0.5 * self.gspacing

def rotate_from_matrix(self, rotation_matrix):
"""Rotate the reciprocal lattice vectors using a (3x3) rotation matrix.

This method creates a new instance of :class:`ReciprocalLatticeVector`
with the rotated vectors.

Parameters
----------
rotation_matrix : numpy.ndarray
(3, 3) rotation matrix.
"""
return ReciprocalLatticeVector(
phase=self.phase, xyz=np.matmul(rotation_matrix.T, self.data.T).T
)

@property
def structure_factor(self):
r"""Kinematical structure factors :math:`F`.
Expand Down
16 changes: 9 additions & 7 deletions diffsims/generators/simulation_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def calculate_diffraction2d(
include_zero_vector=with_direct_beam,
)
phase_vectors = []
for rot in rotate.to_matrix():
for rot in rotate:
# Calculate the reciprocal lattice vectors that intersect the Ewald sphere.
(
intersected_vectors,
Expand Down Expand Up @@ -335,7 +335,7 @@ def calculate_diffraction1d(
def get_intersecting_reflections(
self,
recip: ReciprocalLatticeVector,
rot: np.ndarray,
rot: Rotation,
wavelength: float,
max_excitation_error: float,
shape_factor_width: float = None,
Expand All @@ -348,7 +348,8 @@ def get_intersecting_reflections(
recip
The reciprocal lattice vectors to rotate.
rot
The rotation matrix to apply to the reciprocal lattice vectors.
The rotation to apply to the reciprocal lattice vectors.
Orix conventions apply, i.e. "lab2crystal".
wavelength
The wavelength of the electrons in Angstroms.
max_excitation_error
Expand All @@ -361,13 +362,14 @@ def get_intersecting_reflections(
control. If not set will be set equal to max_excitation_error.
"""
initial_hkl = recip.hkl
rotated_vectors = recip.rotate_from_matrix(rot)
# To ease calculations, we transform the reciprocal lattice vectors rather than the electron beam.
# Therefore, we need to invert the rotation, as it normally transforms the beam (lab2crystal).
rotated_vectors = (~rot * recip.to_miller()).data

if with_direct_beam:
rotated_vectors = np.vstack([rotated_vectors.data, [0, 0, 0]])
rotated_vectors = np.vstack([rotated_vectors, [0, 0, 0]])
initial_hkl = np.vstack([initial_hkl, [0, 0, 0]])
else:
rotated_vectors = rotated_vectors.data

# Identify the excitation errors of all points (distance from point to Ewald sphere)
r_sphere = 1 / wavelength
r_spot = np.sqrt(np.sum(np.square(rotated_vectors[:, :2]), axis=1))
Expand Down