IMP  2.1.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 
9 
10 def create_rigid_body(m, name):
13  prb.set_coordinates_are_optimized(True)
14  prb.set_name(name + " rb")
16  ph.set_name(name)
17  for i in range(0, 2):
18  for j in range(0, 2):
19  for k in range(0, 2):
23  i, j, k) * 10.0,
24  10))
25  ph.add_child(IMP.atom.Fragment.setup_particle(d))
27  prb.add_member(d)
28  d.set_name(name + str(i) + str(j) + str(k))
30  d.set_rotational_diffusion_coefficient(
31  d.get_rotational_diffusion_coefficient() * 100)
32  return prb, ph
33 
34 
35 def display(i, w, hs):
36  w.set_frame(i)
37  for h in hs:
39  w.add_geometry(g)
40 
41 m = IMP.kernel.Model()
42 IMP.base.set_log_level(IMP.base.SILENT)
43 
44 rb0, h0 = create_rigid_body(m, "first")
45 rb1, h1 = create_rigid_body(m, "second")
46 rb1.set_reference_frame(IMP.algebra.ReferenceFrame3D(
48 
51  rb0.get_members() + rb1.get_members()),
52  1, 3)
53 m.add_restraint(ev)
54 
55 #h= IMP.core.Harmonic(0,1)
56 #s= IMP.core.DistanceToSingletonScore(h, IMP.algebra.Vector3D(0,0,0))
57 #r= IMP.core.SingletonRestraint(s, rb0.get_member(0))
58 # m.add_restraint(r)
61 m.add_restraint(cr)
62 
64 bd.set_time_step(10000)
65 
66 nm = IMP.base.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)