Sample simulation

Following code shows sample CeCe simulation with brief explanation of some used features.

You can download the simulation here and the required SVG here.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!--
  Sample simulation definition.

  world-size: physical size of the simulation world.
  dt: physical time step.
  iterations [0]: Total number of simulation iterations. Value 0 or value omitting means unlimited iterations.
  visualized [true]: If simulation is visualized.
  background [white]: Background color. Can be in CSS form: #FFFFFF.
  length-coefficient: Physical engine scale coefficient.
-->
<simulation world-size="600um 300um" dt="500ms" iterations="10000" visualized="true" background="black" length-coefficient="1e-1">

<!------------------------------------------------------------------------------------------------>


    <!-- Parameters -->

    <!-- Define parameter detection concentration (Yeast cells) -->
    <parameter name="DC" value="10nM" />

    <!-- Define parameter prodution rate (Main cell signal) -->
    <parameter name="PR" value="150/s" />

    <!-- Define parameter detection Yeast concentration (inlet) -->
    <parameter name="YC" value="2000/nl" />

    <!-- / Parameters -->


<!------------------------------------------------------------------------------------------------>


    <!-- / Visualization -->

    <visualization enabled="true">

        <!-- Define layer with name 'velocity' and show/hide key. -->
        <layer name="velocity" key="V" />

        <!-- Define layer with name 'density' and show/hide key. -->
        <layer name="density" key="B" />

        <!-- Define layer with name 'fluid' and show/hide key. -->
        <layer name="fluid" key="N" />

        <!-- Define layer with name 'physics' and show/hide key. -->
        <layer name="physics" key="D" />

        <!-- Define layer with name 'objects' and show/hide key -->
        <layer name="objects" key="G" enabled="true" />

    </visualization>

    <!-- / Visualization -->


<!------------------------------------------------------------------------------------------------>


    <!-- Imported plugins -->

    <!--
      Importing a specific plugin allows to simulation use plugin specific
      features (object types, modules, ...).

      Call to get a list of available plugins.
      $ ./bin/cece-cli --plugins
    -->

    <!--
      Allow to use 'cell.Yeast' and 'cell.Cell' object classes
    -->
    <plugin name="cell" />

    <!--
      Allow to use 'python' programs.
    -->
    <plugin name="python" />

    <!--
      Allow to use 'cell' plugin objects in 'python' programs.
    -->
    <plugin name="cell-python" />

    <!--
      Allow to use 'stochastic-reactions' programs.
    -->
    <plugin name="stochastic-reactions" />

    <!--
      Allow to use 'diffusion' module.
    -->
    <plugin name="diffusion-streamlines" />

    <!--
      Import topology from SVG file.

      filename: Path to SVG file. Must be relative to the simulation file.
      color: Created obstacles color.
    -->
    <plugin name="obstacles-svg" filename="sample.svg" color="white" />

    <!--
      Allow to use 'streamlines' module.
    -->
    <plugin name="streamlines" />

    <!--
      Allow to use 'agglutination' module.
    -->
    <plugin name="agglutination" />

    <!--
      Allow to use 'object-generator' module which can communicate with streamlines module
      about inlets and outlets
    -->
    <plugin name="object-streamlines-generator" />

    <!-- / Imported plugins -->


<!------------------------------------------------------------------------------------------------>


    <!-- Object types definitions -->

    <!--
      Allow to define custom object types. Types are based on real type from a plugin where
      only 'name' and 'type' is required. Other configuration is copyied as is defined in
      <object> element.
    -->

    <!--
      Define object class with name 'Yeast1' which is based on 'cell.Yeast' class.
    -->
    <type name="Yeast1" type="cell.Yeast" programs="detectProtein3">
        <!-- Object with this class will have 1000 RFP molecules when is created -->
        <molecule name="RFP" amount="1000" />
        <!-- Object with this class will have 1000 TAG_1 molecules when is created -->
        <molecule name="TAG_1" amount="1000" />
    </type>

    <!-- / Object types definitions -->


<!------------------------------------------------------------------------------------------------>


    <!-- Modules definitions -->

    <!--
      Modules are parts of the simulation which affects the whole simulation. They're updated once an iteration.

      In order to use some specific module a plugin with required module must be imported.
    -->

    <!--
      Create a diffusion module. The module allows you to simulate intercellular communication between cells. All
      supported signals must be defined here.

      plugins: 'diffusion'

      name: 'diffusion'
      grid: Size of diffusion grid. The size of one node is dependent on simulation world-size parameter
            (world-size.x / grid.x, world-size.y / grid.y). Bigger number gives more precise results but
            slows down the simulation.
      inner-iterations [1]: Number of iterations used to precompute diffusion movement in streamlines. When the flow is too high
                            the result might not be precise (there might be artefacts).
    -->
    <module name="diffusion" grid="400 200" inner-iterations="2">
      <!--
        Signal definition. Only signals defined here can be used in simulation. Using other signal names causes an error.

        name: Signal name. In most cases it should match molecule name.
        diffusion-rate: How fast the signal diffuse.
        degradation-rate [0]: How fast the signal degrade.
        color [random]: The signal color in the simulation.
        saturation [1umol/um3]: How much concentration is required to obtain full color in visualization.
      -->
      <signal name="Protein2" diffusion-rate="50um2/s" degradation-rate="0.01/s" color="blue" saturation="13nM" />
      <signal name="Protein3" diffusion-rate="30um2/s" degradation-rate="0.001/s" color="red" saturation="10nM" />
      <!-- More signals... -->
    </module>


    <!--
      Streamlines plugin definition. Adds LB streamlines in the simulation.

      name: 'streamlines'
      init-iterations [0]: Number of initialization iterations. By default the streamlines are initialized to
                           zero velocity and is expected to have already initialized streamlines at the start
                           of the simulation.
      init-file []: Path to precomputed streamlines. Initializing streamlines can be slow. If file doesn't exists or
                    some parameters doesn't match the streamlines are precomputed and saved to the file. The %temp%
                    value is a placement for system user's temporary directory (C:/Users/User/Temp/sample.streamlines.cece).
                    The path itself is relative to the simulation file (e.g. "sample.streamlines.cece" will create file in
                    the same directory).
      char-length [1um]: Characteristic length. Every calculation is relative to characteristic length so world size
                         doesn't affect other parameters.
      number-nodes [1]: Number of LB nodes per characteristic length.
      tau: LB relaxation parameter. Must be bigger than 0.5.
      dynamic [true]: If streamlines are updated during simulation. Enabling this can rapidly slows down the simulation.
      layer-magnitude []: Name of visualization layer which shows the velocity magnitude.
      layer-density []: Name of visualization layer which shows the presure/density.
      layer-dynamics []: Name of visualization layer which shows the node dynamics (fluid, obstacle, inlet, outlet).
    -->
    <module name="streamlines"
            init-iterations="2000"
            init-file="%temp%/sample.streamlines.cece"
            char-length="10um"
            number-nodes="10"
            tau="1.3"
            dynamic="false"
            layer-magnitude="velocity"
            layer-density="density"
            layer-dynamics="fluid"
    >
        <boundary name="i1" type="inlet" position="top" inlet-flow-rate="0.00005nl/s" inlet-profile="constant" />
        <boundary name="i2" type="inlet" position="bottom" inlet-flow-rate="0.00005nl/s" inlet-profile="constant" />

        <boundary name="o" type="outlet" position="right" />
    </module>

    <!--
      Define object generator module. The module generate objects based on some rate.
      In this case the special version of object generator is used. This version can communicate with streamlines
      module about inlets and outlets.

      name: 'object-generator'
    -->
    <module name="object-generator">

      <!--
        Define object generator source for 'Yeast1' class objects at streamlines boundary 'i1'.

        class: Class of generated objects.
        concentration: Object concentration in inlet. The rate is calculated from inlet size and inlet velocity.
                       The "{$YC}" snippet will be replaced by simulation parameter named 'YC'.
        boundary: Name of boundary defined in 'streamlines' module. The object will be created at the inlet
                  position so no need to define spawn area here.
        ...: Other configuration will be passed to the created object.
      -->
      <object class="Yeast1" concentration="{$YC}" boundary="i1" />

      <!--
        Define object generator source for 'Yeast2' class objects at streamlines boundary 'i2'.
      -->
      <object class="cell.Yeast" concentration="1000/nl" boundary="i2">
        <!-- The created cell will have 600 GFP molecules -->
        <molecule name="GFP" amount="600" />
      </object>
    </module>

    <!--
      Define agglutination module. Module can create or delete joints between object based on given constants.

      name: 'agglutination'
    -->
    <module name="agglutination" >
      <!--
        Define binding rule.

        association-constant: Association constant - represents probability of bound creation.
        disassociation-constant: Dissociation constant - represents probability of bound deletion.
        ligand: Name of ligand molecule.
        receptor: Name of receptor molecule.
      -->
      <bond association-constant="10000" disassociation-constant="0.001" ligand="TAG_1" receptor="TAG_2" />
    </module>

    <!-- / Modules definitions -->


<!------------------------------------------------------------------------------------------------>


    <!-- Programs definitions -->

    <!--
      Programs are small functions which can be added to simulation objects (like cells) in order to do something.
      Program can be bound to simulation objects and are executed each iteration for each object they are bound to.

      A program can be written in different languages. The support for specific language is provided by a plugin.
    -->

    <!--
      Create a stochastic reactions program.

      plugins: 'stochastic-reactions'

      name: Program name under which will be available.
      language: 'stochastic-reactions'
    -->
    <program name="detectProtein3" language="stochastic-reactions">
      <!-- CDATA is used to say this is not a XML -->
<![CDATA[
        # If Protein3 is detected produce YFP molecules
        if env Protein3 > par DC: { null > 10/s > YFP; GFP > 5/s > null; }
]]>
    </program>

    <!--
      Create a stochastic reactions program which produce Protein3 into environment.

      plugins: 'stochastic-reactions'

      name: Program name under which will be available.
      language: 'stochastic-reactions'
    -->
    <program name="produceProtein3" language="stochastic-reactions">
      <!-- CDATA is used to say this is not a XML -->
<![CDATA[
        # Protein3 production
        null > par PR > env Protein3;
]]>
    </program>

    <!-- / Programs definitions -->


<!------------------------------------------------------------------------------------------------>


    <!-- Objects definitions -->

    <!--
      Definition of initial simulation objects like cells or obstacles. The plugins are required in order to use
      some object classes. The additional configuration is dependent on used object class. Configuration which
      the object class doesn't support is ignored.
    -->

    <!--
      Define a common cell.

      class: 'cell.Cell'.
      position [0 0]: Initial position in the simulation world. [0 0] is in the middle of the world.
      programs []: space separated list of object programs.
      volume: Cell volume. It's used for object size.
      type [dynamic]: Physical behaviour of the object.
    -->
    <object class="cell.Cell" position="60um 0um" programs="produceProtein3" volume="500um3" type="pinned">
        <molecule name="TAG_2" amount="500" />
    </object>

    <!-- / Objects definitions -->


<!------------------------------------------------------------------------------------------------>

</simulation>