amep.evaluate.VACF#

class amep.evaluate.VACF(traj: ParticleTrajectory, ptype: int | None = None, skip: float = 0.0, nav: int | None = None, direction: str = 'xyz')#

Bases: BaseEvaluation

Velocity autocorrelation function.

__init__(traj: ParticleTrajectory, ptype: int | None = None, skip: float = 0.0, nav: int | None = None, direction: str = 'xyz') None#

Calculate the velocity autocorrelation function.

Averages 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")
>>> vacf = amep.evaluate.VACF(traj, direction="xy")
>>> vacf.save("./eval/vacf.h5")
>>> fig, axs = amep.plot.new()
>>> axs.plot(vacf.times[1:], vacf.frames[1:]/vacf.frames[0])
>>> axs.axhline(0.0, color="k", lw=1, ls="--")
>>> axs.semilogx()
>>> axs.set_ylim(-0.05, 1.0)
>>> axs.set_xlabel(r"$t$")
>>> axs.set_ylabel(r"$C_v(t)/C_v(0)$")
>>> fig.savefig("./figures/evaluate/evaluate-VACF.png")
../_images/evaluate-VACF.png

Methods

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

Calculate the velocity autocorrelation function.

items()

keys()

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

Stores the evaluation result in an HDF5 file.

values()

Attributes

avg

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

direction

Considered spatial directions.

frames

VACF for each frame.

indices

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

name

ptype

Particle type(s) for which the VACF has been calculated.

times

Times at which the VACF is evaluated.

property avg#

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

Returns:

Time-averaged VACF.

Return type:

float

property direction#

Considered spatial directions.

Returns:

Direction specification.

Return type:

str

property frames#

VACF for each frame.

Returns:

VACF for each frame.

Return type:

np.ndarray

property indices#

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

Returns:

Frame indices.

Return type:

np.ndarray

property ptype#

Particle type(s) for which the VACF 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 VACF is evaluated.

Returns:

Times at which the VACF is evaluated.

Return type:

np.ndarray