Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 113 lines (89 sloc) 6.966 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>eGFRD documentation</title>
  <link rel="stylesheet" href="/css/reset.css" type="text/css"/>
  <link rel="stylesheet" href="/css/style.css" type="text/css"/>
  <link rel="stylesheet" href="/css/syntax.css" type="text/css"/>
  <link rel="stylesheet" href="/css/menu.css" type="text/css"/>
  <link rel="stylesheet" href="/css/footer.css" type="text/css"/>

  <script src="/html5media/html5media.min.js"></script>

  <!--[if lt IE 9]>
<script src="/ie7/IE9.js"></script>
<![endif]-->
</head>
<body>

<div class="documentation">
<div id="globalheader">
  <!--googleoff: all-->
  <ul id="globalnav">
    <li id="gn-home"><a href="/">Home</a></li>
    <li id="gn-algorithm"><a href="/algorithm">Algorithm</a></li>
    <li id="gn-background"><a href="/background">Background</a></li>
    <li id="gn-downloads"><a href="/downloads">Downloads</a></li>
    <li id="gn-documentation"><a href="/documentation">Documentation</a></li>
    <li id="gn-support"><a href="/support">Support</a></li>
    <li class="gn-empty"><a></a></li>
  </ul>
  <!--googleon: all-->
  <div id="lastbutton"> </div>
</div>
</div>

<h1>Documentation</h1>
<div id="container">
<p><em>More documentation coming soon.</em></p>

<h2>Overview</h2>

<ul>
<li>Installation. See the
<a href="http://github.com/gfrd/egfrd/tree/develop/INSTALL">INSTALL</a> file.</li>
<li><a href="/simulation">Running a simulation</a></li>
<li><a href="/visualization">Visualization</a></li>
</ul>


<h2>Getting started is easy</h2>

<div class="highlight"><pre><code class="python">
<span class="c"># eGFRD sample script</span>
<span class="c"># This shows how to implement a simple reaction A+B -> C</span>
<span class="c"># in a cubic world with periodic boundary conditions.</span>
<span class="c"># Lengths are measured in [m], times in [s], i.e. rates in [1/s].</span>
<span class="kn">from</span> <span class="nn">egfrd</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">gfrdbase</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">import</span> <span class="kn">model</span>

<span class="c"># Define a reactions model with chemical species and reaction rules</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">model.ParticleModel</span><span class="p">(</span><span class="n">world_size</span><span class="o">=</span><span class="mi">1e-6</span><span class="p">)</span>

<span class="n">A</span> <span class="o">=</span> <span class="n">model.Species</span><span class="p">(</span><span class="s">&#39;A&#39;</span><span class="p">,</span> <span class="n">D</span><span class="o">=</span><span class="mi">1e-12</span><span class="p">,</span> <span class="n">radius</span><span class="o">=</span><span class="mi">2.5e-8</span><span class="p">)</span>
<span class="n">B</span> <span class="o">=</span> <span class="n">model.Species</span><span class="p">(</span><span class="s">&#39;B&#39;</span><span class="p">,</span> <span class="n">D</span><span class="o">=</span><span class="mi">1e-12</span><span class="p">,</span> <span class="n">radius</span><span class="o">=</span><span class="mi">2.5e-8</span><span class="p">)</span>
<span class="n">C</span> <span class="o">=</span> <span class="n">model.Species</span><span class="p">(</span><span class="s">&#39;C&#39;</span><span class="p">,</span> <span class="n">D</span><span class="o">=</span><span class="mi">1e-12</span><span class="p">,</span> <span class="n">radius</span><span class="o">=</span><span class="mi">5.0e-8</span><span class="p">)</span>

<span class="n">m.add_species_type</span><span class="p">(</span><span class="n">A</span><span class="p"><span class="p">)</span>
<span class="n">m.add_species_type</span><span class="p">(</span><span class="n">B</span><span class="p"><span class="p">)</span>
<span class="n">m.add_species_type</span><span class="p">(</span><span class="n">C</span><span class="p"><span class="p">)</span>

<span class="n">R</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">create_binding_reaction_rule</span><span class="p">(</span><span class="n">A</span><span class="p">,</span> <span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">,</span> <span class="n">k</span><span class="o">=</span><span class="mi">1e-18</span><span class="p">)</span>
<span class="n">m.network_rules.add_reaction_rule</span><span class="p">(</span><span class="n">R</span><span class="p"><span class="p">)</span>

<span class="c"># Create a simulation world and assign the reactions model</span>
<span class="c"># Note: matrix_size defines the number of cells per dimension of the neighborhood matrix</span>
<span class="n">w</span> <span class="o">=</span> <span class="n">create_world</span><span class="p">(</span><span class="n">m</span><span class="p">,</span> <span class="n">matrix_size</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>

<span class="c"># Create an eGFRD simulator and assign a random number generator</span>
<span class="n">myrandom.seed</span><span class="p">(</span><span class="n">123</span><span class="p"><span class="p">)</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">EGFRDSimulator</span><span class="p">(</span><span class="n">world</span><span class="o">=</span><span class="n">w</span><span class="p">,</span> <span class="n">rng</span><span class="o">=</span><span class="n">myrandom.rng</span><span class="p"><span class="p">)</span>

<span class="c"># Set up initial condition</span>
<span class="n">throw_in_particles</span><span class="p">(</span><span class="n">w</span><span class="p">,</span> <span class="n">A</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
<span class="n">throw_in_particles</span><span class="p">(</span><span class="n">w</span><span class="p">,</span> <span class="n">B</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>

<span class="c"># Run!</span>
<span class="k">while</span> <span class="n">s</span><span class="o">.</span><span class="n">t</span> <span class="o">&lt;</span> <span class="mi">100</span><span class="p">:</span>
    <span class="n">s</span><span class="o">.</span><span class="n">step</span><span class="p">()</span>
</code></pre>
</div>


<h2>Learn more</h2>

<p>More documentation, including Green&rsquo;s functions and pseudocode for the
algorithm can be found in the <a href="http://github.com/gfrd/egfrd/tree/develop/doc" title="">doc</a> directory of
the code.</p>

</div>

<div id="globalfooter">
  <p>Copyright &copy; 2012 FOM institute AMOLF</p>
  <ul class="piped">
    <li><a href="/about">About</a></li>
    <li><a href="/credits">Credits</a></li>
  </ul>
</div>

</body>
</html>
Something went wrong with that request. Please try again.