xnn.ffnn.models.classical_cpu#

The classical kernels on the CPU: xnn.common.cpu_kernels.launch() runs them as C++ loops, with the lane-wise twins of the helpers that reduce over a block, and Plan holds the launches of one molecular-dynamics step.

Functions

cpu_pairs(pos, cutoff, cell, pbc[, rows, half])

stepper_pairs() on the grid of cell_grid() or on a small_cell(), or None where neither applies.

decode_images(img)

The integer shifts (E, 3) of the image indices of stepper_pairs().

hbond_triplets(rows, dst, img, pos, lengths, ...)

The hydrogen-bond triplets (donor, H, acceptor) (3, H) of a stepper's list (atom i's partners dst[beg[i]:end[i]] for rows (beg, end) of stepper_pairs(), one orthorhombic cell of edges lengths) within cutoff, once per hydrogen of the donor (hyd (N, R), -1 padded), the pairs with the donor first then those with the acceptor first, and the image shifts (2, H, 3) of their donor-acceptor and hydrogen-donor vectors, and H; written into the first H columns of the buffers out (3, C), (2, C, 3) where they fit (idx and the shifts are then those buffers).

small_cell(pos, cutoff, cell, pbc)

The edges of an orthorhombic cell, periodic on every axis, each edge over twice cutoff, of a structure of at most ALL_PAIRS_ATOMS atoms on the CPU: the cells stepper_pairs() searches by testing every pair (no room for a grid); otherwise None.

stepper_pairs(pos, cutoff, grid, rows[, ...])

A stepper's pairs i < k within cutoff on the CPU from one grid search (grid of cell_grid()), or from testing every pair where grid is the edges of a cell too small for one (small_cell()), the excluded pairs of the compressed rows rows (or None) left out, each atom's partners within inner first where given: i, k (int32), the image indices (int8) of grid_pairs_staged() and where each atom's pairs start (N + 1,) (int64), or None when the search needs its two passes; work a dict that keeps the search's buffers between calls.

torsion_coefficients(k, n, cg, sg, form, nmax)

The torsion terms (M, S) of form 0 or 1 of _torsion() summed by multiplicity: per torsion sum K, then a_n = sum K cg for n 1 to nmax (a multiplicity outside 2 to nmax counts as 1, as in the kernel), and for form 1 b_n = sum K sg; the coefficient rows of forms 3 and 4 (kept for the same parameters).

Classes

BondedImages(pos, terms)

The image shifts of the vectors of a stepper's bonded terms in one orthorhombic cell, as image_shifts() gives them, from one launch: terms the (idx, kind) of each class.

Moves(new, pos, ref, half_skin)

The positions of a step copied into a stepper's buffer and its list's test (whether an atom moved by more than half the skin) in one launch.

Plan(pos, cell, batch, dtype)

The energy and the forces of one structure at the positions in pos (the tensor a stepper writes them into) from launches prepared once per list: each class of bonded terms and the pairs by one pass (_bonded_energy_forces(), _pairs_energy_forces()).