Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5387147
docs: spelling improvements
Mo-Gul Oct 14, 2025
a9717b6
docs: MD022/blanks-around-headings
Mo-Gul Oct 14, 2025
275e923
docs: MD031/blanks-around-fences
Mo-Gul Oct 14, 2025
8b30e46
docs: MD032/blanks-around-lists
Mo-Gul Oct 15, 2025
955771d
docs: MD004/ul-style
Mo-Gul Oct 15, 2025
12eedc4
docs: MD012/no-multiple-blanks
Mo-Gul Oct 15, 2025
d5aaa89
docs: MD040/fenced-code-language
Mo-Gul Oct 15, 2025
399d0af
docs: MD010/no-hard-tabs
Mo-Gul Oct 15, 2025
a6a29e3
docs: harmonize indention
Mo-Gul Oct 15, 2025
e2443f1
docs: add link to `JumpProcesses`
Mo-Gul Oct 14, 2025
21770e3
docs: MD038/no-space-in-code
Mo-Gul Oct 15, 2025
552dedb
docs: MD034/no-bare-urls
Mo-Gul Oct 15, 2025
d8eb77a
docs: add missing closing brackets
Mo-Gul Oct 15, 2025
9eed348
docs: fix typo in label
Mo-Gul Oct 15, 2025
6829fd2
docs: harmonize "time span"
Mo-Gul Oct 14, 2025
a432ac2
docs: harmonize "sub-library"
Mo-Gul Oct 17, 2025
0aab4bf
docs: fix typos
Mo-Gul Oct 17, 2025
1d3047b
docs: add missing punctuation
Mo-Gul Oct 17, 2025
7d91e1e
docs: MD055/table-pipe-style
Mo-Gul Oct 17, 2025
6af1f05
docs: MD026/no-trailing-punctuation
Mo-Gul Oct 17, 2025
7400593
docs: add missing dots in name abbreviations
Mo-Gul Oct 17, 2025
cda28c0
docs: remove spaces before refs
Mo-Gul Oct 17, 2025
17cd9dd
docs: MD029/ol-prefix
Mo-Gul Oct 17, 2025
d242bb2
docs: one time ignore MD046/code-block-style
Mo-Gul Oct 17, 2025
cc189a0
docs: fix changed link
Mo-Gul Oct 14, 2025
8835b18
docs: use right ref style
Mo-Gul Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/old_files/advanced.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
# The Reaction DSL - Advanced

This section covers some of the more advanced syntax and features for building
chemical reaction network models (still not very complicated!).

#### User defined functions in reaction rates

The reaction network DSL can "see" user defined functions that work with
ModelingToolkit. E.g., this is should work

```julia
myHill(x) = 2.0*x^3/(x^3+1.5^3)
rn = @reaction_network begin
myHill(X), ∅ → X
end
```

In some cases, it may be necessary or desirable to register functions with
Symbolics.jl before their use in Catalyst, see the discussion
[here](https://symbolics.juliasymbolics.org/dev/manual/functions/).

#### Ignoring mass action kinetics

While generally one wants the reaction rate to use the law of mass action, so
the reaction

```julia
rn = @reaction_network begin
k, X → ∅
end
```

occurs at the rate ``d[X]/dt = -k[X]``, it is possible to ignore this by using
any of the following non-filled arrows when declaring the reaction: `<=`, `⇐`, `⟽`,
`⇒`, `⟾`, `=>`, `⇔`, `⟺` (`<=>` currently not possible due to Julia language technical reasons). This means that the reaction
Expand Down
5 changes: 3 additions & 2 deletions docs/old_files/unused_tutorials/advanced_examples.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Advanced Chemical Reaction Network Examples

For additional flexibility, we can convert the generated `ReactionSystem` first
to another `ModelingToolkit.AbstractSystem`, e.g., an `ODESystem`, `SDESystem`,
`JumpSystem`, etc. These systems can then be used in problem generation. Please
Expand All @@ -11,6 +12,7 @@ Note, when generating problems from other system types, `u0` and `p` must
provide vectors, tuples or dictionaries of `Pair`s that map each the symbolic
variables for each species or parameter to their numerical value. E.g., for the
Michaelis-Menten example above we'd use

```julia
rs = @reaction_network begin
c1, X --> 2X
Expand All @@ -20,10 +22,9 @@ end
p = (:c1 => 1.0, :c2 => 2.0, :c3 => 50.)
pmap = symmap_to_varmap(rs,p) # convert Symbol map to symbolic variable map
tspan = (0.,4.)
u0 = [:X => 5.]
u0 = [:X => 5.]
u0map = symmap_to_varmap(rs,u0) # convert Symbol map to symbolic variable map
osys = convert(ODESystem, rs)
oprob = ODEProblem(osys, u0map, tspan, pmap)
sol = solve(oprob, Tsit5())
```

34 changes: 27 additions & 7 deletions docs/old_files/unused_tutorials/models.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Model Simulation

Once created, a reaction network can be used as input to various problem types,
which can be solved by
[DifferentialEquations.jl](http://docs.sciml.ai/DiffEqDocs/stable/),
and more broadly used within [SciML](https://sciml.ai) packages.

#### Deterministic simulations using ODEs

A reaction network can be used as input to an `ODEProblem` instead of a
function, using

```julia
odeprob = ODEProblem(rn, args...; kwargs...)
```

E.g., a model can be created and solved using:

```julia
using DiffEqBase, OrdinaryDiffEq
rn = @reaction_network begin
Expand All @@ -23,6 +28,7 @@ tspan = (0.,1.)
prob = ODEProblem(rn,u0,tspan,p)
sol = solve(prob, Tsit5())
```

Here, the order of unknowns in `u0` and `p` matches the order that species and
parameters first appear within the DSL. They can also be determined by examining
the ordering within the `species(rn)` and `parameters` vectors, or accessed more
Expand All @@ -34,37 +40,47 @@ DSL](@ref)). Note, if no parameters are given in the
[`@reaction_network`](@ref), then `p` does not need to be provided.

We can then plot the solution using the solution plotting recipe:

```julia
using Plots
plot(sol, lw=2)
```

![models1](../assets/models1.svg)

To solve for a steady state starting from the guess `u0`, one can use

```julia
using SteadyStateDiffEq
prob = SteadyStateProblem(rn,u0,p)
sol = solve(prob, SSRootfind())
```

or

```julia
prob = SteadyStateProblem(rn,u0,p)
sol = solve(prob, DynamicSS(Tsit5()))
```

#### Stochastic simulations using SDEs

In a similar way an SDE can be created using

```julia
using StochasticDiffEq
sdeprob = SDEProblem(rn, args...; kwargs...)
```

In this case the chemical Langevin equations (as derived in Gillespie, J. Chem.
Phys. 2000) will be used to generate stochastic differential equations.

#### Stochastic simulations using discrete stochastic simulation algorithms

Instead of solving SDEs, one can create a stochastic jump process model using
integer copy numbers and a discrete stochastic simulation algorithm (i.e.,
Gillespie Method or Kinetic Monte Carlo). This can be done using:

```julia
using JumpProcesses
rn = @reaction_network begin
Expand All @@ -78,30 +94,34 @@ discrete_prob = DiscreteProblem(rn, u0, tspan, p)
jump_prob = JumpProblem(rn, discrete_prob, Direct())
sol = solve(jump_prob, SSAStepper())
```

Here, we used Gillespie's `Direct` method as the underlying stochastic simulation
algorithm. We get:

```julia
plot(sol, lw=2)
```

![models2](../assets/models2.svg)

### [`Reaction`](@ref) fields

Each `Reaction` within `reactions(rn)` has a number of subfields. For `rx` a
`Reaction` we have:
* `rx.substrates`, a vector of ModelingToolkit expressions storing each

- `rx.substrates`, a vector of ModelingToolkit expressions storing each
substrate variable.
* `rx.products`, a vector of ModelingToolkit expressions storing each product
- `rx.products`, a vector of ModelingToolkit expressions storing each product
variable.
* `rx.substoich`, a vector storing the corresponding stoichiometry of each
- `rx.substoich`, a vector storing the corresponding stoichiometry of each
substrate species in `rx.substrates`.
* `rx.prodstoich`, a vector storing the corresponding stoichiometry of each
- `rx.prodstoich`, a vector storing the corresponding stoichiometry of each
product species in `rx.products`.
* `rx.rate`, a `Number`, `ModelingToolkit.Sym`, or ModelingToolkit expression
- `rx.rate`, a `Number`, `ModelingToolkit.Sym`, or ModelingToolkit expression
representing the reaction rate. E.g., for a reaction like `k*X, Y --> X+Y`,
we'd have `rate = k*X`.
* `rx.netstoich`, a vector of pairs mapping the ModelingToolkit expression for
- `rx.netstoich`, a vector of pairs mapping the ModelingToolkit expression for
each species that changes numbers by the reaction to how much it changes. E.g.,
for `k, X + 2Y --> X + W`, we'd have `rx.netstoich = [Y(t) => -2, W(t) => 1]`.
* `rx.only_use_rate`, a boolean that is `true` if the reaction was made with
- `rx.only_use_rate`, a boolean that is `true` if the reaction was made with
non-filled arrows and should ignore mass action kinetics. `false` by default.
Loading
Loading