amep.evaluate.PCF2d#

class amep.evaluate.PCF2d(traj: ParticleTrajectory, skip: float = 0.0, nav: int = 10, ptype: int | None = None, other: int | None = None, **kwargs)#

Bases: BaseEvaluation

2d pair correlation function.

__init__(traj: ParticleTrajectory, skip: float = 0.0, nav: int = 10, ptype: int | None = None, other: int | None = None, **kwargs) None#

Calculate the two-dimensional pair correlation function \(g(x,y)\).

Implemented for a 2D system. Takes the time average over several time steps.

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 points along the x axis (see Ref. [1] for details).

Notes

The 2D pair correlation function 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})\]

References:

Parameters:
  • traj (ParticleTrajectory) – Trajectory object with particle-based simulation data.

  • skip (float, optional) – Skip this fraction at the beginning of the trajectory. The default is 0.0.

  • nav (int, optional) – Number of frames to consider for the time average. The default is 10.

  • ptype (float or None, optional) – Particle type. The default is None.

  • other (float or None, optional) – Other particle type (to calculate the correlation between different particle types). The default is None.

  • **kwargs – All other keyword arguments are forwarded to amep.spatialcor.pcf2d.

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> pcf2d = amep.evaluate.PCF2d(
...     traj, nav=2, nxbins=2000, nybins=2000, njobs=4, skip=0.9
... )
>>> pcf2d.save("./eval/pcf2d.h5")
>>> fig, axs = amep.plot.new(figsize=(3.6,3))
>>> mp = amep.plot.field(axs, pcf2d.avg, pcf2d.x, pcf2d.y)
>>> cax = amep.plot.add_colorbar(
...     fig, axs, mp, label=r"$g(\Delta x, \Delta y)$"
... )
>>> axs.set_xlim(-5,5)
>>> axs.set_ylim(-5,5)
>>> axs.set_xlabel(r"$\Delta x$")
>>> axs.set_ylabel(r"$\Delta y$")
>>> fig.savefig("./figures/evaluate/evaluate-PCF2d.png")
>>>

Methods

__init__(traj[, skip, nav, ptype, other])

Calculate the two-dimensional pair correlation function \(g(x,y)\).

items()

keys()

The keys to the evaluation object.

save(path[, backup, database, name])

Stores the evaluation result in an HDF5 file.

values()

Attributes

avg

Time-averaged PCF2d (averaged over the given number of frames).

frames

PCF2d for each frame.

indices

Indices of all frames for which the PCF2d has been evaluated.

name

times

Times at which the PCF2d is evaluated.

x

x values.

y

y values.

property avg#

Time-averaged PCF2d (averaged over the given number of frames).

Returns:

Time-averaged PCF2d.

Return type:

np.ndarray

property frames#

PCF2d for each frame.

Returns:

PCF2d for each frame.

Return type:

np.ndarray

property indices#

Indices of all frames for which the PCF2d has been evaluated.

Returns:

Frame indices.

Return type:

np.ndarray

keys() list[str]#

The keys to the evaluation object.

Used so Evaluation-objects can be used as dictionaries.

save(path: str, backup: bool = True, database: bool = False, name: str | None = None) None#

Stores the evaluation result in an HDF5 file.

Parameters:
  • path (str) – Path of the ‘.h5’ file in which the data should be stored. If only a directory is given, the filename is chosen as self.name. Raises an error if the given directory does not exist or if the file extension is not ‘.h5’.

  • backup (bool, optional) – If True, an already existing file is backed up and not overwritten. This keyword is ignored if database=True. The default is True.

  • database (bool, optional) – If True, the results are appended to the given ‘.h5’ file if it already exists. If False, a new file is created and the old is backed up. If False and the given ‘.h5’ file contains multiple evaluation results, an error is raised. In this case, database has to be set to True. The default is False.

  • name (str or None, optional) – Name under which the data should be stored in the HDF5 file. If None, self.name is used. The default is None.

Return type:

None.

property times#

Times at which the PCF2d is evaluated.

Returns:

Times at which the PCF2d is evaluated.

Return type:

np.ndarray

property x#

x values.

Returns:

x values.

Return type:

np.ndarray

property y#

y values.

Returns:

y values.

Return type:

np.ndarray