IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
pair_restraint.py
1## \example core/pair_restraint.py
2# Restrain the distance between a pair of particles.
3#
4
5import IMP.algebra
6import IMP.core
7import sys
8
9IMP.setup_from_argv(sys.argv, "pair restraint")
10
11# Make two xyz particles randomly distributed in space
12m = IMP.Model()
14 IMP.algebra.Vector3D(10,10,10))
15inds = []
16for i in range(2):
17 p = m.add_particle("p")
20 inds.append(p)
21
22# Score the distance between the two particles with a harmonic function
23uf = IMP.core.Harmonic(0, 1)
25r = IMP.core.PairRestraint(m, df, (inds[0], inds[1]))
26
27# Print the current score of the restraint, without first derivatives
28print(r.evaluate(False))
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Score a pair of particles based on the distance between their centers.
Harmonic function (symmetric about the mean)
Applies a PairScore to a Pair.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition XYZR.h:48
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
VectorD< 3 > Vector3D
Definition VectorD.h:407
VectorD< D > get_random_vector_in(const BoundingBoxD< D > &bb)
Generate a random vector in a box with uniform density.
Basic functionality that is expected to be used by a wide variety of IMP users.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.