IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
5import IMP.atom
6import IMP.rmf
7import RMF
8import IMP.container
9import IMP.display
10import sys
11
12IMP.setup_from_argv(sys.argv, "simulation")
13
14k = 10.0
15np = 10
16frames = 10
17
18m = IMP.Model()
20 IMP.algebra.Vector3D(10, 10, 10))
21
23 for i in range(0, np)]
25for p in ps:
26 p.set_radius(1)
27 p.set_coordinates_are_optimized(True)
30 p.set_coordinates(IMP.algebra.get_random_vector_in(bb))
31rs = []
33pl = []
34for i in range(0, len(ps) // 2):
35 pp = (ps[2 * i], ps[2 * i + 1])
36 pl.append(pp)
37 # create OK staring position
38 pp[1].set_coordinates(IMP.algebra.get_random_vector_on(pp[0].get_sphere()))
42 IMP.Particle(m, "molecule " + str(i)))
43 hr.add_child(IMP.atom.Hierarchy.setup_particle(pp[0]))
44 hr.add_child(IMP.atom.Hierarchy.setup_particle(pp[1]))
45 h.add_child(hr)
46r = IMP.container.PairsRestraint(link, pl, "Bonds")
47rs.append(r)
48
49ev = IMP.core.ExcludedVolumeRestraint(ps, k, 1, "EV")
50rs.append(ev)
51
55rs.append(bbr)
56
58
60bd.set_log_level(IMP.SILENT)
61bd.set_scoring_function(sf)
62
63bd.set_maximum_time_step(10)
64
65rmf = RMF.create_rmf_file("brownian.rmf")
66rmf.set_description("Brownian dynamics trajectory with 10fs timestep.\n")
70
72os.update_always("initial conformation")
73os.set_log_level(IMP.SILENT)
74os.set_simulator(bd)
75bd.add_optimizer_state(os)
76
77bd.optimize(frames)
78
79print("file is", rmf.get_name())
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Simple Brownian dynamics simulator.
static Diffusion setup_particle(Model *m, ParticleIndex pi, Float D)
Setup the particle with the specified diffusion coefficient.
Definition Diffusion.h:76
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
static Mass setup_particle(Model *m, ParticleIndex pi, Float mass)
Definition Mass.h:48
Applies a PairScore to each Pair in a list.
Applies a SingletonScore to each Singleton in a list.
Prevent a set of particles and rigid bodies from inter-penetrating.
A harmonic upper bound on the distance between two spheres.
Upper bound harmonic function (non-zero when feature > mean).
Create a scoring function on a list of restraints.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition XYZR.h:48
static Colored setup_particle(Model *m, ParticleIndex pi, Color color)
Definition Colored.h:62
Periodically dump the state of all associated objects into the RMF file.
VectorD< 3 > Vector3D
Definition VectorD.h:407
VectorD< D > get_random_vector_on(const BoundingBoxD< D > &bb)
Generate a random vector on a box with uniform density.
VectorD< D > get_random_vector_in(const BoundingBoxD< D > &bb)
Generate a random vector in a box with uniform density.
Functionality for loading, creating, manipulating and scoring atomic structures.
Various classes to hold sets of particles.
Output IMP model data in various file formats.
Color get_display_color(unsigned int i)
Support for the RMF file format for storing hierarchical molecular data and markup.
void add_restraints(RMF::FileHandle fh, const Restraints &hs)
void add_geometry(RMF::FileHandle file, display::Geometry *r)
Add a single geometry to the file.
void add_hierarchy(RMF::FileHandle fh, atom::Hierarchy hs)
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.