# NeutronScattering¶

class NeutronScattering(md_trajectory, start_time=None, end_time=None, pair_selection=None, maximum_q_value=None, q_resolution=None, scattering_length=None, cutoff_radius=None, resolution=None, time_resolution=None, info_panel=None)

Class for calculating the total neutron scattering structure factor from an MD simulation.

Parameters: md_trajectory (MDTrajectory | AtomicConfiguration) – The MDTrajectory or configuration to calculate the neutron scattering for. start_time (PhysicalQuantity of type time) – The start time. Default: 0.0 * fs end_time (PhysicalQuantity of type time) – The end time. Default: The last time frame pair_selection (sequence) – Only include contributions between this selection of atoms. A sequence has to contain two of the following types: Element, tag name, list of indices, or None. Default: all atoms pairs maximum_q_value (PhysicalQuantity of type inverse length) – The maximum scattering vector length. Default: 15.0 / Angstrom q_resolution (PhysicalQuantity of type inverse length) – The resolution of the neutron structure factor curve. Default: 0.05/Angstrom scattering_length (PhysicalQuantity of type length) – A dictionary of elements and corresponding neutron scattering lengths. By default it is assumed that all elements have the same scattering length. Default: None cutoff_radius (PhysicalQuantity of type length.) – Upper limit on sampled distances. Default: Half the diagonal of the unit resolution (PhysicalQuantity of type length) – The bin size determining the resolution of the underlying radial-distribution-function. Default: 0.05 * Angstrom time_resolution (PhysicalQuantity of type time) – The time interval between snapshots in the MD trajectory that are included in the analysis. info_panel (InfoPanel (Plot2D)) – Info panel to show the calculation progress. Default: No info panel
data()

Return the neutron scattering structure factor.

qRange()

Return the list of scattering vector magnitudes.

## Usage Examples¶

Load an MDTrajectory and calculate the neutron scattering structure factor using experimental values for the neutron scattering lengths of the different elements (see Ref. [GJ02]):

md_trajectory = nlread('alumina_trajectory.nc')[-1]

# Define the neutron scattering lengths for the elements.
scattering_length={Aluminum : 0.00003449*Angstrom,
Oxygen   : 0.00005805*Angstrom}

neutron_scattering = NeutronScattering(md_trajectory,
scattering_length=scattering_length)

# Get the q-values and the neutron structure function.
q_values = neutron_scattering.qRange().inUnitsOf(Angstrom**-1)
s_q      = neutron_scattering.data()

# Plot the data using pylab.
import pylab

pylab.plot(q_values, s_q, label='Structure factor of alumina')
pylab.xlabel('q (1/Ang)')
pylab.ylabel('S(q)')
pylab.legend()

pylab.show()


neutron_scattering.py

## Notes¶

This object calculates the isotropic (i.e. averaged over all scattering angles) neutron scattering structure factor. It is therefore predominantly aimed at the characterization of amorphous materials.

The neutron scattering structure factor is calculated as described in Ref. [GJ02]:

$S(q)=\frac{\sum_{\alpha,\beta} b_{\alpha}b_{\beta}(c_{\alpha} c_{\beta})^{1/2} \left[ S_{\alpha, \beta}(q) - \delta_{\alpha, \beta} + (c_{\alpha} c_{\beta})^{1/2}\right]} {\left ( \sum_{\alpha}b_{\alpha}c_{\alpha} \right)^{1/2}},$

where $$c_{\alpha}$$ and $$b_{\alpha}$$ are the mole fraction and neutron scattering length of element $$\alpha$$. The PartialStructureFactor is calculated from the partial radial distribution functions, $$g_{\alpha,\beta}(r)$$, as follows,

$S_{\alpha, \beta}(q) = \delta_{\alpha, \beta} + 4 \pi \rho (c_{\alpha} c_{\beta})^{1/2} \int_0^{r_{max}} r^2 [g_{\alpha, \beta}(r) - 1] \frac{\sin(qr)}{qr}\frac{\sin(\pi r_{max}r)}{\pi r_{max} r} dr.$

If no scattering lengths are provided (default), the partial structure factors are weighted only by the respective mole fractions, i.e. the scattering lengths are all set to one. As the scattering lengths are typically of the order of femto-meter, you should either provide scattering lengths for all elements or none at all to avoid overestimating the contributions of some elements.

If a single pair of elements, or a selection via indices or tags, is specified in the pair_selection parameter, the PartialStructureFactor of the selected pair is returned.

The cutoff_radius parameter determines the range of the radial distribution function. This parameter might have an influcence on the calculated structure factor at small scattering vectors.

 [GJ02] (1, 2) G. Gutiérrez and B. Johansson. Molecular dynamics study of structural properties of amorphous al2o3. Phys. Rev. B, 65:104202, Feb 2002. doi:10.1103/PhysRevB.65.104202.