Code Monkey home page Code Monkey logo

finitestateprojection.jl's Introduction

FiniteStateProjection.jl

Dev

Finite State Projection [1] algorithms for chemical reaction networks based on Catalyst.jl and ModelingToolkit.jl. Converts descriptions of reaction networks into ODEProblems for use with DifferentialEquations.jl.

Features:

  • Built on top of Catalyst.jl
  • FSP equations are generated as ODEFunction/ODEProblems and can be solved with DifferentialEquations.jl, with on-the-fly generation of targeted functions for improved performance
  • The Chemical Master Equation can be represented as a SparseMatrixCSC
  • Automatic dimensionality reduction for systems with conserved quantities

More information is available in the documentation. Please feel free to open issues and submit pull requests!

Examples

Birth-Death System

using FiniteStateProjection
using OrdinaryDiffEq

@parameters σ d
rn = @reaction_network begin
    σ, 0 --> A
    d, A --> 0
end σ d

sys = FSPSystem(rn)

# Parameters for our system
ps = [ 10.0, 1.0 ]

# Initial values
u0 = zeros(50)
u0[1] = 1.0

prob = ODEProblem(sys, u0, (0, 10.0), ps)
sol = solve(prob, Vern7(), atol=1e-6)

Visualisation

Telegraph Model

using FiniteStateProjection
using OrdinaryDiffEq

@parameters ρ σ_on σ_off d
rn = @reaction_network begin
    ρ, G_on --> G_on + M
    (σ_on, σ_off), G_off <--> G_on
    d, M --> 0
end ρ σ_on σ_off d

# This automatically reduces the dimensionality of the
# network by exploiting conservation laws
ih = ReducingIndexHandler(rn)
sys = FSPSystem(rn, ih)

# There is one conserved quantity: G_on + G_off
cons = conservedquantities([1, 0, 0], sys)

# Parameters for our system
ps = [ 15.0, 0.25, 0.15, 1.0 ]

# In the reduced model, G_off = 1 - G_on does not have to be tracked
u0 = zeros(2, 50)
u0[1,1] = 1.0

prob = ODEProblem(sys, u0, (0, 10.0), (ps, cons))
sol = solve(prob, Vern7(), atol=1e-6)

Visualisation

TODO:

  • Add bursty reactions
  • Add stationary FSP support
  • Add support for sparse Jacobians

References

[1] B. Munsky and M. Khammash, "The Finite State Projection algorithm for the solution of the Chemical Master Equation", Journal of Chemical Physics 124, 044104 (2006). https://doi.org/10.1063/1.2145882

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.