IMP logo
IMP Reference Guide  2.18.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 
45 m = IMP.Model()
46 IMP.set_log_level(IMP.SILENT)
47 
48 rb0, h0 = create_rigid_body(m, "first")
49 rb1, h1 = create_rigid_body(m, "second")
50 rb1.set_reference_frame(IMP.algebra.ReferenceFrame3D(
52 
55  m, rb0.get_rigid_members() + rb1.get_rigid_members()), 1, 3)
56 
59 
61 
63 bd.set_scoring_function(sf)
64 bd.set_time_step(10000)
65 
66 nm = IMP.create_temporary_file_name("rigid_bd", ".pym")
67 nm = "rigid.pym"
69 for i in range(0, 100):
70  display(i, w, [h0, h1])
71  bd.optimize(10)