IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
rigid_brownian_dynamics.py
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
def
create_rigid_body
(m, name):
10
prb=
IMP.core.RigidBody.setup_particle
(
IMP.Particle
(m),
IMP.algebra.ReferenceFrame3D
())
11
prb.set_coordinates_are_optimized(
True
)
12
prb.set_name(name+
" rb"
)
13
ph=
IMP.atom.Molecule.setup_particle
(
IMP.Particle
(m))
14
ph.set_name(name)
15
for
i
in
range(0,2):
16
for
j
in
range(0,2):
17
for
k
in
range(0,2):
18
d=
IMP.core.XYZR.setup_particle
(
IMP.Particle
(m),
19
IMP.algebra.Sphere3D
(
IMP.algebra.Vector3D
(i,j,k)*10.0,
20
10))
21
ph.add_child(
IMP.atom.Fragment.setup_particle
(d))
22
IMP.atom.Mass.setup_particle
(d, 1000)
23
prb.add_member(d)
24
d.set_name(name+str(i)+str(j)+str(k))
25
d=
IMP.atom.RigidBodyDiffusion.setup_particle
(prb)
26
d.set_rotational_diffusion_coefficient(d.get_rotational_diffusion_coefficient()*100)
27
return
prb, ph
28
29
def
display(i, w, hs):
30
w.set_frame(i)
31
for
h
in
hs:
32
g=
IMP.atom.HierarchyGeometry
(h)
33
w.add_geometry(g)
34
35
m=
IMP.Model
()
36
IMP.base.set_log_level
(IMP.base.SILENT)
37
38
rb0, h0=
create_rigid_body
(m,
"first"
)
39
rb1, h1=
create_rigid_body
(m,
"second"
)
40
rb1.set_reference_frame(
IMP.algebra.ReferenceFrame3D
(
IMP.algebra.Transformation3D
(
IMP.algebra.Vector3D
(30,0,0))))
41
42
ev=
IMP.core.ExcludedVolumeRestraint
(
IMP.container.ListSingletonContainer
(rb0.get_members()+rb1.get_members()),
43
1, 3)
44
m.add_restraint(ev)
45
46
#h= IMP.core.Harmonic(0,1)
47
#s= IMP.core.DistanceToSingletonScore(h, IMP.algebra.Vector3D(0,0,0))
48
#r= IMP.core.SingletonRestraint(s, rb0.get_member(0))
49
#m.add_restraint(r)
50
cr=
IMP.atom.create_distance_restraint
(
IMP.atom.Selection
(h0),
IMP.atom.Selection
(h1), 0, 1)
51
m.add_restraint(cr)
52
53
bd=
IMP.atom.BrownianDynamics
(m)
54
bd.set_time_step(10000)
55
56
nm=
IMP.base.create_temporary_file_name
(
"rigid_bd"
,
".pym"
)
57
nm=
"rigid.pym"
58
w=
IMP.display.PymolWriter
(nm)
59
for
i
in
range(0,100):
60
display(i, w, [h0, h1])
61
bd.optimize(10)