amep.spatialcor.pcf2d#
- amep.spatialcor.pcf2d(coords: ndarray, box_boundary: ndarray, other_coords: ndarray | None = None, nxbins: int | None = None, nybins: int | None = None, rmax: float | None = None, psi: ndarray | None = None, njobs: int = 1, pbc: bool = True, verbose: bool = False, chunksize: int | None = None) tuple[ndarray, ndarray, ndarray] #
Calculates the 2D pair correlation function by calculating histograms. To allow for averaging the result (either with respect to time or to make an ensemble average), the coordinates are rotated such that the mean orientation (given by the vector psi) points along the x axis (see Ref. [1] for details).
Notes
The 2D pair correlation function between the particles themselfes, i.e., for i=j, is defined by
\[g(x,y) = \frac{1}{\rho N}\sum\limits_{i=1}^{N} \sum\limits_{j\neq i}^{N}\delta(x-x_{ij})\delta(y-y_{ij}).\]The cross correlation between different particle species is given by
\[g_{ij}(x,y)=\frac{1}{\rho_i N_j}\sum\limits_{n=1}^{N_i} \sum\limits_{m=1}^{N_j}\delta(x-x_{nm})\delta(y-y_{nm}).\]This version only works for (quadratic) 2D systems. For 3D systems, the z coordinate is discarded.
References:
- Parameters:
coords (np.ndarray of shape (N,3)) – Coordinates.
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 of shape (M,3), optional) – Coordinate frame of the other species to which the pair correlation is calculated. The default is None (uses coords).
nxbins (int or None, optional) – Number of x bins. The default is None.
nybins (int or None, optional) – Number of y bins. The default is None.
rmax (float or None, optional) – Maximum distance to consider (should be smaller than the largest box length divided by 2*sqrt(2)). The default is None.
psi (np.ndarray of shape (2,) or None, optional) – Mean orientation of the whole system. If not None, the particles positions are rotated such that the x-axis of the system points into the direction of psi. According to Ref. [1], use psi=(Re{Psi_6},Im{Psi_6}), where Psi_6 is the mean hexagonal order parameter of the whole system.
njobs (int, optional) – Number of jobs for parallel computation. The default is 1.
pbc (bool, optional) – If True, periodic boundary conditions are applied. The default is True.
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 – g(x,y) (2D array of floats)
np.ndarray – x coordinate values (1D array of floats)
np.ndarray – y coordinate (1D array of floats)
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> frame = traj[-1] >>> gxy, x, y = amep.spatialcor.pcf2d( ... frame.coords(), frame.box, njobs=4, ... nxbins=1000, nybins=1000 ... ) >>> fig, axs = amep.plot.new(figsize=(3.7,3)) >>> mp = amep.plot.field(axs, gxy, x, y) >>> cax = amep.plot.add_colorbar( ... fig, axs, mp, label=r'$g(\Delta x, \Delta y)$' ... ) >>> axs.set_xlim(-10,10) >>> axs.set_ylim(-10,10) >>> axs.set_xlabel(r'$\Delta x$') >>> axs.set_ylabel(r'$\Delta y$') >>> fig.savefig('./figures/spatialcor/spatialcor-pcf2d.png') >>>