IMP logo
IMP Reference Guide  2.20.1
The Integrative Modeling Platform
core/rigid_collisions.py

Collision detection and building of a non-bonded list can be sped up when rigid bodies are used. To do this, use a RigidClosePairsFinder.

1 ## \example core/rigid_collisions.py
2 # Collision detection and building of a non-bonded list can be sped up when
3 # rigid bodies are used. To do this, use a RigidClosePairsFinder.
4 
5 import IMP
6 import IMP.core
7 import IMP.atom
8 import IMP.container
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "rigid collisions")
12 
13 # This example adds a restraint on nonbonded interactions
14 # Since it is between two rigid bodies, internal interactions are ignored
15 
16 m = IMP.Model()
17 # The particles in the rigid bodies
18 rbps0 = IMP.core.create_xyzr_particles(m, 3, 1)
19 rbps1 = IMP.core.create_xyzr_particles(m, 3, 1)
20 
21 rbp0 = IMP.Particle(m)
22 rbp1 = IMP.Particle(m)
23 
25 
27 
29 lsc.add(rbps0)
30 lsc.add(rbps1)
31 
32 # Set up the nonbonded list
34  lsc, 0, IMP.core.RigidClosePairsFinder(), 2.0)
35 
36 # Set up excluded volume
38 evr = IMP.container.PairsRestraint(ps, nbl)
40 
41 # Set up optimizer
43 o.set_scoring_function(sf)
44 
45 done = False
46 while not done:
47  try:
48  o.optimize(1000)
49  except IMP.ModelException:
50  for d in [rbss0, rbss1]:
51  d.set_transformation(
57  0, 0, 0),
58  IMP.algebra.Vector3D(10, 10, 10)))))
59  else:
60  done = True