torchspin.lft.grids#

Field-direction grids for magnetometry: single crystal, axes, exact Gauss hemisphere, DDN igloo.

E_i(-B) = E_i(B) (time reversal; the ligand field is real), so M(n) = M(-n) and a hemisphere is a full powder average. Every grid returns unit vectors and weights summing to 1 as NumPy arrays (the grids carry no gradients). Angles are in radians (torchspin’s convention) except where DDN’s own input is reproduced (ddn_igloo(), whose ranges are DDN’s RTH/RPH in degrees).

ddn_igloo() reproduces DDNSUSCALP.F / DDNMAGCALP.F ll. 262-312 exactly, including the main-program clamps (DDNSUSFITP.F ll. 308-319). Its (90, 90) octant is NOT a powder average for a low-symmetry complex (off-diagonal chi in the molecular frame); (180, 180) is a hemisphere. gauss_hemisphere(n) is exact for every polynomial in the direction up to degree 2n (a 3x3 tensor for any n >= 1); use it unless you are reproducing DDN. Copied from telser-tools (telser_tools.magnetometry.powder).

Examples

>>> from torchspin.lft import grids
>>> g = grids.gauss_hemisphere(2)
>>> len(g), round(float(g.weights.sum()), 12)
(10, 1.0)
>>> round(float((g.weights * g.vectors[:, 2] ** 2).sum()), 12)     # <n_z^2> = 1/3, exact
0.333333333333
>>> len(grids.ddn_igloo(90, 90, 5))
22
class torchspin.lft.grids.OrientationGrid(vectors, weights, label='')[source]#

A set of field directions with weights.

Variables:
  • vectors (ndarray, shape (N, 3)) – Unit field directions.

  • weights (ndarray, shape (N,)) – Weights summing to 1.

  • label (str) – Description.

property theta: ndarray[source]#

Polar angles in radians, shape (N,).

property phi: ndarray[source]#

Azimuths in radians, 0 … 2 pi, shape (N,).

torchspin.lft.grids.axes()[source]#

The x, y, z directions with weight 1/3 each (equal to DDN’s (90, 90, IGLOO=1) grid).

torchspin.lft.grids.ddn_igloo(rth, rph, igloo, clamp=True)[source]#

DDN’s igloo powder grid (equal weights).

Parameters:
  • rth (float) – DDN’s theta and phi ranges in degrees (90 or 180 after clamping).

  • rph (float) – DDN’s theta and phi ranges in degrees (90 or 180 after clamping).

  • igloo (int) – DDN’s grid density parameter.

  • clamp (bool, default True) – Apply ddn_igloo_settings() first, as DDN does.

Returns:

OrientationGrid

Return type:

OrientationGrid

torchspin.lft.grids.ddn_igloo_settings(rth, rph, igloo)[source]#

DDN’s clamps of the igloo settings (DDNSUSFITP.F ll. 308-319).

rth, rph are DDN’s theta and phi ranges in degrees, igloo its grid parameter. Ranges <= 90 become 90; ranges > 90 become 180 and halve igloo; igloo is then clamped to 1 … 50. Returns (rth, rph, igloo).

torchspin.lft.grids.directions(vectors)[source]#

Arbitrary directions vectors (3,) or (N, 3) (normalized here) with equal weights; returns an OrientationGrid.

torchspin.lft.grids.gauss_hemisphere(n=12)[source]#

Gauss product grid on the upper hemisphere.

The positive nodes of 2n-point Gauss-Legendre in cos(theta) times (2n+1) equally spaced phi. For an even function of the direction this is the full-sphere product rule, exact for every polynomial in (n_x, n_y, n_z) up to degree 2n.

Parameters:

n (int, default 12) – Order; the grid has n (2n+1) directions.

Returns:

OrientationGrid

Return type:

OrientationGrid

torchspin.lft.grids.single(theta=0.0, phi=0.0, degrees=False)[source]#

One field direction (a single-crystal measurement).

theta, phi are the polar angle and azimuth (radians, or degrees with degrees=True). Returns an OrientationGrid with weight 1.