resize_gradient

qcmanybody.resize_gradient(grad, bas, fragment_size_dict, fragment_slice_dict, *, reverse=False)[source]

Pads or extracts a gradient array between subsystem and full supersystem sizes.

Parameters:
  • grad (ndarray) – Gradient matrix of natural size for bas, (3 * _<nat in bas>_, 3). If reverse=True, gradient matrix of supersystem size, (3 * _<nat of all fragments>_, 3).

  • bas (Tuple[int, ...]) – 1-indexed fragments active in grad. If reverse=True, 1-indexed fragments to be extracted from grad.

  • fragment_size_dict (Dict[int, int]) – Dictionary containing the number of atoms of each 1-indexed fragment. For He–HOOH–Me cluster, {1: 1, 2: 4, 3: 5}.

  • fragment_slice_dict (Dict[int, slice]) – Dictionary containing slices that index the gradient matrix for each of the 1-indexed fragments. For He–HOOH–Me cluster, {1: slice(0, 1), 2: slice(1, 5), 3: slice(5, 10)}.

  • reverse (bool) – If True, contract grad from supersystem size and shape to that which is natural for bas.

Returns:

Gradient array padded with zeros to supersystem size, (3 * _<nat of supersystem>_, 3). If reverse=True, gradient array extracted to natural size, (3 * _<nat in bas>_, 3).

Return type:

np.ndarray