IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/26
The Integrative Modeling Platform
atom/Diffusion_decorator.py

This is a simple example using the Diffusion decorator to set the coordinates and translational diffusion coefficient of some particles

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 
5 import IMP
6 import IMP.core
7 import IMP.atom
8 import IMP.algebra
9 import sys
10 
11 C0=[0,1,2] # in A
12 C1=[1,2,3] # in A
13 D1 = 3.0 # in A^2/fs
14 R0=5 # in A
15 IMP.setup_from_argv(sys.argv, "Diffusion decorator example")
16 m = 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
20 p0 = m.add_particle("diffusion0")
21 xyzr0 = IMP.core.XYZR.setup_particle(m, p0,
22  IMP.algebra.Sphere3D(C0, R0))
24 print("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:
28 d0.set_diffusion_coefficient(d0.get_diffusion_coefficient()/2.0)
29 print("D reset to {:.2e} A^2/fs".format(d0.get_diffusion_coefficient()))
30 
31 # Setup a diffusion particle with an explicitly-set diffusion coefficient
32 p1 = m.add_particle("diffusion1")
33 d1 = IMP.atom.Diffusion.setup_particle(m, p1, C1, D1)
34 print("D explicitly set to {:.2e} A^2/fs for coordinates {} A"
35  .format(d1.get_diffusion_coefficient(), d1.get_coordinates()))