periodic module

Full Documentation for hippynn.layers.pairs.periodic module. Click here for a summary page.

class PeriodicPairIndexer(hard_dist_cutoff)[source]

Bases: _PairIndexer

Finds pairs in general periodic conditions.

forward(coordinates, nonblank, real_atoms, inv_real_atoms, cells)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class PeriodicPairIndexerMemory(skin, dist_hard_max=None, hard_dist_cutoff=None)[source]

Bases: PairMemory

Implementation of PeriodicPairIndexer with additional memory component.

Stores current pair indices in memory and reuses them to compute the pair distances if no particle has moved more than skin/2 since last pair calculation. Otherwise uses the _pair_indexer_class to recompute the pairs.

Increasing the value of ‘skin’ will increase the number of pair distances computed at each step, but decrease the number of times new pairs must be computed. Skin should be set to zero while training for fastest results.

forward(coordinates, nonblank, real_atoms, inv_real_atoms, cells)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class StaticImagePeriodicPairIndexer(*args, n_images=1, **kwargs)[source]

Bases: _PairIndexer

Finds Pairs within a given number of images

forward(coordinates, nonblank, real_atoms, inv_real_atoms, cells)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

filter_pairs(cutoff, distflat, *addn_features)[source]
union_indices_2d_masks(*arrays)[source]

Compute the indices of the union of a list of 2D mask arrays.

Assume a set of arrays a_1…a_n, each with shape (b,f_1),(b,f_2)…(b,f_n) The output is equivalent to broadcasting the combined multiplication:

m = a1*a2*a3*a4

into shape (b,f_1,f_2,..f_n) and return torch.nonzero(m). However, this function does not materialize the large intermediate array of all possible products. It does call nonzero several times which causes blocking ops on the GPU, but because they are almost back-to-back this is usually not worse than calling nonzero in the first place.

Performance heuristic note: Provide the arrays in ascending sparsity order.