Skip to content

Action: IMAGE_DISTANCE

Module colvar
Description Usage
Calculate the minimum distance between a whole group and a distinct periodic image of itself. used in 0 tutorialsused in 0 eggs
output value type
the minimum distance to a nonzero periodic image of the group scalar

Details and examples

Calculate the minimum distance between a whole group and a distinct periodic image of itself.

For whole coordinates , the result is \f[ d=\min_{i,j;\,n\in\mathbb{Z}^3\setminus{0}}|r_j-r_i+B^T n|, \f] where cell vectors are rows of . Zero translation is excluded for ALL pairs. An atom and its own translated image are valid candidates: for one atom this returns the shortest nonzero lattice-vector length, not zero.

Whole coordinates

This action neither reconstructs nor wraps coordinates. Use WHOLEMOLECULES first if atoms are individually wrapped:

Click on the labels of the actions for more information on what each action computes
tested on2.11
WHOLEMOLECULESThis action is used to rebuild molecules that can become split by the periodic boundary conditions. More details ENTITY0the atoms that make up a molecule that you wish to align=1-100
img: IMAGE_DISTANCECalculate the minimum distance between a whole group and a distinct periodic image of itself. More details ATOMSatoms of one whole group; use WHOLEMOLECULES first when necessary=1-100
LOWER_WALLSDefines a wall for the value of one or more collective variables, More details ARGthe arguments on which the bias is acting=img ATthe positions of the wall=0.8 KAPPAthe force constant for the wall=1000 EXP the powers for the walls=2
PRINTPrint quantities to a file. More details ARGthe labels of the values that you would like to print to the file=img FILEthe name of the file on which to output these quantities=COLVAR

Consecutive atoms in ENTITY0 must remain sufficiently close for unambiguous minimum-image reconstruction; see WHOLEMOLECULES. Connecting atoms can be included in ENTITY0 without being selected in ATOMS. An arbitrary disconnected group has no unique reconstruction. Once whole, the scalar is independent of selection order and coherent translations, including lattice translations. Individually wrapping atoms without reconstruction changes the specified copy and can change the result. There is no maximum extent or compactness assumption.

Guaranteed search and cost

A nonsingular three-dimensional periodic cell is required; orthorhombic and triclinic cells are supported. After lattice reduction, define and . A candidate of length at most satisfies . Enumerating these bounded integer intervals includes every possible improvement. Initially is a nonzero basis-vector length. Reduction changes neither the lattice nor the zero translation. Bounds are padded outwards for floating point roundoff. This search includes extended groups and does not assume 26 neighboring images suffice. As with other geometric CVs, extremely ill-conditioned cells and coordinates beyond floating point/integer resolution are unsuitable; unrepresentable integer bounds are rejected.

For at least 64 atoms, the default search rebuilds a balanced Cartesian spatial tree from the whole coordinates every frame. If is the span of their reduced fractional coordinates, every improving image satisfies . These globally bounded nonzero shifts are queried against the tree. The Cartesian distance to a node's bounding box is a lower bound on all distances to atoms in that node, so nodes farther than the current winner are skipped. Surviving leaves evaluate the same displacement as the exhaustive pair kernel. Conservative padding retains tied candidates and protects the broad phase against floating point cancellation and changes of origin.

The tree is rebuilt on every calculation, including changes of the cell and whole coordinates; there is no cached neighbor list, skin or update stride. BRUTE_FORCE disables this spatial pruning for validation. Small selections and frames requiring more than 4096 globally bounded shifts use the original exact pair scan instead. The scan is also used when the shift count exceeds , avoiding excessive image queries for sparse extended groups. This fallback adds no restriction on group extent or cell geometry. Tree construction costs ; query cost depends on geometry, and worst-case pair work remains quadratic. The exhaustive scan costs for bounded image candidates per pair. No pair/image matrix is stored.

Atom query rows are distributed cyclically over the action MPI communicator and scheduled dynamically over OpenMP threads on each rank. Each worker keeps its own minimum; a deterministic reduction selects the same winning pair and image regardless of rank/thread count. Final atomic and box gradients are replicated using normal Colvar force propagation. MPI exchanges one winner per rank. Storage per rank is for shifts, threads and ranks, with bounded by the fallback threshold. OpenMP is disabled below 4096 local potential pairs per requested thread; MPI communication and replicated tree construction can dominate small selections. PLUMED_NUM_THREADS controls the OpenMP thread count. SERIAL disables both forms of work sharing and retains the spatial search. Benchmark representative geometry before production use.

Biasing and derivatives

The exact minimum is continuous but piecewise differentiable; forces can jump at pair/image switches. Exact ties use the initial self-image basis vector / first strict self-image improvement, followed by the lexicographically smallest selection-index pair and reduced-basis integer shift. This reproduces the serial traversal order independently of OpenMP scheduling and MPI rank count. This is one branch's derivative, not a unique gradient at a cusp; selection order or basis changes can affect derivatives at a tie. Biasing this exact scalar is supported with that caveat. No smooth minimum is provided. MIN/ALT_MIN reductions define other quantities whose image truncation and multiplicities would need specification; an adaptive winner-only candidate set cannot simply be softened.

For the active , atomic gradients are and cancel for . The PLUMED box derivative is under homogeneous coordinate and cell deformation, including the image shift. Thus one atom has a box derivative despite zero atomic gradients. Empty selections, nonfinite inputs, missing/singular boxes and exactly coincident image contacts are errors; at zero contact the distance gradient is undefined.

Input

The atoms that serve as the input for this action are specified using one or more of the keywords in the following table.

Keyword Type Description
ATOMS atoms atoms of one whole group; use WHOLEMOLECULES first when necessary

Full list of keywords

The following table describes the keywords and options that can be used with this action

Keyword Type Default Description
ATOMS input none atoms of one whole group; use WHOLEMOLECULES first when necessary
NUMERICAL_DERIVATIVESThis keyword do not have examples optional false calculate the derivatives for these quantities numerically
SERIALThis keyword do not have examples optional false disable MPI work distribution and OpenMP threading for this action
BRUTE_FORCEThis keyword do not have examples optional false disable spatial pruning and scan every atom pair for validation