ReaDDy - A particle-based
reaction-diffusion simulator

Simple example

In [2]:
import readdy
print(readdy.__version__)
v1.0.1-0

Step 1: Set up a reaction diffusion system

In [3]:
system = readdy.ReactionDiffusionSystem([25.,25.,25.], temperature=300.*readdy.units.kelvin)
system.add_species("A", 1.0)

Define reactions

In [4]:
system.reactions.add("myfusion: A +(2) A -> A", rate=10.)
system.reactions.add("myfission: A -> A +(2) A", rate=3.)

Define potentials

In [5]:
system.potentials.add_harmonic_repulsion("A", "A", force_constant=10., 
                                         interaction_distance=2.)

Step 2: Create a corresponding simulation

In [6]:
simulation = system.simulation(kernel="CPU")

simulation.output_file = "out.h5"
simulation.reaction_handler = "UncontrolledApproximation"

simulation.add_particle("A", [0.,0.,0.])

simulation.record_trajectory(stride=1)
simulation.observe.number_of_particles(stride=100, callback=lambda n: print("#A:", n))

Step 3: Run the simulation

In [7]:
simulation.run(n_steps=3000, timestep=1e-2)
Configured kernel context with:
--------------------------------
 - kBT = 2.49434
 - periodic b.c. = (true, true, true)
 - box size = (25, 25, 25)
 - particle types:
     *  particle type "A" with D=1
 - potentials of order 2:
     * for types "A" and "A"
         * Harmonic repulsion with force constant k=10
 - unimolecular reactions:
     * Fission A -> A + A with a rate of 3, a product distance of 2, and weights 0.5 and 0.5
 - bimolecular reactions:
     * Fusion A + A -> A with a rate of 10, an educt distance of 2, and weights 0.5 and 0.5

#A: [1]
#A: [2]
#A: [2]
#A: [3]
#A: [5]
#A: [8]
#A: [15]
#A: [23]
#A: [43]
#A: [60]
#A: [87]
#A: [133]
#A: [184]
#A: [219]
#A: [254]
#A: [264]
#A: [303]
#A: [303]
#A: [318]
#A: [326]
#A: [331]
#A: [325]
#A: [296]
#A: [307]
#A: [325]
#A: [340]
#A: [345]
#A: [339]
#A: [318]
#A: [336]
#A: [318]

Step 4: Look at results

In [8]:
trajectory = readdy.Trajectory('out.h5')
trajectory.convert_to_xyz(particle_radii={'A': 1.})

Visualize in VMD

In [ ]:
!vmd -e out.xyz.tcl
© Copyright 2018 CMB group