Skip to main content

Python package for stochastic simulations

Project description

pyssa : Python package for stochastic simulations

Build Status Build Status codecov Updates Documentation Status pypi License Code style: black

Introduction

pyssa is a Python package for stochastic simulations. It offers a simple API to define models, perform stochastic simulations with them and visualize the results in a convenient manner.

Currently under active development in the develop branch.

Install

Install with pip:

$ pip install pyssa

Documentation

Usage

A short summary follows, but a more detailed tutorial can be found at https://pyssa.readthedocs.io/en/latest/tutorial.html

from pyssa.simulation import Simulation
V_r = np.array([[1, 0], [0, 1], [0, 0]])  # Reactant matrix
V_p = np.array([[0, 0], [1, 0], [0, 1]])  # Product matrix
X0 = np.array([100, 0, 0])  # Initial state
k = np.array([1.0, 1.0])  # Rate constants
sim = Simulation(V_r, V_p, X0, k)  # Declare the simulation object
# Run the simulation
sim.simulate(max_t=150, max_iter=1000, chem_flag=True, n_rep=10)

Change simulation algorithm

You can change the algorithm used to perform the simulation by changing the algorithm parameter

sim.simulate(max_t=150, max_iter=1000, chem_flag=True, n_rep=10, algorithm="tau_adaptive")

Run simulations in parallel

You can run the simulations on multiple cores by specifying the n_procs parameter

sim.simulate(max_t=150, max_iter=1000, chem_flag=True, n_rep=10, n_procs=4)

Plot simulation results

sim.plot()

Plot of species A, B and C

Accessing simulation results

results = sim.results

You can also access the final states of all the simulation runs by

final_times, final_states = results.final

License

Copyright (c) 2018-2020, Dileep Kishore, Srikiran Chandrasekaran. Released under: Apache Software License 2.0

Credits

Project details


Download files

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

Source Distribution

pyssa-0.9.0.tar.gz (784.1 kB view details)

Uploaded Source

File details

Details for the file pyssa-0.9.0.tar.gz.

File metadata

  • Download URL: pyssa-0.9.0.tar.gz
  • Upload date:
  • Size: 784.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.1

File hashes

Hashes for pyssa-0.9.0.tar.gz
Algorithm Hash digest
SHA256 2a7708943564740b8a74576cfd6a25fad07338c0226432d0d7498531367627a8
MD5 0c7090101dd4d5c9815cd4260bfbb1c9
BLAKE2b-256 6cdf71a6c566523508320be4aa43507765e421bd37e46a8d9733aa14fc39bfb0

See more details on using hashes here.

Supported by

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