amep.evaluate.PCFangle#

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

Bases: BaseEvaluation

2d angular 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(r,theta).

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 angle-dependent pair correlation function is defined by (see Ref. [2])

\[g(r,\theta) = \frac{1}{\langle \rho\rangle_{local,\theta} N} \sum\limits_{i=1}^{N} \sum\limits_{j\neq i}^{N} \frac{\delta(r_{ij} -r) \delta(\theta_{ij}-\theta)}{2\pi r^2 \sin(\theta)}\]

The angle \(\theta\) is defined with respect to a certain axis \(\vec{e}\) and is given by

\[\cos(\theta)=\frac{{\vec{r}}_{ij}\cdot\vec{e}}{r_{ij}e}\]

Here, we choose \(\vec{e}=\hat{e}_x\).

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) – Maximum 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.pcf_angle.

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> pcfangle = amep.evaluate.PCFangle(
...     traj, nav=2, ndbins=1000, nabins=1000,
...     njobs=4, rmax=8.0, skip=0.9
... )
>>> pcfangle.save("./eval/pcfangle.h5")
>>> r = pcfangle.r
>>> theta = pcfangle.theta
>>> X = r*np.cos(theta)
>>> Y = r*np.sin(theta)
>>> fig, axs = amep.plot.new(figsize=(3.6,3))
>>> mp = amep.plot.field(
...     axs, pcfangle.avg, X, 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-PCFangle.png")
>>>

Methods

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

Calculate the two-dimensional pair correlation function g(r,theta).

items()

keys()

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

Stores the evaluation result in an HDF5 file.

values()

Attributes

avg

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

frames

PCFangle for each frame.

indices

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

name

r

Distances.

theta

Angles.

times

Times at which the PCFangle is evaluated.

property avg#

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

Returns:

Time-averaged function value.

Return type:

np.ndarray

property frames#

PCFangle for each frame.

Returns:

PCFangle for each frame.

Return type:

np.ndarray

property indices#

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

Returns:

Frame indices.

Return type:

np.ndarray

property r#

Distances.

Returns:

Distances.

Return type:

np.ndarray

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 theta#

Angles.

Returns:

Angles.

Return type:

np.ndarray

property times#

Times at which the PCFangle is evaluated.

Returns:

Times at which the PCFangle is evaluated.

Return type:

np.ndarray