Skip to content

Commit be19d4f

Browse files
committed
Adress #234
1 parent ccdb65a commit be19d4f

File tree

4 files changed

+201
-122
lines changed

4 files changed

+201
-122
lines changed

diffsims/crystallography/_diffracting_vector.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ def intensity(self, value):
202202
raise ValueError("Length of intensity array must match number of vectors")
203203
self._intensity = np.array(value)
204204

205-
def calculate_structure_factor(self):
206-
raise NotImplementedError(
207-
"Structure factor calculation not implemented for DiffractionVector. "
208-
"Use ReciprocalLatticeVector instead."
209-
)
205+
# def calculate_structure_factor(self):
206+
# raise NotImplementedError(
207+
# "Structure factor calculation not implemented for DiffractionVector. "
208+
# "Use ReciprocalLatticeVector instead."
209+
# )
210210

211211
def to_flat_polar(self):
212212
"""Return the vectors in polar coordinates as projected onto the x,y plane"""

diffsims/crystallography/reciprocal_lattice_vector.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@ def allowed(self):
644644

645645
# ------------------------- Custom methods ----------------------- #
646646

647-
def calculate_structure_factor(self, scattering_params="xtables"):
647+
def calculate_structure_factor(
648+
self, scattering_params="xtables", debye_waller_factors=None
649+
):
648650
r"""Populate :attr:`structure_factor` with the complex
649651
kinematical structure factor :math:`F_{hkl}` for each vector.
650652
@@ -653,6 +655,8 @@ def calculate_structure_factor(self, scattering_params="xtables"):
653655
scattering_params : str
654656
Which atomic scattering factors to use, either ``"xtables"``
655657
(default) or ``"lobato"``.
658+
debye_waller_factors: dict
659+
Debye-Waller factors for atoms in the structure.
656660
657661
Examples
658662
--------
@@ -712,6 +716,7 @@ def calculate_structure_factor(self, scattering_params="xtables"):
712716
structure=self.phase.structure,
713717
g_indices=hkl_unique,
714718
g_hkls_array=self.phase.structure.lattice.rnorm(hkl_unique),
719+
debye_waller_factors=debye_waller_factors,
715720
scattering_params=scattering_params,
716721
)
717722

@@ -933,6 +938,12 @@ def sanitise_phase(self):
933938
space_group = self.phase.space_group
934939
structure = self.phase.structure
935940

941+
# Lattice basis transform for hexagonal crystals can sometimes move atoms below 0
942+
for atom in structure:
943+
for i in range(3):
944+
if -1e-6 < atom.xyz[i] < 0:
945+
atom.xyz[i] = 0
946+
936947
new_structure = _expand_unit_cell(space_group, structure)
937948
for atom in new_structure:
938949
if np.issubdtype(type(atom.element), np.integer):

0 commit comments

Comments
 (0)