A python binding of C++ package for stochastic simulations of spatially extended systems
Project description
StoSpa2
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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pystospa-2.0.17-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 093dd6e06ade04ecd78cc61f14f15975f6628ff036ddcda2ecc56f9df4c9958c |
|
MD5 | ec602520d6acfaf83d97f0ca6ce18d0e |
|
BLAKE2b-256 | 07dc06dcad0676a57b9f9ee5276cb7bbd0fc0275f71d9de19a5e694ca9535913 |
Hashes for pystospa-2.0.17-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d31ed522077ae765afd747ad76cef008b98ed307495a1e821aa4a5fb1ab4b8bf |
|
MD5 | 0a65b51dd1d53ccfeaa7c448717cb27b |
|
BLAKE2b-256 | 41feb3a5902317800be723a651e2c43ac9d60a051990a049f9a0969787228c64 |
Hashes for pystospa-2.0.17-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c55145877cd401577cbedd24652442f4f2f6ca81686090d20214e03b19cf634f |
|
MD5 | 8e92d19bbfc8e54a782309103ff3339e |
|
BLAKE2b-256 | d07224a3b1d463014e655a21bb6e05e95733972d5ff69b34c20622269fbbb16e |
Hashes for pystospa-2.0.17-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b04371f103abe81c51c3ba7f13df7a06324be468d0dae8addf682a47cc6d7ad |
|
MD5 | c2d8e37c71a3088c07c1f83404dc2347 |
|
BLAKE2b-256 | 1119e6df5372bf6239d80a62fc906a1f7bd00fef1945d112ba68e81ed94f6ba6 |
Hashes for pystospa-2.0.17-cp34-cp34m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bda2c0e4856a5549f24801d9c761f11c84ed07c2b23dbee8dc1ff215a9be9f52 |
|
MD5 | 5d441900d3aa3a60803d5b1f528d366d |
|
BLAKE2b-256 | 15bd428b64d66fb43b33474e1c8411ced96d9f1f80bad0a1911fe6f09f185aa9 |
Hashes for pystospa-2.0.17-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7fd11ee0eab1df6869d782f841d5f96d0c2ae826b2a34f9f823af3bdaef6548 |
|
MD5 | 56cb9d086191a1df4d43c5ef4d57ff56 |
|
BLAKE2b-256 | c1de6014596f571c117819ddc0492b82ff2b698e944f7a4ef1f7191320fdcffb |
Hashes for pystospa-2.0.17-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffc5a006d3e440b7b5f62379834898fc91f29c733a4a89d42623899f6f71d39e |
|
MD5 | 6c767b4e2280d2516f63d40054a6b331 |
|
BLAKE2b-256 | c02d1d23b61fee52c79a10aa8960910192c7c4f986d0e7afc82a32e404e85d7c |