Debye sums¶
Debye sums for a set of point scatterers.
Every kernel computes the same quantity:
for scattering lengths \(b\) (Å), volumes \(v\) (ų) and a solvent SLD
\(\rho\) (Å⁻²), at positions in Å. debye_pairs enumerates pairs and works
for any point set. The spectrum builders first collect the pairs into a
DistanceSpectrum, a list of distances with the weights b·b, b·v and
v·v kept apart, so another solvent costs only the sinc sums:
spectrum_lattice: the autocorrelation of weight grids, exact for points on a lattice and fast for large grids.spectrum_histogram: pairs counted by distance in bins of a given width, for any point set (coords2sans's pass).spectrum_radial: each point's distance from a centre, the squared orientation-averaged amplitude ⟨A⟩², exact only for spherically symmetric structures (SasView'sis_avg).
DistanceSpectrum
dataclass
¶
The part of a Debye sum that does not depend on q or the solvent.
Attributes:
| Name | Type | Description |
|---|---|---|
r |
ndarray
|
Distances, Å; only those with a non-zero component. |
components |
ndarray
|
|
squared |
bool
|
Which of the two forms. |
CalculationInterrupted ¶
Bases: Exception
Raised when a progress callback asks a running calculation to stop.
debye_pairs ¶
debye_pairs(q, xyz, w, *, block: int | None = None, progress: Callable[[float], bool | None] | None = None) -> np.ndarray
Exact Debye sum by enumerating the upper triangle of pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Momentum transfers, 1/Å, any values >= 0. |
required | |
xyz
|
Positions, shape (N, 3), Å. |
required | |
w
|
Weights, shape (N,). |
required | |
block
|
int | None
|
Rows per block. Defaults to a size that keeps each pair buffer
near |
None
|
progress
|
Callable[[float], bool | None] | None
|
Called with the completed fraction after each block. A
return value of True stops the sum with |
None
|
spectrum_lattice ¶
spectrum_lattice(grid_b, grid_v, step) -> DistanceSpectrum
The exact spectrum of weights on a rectangular lattice.
On a lattice every pair displacement is an integer vector \(\Delta\), so the pair weights are correlations of two grids, such as
Lags are grouped by the exact integer key \((|i|, |j|, |k|)\), so no floating-point rounding enters the grouping. A lag that some pair of occupied sites has gets \(C_{vv}\) of at least the smallest volume squared, far above the FFT noise of the empty lags, which are dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_b
|
Scattering lengths on the grid, shape (nx, ny, nz); empty sites hold 0. |
required | |
grid_v
|
Volumes on the same grid; positive at every occupied site. |
required | |
step
|
Lattice steps along x, y and z, Å. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no site has a positive volume, or a site with a scattering length has none. |
spectrum_histogram ¶
spectrum_histogram(xyz, b, v, bin_width: float, *, block: int | None = None, progress: Callable[[float], bool | None] | None = None) -> DistanceSpectrum
The spectrum of all pairs, counted by distance rounded to bin_width.
Squared distances come from a matrix product per block of rows; each distance is rounded to the nearest multiple of the bin, which moves a pair by at most bin/2, a phase error of at most q·bin/2. Only occupied bins are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xyz
|
Positions, shape (N, 3), Å. |
required | |
b
|
Scattering lengths, shape (N,). |
required | |
v
|
Volumes, shape (N,). |
required | |
bin_width
|
float
|
Bin width, Å. |
required |
block
|
int | None
|
Rows per block. Defaults to about |
None
|
progress
|
Callable[[float], bool | None] | None
|
Called with the completed fraction after each block. A
return value of True stops the pass with |
None
|
spectrum_radial ¶
spectrum_radial(xyz, b, v, centre) -> DistanceSpectrum
The squared spectrum ⟨A⟩²: each point's distance from centre, Å.
The orientation-averaged amplitude about the centre \(c\) is \(A(q) = \sum_j w_j \operatorname{sinc}(q |x_j - c|)\), and \(A(q)^2\) equals \(D(q)\) only for spherically symmetric structures.