# Structure factor pro

Added in version 3.13.0.

This modifier calculates the structure factor \(S(k)\) of a system of particles, i.e., a virtual diffraction pattern. It supports two different calculation methods: The direct method performs a summation in k-space while the Debye method relies on the integration of the radial distribution function \(g(r)\). In both cases the resulting structure factor is provided as a function of the magnitude of the wave vector, \(k\). It is related to the commonly defined scattering vector by \(q = k / 2\pi\).

The direct method provides better results especially for small \(k\) values, however, it is much slower and can only be used for small simulation cells densely packed with not too many atoms. The Debye method, on the other hand, is much faster and can be applied to large simulation cells containing millions of atoms. This method suffers from ringing artifacts due to the finite cutoff radius in the calculation of the radial distribution function.

The modifier can either calculate the total structure factor, \(S(k)\), or the X-ray structure factor, \(S^X(k)\), which takes the atomic X-ray form factors into account. It can also calculate partial structure factors, \(S_{\alpha\beta}(k)\), and Faber-Ziman partial factors, \(A_{\alpha\beta}(k)\). The partial structure factors are normalized such that

> \({\displaystyle S(k) = \sum ( 2 - \delta_{\alpha\beta} ) S_{\alpha\beta}(k) }\).

For a 2-component system this equates to the following decomposition of the total structure factor into partials \(S_{\alpha\alpha}\), \(S_{\alpha\beta}\), and \(S_{\beta\beta}\):

> \({\displaystyle S(k) = S_{\alpha\alpha}(k) + 2 S_{\alpha\beta}(k) + S_{\beta\beta}(k) }\).

The following figure shows a comparison between the two supported calculation methods, for total and partial structure factor results:

The following figure shows total \(S(k)\) and partial \(S_{\alpha\beta}(k)\) structure factors calculated using this OVITO function (direct method), the freud Python package (direct method), and an implementation from [LE2024] (Debye method). The analyzed input structure was taken from the same paper:

## Parameters

Mode

  Selects the calculation method: Direct or Debye.

Minimum k value

  Minimum length of \(\vec{k}\) for which the structure factor is calculated.

Maximum k value

  Maximum length of \(\vec{k}\) for which the structure factor is calculated. Larger \(k\) values increase the processing time of the modifier.

Number of histogram bins

  Controls the resolution of the resulting tabulated structure factor function.

Compute partial structure factors

  If enabled, computes both partial and Faber-Ziman partial structure factors.

Use atomic form factors

  Use the atomic form factors \(f(k)\) tabulated here to calculate the X-ray structure factors \(S^X(k)\). For this to work, the particle types in OVITO must have names matching the atomic species in the table.

Use only selected particles

  Constrain the calculation to atoms included in the current selection set. Unselected atoms will be treated as if they were not present in the system.

## Background

### Direct method

Computationally, the structure factor \(S(k)\) is calculated from the scattering function \(F(k)\), defined as

> \({\displaystyle F(k) = \frac{1}{\sqrt{N}} \sum_{i=0}^{N} \exp \left( j \vec{k} \cdot \vec{r}_i \right)}\),

where \(N\) is the number of particles, \(\vec{r}\) is the particle position, and \(j\) is the imaginary unit.

Subsequently, the structure factor can be obtained from the scattering function:

> \({\displaystyle S(k) = \Re\left( F^{*}(k) F(k) \right)}\).

The \(^*\) denotes the complex conjugate and \(\Re\) is the real part of the complex number.

This method can be extended to the calculation of the partial structure factors of two particle types \(\alpha\) and \(\beta\) by calculating \(S(k)\) for this subset of particles only.

### Debye method

The Debye method uses

> \({\displaystyle S(k) = \frac{4 \pi \rho}{k} \int_0^{L/2} r \sin(kr) g(r) w(r) \, dr }\),

where

> \({\displaystyle w(r) = \frac{ \sin(2 \pi r / L) }{ 2 \pi r / L } }\)

is applied to reduce finite-cutoff ringing artifacts. Here, \(\rho\) is the particle density, \(L\) the maximum simulation cell vector length, and \(g(r)\) the radial distribution function (RDF) internally calculated using the Radial distribution function (RDF) function of OVITO.

Partial structure factors are calculated from partial radial distribution functions.

### Faber-Ziman partial structure factor

The partial structure factor \(S_{\alpha\beta}\) discussed above can be converted to the Faber-Ziman partial structure factor \(A_{\alpha\beta}\) often mentioned in the literature:

> \({\displaystyle A_{\alpha\beta}(k) = \frac{ S_{\alpha\beta}(k) - x_\alpha \delta_{\alpha\beta} }{ x_\alpha x_\beta} + 1 }\),

where \(x\) denotes the concentration of either species.

The figure below shows a comparison between the partial structure factors and the Faber-Ziman partial structure factors. One can see the different normalizations. The partial structure factors are normalized so that the \(S_{\alpha\alpha}(k)\) tend to the concentration of \(\alpha\) while the \(S_{\alpha\beta}(k)\) tend towards 0 as \(k\) goes to infinity.

The Faber-Ziman partial structure factors, on the other hand, all approach 1 for large \(k\).

### X-ray atomic form factors

For comparison with experiments, the X-ray atomic form factors \(f(k)\) can be taken into account using this equation:

> \({\displaystyle A^\mathrm{X}_{\alpha\beta}(k) = \frac{ f_\alpha(k) f_\beta(k) }{ \left[ \sum_i f_i(k) x_i \right] ^2 } A_{\alpha\beta}(k) }\).

The atomic form factors for each species are calculated following

> \({ f(k) = c + \sum_{i=0}^4 a_i \exp \left( -b_i \left(\frac{k}{4 \pi}\right)^2 \right) }\),

with parameters taken from the atomic form factors table from TU Graz.

These Faber-Ziman structure factors \(A^\mathrm{X}_{\alpha\beta}(k)\) can subsequently be converted into partial structure factors \(S^\mathrm{X}_{\alpha\beta}(k)\) using the equation outlined above. Lastly, these partial structure factors can be combined to obtain the total structure factor \(S^\mathrm{X}\).

## References and further reading

Links to the documentation of the `freud` Python package, which also implements both calculation methods:

- https://freud.readthedocs.io/en/latest/modules/diffraction.html#freud.diffraction.StaticStructureFactorDirect

- https://freud.readthedocs.io/en/latest/modules/diffraction.html#freud.diffraction.StaticStructureFactorDebye

Discussion about the normalization of \(S(k)\) with the freud developers:

- https://github.com/glotzerlab/freud/issues/1313

Detailed description of the calculation and normalization of \(S(k)\) and \(A(k)\):

- Liu, H., & Paddison, S. J. (2016). Direct calculation of the X-ray structure factor of ionic liquids. In Physical Chemistry Chemical Physics (Vol. 18, Issue 16, pp. 11000-11007). Royal Society of Chemistry (RSC). https://doi.org/10.1039/c5cp06199g

We acknowledge the helpful contributions of Linus C. Erhard to the development and verification of this OVITO function. See also:

- [LE2024] Erhard, L. C., Rohrer, J., Albe, K. & Deringer, V. L. Modelling atomic and nanoscale structure in the silicon-oxygen system through active machine learning. Nat Commun 15, (2024) https://doi.org/10.1038/s41467-024-45840-9

See also

`ovito.modifiers.StructureFactorModifier` (Python API)