# Spatial Stochastic Simulations

%CODE1%
← Back
Example: Annihilation of two species in a cylinder
The spatial stochastic simulation capabilities in StochSS are based on
PyURDME [8]. PyURDME is a general software framework for modeling and simulation of stochastic reaction-diffusion processes on unstructured, tetrahedral (3D) and triangular (2D) meshes. The current core simulation algorithm is based on the mesoscopic reaction-diffusion master equation (RDME) model. The default solver is an efficient implementation of the next subvolume method (NSM) [7].

#### Example: Annihilation of two species in a cylinder

We will build a simple annihilation model based on an cylinder geometry. At each end of the cylinder, different chemicals will be produced. When they diffuse and meet at the center, they will annihilate each other.

1. Navigate to the main Model editor.
2. Add a new model. Select Population, spatial in the dropdown menu.
3. Click Mesh and select Cylinder. The cylindrical mesh is divided into three subdomains which can be visualized with the controls below the wireframe view.
4. Add two species, $A$ and $B$, both with diffusion constant 1.
5. Click Initial Condition, select scatter, and add 500 molecules of species $A$ in subdomain 1 and 500 molecules of species $B$ in subdomain 3.
6. Add two parameters, $k0$ and $k1$, and set their values to 1 and 100, respectively.
\begin{align*}
8. Reaction $R1$ should be restricted to subdomain 1 and reaction $R2$ to subdomain 3. Reaction $R3$ should be allowed throughout the whole domain.