IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
atom/rigid_brownian_dynamics.py

This example shows how to run brownian dynamics with rigid bodies.

1 ## \example atom/rigid_brownian_dynamics.py
2 # This example shows how to run brownian dynamics with rigid bodies.
3 
4 import IMP.atom
5 import IMP.core
6 import IMP.algebra
7 import IMP.display
8 import sys
9 
10 IMP.setup_from_argv(sys.argv, "rigid brownian dynamics")
11 
12 
13 def create_rigid_body(m, name):
16  prb.set_coordinates_are_optimized(True)
17  prb.set_name(name + " rb")
19  ph.set_name(name)
20  for i in range(0, 2):
21  for j in range(0, 2):
22  for k in range(0, 2):
26  i, j, k) * 10.0,
27  10))
28  ph.add_child(IMP.atom.Fragment.setup_particle(d))
30  prb.add_member(d)
31  d.set_name(name + str(i) + str(j) + str(k))
33  d.set_rotational_diffusion_coefficient(
34  d.get_rotational_diffusion_coefficient() * 100)
35  return prb, ph
36 
37 
38 def display(i, w, hs):
39  w.set_frame(i)
40  for h in hs:
42  w.add_geometry(g)
43 
44 m = IMP.Model()
45 IMP.set_log_level(IMP.SILENT)
46 
47 rb0, h0 = create_rigid_body(m, "first")
48 rb1, h1 = create_rigid_body(m, "second")
49 rb1.set_reference_frame(IMP.algebra.ReferenceFrame3D(
51 
54  m, rb0.get_rigid_members() + rb1.get_rigid_members()), 1, 3)
55 
56 #h= IMP.core.Harmonic(0,1)
57 #s= IMP.core.DistanceToSingletonScore(h, IMP.algebra.Vector3D(0,0,0))
58 #r= IMP.core.SingletonRestraint(s, rb0.get_member(0))
59 # m.add_restraint(r)
62 
64 
66 bd.set_scoring_function(sf)
67 bd.set_time_step(10000)
68 
69 nm = IMP.create_temporary_file_name("rigid_bd", ".pym")
70 nm = "rigid.pym"
72 for i in range(0, 100):
73  display(i, w, [h0, h1])
74  bd.optimize(10)