amep.evaluate.VelDist#
- class amep.evaluate.VelDist(traj, skip: float = 0.0, nav: int = 10, nbins: int = 50, ptype: int | None = None, vmin: float | None = None, vmax: float | None = None, v2min: float | None = None)#
Bases:
BaseEvaluation
Velocity distribution.
- __init__(traj, skip: float = 0.0, nav: int = 10, nbins: int = 50, ptype: int | None = None, vmin: float | None = None, vmax: float | None = None, v2min: float | None = None) None #
Calculate the distribution of velocities.
Namely the components \(v_x, v_y, v_z\) as well as the magnitude \(v\) of the velocity and its square \(v^2\). It also takes an average over several frames (= time average).
For the \(v^2\) distribution, logarithmic bins are used. Therefore v2min\(\ge 0\) needs to be ensured. For the maximum value, vmax is used as \(3v_{max}^2\). Analogously for the maximum of :math:’v’, where \(\sqrt{3v_{max}}\) is used. For the minimum of :math:’v’, the square root of v2min is used.
- Parameters:
traj (Traj) – Trajectory object.
skip (float, optional) – Skip this fraction at the beginning of the trajectory. The default is 0.0.
nav (int, optional) – Number of frames to use for the average. The default is 10.
nbins (int, optional) – Number of bins. The default is 50.
ptype (float, optional) – Particle type. The default is None.
vmin (float | None, optional) – Minimum value for the histogram in each spatial dimension \(v_x, v_y, v_z\). If None, then the minimum value of the last frame will be used
vmax (float | None, optional) – Maximum value for the histogram in each spatial dimension \(v_x, v_y, v_z\). If None, then the maximum value of the last frame will be used
v2min (float | None, optional) – Minimum value for the velocity-squared histogram. This value has to be \(\ge 0\) due to the use of logarithmic bins for the \(v^2\) distribution. If None, then the minimum value of the last frame will be used.
- Return type:
None
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> vdist = amep.evaluate.VelDist(traj, skip=0.9, nav=2) >>> vdist.save("./eval/vdist.h5") >>> fig, axs = amep.plot.new() >>> axs.plot(vdist.v, vdist.vdist) >>> axs.set_xlabel(r"$|\vec{v}|$") >>> axs.set_ylabel(r"$p(|\vec{v}|)$") >>> fig.savefig("./figures/evaluate/evaluate-VelDist.png")
Methods
__init__
(traj[, skip, nav, nbins, ptype, ...])Calculate the distribution of velocities.
items
()keys
()The keys to the evaluation object.
save
(path[, backup, database, name])Stores the evaluation result in an HDF5 file.
values
()Attributes
VelDist for each frame.
Indices of all frames for which the VelDist has been evaluated.
name
Times at which the VelDist is evaluated.
Magnitude of the velocities.
Squared magnitude of the velocities.
Time-averaged distribution of the squared magnitude of the velocity.
Time-averaged distribution of the magnitude of the velocity.
x-component of the velocities.
Time-averaged distribution of the x-component of the velocity.
y-component of the velocities.
Time-averaged distribution of the y-component of the velocity.
z-component of the velocities.
Time-averaged distribution of the z-component of the velocity.
- property frames#
VelDist for each frame.
- Returns:
VelDist for each frame.
- Return type:
np.ndarray
- property indices#
Indices of all frames for which the VelDist 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 VelDist is evaluated.
- Returns:
Times at which the VelDist is evaluated.
- Return type:
np.ndarray
- property v#
Magnitude of the velocities.
- Returns:
Magnitude of the velocities.
- Return type:
np.ndarray
- property v2#
Squared magnitude of the velocities.
- Returns:
Squared magnitude of the velocities.
- Return type:
np.ndarray
- property v2dist#
Time-averaged distribution of the squared magnitude of the velocity.
- Returns:
Distribution of the squared magnitude of the velocity.
- Return type:
np.ndarray
- property vdist#
Time-averaged distribution of the magnitude of the velocity.
- Returns:
Distribution of the magnitude of the velocity.
- Return type:
np.ndarray
- property vx#
x-component of the velocities.
- Returns:
x-component of the velocities..
- Return type:
np.ndarray
- property vxdist: ndarray#
Time-averaged distribution of the x-component of the velocity.
- Returns:
Distribution of the x-component of the velocity.
- Return type:
np.ndarray
- property vy#
y-component of the velocities.
- Returns:
y-component of the velocities..
- Return type:
np.ndarray
- property vydist: ndarray#
Time-averaged distribution of the y-component of the velocity.
- Returns:
Distribution of the y-component of the velocity.
- Return type:
np.ndarray
- property vz#
z-component of the velocities.
- Returns:
z-component of the velocities..
- Return type:
np.ndarray
- property vzdist: ndarray#
Time-averaged distribution of the z-component of the velocity.
- Returns:
Distribution of the z-component of the velocity.
- Return type:
np.ndarray