IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
Diffusion_decorator.py
1## \example atom/Diffusion_decorator.py
2# This is a simple example using the Diffusion decorator to set the coordinates
3# and translational diffusion coefficient of some particles
4
5import IMP
6import IMP.core
7import IMP.atom
8import IMP.algebra
9import sys
10
11C0=[0,1,2] # in A
12C1=[1,2,3] # in A
13D1 = 3.0 # in A^2/fs
14R0=5 # in A
15IMP.setup_from_argv(sys.argv, "Diffusion decorator example")
16m = IMP.Model()
17
18# Setup a diffusion particle with an implicitly-set diffusion coefficient
19# using the Stokes-Einstein equation, treating radius as the Stokes radius
20p0 = m.add_particle("diffusion0")
24print("D automatically set to {:.2e} A^2/fs for radius {:.1f} A"
25 .format(d0.get_diffusion_coefficient(), xyzr0.get_radius()))
26
27# Explicitly change the diffusion coefficient:
28d0.set_diffusion_coefficient(d0.get_diffusion_coefficient()/2.0)
29print("D reset to {:.2e} A^2/fs".format(d0.get_diffusion_coefficient()))
30
31# Setup a diffusion particle with an explicitly-set diffusion coefficient
32p1 = m.add_particle("diffusion1")
33d1 = IMP.atom.Diffusion.setup_particle(m, p1, C1, D1)
34print("D explicitly set to {:.2e} A^2/fs for coordinates {} A"
35 .format(d1.get_diffusion_coefficient(), d1.get_coordinates()))
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
static Diffusion setup_particle(Model *m, ParticleIndex pi, Float D)
Setup the particle with the specified diffusion coefficient.
Definition Diffusion.h:76
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition XYZR.h:48
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Functionality for loading, creating, manipulating and scoring atomic structures.
Basic functionality that is expected to be used by a wide variety of IMP users.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.