xnn.ffnn.models.classical_fast#

The fast nonbonded pair terms of the classical force fields (OPLS, AMBER, CHARMM, DREIDING): the half neighbor list, the exclusion weights, the per-type-pair table over the atom types a topology uses, and the call of the pair kernel of classical_kernels. Each model supplies its table and charges; the numbers are those of its eager nonbonded block to round-off.

Functions

evaluate_spec(data, spec, module)

The per-atom energies {name: (N,)} of a model's kernel spec (its _fast_spec): "bonded" a list of (name, kind, idx, params, options) (fast_bonded()), "pairs14" (names, pairs, compact, q, table, ke) or None (fast_pairs14()), "nonbonded" (names, compact, q, table, ke, excl_index, n, cutoff, width, form) (fast_nonbonded()); one search for every term's image shifts.

exclusion_rows(module, excl_index, n)

The excluded partners of every atom of one structure as compressed rows (ptr (n + 1,), cols, width) (int32; each pair i < k of excl_index in the row of i; width the longest row), made once per device.

fast_bonded(data, idx, kind, params, shifts)

The per-atom energies (N,) of one class of bonded terms from the kernels of classical_kernels (kind, params and extra as there), in the model's dtype; twice the kernels differentiable twice (classical_train); tiny the regularizer of the lengths (0 for none).

fast_nonbonded(data, n, B, compact, q, ...)

The per-atom van der Waals and Coulomb energies (N,) each, in the model's dtype, from the pair kernel on the graph's directed neighbor list (each pair once, i < k), without the excluded pairs excl_index (2, E) of one structure (i < k), with the compact types compact (n,) of one structure, the charges q (N,) and the (T, T, 3) table of the form; twice the kernels differentiable twice (classical_train); tiny the regularizer of the distances (0 for none).

fast_pairs14(data, pairs, shifts, compact, ...)

The per-atom van der Waals and Coulomb energies (N,) each of the 1,4 pairs pairs (2, P) (i < k, of the batch) with their image shifts (1, P, 3) from the pair kernel, without a cutoff, the tables and the Coulomb constant already scaled.

fast_supported(device, dtype)

Whether the pair kernel runs on device in dtype (CUDA and Triton).

image_shifts(data, terms)

The image shifts (V, M, 3) of the vectors of every (idx, kind) in terms from one search (pair_image_shifts()), or None each without cells.

lj_table(A, B, R)

The (T, T, 3) table of the 12-6 form A (x^2 - B x), x = (R^2 / r^2)^3.

needs_twice(module[, data])

Whether an evaluation takes the kernels differentiable twice (classical_train): gradients on and no cell gradient (the cell is a constant of those kernels; with a cell gradient, the stress, the kernels differentiable once run, which carry it).

used_types(module, top_type)

The library type indices a bound topology uses (T,) and each atom's index among them (n,), made once per device.

wants_fast(module, use_fast, data, *params)

Whether an evaluation takes the kernels: use_fast on, a CUDA device with Triton, no intermediates kept, and, where the kernels must be differentiable twice (training, trained parameters), no cell gradient (a stress loss takes the reference terms).

x6_table(a, b, c)

The (T, T, 3) table of the exponential-6 form a exp(-c r) - b / r^6.

Classes

ClassicalFastPath()

The use_fast setting of a classical force field with kernel terms (OPLS, AMBER, CHARMM, DREIDING).