IMP  2.1.0
The Integrative Modeling Platform
BallMover.py
1 import IMP
2 import IMP.symmetry
3 import IMP.core
4 
5 
6 # parameters
7 S_ = 20. # cubic cell size
8 K_ = 1.0 # intensity harmonic restraint
9 KBT_ = 1.0 # temperature
10 
11 # create model
12 m = IMP.kernel.Model()
13 
14 # add 2 particles
15 ps = []
16 for i in range(2):
17  p = IMP.kernel.Particle(m)
20  d.set_coordinates_are_optimized(True)
21  ps.append(p)
22 
23 # add harmonic restraint to distance
24 h = IMP.core.Harmonic(0.0, K_)
26 pr = IMP.core.PairRestraint(sps, IMP.kernel.ParticlePair(ps[0], ps[1]))
27 m.add_restraint(pr)
28 
29 # define cell centers
30 ctrs = []
31 for i in [0.0, -1.0, +1.0]:
32  for j in [0.0, -1.0, +1.0]:
33  for k in [0.0, -1.0, +1.0]:
34  ctrs.append(IMP.algebra.Vector3D(
35  float(i) * S_, float(j) * S_, float(k) * S_))
36 
37 # define transformation from primitive to all cells
38 trs = []
39 for ctr in ctrs:
40  trs.append(IMP.algebra.Transformation3D(ctr))
41 
42 # movers
43 movers = []
44 # symmetry mover with ps[0] being the master particle
45 movers.append(IMP.symmetry.BallMover(ps[0], [ps[1]], 1.0, ctrs, trs))
46 # normal BallMover for the other particle
47 movers.append(IMP.core.BallMover([ps[1]], 1.0))
48 # serial mover
49 sm = IMP.core.SerialMover(movers)
50 
51 # sampler
52 mc = IMP.core.MonteCarlo(m)
53 mc.set_kt(KBT_)
54 mc.set_return_best(False)
55 mc.add_mover(sm)
56 
57 # prepare output
58 log = open("traj.xyz", "w")
59 
60 # start sampling loop
61 for istep in range(0, 5000):
62  # do optimization
63  mc.optimize(10)
64 
65  # coordinates
66  xyz0 = IMP.core.XYZR(ps[0]).get_coordinates()
67  xyz1 = IMP.core.XYZR(ps[1]).get_coordinates()
68 
69  # print
70  log.write("\n2\n")
71  log.write("Na %6.3f %6.3f %6.3f\n" % (xyz0[0], xyz0[1], xyz0[2]))
72  log.write("Cl %6.3f %6.3f %6.3f\n" % (xyz1[0], xyz1[1], xyz1[2]))
A Monte Carlo optimizer.
Definition: MonteCarlo.h:47
Simple 3D transformation class.
See IMP.symmetry for more information.
Move a particle and keep it in the primitive cell of a periodic lattice.
A score on the distance between the surfaces of two spheres.
Modify a set of continuous variables by perturbing them within a ball.
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZR.h:48
Class to handle individual model particles.
See IMP.core for more information.
Applies a PairScore to a Pair.
Definition: PairRestraint.h:30
Apply a list of movers one at a time.
Definition: SerialMover.h:23
Class for storing model, its restraints, constraints, and particles.
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:25
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27