amep.evaluate.OACF#
- class amep.evaluate.OACF(traj, ptype=None, skip=0.0, nav=None, direction='xyz')#
Bases:
BaseEvaluation
Orientational autocorrelation function.
- __init__(traj, ptype=None, skip=0.0, nav=None, direction='xyz')#
Calculate the orientational autocorrelation function averaged over all particles of the given type.
- Parameters:
traj (amep.base.BaseTrajectory) – Trajectory object.
ptype (int, optional) – Particle type. The default is None.
skip (float, optional) – Skip this fraction of frames at the beginning of the trajectory. The default is 0.0.
nav (int, optional) – Number of time steps at which the autocorrelation function should be evaluated. The default is None.
direction (str, optional) – ‘x’, ‘y’, ‘z’, or any combination of it. The default is ‘xyz’ (average over all directions).
- Return type:
None.
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> oacf = amep.evaluate.OACF(traj) >>> oacf.save('./eval/oacf.h5') >>> fig, axs = amep.plot.new() >>> axs.plot( ... oacf.times[1:], oacf.frames[1:], ... label="data", ls="", c="darkorange" ... ) >>> axs.plot( ... oacf.times[1:], np.exp(-oacf.times[1:]), c="k", ... label=r"$\exp(-t)$", lw=1, ls="--", ... marker="" ... ) >>> axs.set_xlabel(r"$t$") >>> axs.set_ylabel(r"$\langle\vec{\mu}(t)\cdot\vec{\mu}(0)\rangle$") >>> axs.legend() >>> axs.semilogx() >>> fig.savefig("./figures/evaluate/evaluate-OACF.png")
Methods
__init__
(traj[, ptype, skip, nav, direction])Calculate the orientational autocorrelation function averaged over all particles of the given type.
items
()keys
()The keys to the evaluation object.
save
(path[, backup, database, name])Stores the evaluation result in an HDF5 file.
values
()Attributes
Time-averaged OACF (averaged over the given number of frames).
Considered spatial directions.
OACF for each frame.
Indices of all frames for which the OACF has been evaluated.
name
Particle type(s) for which the OACF has been calculated.
Times at which the OACF is evaluated.
- property avg#
Time-averaged OACF (averaged over the given number of frames).
- Returns:
Time-averaged OACF.
- Return type:
float
- property direction#
Considered spatial directions.
- Returns:
Direction specification.
- Return type:
str
- property frames#
OACF for each frame.
- Returns:
OACF for each frame.
- Return type:
np.ndarray
- property indices#
Indices of all frames for which the OACF 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.
- property ptype#
Particle type(s) for which the OACF has been calculated.
- Returns:
Particle type(s).
- Return type:
float or list of floats
- 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 OACF is evaluated.
- Returns:
Times at which the OACF is evaluated.
- Return type:
np.ndarray