amep.evaluate.ClusterGrowth#

class amep.evaluate.ClusterGrowth(traj: ParticleTrajectory | FieldTrajectory, skip: float = 0.0, nav: int | None = None, min_size: int = 0, ptype: int | None = None, ftype: str | list | None = None, mode: str = 'largest', use_density: bool = True, **kwargs)#

Bases: BaseEvaluation

Growth of clusters over time.

__init__(traj: ParticleTrajectory | FieldTrajectory, skip: float = 0.0, nav: int | None = None, min_size: int = 0, ptype: int | None = None, ftype: str | list | None = None, mode: str = 'largest', use_density: bool = True, **kwargs) None#

Calculates the size of the largest cluster, the mean cluster size, or the weighted mean cluster size for each time step as studied in Refs. [1] and [2] for example.

References

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) – Total number of time steps (frames) to consider. The default is None.

  • min_size (int, optional) – Consider only clusters with at least this size. If a ParticleTrajectory is supplied, the minimum size is given in number of particles. If a FieldTrajectory is supplied, it is either given in area units (use_density=False) or density units (use_density=True). The default is 2.

  • ptype (float, optional) – Particle type. If None, all particles are considered. The default is None.

  • ftype (str or None, optional) – Allows to specify for which field in the given FieldTrajectory the cluster growth should be calculated. If None, the cluster growth is calculated for the first field in the list of ftype keys and a warning is printed. The default is None.

  • mode (str, otptional) – Quantity to be used for calculating the cluster growth. Possible options are “largest” (size of the largest cluster), “mean” (mean cluster size), and “weighted mean” (weighted mean cluster size). The default is “largest”.

  • use_density (bool, optional) – Decides wether to use the integrated value of the field or the area as clustersize. Only set to false if your field cannot be interpreted as a density, i.e., if it can be negative. The default is True.

  • **kwargs – Other keyword arguments are forwarded to amep.cluster.cluster and amep.continuum.identify_clusters for ParticleTrajectories and FieldTrajectories, respectively.

Return type:

None.

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> fig, axs = amep.plot.new()
>>> clg = amep.evaluate.ClusterGrowth(traj, mode="largest")
>>> axs.plot(clg.times, clg.frames, label="largest")
>>> clg = amep.evaluate.ClusterGrowth(traj, mode="mean")
>>> axs.plot(clg.times, clg.frames, label="mean")
>>> clg = amep.evaluate.ClusterGrowth(ptraj, mode="mean", min_size=20)
>>> axs.plot(clg.times, clg.frames, label="mean min 20")
>>> clg = amep.evaluate.ClusterGrowth(ptraj, mode="weighted mean")
>>> axs.plot(clg.times, clg.frames, label="weighted mean")
>>> axs.loglog()
>>> axs.legend()
>>> axs.set_xlabel(r"$t$")
>>> axs.set_ylabel(r"$\langle m\rangle$")
>>> fig.savefig("./figures/evaluate/evaluate-ClusterGrowth_1.png")
../_images/evaluate-ClusterGrowth_1.png
>>> traj = amep.load.traj("../examples/data/continuum.h5amep")
>>> clg = amep.evaluate.ClusterGrowth(
...     traj, ftype="p", threshold=0.2
... )
>>> fig, axs = amep.plot.new()
>>> axs.plot(clg.times, clg.frames)
>>> axs.loglog()
>>> axs.set_xlabel(r"$t$")
>>> axs.set_ylabel(r"$\langle m\rangle$")
>>> fig.savefig("./figures/evaluate/evaluate-ClusterGrowth_2.png")
../_images/evaluate-ClusterGrowth_2.png

Methods

__init__(traj[, skip, nav, min_size, ptype, ...])

Calculates the size of the largest cluster, the mean cluster size, or the weighted mean cluster size for each time step as studied in Refs.

items()

keys()

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

Stores the evaluation result in an HDF5 file.

values()

Attributes

avg

Time-averaged size of the largest cluster (averaged over the given number of frames).

frames

Size of the largest cluster for each frame.

indices

Indices of all frames for which the size of the largest cluster has been calculated.

name

times

Times at which the size of the largest cluster is evaluated.

property avg#

Time-averaged size of the largest cluster (averaged over the given number of frames).

Returns:

Time-averaged size of the largest cluster.

Return type:

float

property frames#

Size of the largest cluster for each frame.

Returns:

Function value for each frame.

Return type:

np.ndarray

property indices#

Indices of all frames for which the size of the largest cluster has been calculated.

Returns:

Frame indices.

Return type:

np.ndarray

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 size of the largest cluster is evaluated.

Returns:

Times at which the size of the largest cluster is evaluated.

Return type:

np.ndarray