IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/26
The Integrative Modeling Platform
core/pair_restraint.py

Restrain the distance between a pair of particles.

1 ## \example core/pair_restraint.py
2 # Restrain the distance between a pair of particles.
3 #
4 
5 import IMP.algebra
6 import IMP.core
7 import sys
8 
9 IMP.setup_from_argv(sys.argv, "pair restraint")
10 
11 # Make two xyz particles randomly distributed in space
12 m = IMP.Model()
14  IMP.algebra.Vector3D(10,10,10))
15 inds = []
16 for 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
23 uf = IMP.core.Harmonic(0, 1)
25 r = IMP.core.PairRestraint(m, df, (inds[0], inds[1]))
26 
27 # Print the current score of the restraint, without first derivatives
28 print(r.evaluate(False))