torchref.refinement.targets.adp.locality module

class torchref.refinement.targets.adp.locality.ADPLocalityTarget(model=None, k_neighbors=50, correlation_length=5.0, scale=5.0, exclude_bonded=True, verbose=0)[source]

Bases: ADPTarget

Proximity-based ADP restraint using K nearest neighbors.

Uses a spatial cell-list (O(N) memory, O(N·k) time) instead of a full N×N distance matrix, so it scales to arbitrarily large structures without memory issues.

Parameters:
  • model (Model) – Reference to Model object.

  • k_neighbors (int, optional) – Number of nearest neighbors to consider. Default is 50.

  • correlation_length (float, optional) – Distance scale for weight decay in Angstrom. Default is 5.0.

  • scale (float, optional) – Scaling factor for loss magnitude. Default is 5.0.

  • exclude_bonded (bool, optional) – Exclude directly bonded atoms. Default is True.

  • verbose (int, optional) – Verbosity level. Default is 0.

name: str = 'adp/locality'
__init__(model=None, k_neighbors=50, correlation_length=5.0, scale=5.0, exclude_bonded=True, verbose=0)[source]

Initialize model target.

Parameters:
  • model (Model, optional) – Reference to the Model object (optional for empty init).

  • verbose (int, optional) – Verbosity level. Default is 0.

property k_neighbors: int
property correlation_length: float
property scale: float
forward(recompute_neighbors=False)[source]

Compute weighted MSE on log(B) differences with inverse-distance weights.

loss = scale * mean_ij [w_ij * (log(B_i) - log(B_j))^2] where w_ij = 1 / (d_ij + eps)

stats()[source]

Get locality restraint statistics.