amep.evaluate.EkinTot#
- class amep.evaluate.EkinTot(traj: ParticleTrajectory, mass: float | ndarray, inertia: float | ndarray, skip: float = 0.0, nav: int = 10, **kwargs)#
Bases:
BaseEvaluation
Total kinetic energy.
- __init__(traj: ParticleTrajectory, mass: float | ndarray, inertia: float | ndarray, skip: float = 0.0, nav: int = 10, **kwargs)#
Calculate the total kinetic energy of each particle over a trajectory.
- Parameters:
traj (Traj) – Trajectory object with simulation data.
skip (float, default=0.0) – Skip this fraction at the beginning of the trajectory.
nav (int, default=10) – number of frames to consider for the time average.
mass (float or np.ndarray) – Mass(es) of the particles.
inertia (float or np.ndarray) – Moment of inertia of the particles.
**kwargs (Keyword Arguments) – General python keyword arguments to be forwarded to the function f
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> ekintotal = amep.evaluate.EkinTot( ... traj, mass=1.0, inertia=0.1, nav=traj.nframes ... ) >>> fig, axs = amep.plot.new() >>> axs.plot(ekintotal.times, ekintotal.frames) >>> axs.axhline(ekintotal.avg, ls="--", c="k") >>> axs.set_xlabel(r'$t$') >>> axs.set_ylabel(r'$E_{\rm tot}$') >>> axs.semilogy() >>> fig.savefig("./figures/evaluate/evaluate-EkinTot.png")
Methods
__init__
(traj, mass, inertia[, skip, nav])Calculate the total kinetic energy of each particle over a trajectory.
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 total kinetic energy (averaged over the given number of frames).
Total kinetic energy for each frame.
Indices of all frames for which the total kinetic energy has been evaluated.
name
Times at which the total kinetic energy is evaluated.
- property avg#
Time-averaged total kinetic energy (averaged over the given number of frames).
- Returns:
Time-averaged total kinetic energy of each particle.
- Return type:
np.ndarray
- property frames#
Total kinetic energy for each frame.
- Returns:
Total kinetic energy for each frame.
- Return type:
np.ndarray
- property indices#
Indices of all frames for which the total kinetic energy 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 total kinetic energy is evaluated.
- Returns:
Times at which the total kinetic energy is evaluated.
- Return type:
np.ndarray