Crates.io | crn |
lib.rs | crn |
version | 0.1.2 |
source | src |
created_at | 2023-08-08 18:30:50.238981 |
updated_at | 2023-08-13 03:39:16.421268 |
description | Stochastic and deterministic simulation of chemical reaction networks. |
homepage | https://github.com/marshallmoats/crn |
repository | |
max_upload_size | |
id | 939419 |
size | 335,399 |
crn
can simulate both stochastic and deterministic CRNs with StoCrn
and DetCrn
, respectively.
To create your own CRN, first declare the initial counts of each molecule, and then add the reactions, each optionally followed by a rate parameter (10 in the first reaction):
let crn_string = "
a = 10;
b = 5;
c = 0;
a + b -> 2c : 10;
c -> 3b;
";
Pass the whole string to the parser:
let mut crn = StoCrn::parse(crn_string).unwrap()
Now let's simulate it for 3 seconds of virtual time:
let data = crn.simulate_history(3.0);
Some premade CRNs can be found in the presets
module.
Run this for a graphical demonstration!
cargo run --release --example gui
Note: deterministic simulations tend to be unstable with large numbers -- I'm still working on this. Try scaling down all initial amounts (can be noninteger, unlike stochastic simulations) if you're having issues.