Skip to content

Commit 2bfce64

Browse files
committed
new option for neutron scattering lengths
functions_crystallography.py - added option for neutron scattering lengths from Sears 1995 - 'neutron_isotope_scattering_lengths_sears.dat' tests - Tests now pass as comparison of neutron structure factors with Vesta is now identical - additional tests for functionality added
1 parent fd957bb commit 2bfce64

File tree

9 files changed

+1273
-27
lines changed

9 files changed

+1273
-27
lines changed

Dans_Diffraction/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
Diamond
3232
2017
3333
34-
Version 3.3.1
35-
Last updated: 08/11/2024
34+
Version 3.3.2
35+
Last updated: 20/11/2024
3636
3737
Version History:
3838
02/03/18 1.0 Version History started.
@@ -82,6 +82,7 @@
8282
25/09/24 3.2.4 Fixed error of missing rotation matrices after load_spacegroup. Thanks asteppke!
8383
26/09/24 3.3.0 Added complex neutron scattering lengths for isotopes from package periodictable. Thanks thamnos!
8484
06/11/24 3.3.1 Fixed incorrect cell basis for triclinic cells. Added functions_lattice.py and tests. Thanks LeeRichter!
85+
20/11/24 3.3.2 Added alternate option for neutron scattering lengths
8586
8687
Acknoledgements:
8788
2018 Thanks to Hepesu for help with Python3 support and ideas about breaking up calculations
@@ -162,8 +163,8 @@
162163
'Structures', 'Fdmnes', 'FdmnesAnalysis']
163164

164165

165-
__version__ = '3.3.1'
166-
__date__ = '2024/11/08'
166+
__version__ = '3.3.2'
167+
__date__ = '2024/11/20'
167168

168169

169170
# Build

Dans_Diffraction/classes_scattering.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class Scattering:
104104
# Uses the coefficients for analytical approximation to the scattering factors from:
105105
# "Waasmaier and Kirfel, Acta Cryst. (1995) A51, 416-431"
106106
_use_waaskirf_scattering_factor = False
107+
108+
# Use the neutron scattering factors from the Internation tables (Sears 1995)
109+
_use_sears_scattering_lengths = False
107110

108111
# Thermal Factors
109112
_use_isotropic_thermal_factor = True
@@ -161,6 +164,8 @@ def __str__(self):
161164
out += ' max twotheta: %s\n' % self._scattering_max_twotheta
162165
out += ' ---X-Ray Settings---\n'
163166
out += ' Waasmaier scattering factor: %s\n' % self._use_waaskirf_scattering_factor
167+
out += ' ---Neutron Settings---\n'
168+
out += ' Sears (ITC) scattering lengths: %s\n' % self._use_sears_scattering_lengths
164169
out += ' ---Magnetic Settings---\n'
165170
out += ' Mag. scattering: %s\n' % self._calclate_magnetic_component
166171
out += ' Mag. form factor: %s\n' % self._use_magnetic_form_factor
@@ -185,7 +190,7 @@ def setup_scatter(self, scattering_type=None, energy_kev=None, wavelength_a=None
185190
powder_units=None, powder_pixels=None, powder_lorentz=None, powder_overlap=None,
186191
specular=None, parallel=None, theta_offset=None,
187192
min_theta=None, max_theta=None, min_twotheta=None, max_twotheta=None,
188-
output=True, scattering_factors=None, magnetic_formfactor=None,
193+
output=True, scattering_factors=None, scattering_lengths=None, magnetic_formfactor=None,
189194
polarisation=None, polarisation_vector=None, azimuthal_reference=None, azimuth=None, flm=None):
190195
"""
191196
Simple way to set scattering parameters, each parameter is internal to xtl (self)
@@ -205,6 +210,7 @@ def setup_scatter(self, scattering_type=None, energy_kev=None, wavelength_a=None
205210
specular : self._scattering_specular_direction : [h,k,l] : reflections normal to sample surface
206211
parallel : self._scattering_parallel_direction : [h,k,l] : reflections normal to sample surface
207212
scattering_factors: self._use_waaskirf_scattering_factor : xray scattering factor ['waaskirf', 'itc']
213+
scattering_lengths: self._use_sears_scattering_lengths : neutron scattering lengths ['sears', 'default']
208214
magnetic_formfactor: self._use_magnetic_form_factor: True/False magnetic form factor for magnetic SF
209215
polarisation: self._polarisation : beam polarisation setting ['ss', 'sp'*, 'sp', 'pp']
210216
polarisation_vector: _polarisation_vector_incident: [x,y,z] incident polarisation vector
@@ -263,6 +269,14 @@ def setup_scatter(self, scattering_type=None, energy_kev=None, wavelength_a=None
263269
print('Using scattering factors from: International Tables of Crystallography Vol. C, Table 6.1.1.4')
264270
self._use_waaskirf_scattering_factor = False
265271

272+
if scattering_lengths is not None:
273+
if scattering_lengths.lower() in ['sears', 'itc', 'alternate', 'alt']:
274+
print('Using scattering lengths from International Tables of Crystallography Vol. C, Table 4.4.4.1')
275+
self._use_sears_scattering_lengths = True
276+
else:
277+
print('Using scattering lengths from Neutron Data Booklet')
278+
self._use_sears_scattering_lengths = False
279+
266280
if magnetic_formfactor is not None:
267281
self._use_magnetic_form_factor = magnetic_formfactor
268282

@@ -470,8 +484,11 @@ def structure_factor(self, hkl=None, scattering_type=None, int_hkl=True, **kwarg
470484
qmag = fg.mag(_q) # q magnitude
471485
# Scattering factors
472486
if scattering_type in fs.SCATTERING_TYPES['neutron']:
473-
# ff = fc.atom_properties(atom_type, 'Coh_b')
474-
ff = fc.neutron_scattering_length(atom_type)
487+
if self._use_sears_scattering_lengths:
488+
ff = fc.neutron_scattering_length(atom_type, 'Sears')
489+
else:
490+
# ff = fc.atom_properties(atom_type, 'Coh_b')
491+
ff = fc.neutron_scattering_length(atom_type)
475492
elif scattering_type in fs.SCATTERING_TYPES['electron']:
476493
ff = fc.electron_scattering_factor(atom_type, qmag)
477494
elif scattering_type in fs.SCATTERING_TYPES['xray fast']:

Dans_Diffraction/data/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ $ ipython -i -m Dans_Diffraction
2323
### Datasources
2424
The data is taken from a number of sources:
2525
* Neutron scattering lengths: [NIST](http://www.ncnr.nist.gov/resources/n-lengths/)
26+
* Neutron scattering lengths (Neutron Data Bookelet, 2003-2023)(default): [Periodic Table](https://github.com/pkienzle/periodictable)
27+
* Neutron scattering lengths (V. F. Sears 1995): [ITC](https://it.iucr.org/C/), Table 4.4.4.1
2628
* X-ray Form factor: [ITC](https://it.iucr.org/C/), p578, Table 6.1.1.4
2729
* X-ray Form factor (Waasmaier & Kirfel, Acta Cryst. A 51, 416-431 (1995)): [diffpy](https://github.com/diffpy/libdiffpy/blob/master/src/runtime/f0_WaasKirf.dat)
2830
* Magnetic Form Factor: [ILL](https://www.ill.eu/sites/ccsl/ffacts/ffactnode4.html)
@@ -86,7 +88,7 @@ Where f^0(|Q|) is the standard form factor and f', f'' are the dispersion correc
8688
online tables can be converted to f', f'' using the following:
8789
<div align="center">f' = f1 - f^0(0)</div>
8890
<div align="center">f'' = -f2</div>
89-
For a particular energy or energy range, f' and f'' can be calcualted, as well as the toal scattering factor:
91+
For a particular energy or energy range, f' and f'' can be calcualted, as well as the total scattering factor:
9092

9193
```python
9294
en = np.arange(5, 10, 0.001)
@@ -95,3 +97,20 @@ f1, f2 = dif.fc.xray_dispersion_corrections('Co', en)
9597
# Total: f0+f1+if2 (complex)
9698
f = dif.fc.xray_scattering_factor_resonant('Co', Qmag=0, energy_kev=en)
9799
```
100+
101+
### Neutron Scattering Lengths
102+
Neutron scattering lengths of elements and isotopes has been extracted from several sources:
103+
104+
* [NIST Website](http://www.ncnr.nist.gov/resources/n-lengths/), with data originally from [V. F. Sears, Neutron News, Vol. 3, No. 3, 1992, pp. 29-37.](https://doi.org/10.1080/10448639208218770)
105+
* [Periodic Table](https://github.com/pkienzle/periodictable), with data originally from [Neutron Data Booklet](https://www.ill.eu/fileadmin/user_upload/ILL/1_About_ILL/Documentation/NeutronDataBooklet.pdf), by A-J Dianoux, G. Lander (2003), with additions and corrections upto v1.7.0 (2023)
106+
* Table 4.4.4.1 in [International Tables Crystallography, Vol. C](https://it.iucr.org/C/) by V. F. Sears, 1995
107+
108+
Thie NIST website values were originally used and stored in the `Dans Element Properties.txt` file with other elemental data.
109+
More recent values, including complex scattering lengths for isotopes are now included in `neutron_isotope_scattering_lengths.dat`.
110+
Complex isotope scattering lengths from the table by Sears(1995) is also included, stored in `neutron_isotope_scattering_lengths_sears.dat`.
111+
112+
Neutron scattering lengths can be read using the built in functions:
113+
114+
```python
115+
116+
```

0 commit comments

Comments
 (0)