XRayScattering¶
- class XRayScattering(md_trajectory, start_time=None, end_time=None, pair_selection=None, maximum_q_value=None, q_resolution=None, cutoff_radius=None, resolution=None, time_resolution=None, info_panel=None, charges=None, parameters=None)¶
Class for calculating the total X-ray scattering structure factor from an MD simulation.
- Parameters:
md_trajectory (
MDTrajectory
|MoleculeConfiguration
|BulkConfiguration
|DeviceConfiguration
|SurfaceConfiguration
) – The MDTrajectory or configuration to calculate the X-ray 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 X-ray structure factor curve. Default:
0.05/Angstrom
.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.
charges (dictionary) – Which charge state to use for the elements. Default: Charge state 0 for all elements.
parameters (nested dictionary) – Parameters for the analytic approximation of scattering factors. Default: Parameters taken from P. J. Brown, A. G. Fox, E. N. Maslen, M. A. O’Keefe and B. T. M. Willis. International Tables for Crystallography (2006). Vol. C, ch. 6.1, pp. 554-595 [doi:10.1107/97809553602060000600]
- data()¶
- Returns:
The X-ray scattering structure factor.
- Return type:
numpy.ndarray
- qRange()¶
- Returns:
The list of scattering vector magnitudes.
- Return type:
PhysicalQuantity of type inverse length
Usage Examples¶
Load an MDTrajectory and calculate the X-ray scattering structure factor using theoretically determined parameters approximating atomic scattering factors of the different elements (see Ref. [1]):
parameters = {
'O': {
'0': [3.0, 13.2, 2.2, 5.7, 1.5, 0.3, 0.8, 32.9, 0.2],
'1-': [4.1, 12.8, 1.6, 4.1, 1.53, 47.0, -20.3, -0.0, 21.9],
},
'Si': {
'0': [5.6, 2.6, 3.0, 38.6, 2.6, 0.9, 1.3, 93.5, 1.2],
'4+': [4.4, 1.6, 3.2, 3.4, 1.1, 0.2, 0.4, 6.6, 0.7],
},
}
charges = {
'O': '0',
'Si': '0',
}
md_trajectory = nlread('SiO2simulation_traj.hdf5', MDTrajectory,)[0]
xray_scattering = XRayScattering(
md_trajectory,
maximum_q_value=15.0 * Angstrom**-1,
q_resolution=0.05 * Angstrom**-1,
cutoff_radius=10 * Angstrom,
time_resolution=399*fs,
charges=charges,
parameters=parameters
)
# Get the q-values and the X-ray structure function.
q_values = xray_scattering.qRange()
s_q = xray_scattering.data()
model = Plot.PlotModel(x_unit=Angstrom**-1)
model.title().setText('X-ray scattering')
model.xAxis().setLabel('q')
model.yAxis().setLabel('S(q)')
model.legend().setVisible(True)
line = Plot.Line(q_values, s_q)
line.setLabel('Amorphous hafnia')
model.addItem(line)
# Set the ranges and show the plot
model.setLimits()
Plot.show(model)
Notes¶
This object calculates the isotropic (i.e. averaged over all scattering angles) X-ray scattering structure factor. It is therefore predominantly aimed at the characterization of amorphous materials.
The X-ray scattering structure factor is calculated as described in Ref. [2]:
where \(c_{\alpha}\) and \(f_{\alpha}(q)\) are the mole fraction and scattering factor of element \(\alpha\).
where \(a_{\alpha,i}\), \(b_{\alpha,i}\) and \(c_{\alpha}\) are scattering parameters.
The PartialStructureFactor is calculated from the partial radial distribution functions, \(g_{\alpha,\beta}(r)\), as follows,
If no scattering parameters are provided by the user, the (default) parameters are taken from [1]. This parameter set contains several charge states for some elements. By default all elements are considered to be charge neutral. The user may select a different charge state using a dictionary as given in the example above.
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 influence on the calculated structure factor at small scattering vectors.