Skip to content

Commit c3c26ee

Browse files
committed
update docs
1 parent e6698b5 commit c3c26ee

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

docs/src/api/catalyst_api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ be converted to other `ModelingToolkit.AbstractSystem`s, including a
1111
`ModelingToolkit.ODESystem`, `ModelingToolkit.SDESystem`, or
1212
`ModelingToolkit.JumpSystem`.
1313

14-
An empty network can be generated using [`@reaction_network`](@ref) with no arguments or
15-
the [`make_empty_network`](@ref) function. These can then be extended
14+
An empty network can be generated using [`@reaction_network`](@ref) with no
15+
arguments (or one argument to name the system), or the
16+
[`make_empty_network`](@ref) function. These can then be extended
1617
programmatically using [`addspecies!`](@ref), [`addparam!`](@ref), and
1718
[`addreaction!`](@ref).
1819

docs/src/tutorials/generated_systems.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Each `Reaction` within `reactions(rn)` has a number of subfields. For `rx` a
3333
non-filled arrows and should ignore mass action kinetics. `false` by default.
3434

3535
Empty `ReactionSystem`s can be generated via [`make_empty_network`](@ref) or
36-
[`@reaction_network`](@ref) with no arguments. `ReactionSystem`s can be
37-
programmatically extended using [`addspecies!`](@ref), [`addparam!`](@ref),
38-
[`addreaction!`](@ref), [`@add_reactions`](@ref), or composed using `merge` and
39-
`merge!`.
36+
[`@reaction_network`](@ref) with no arguments (giving one argument to the latter
37+
will specify a system name). `ReactionSystem`s can be programmatically extended
38+
using [`addspecies!`](@ref), [`addparam!`](@ref), [`addreaction!`](@ref),
39+
[`@add_reactions`](@ref), or composed using `merge` and `merge!`.

src/networkapi.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ end
219219
######################## functions to extend a network ####################
220220

221221
"""
222-
make_empty_network(; iv=Sym{ModelingToolkit.Parameter{Real}}(:t), name=gensym(:ReactionSystem))
222+
make_empty_network(; iv=Sym{ModelingToolkit.Parameter{Real}}(:t),
223+
name=gensym(:ReactionSystem))
223224
224225
Construct an empty [`ReactionSystem`](@ref). `iv` is the independent variable,
225-
usually time.
226+
usually time, and `name` is the name to give the `ReactionSystem`.
226227
"""
227228
function make_empty_network(; iv=Sym{ModelingToolkit.Parameter{Real}}(:t), name=gensym(:ReactionSystem))
228229
ReactionSystem(Reaction[], iv, [], [], Equation[], name, ReactionSystem[])

src/reaction_network.jl

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ bwd_arrows = Set{Symbol}([:<, :←, :↢, :↤, :⇽, :⟵, :⟻, :⥚, :⥞, :
6565
double_arrows = Set{Symbol}([:, :, :, :, :, :, :, :])
6666
pure_rate_arrows = Set{Symbol}([:, :, :, :, :, :])
6767

68+
# unfortunately the following doesn't seem to work on 1.5, so supporting these
69+
# operators seems to require us to only support 1.6 and up...
70+
# @static if VERSION >= v"1.6.0"
71+
# push!(bwd_arrows, :<--)
72+
# push!(double_arrows, :<-->)
73+
# end
74+
75+
6876
# Declares symbols which may neither be used as parameters not varriables.
6977
forbidden_symbols = [:t, , :pi, :ℯ, :im, :nothing, :∅]
7078

@@ -78,6 +86,27 @@ network.
7886
7987
See the [Catalyst.jl for Reaction Models](@ref) documentation for details on
8088
parameters to the macro.
89+
90+
Examples:
91+
```julia
92+
# a basic SIR model, with name SIR
93+
sir_model = @reaction_network SIR begin
94+
c1, s + i --> 2i
95+
c2, i --> r
96+
end c1 c2
97+
98+
# a basic SIR model, with random generated name
99+
sir_model = @reaction_network begin
100+
c1, s + i --> 2i
101+
c2, i --> r
102+
end c1 c2
103+
104+
# an empty network with name empty
105+
emptyrn = @reaction_network empty
106+
107+
# an empty network with random generated name
108+
emptyrn = @reaction_network
109+
```
81110
"""
82111
macro reaction_network(name::Symbol, ex::Expr, parameters...)
83112
make_reaction_system(MacroTools.striplines(ex), parameters; name=name)
@@ -87,10 +116,7 @@ macro reaction_network(ex::Expr, parameters...)
87116
make_reaction_system(MacroTools.striplines(ex), parameters)
88117
end
89118

90-
91-
### Macros used for manipulating, and successively builing up, reaction systems. ###
92-
93-
#Returns a empty network (with, or without, parameters declared)
119+
#Returns a empty network (with, or without, a declared name)
94120
macro reaction_network(name::Symbol=gensym(:ReactionSystem))
95121
return Expr(:block,:(@parameters t),
96122
:(ReactionSystem(Reaction[],
@@ -102,6 +128,8 @@ macro reaction_network(name::Symbol=gensym(:ReactionSystem))
102128
ReactionSystem[])))
103129
end
104130

131+
### Macros used for manipulating, and successively builing up, reaction systems. ###
132+
105133
"""
106134
@add_reactions
107135

0 commit comments

Comments
 (0)