Skip to main content

A python binding of C++ package for stochastic simulations of spatially extended systems

Project description

StoSpa2

Build Status Documentation Status


A C++ software package for stochastic simulations of spatially extended systems. Code-base has been completely refactored since the previous version of StoSpa. Python bindings have also been included.

Requirements

Necessary:

  • C++ compiler (GCC, clang)
  • Cmake (>= 3.5)
  • Make (or ninja)

Optional:

  • Pybind11 - to build pystospa (python binding of StoSpa2)
  • Python (>=3.5)
  • Boost - if boost branch of StoSpa2 is used
  • Doxygen - to build C++ documentation
  • Sphinx - to build python documentation

Installation

After cloning this repository using

git clone https://github.com/BartoszBartmanski/StoSpa2.git --recursive

compile the package with

cd StoSpa2
mkdir build
cmake ../
make all

Example

Included in the src directory is a cpp file example.cpp where we run a simple simulation of diffusion on a one-dimensional domain [0, 10] discretised into 10 voxels.

First, we include the main header from StoSpa2 and we start the main function that will contain the code for the simulation.

#include "simulator.hpp"

using namespace StoSpa2;

int main() {

Within the main function we first define a lambda function for the propensity function of a diffusion reaction.

auto diffusion = [](const std::vector<unsigned>& mols, const double& area) { return mols[0]; };

Then, we create an array of voxels, each of size 1, with 10000 molecules in the leftmost one, as shown below.

std::vector<Voxel> vs = std::vector<Voxel>(9, Voxel({0}, 1.0));
vs.insert(vs.begin(), Voxel({10000}, 1.0));

We add diffusion reactions to all the voxels

for (unsigned i=0; i<vs.size()-1; i++) {
    vs[i].add_reaction(Reaction(1.0, diffusion, {-1}, i+1));
    vs[i+1].add_reaction(Reaction(1.0, diffusion, {-1}, i));
}

and finally, we create a simulator instance and run the simulation.

Simulator sim(vs);
sim.run("example.dat", 0.01, 1000);
}

The resulting simulation output:

Simulation output

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pystospa-2.0.17-cp38-cp38-manylinux2010_x86_64.whl (116.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pystospa-2.0.17-cp37-cp37m-manylinux2010_x86_64.whl (117.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

pystospa-2.0.17-cp36-cp36m-manylinux2010_x86_64.whl (117.3 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

pystospa-2.0.17-cp35-cp35m-manylinux2010_x86_64.whl (117.3 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

pystospa-2.0.17-cp34-cp34m-manylinux2010_x86_64.whl (117.3 kB view hashes)

Uploaded CPython 3.4m manylinux: glibc 2.12+ x86-64

pystospa-2.0.17-cp27-cp27mu-manylinux2010_x86_64.whl (117.9 kB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

pystospa-2.0.17-cp27-cp27m-manylinux2010_x86_64.whl (117.9 kB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page