amep.spatialcor.sf2d#

amep.spatialcor.sf2d(coords: ndarray, box_boundary: ndarray, other_coords: ndarray | None = None, qmax: float = 20.0, njobs: int = 1, mode: str = 'std', Ntot: int | None = None, accuracy: float = 0.1, chunksize: int | None = None, verbose: bool = False) tuple[ndarray, ndarray, ndarray]#

Calculates the 2d static structure factor.

Notes

The static structure factor is defined by

\[\begin{split}S(\vec{q}) = \frac{1}{N} \left\langle\sum_{j=1}^{N}\sum_{k=1}^{N}\exp\left\lbrace-i\vec{q}\cdot(\vec{r}_j-\vec{r}_k)\right\rbrace\right\rangle\\ = \frac{1}{N} \left\langle\sum_{j=1}^{N}\left\lvert\exp\left\lbrace-i\vec{q}\cdot\vec{r}_j\right\rbrace\right\rvert^2\right\rangle,\end{split}\]

where $rho(vec{q})$ is the Fourier transform of the particle number density (see Ref. [1] for further information).

S(0,0) is set to 0

References

Parameters:
  • coords (np.ndarray) – Coordinate frame (3D).

  • box_boundary (np.ndarray of shape (3,2)) – Boundary of the simulation box in the form of np.array([[xmin, xmax], [ymin, ymax], [zmin, zmax]]).

  • other_coords (np.ndarray, optional) – Coordinate frame of the other species to which the pair correlation is calculated. The default is None (uses coords).

  • qmax (float, optional) – Maximum wave number to consider. The default is 20.

  • njobs (int, optional) – Number of jobs used for parallel computation. The default is 4.

  • mode (str, optional) – Calculation method. Mode ‘fft’ converts the particle coordinates to a density field and uses the continuum method (FFT) to calculate the structure factor. Mode ‘std’ uses the particle coordinates directly, which is much slower. The default is ‘fft’.

  • Ntot (int, optional) – Total number of particles in the system. This value is needed for the correct normalization of the structure factor. If None, Ntot is calculated from coords. The default is None.

  • accuracy (float, optional) – Accuracy for fft mode. 0.0 means least accuracy, 1.0 best accuracy. The default is 0.1. Note that a higher accuracy needs more memory for the computation. accuracy must be in (0,1].

  • verbose (bool, optional) – If True, a progress bar is shown. The default is False.

  • chunksize (int or None, optional) – Divide calculation into chunks of this size. The default is None.

Returns:

  • np.ndarray – Two dimensional static structure factor.

  • np.ndarray – Wave vector’s x component.

  • np.ndarray – Wave vector’s y component.

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> frame = traj[-1]
>>> sxy, qx, qy = amep.spatialcor.sf2d(
...     frame.coords(), frame.box, verbose=True, mode='std', njobs=4
... )
>>> fig, axs = amep.plot.new(figsize=(3.7,3))
>>> mp = amep.plot.field(axs, sxy, qx, qy)
>>> cax = amep.plot.add_colorbar(
...     fig, axs, mp, label=r'$S(q_x, q_y$'
... )
>>> axs.set_xlabel(r'$q_x$')
>>> axs.set_ylabel(r'$q_y$')
>>> fig.savefig('./figures/spatialcor/spatialcor-sf2d.png')
>>>
../_images/spatialcor-sf2d.png