home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.20.1
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
version 2.20.1
core/excluded_volume.py
Setup an excluded volume restraint between a bunch of particles with radius.
1
## \example core/excluded_volume.py
2
# Setup an excluded volume restraint between a bunch of particles with radius.
3
#
4
5
import
IMP.container
6
import
sys
7
8
IMP.setup_from_argv
(sys.argv,
"excluded volume"
)
9
10
# Make 100 particles randomly distributed in a cubic box
11
m =
IMP.Model
()
12
lsc =
IMP.container.ListSingletonContainer
(m)
13
b =
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0,0,0),
14
IMP.algebra.Vector3D
(10,10,10))
15
for
i
in
range(100):
16
p = m.add_particle(
"p"
)
17
lsc.add(p)
18
d =
IMP.core.XYZR.setup_particle
(m, p,
19
IMP.algebra.Sphere3D
(
IMP.algebra.get_random_vector_in
(b), 1))
20
21
# this container lists all pairs that are close at the time of evaluation
22
nbl =
IMP.container.ClosePairContainer
(lsc, 0, 2)
23
h =
IMP.core.HarmonicLowerBound
(0, 1)
24
sd =
IMP.core.SphereDistancePairScore
(h)
25
# use the lower bound on the inter-sphere distance to push the spheres apart
26
nbr =
IMP.container.PairsRestraint
(sd, nbl)
27
28
# alternatively, one could just do
29
r =
IMP.core.ExcludedVolumeRestraint
(lsc)
30
31
# get the current score
32
sf =
IMP.core.RestraintsScoringFunction
([nbr, r])
33
print(sf.evaluate(
False
))