pylj.scattering#
The structure factor of a configuration, evaluated at the wavevectors commensurate with its box.
Structure factor calculations.
- pylj.scattering.MOST_WAVEVECTORS = 1000000#
Most wavevectors a structure factor is evaluated at. Building them and the amplitudes takes a few tens of bytes each, so this bounds the working memory to under a hundred megabytes. The default range asks for about a hundred thousand of them for a thousand atoms.
- pylj.scattering.default_q_max(number_of_atoms: int, box: float) float[source]#
Chooses the default largest wavevector magnitude, in 1/m.
2 pi sqrt(N) / Lmatches the mean spacing betweenNatoms in a box of sideL; the default is six times it.- Parameters:
number_of_atoms – The number of atoms.
box – The side length of the square box, in metres.
- Returns:
The wavevector magnitude, in 1/m.
- pylj.scattering.check_q_max(q_max: float, box: float) None[source]#
Checks a wavevector magnitude against the box and the wavevector limit.
- Parameters:
q_max – The largest wavevector magnitude, in 1/m.
box – The side length of the square box, in metres.
- Raises:
ValueError – If
q_maxis below2 pi / L, or needs more thanMOST_WAVEVECTORS.
- pylj.scattering.wavevectors(box: float, q_max: float) tuple[NDArray[float64], NDArray[int64], NDArray[int64]][source]#
Enumerates the wavevectors commensurate with a box, grouped by magnitude.
A square box of side
Lthat repeats in both directions has the wavevectors2 pi (h, k) / L, for integerhandk. The pair where both are zero is left out. The wavevectors that share a magnitude make up a shell.- Parameters:
box – The side length of the square box, in metres.
q_max – The largest magnitude to return, in 1/m.
- Returns:
The distinct magnitudes in increasing order, in 1/m; the pair of integers
(h, k)of each wavevector, of shape(M, 2); and, for each wavevector, the position in that list of magnitudes of the shell it belongs to.
- pylj.scattering.shell_average(positions: NDArray[float64], box: float, index: NDArray[int64], shell: NDArray[int64]) NDArray[float64][source]#
Computes the structure factor of a configuration.
The amplitude at a wavevector is
sum_j exp(i q . r_j)over the atom positions, and the structure factor is the square of its modulus divided by the number of atoms. Every atom counts alike, whatever its species, and the wavevectors of a shell are averaged together.- Parameters:
positions – The atom positions, shape
(N, 2), in metres.box – The side length of the square box, in metres.
index – The pair of integers of each wavevector, shape
(M, 2).shell – The index of the shell each wavevector belongs to.
- Returns:
The structure factor at each shell magnitude.