amep.utils.sq_from_gr#
- amep.utils.sq_from_gr(r: ndarray, gr: ndarray, q: ndarray, rho: float, twod: bool = True) ndarray #
Compute the static structure factor as fourier transform of the pair correlation function.
Notes
The relation between g(r) and S(q) is given by (here in 3D; see Ref. [1] for further information)
\[S(q) = 1 + \frac{4\pi\rho}{q}\int\limits_0^\infty dr\,r\sin(qr)(g(r)-1)\]References
- Parameters:
r (np.ndarray) – Distances.
gr (np.ndarray) – Radial pair-distribution function.
q (np.ndarray) – Wave numbers.
rho (float) – Number density.
twod (bool, default=True) – If True, the slightly different formula for the two-dimensional case is used (which includes a Bessel function and can be derived by using zylindrical coordinates and calculating the angular integral by setting w.l.o.g. q parallel to e_x.)
- Returns:
Isotropic static structure factor.
- Return type:
np.ndarray
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> rdf = amep.evaluate.RDF(traj, nav=10, skip=0.8, njobs=4) >>> boxlength = np.max(traj[0].box[:,1] - traj[0].box[:,0]) >>> q = np.arange(2*np.pi/boxlength, 20.0, 2*np.pi/boxlength) >>> S = amep.utils.sq_from_gr( ... rdf.r, rdf.avg, q, traj[0].density(), twod=True ... ) >>> fig, axs = amep.plot.new() >>> axs.plot(q, S) >>> axs.axhline(0.0, ls='--', c='k') >>> axs.set_xlabel(r'$q$') >>> axs.set_ylabel(r'$S(q)$') >>> axs.set_ylim(-1, 10) >>> fig.savefig('./figures/utils/utils-sq_from_gr.png') >>>