IMP  2.1.0
The Integrative Modeling Platform
simulation.py
1 ## \example rmf/simulation.py
2 # This example shows writing a brownian dynamics simulation to a rmf file.
3 # It includes a bounding box, restraints and a hierarchy of particles.
4 
5 import IMP.atom
6 import IMP.rmf
7 import RMF
8 import IMP.container
9 import IMP.display
10 
11 k = 10.0
12 np = 10
13 frames = 10
14 
15 m = IMP.kernel.Model()
17  IMP.algebra.Vector3D(10, 10, 10))
18 
20  for i in range(0, np)]
22 for p in ps:
23  p.set_radius(1)
24  p.set_coordinates_are_optimized(True)
27  p.set_coordinates(IMP.algebra.get_random_vector_in(bb))
28 rs = []
30 pl = []
31 for i in range(0, len(ps) / 2):
32  pp = (ps[2 * i], ps[2 * i + 1])
33  pl.append(pp)
34  # create OK staring position
35  pp[1].set_coordinates(IMP.algebra.get_random_vector_on(pp[0].get_sphere()))
39  IMP.kernel.Particle(m, "molecule " + str(i)))
40  hr.add_child(IMP.atom.Hierarchy.setup_particle(pp[0]))
41  hr.add_child(IMP.atom.Hierarchy.setup_particle(pp[1]))
42  h.add_child(hr)
43 r = IMP.container.PairsRestraint(link, pl, "Bonds")
44 rs.append(r)
45 
46 ev = IMP.core.ExcludedVolumeRestraint(ps, k, 1, "EV")
47 rs.append(ev)
48 
52 rs.append(bbr)
53 
55 
57 bd.set_log_level(IMP.base.SILENT)
58 bd.set_scoring_function(sf)
59 
60 bd.set_maximum_time_step(10)
61 
62 name = IMP.base.create_temporary_file_name("brownian", ".rmf")
63 rmf = RMF.create_rmf_file(name)
64 rmf.set_description("Brownian dyanmics trajectory with 10fs timestep.\n")
67 IMP.rmf.add_geometry(rmf, IMP.display.BoundingBoxGeometry(bb))
68 
70 os.update_always("initial conformation")
71 os.set_log_level(IMP.base.SILENT)
72 os.set_simulator(bd)
73 bd.add_optimizer_state(os)
74 
75 bd.optimize(frames)
76 
77 print "file is", rmf.get_name()
Applies a SingletonScore to each Singleton in a list.
A harmonic upper bound on the distance between two spheres.
void add_restraints(RMF::NodeHandle fh, const kernel::Restraints &hs)
See IMP.container for more information.
Upper bound harmonic function (non-zero when feature > mean)
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Score particles based on how far outside a box they are.
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZR.h:48
void add_hierarchy(RMF::FileHandle fh, atom::Hierarchy hs)
Simple Brownian dynamics optimizer.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
static Colored setup_particle(kernel::Model *m, ParticleIndex pi, Color color)
Definition: Colored.h:62
Color get_display_color(unsigned int i)
Class to handle individual model particles.
static Mass setup_particle(kernel::Model *m, ParticleIndex pi, Float mass)
Definition: Mass.h:45
Prevent a set of particles and rigid bodies from inter-penetrating.
static Diffusion setup_particle(kernel::Model *m, ParticleIndex pi, Float D)
Definition: Diffusion.h:47
VectorD< D > get_random_vector_on(const SphereD< D > &s)
Generate a random vector on a sphere with uniform density.
See IMP.display for more information.
Definition: BildWriter.h:20
See IMP.atom for more information.
See IMP.rmf for more information.
Definition: associations.h:20
Applies a PairScore to each Pair in a list.
Class for storing model, its restraints, constraints, and particles.