amep.evaluate.HexOrderCor#
- class amep.evaluate.HexOrderCor(traj: ParticleTrajectory, skip: float = 0.0, nav: int = 10, ptype: int | None = None, other: int | None = None, **kwargs)#
Bases:
BaseEvaluation
Spatial correlation function of the hexagonal order parameter.
- __init__(traj: ParticleTrajectory, skip: float = 0.0, nav: int = 10, ptype: int | None = None, other: int | None = None, **kwargs) None #
Calculate the spatial correlation function of \(\Psi_6\).
The hexagonal order parameter is defined by
\[\Psi_6(\vec{r}_j)=\frac{1}{N_j}\sum_{k=1}^{N_j}\exp(i6\theta_{jk})\]where the sum goes over the six next neighbors of particle j. The angle \(\theta_{jk}\) denotes the angle between the vector that connects particle j with its k-th nearest neighbor and the x-axis. The hexagonal order correlation function is then defined by
\[g_6(r=|\vec{r}_j-\vec{r}_i|)=<\Psi_6(\vec{r}_j)\Psi_6(\vec{r}_i)> / <\Psi_6^2(\vec{r}_j)>.\]See Refs. [1] [2] [3] for further information.
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, optional) – Particle type. The default is None.
other (float, optional) – Other particle type. If None, ptype is used. The default is None.
**kwargs – All other keyword arguments are forwarded to amep.spatialcor.spatialcor.
Examples
>>> import amep >>> import numpy as np >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> hoc = amep.evaluate.HexOrderCor( ... traj, skip=0.9, nav=2, njobs=4, rmax=30 ... ) >>> hoc.save("./eval/hoc.h5") >>> fig, axs = amep.plot.new() >>> axs.plot(hoc.r, np.real(hoc.avg)) >>> axs.set_xlabel(r'$r$') >>> axs.set_ylabel(r'$g_6(r)$') >>> axs.loglog() >>> fig.savefig('./figures/evaluate/evaluate-HexOrderCor.png')
Methods
__init__
(traj[, skip, nav, ptype, other])Calculate the spatial correlation function of \(\Psi_6\).
items
()keys
()save
(path[, backup, database, name])Stores the evaluation result in an HDF5 file.
values
()Attributes
Time-averaged HexOrderCor (averaged over the given number of frames).
HexOrderCor for each frame.
Indices of all frames for which the HexOrderCor has been evaluated.
name
Distances.
Times at which the HexOrderCor is evaluated.
- property avg#
Time-averaged HexOrderCor (averaged over the given number of frames).
- Returns:
Time-averaged HexOrderCor.
- Return type:
np.ndarray
- property frames#
HexOrderCor for each frame.
- Returns:
HexOrderCor for each frame.
- Return type:
np.ndarray
- property indices#
Indices of all frames for which the HexOrderCor 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 times#
Times at which the HexOrderCor is evaluated.
- Returns:
Times at which the HexOrderCor is evaluated.
- Return type:
np.ndarray