amep.evaluate.SF2d#

class amep.evaluate.SF2d(traj: ParticleTrajectory | FieldTrajectory, skip: float = 0.0, nav: int = 10, ptype: int = None, other: int = None, rotate: bool = True, ftype: str | list | None = None, **kwargs)#

Bases: BaseEvaluation

2d static structure factor.

__init__(traj: ParticleTrajectory | FieldTrajectory, skip: float = 0.0, nav: int = 10, ptype: int = None, other: int = None, rotate: bool = True, ftype: str | list | None = None, **kwargs) None#

Calculate the 2d static structure factor.

Notes

The static structure factor is defined by

\[S(\vec{q}) = \frac{1}{N} \left\langle\sum_{j=1}^{N}\sum_{k=1}^{N}\exp\left\lbrace-i\vec{q}\cdot(\vec{r}_j-\vec{r}_k)\right\rbrace\right\rangle = \frac{1}{N} \left\langle\left|\sum_{j=1}^{N}\exp\left\lbrace-i\vec{q}\cdot\vec{r}_j\right\rbrace\right|^2\right\rangle,\]

(see Ref. [1] for further information).

References

Parameters:
  • traj (ParticleTrajectory or FieldTrajectory) – 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 consider for the time average. The default is 10.

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

  • other (float, optional) – Other particle type (to calculate the correlation between different particle types). The default is None.

  • rotate (bool, optional) – If True, the whole system is rotated according to its psi6 parameter (mean orientation along x axis). The default is True.

  • ftype (str or list or None, optional) – Allows to specify for which field(s) in a given FieldTrajectory the 2d structure factor should be calculated. If None, the 2d structure factor is calculated for all fields. The default is None.

  • **kwargs – Other keyword arguments are forwarded to amep.spatialcor.sf2d in the case of particle-based simulation data and to amep.continuum.csf2d in the case of continuum simulation data.

Return type:

None.

Examples

>>> import amep
>>> ptraj = amep.load.traj("../examples/data/lammps.h5amep")
>>> psf2d = amep.evaluate.SF2d(ptraj, skip=0.9, nav=2)
>>> psf2d.save("./eval/sf2d_eval.h5", database=True, name="particles")
>>> ftraj = amep.load.traj("../examples/data/continuum.h5amep")
>>> fsf2d = amep.evaluate.SF2d(ftraj, skip=0.9, nav=2, ftype="p")
>>> fsf2d.save("./eval/sf2d_eval.h5", database=True, name="field")
>>> fig, axs = amep.plot.new(ncols=2, figsize=(7.5,3))
>>> mp1 = amep.plot.field(
...     axs[0], psf2d.avg, psf2d.qx, psf2d.qy,
...     cscale="log", vmin=1e-1
... )
>>> cax1 = amep.plot.add_colorbar(
...     fig, axs[0], mp1, label=r"$S(q_x, q_y)$"
... )
>>> axs[0].set_xlabel(r"$q_x$")
>>> axs[0].set_ylabel(r"$q_y$")
>>> axs[0].set_title("active Brownian particles")
>>> mp2 = amep.plot.field(
...     axs[1], fsf2d.avg, fsf2d.qx, fsf2d.qy,
...     cscale="log", vmin=1e0
... )
>>> cax2 = amep.plot.add_colorbar(
...     fig, axs[1], mp2, label=r"$S(q_x, q_y)$"
... )
>>> axs[1].set_xlabel(r"$q_x$")
>>> axs[1].set_ylabel(r"$q_y$")
>>> axs[1].set_title("Keller-Segel model")
>>> fig.savefig("./figures/evaluate/evaluate-SF2d.png")
../_images/evaluate-SF2d.png

Methods

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

Calculate the 2d static structure factor.

items()

keys()

The keys to the evaluation object.

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

Stores the evaluation result in an HDF5 file.

values()

Attributes

avg

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

frames

SF2d for each frame.

indices

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

name

qx

x-components of the scattering vectors.

qy

y-components of the scattering vectors.

times

Times at which the SF2d is evaluated.

property avg#

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

Returns:

Time-averaged SF2d.

Return type:

np.ndarray

property frames#

SF2d for each frame.

Returns:

SF2d for each frame.

Return type:

np.ndarray

property indices#

Indices of all frames for which the SF2d 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.

property qx#

x-components of the scattering vectors.

Returns:

x-components of the scattering vectors.

Return type:

np.ndarray

property qy#

y-components of the scattering vectors.

Returns:

y-components of the scattering vectors.

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 SF2d is evaluated.

Returns:

Times at which the SF2d is evaluated.

Return type:

np.ndarray