amep.evaluate.SFiso#
- class amep.evaluate.SFiso(traj: ParticleTrajectory | FieldTrajectory, skip: float = 0.0, nav: int = 10, qmax: float = 20.0, twod: bool = True, njobs: int = 1, chunksize: int = 1000, mode: str = 'fast', ptype: int | None = None, other: int | None = None, accuracy: float = 0.5, num: int = 8, ftype: str | list | None = None)#
Bases:
BaseEvaluation
Isotropic static structure factor.
- __init__(traj: ParticleTrajectory | FieldTrajectory, skip: float = 0.0, nav: int = 10, qmax: float = 20.0, twod: bool = True, njobs: int = 1, chunksize: int = 1000, mode: str = 'fast', ptype: int | None = None, other: int | None = None, accuracy: float = 0.5, num: int = 8, ftype: str | list | None = None) None #
Calculate the isotropic static structure.
Average over several frames.
Notes
The isotropic static structure factor is defined by
\[S_{3D}(q) = \frac{1}{N}\left\langle\sum_{m,l=1}^N\frac{\sin(qr_{ml})}{qr_{ml}}\right\rangle\]\[S_{2D}(q) = \frac{1}{N}\left\langle\sum_{m,l=1}^N J_0(qr_{ml}\right\rangle\]with \(r_{ml}=|\vec{r}_m-\vec{r}_l|\) and the Bessel function of the first kind $J_0(x)$. See also Ref. [1] for further information on the static structure factor.
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) – Max. number of frames to consider for the time average. The default is 10.
qmax (float, optional) – Maximum wave number to consider. This value is ignored if a FieldTrajectory is provided as input data. The default is 20.0.
twod (bool, optional) – If True, the 2D form is used. The default is True.
njobs (int, optional) – Number of jobs for multiprocessing. The default is 1.
chunksize (int, optional) – Divide calculation into chunks of this size. The default is 1000.
mode (str, optional) – One of [‘std’, ‘fast’, ‘fft’]. The ‘fft’ mode only works if twod=True. The default is ‘fast’.
ptype (int or None, optional) – Particle type. The default is None.
other (int or None, optional) – Other particle type (to calculate the correlation between different particle types). The default is None.
accuracy (float, optional) – Accuracy for mode=’fft’. 0.0 means least accuracy, 1.0 best accuracy. The default is 0.5. Note that a higher accuracy needs more memory for the computation. The accuracy must be in (0,1].
num (int, optional) – Number of q vectors to average over in mode=’fast’. If twod is False, the number of q vectors is equal to num^2. The default is 8.
ftype (str or list or None, optional) – Allows to specify for which field(s) in a given FieldTrajectory the isotropic structure factor should be calculated. If None, the isotropic structure factor is calculated for all field. The default is None.
Examples
>>> import amep >>> ptraj = amep.load.traj("../examples/data/lammps.h5amep") >>> ftraj = amep.load.traj("../examples/data/continuum.h5amep") >>> psfiso = amep.evaluate.SFiso(ptraj, skip=0.9, nav=2, qmax=20) >>> fsfiso = amep.evaluate.SFiso(ftraj, skip=0.9, nav=2, ftype="c") >>> psfiso.save("./eval/sfiso_eval.h5", database=True, name="particles") >>> fsfiso.save("./eval/sfiso_eval.h5", database=True, name="field") >>> L = amep.utils.domain_length(psfiso.avg, psfiso.q, qmax=1.0) >>> print(L) 57.88815991321122 >>> fig, axs = amep.plot.new(figsize=(7,3), ncols=2) >>> axs[0].plot(psfiso.q, psfiso.avg) >>> axs[0].set_xlabel(r"$q$") >>> axs[0].set_ylabel(r"$S(q)$") >>> axs[0].set_title("active Brownian particles") >>> axs[0].set_ylim(-0.5,50) >>> axs[1].plot(fsfiso.q, fsfiso.avg) >>> axs[1].set_xlabel(r"$q$") >>> axs[1].set_ylabel(r"$S(q)$") >>> axs[1].set_title("Keller-Segel model") >>> fig.savefig("./figures/evaluate/evaluate-SFiso.png")
Methods
__init__
(traj[, skip, nav, qmax, twod, ...])Calculate the isotropic static structure.
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 SFiso (averaged over the given number of frames).
SFiso for each frame.
Indices of all frames for which the SFiso has been evaluated.
name
Magnitude of the scattering vectors.
Times at which the SFiso is evaluated.
- property avg#
Time-averaged SFiso (averaged over the given number of frames).
- Returns:
Time-averaged SFiso.
- Return type:
np.ndarray
- property frames#
SFiso for each frame.
- Returns:
SFiso for each frame.
- Return type:
np.ndarray
- property indices#
Indices of all frames for which the SFiso 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 q#
Magnitude of the scattering vectors.
- Returns:
Magnitude 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 SFiso is evaluated.
- Returns:
Times at which the SFiso is evaluated.
- Return type:
np.ndarray