amep.evaluate.Dist#

class amep.evaluate.Dist(traj: ParticleTrajectory | FieldTrajectory, keys: str | list[str, ...], func: Callable | None = None, skip: float = 0.0, nav: int = 10, nbins: int = 50, ptype: float | None = None, ftype: str | None = None, logbins: bool = False, xmin: float | None = None, xmax: float | None = None, **kwargs)#

Bases: BaseEvaluation

General distribution.

__init__(traj: ParticleTrajectory | FieldTrajectory, keys: str | list[str, ...], func: Callable | None = None, skip: float = 0.0, nav: int = 10, nbins: int = 50, ptype: float | None = None, ftype: str | None = None, logbins: bool = False, xmin: float | None = None, xmax: float | None = None, **kwargs)#

Calculate the distribution of a user-defined key or keys.

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).

Parameters:
  • traj (Traj) – Trajectory object.

  • skip (float, optional) – Skip this fraction at the beginning of the trajectory. The default is 0.0.

  • keys (name)

  • keys

  • func=None

  • ...todo...

  • xmin (float | None, optional) – Minimum value for the histogram. If None, then the minimum value of the last frame will be used

  • xmax (float | None, optional) – Maximum value for the histogram. If None, then the maximum value of the last frame will be used

  • nav (int, optional) – Number of frames to consider for the time average. The default is 10.

  • nbins (int, optional) – Number of bins. The default is None.

  • ptype (float, optional) – Particle type. The default is None.

Return type:

None

Examples

>>> import amep
>>> path="/home/dormann/Documents/git_amep/examples/data/lammps.h5amep"
>>> traj= amep.load.traj(path)
>>> # distribution of the absolute velocity
>>> dist=amep.evaluate.Dist(traj, "v*", func=np.linalg.norm, axis=1, skip=0.5, logbins=True)
>>> # save results in hdf5 format
>>> dist.save("./eval/dist-eval.h5", name="velocitydistribution")
>>> fig,axs=amep.plot.new()
>>> axs.plot(dist.x, dist.xdist)
>>> axs.set_xlabel("Velocity")
>>> axs.set_ylabel("P(Velocity)")
>>> axs.semilogx()
>>> fig.savefig("/home/dormann/Documents/git_amep/doc/source/_static/images/evaluate/evaluate-Dist.png")
>>> # more examples:
>>> # distribution of the x-position
>>> dist=amep.evaluate.Dist(traj, "x", skip=0.5, logbins=True)
>>> # distribution of the angular velocity
>>> dist=amep.evaluate.Dist(traj, "omega*", func=np.linalg.norm, axis=1, skip=0.5, logbins=True)
../_images/evaluate-Dist.png

Methods

__init__(traj, keys[, func, skip, nav, ...])

Calculate the distribution of a user-defined key or keys.

items()

keys()

The keys to the evaluation object.

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

Stores the evaluation result in an HDF5 file.

values()

Attributes

frames

VelDist for each frame.

indices

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

name

times

Times at which the VelDist is evaluated.

x

Magnitude of the velocities.

xdist

Time-averaged distribution of the magnitude 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 x#

Magnitude of the velocities.

Returns:

Magnitude of the velocities.

Return type:

np.ndarray

property xdist#

Time-averaged distribution of the magnitude of the velocity.

Returns:

Distribution of the magnitude of the velocity.

Return type:

np.ndarray