Skip to content

Commit d1c61df

Browse files
committed
add JumpSystem docs
1 parent 091c95b commit d1c61df

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

docs/make.jl

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ makedocs(
1515
"systems/AbstractSystem.md",
1616
"systems/ODESystem.md",
1717
"systems/SDESystem.md",
18+
"systems/JumpSystem.md",
1819
"systems/NonlinearSystem.md",
1920
"systems/OptimizationSystem.md",
2021
"systems/ReactionSystem.md",

docs/src/systems/JumpSystem.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# JumpSystem
2+
3+
## System Constructors
4+
5+
```@docs
6+
JumpSystem
7+
```
8+
9+
## Composition and Accessor Functions
10+
11+
- `sys.eqs` or `equations(sys)`: The equations that define the jump system.
12+
- `sys.states` or `states(sys)`: The set of states in the jump system.
13+
- `sys.parameters` or `parameters(sys)`: The parameters of the jump system.
14+
- `sys.iv` or `independent_variable(sys)`: The independent variable of the jump system.
15+
16+
## Problem Constructors
17+
18+
```@docs
19+
DiscreteProblem
20+
JumpProblem
21+
```

src/systems/jumps/jumpsystem.jl

+29-10
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,43 @@ JumpType = Union{VariableRateJump, ConstantRateJump, MassActionJump}
33
"""
44
$(TYPEDEF)
55
6-
A system of jumps processes.
6+
A system of jump processes.
77
88
# Fields
99
$(FIELDS)
1010
1111
# Example
1212
1313
```
14-
using ModelingToolKit, DiffEqJump
14+
using ModelingToolkit
1515
1616
@parameters β γ t
1717
@variables S I R
1818
rate₁ = β*S*I
1919
affect₁ = [S ~ S - 1, I ~ I + 1]
20-
rate₂ = γ*I+t
20+
rate₂ = γ*I
2121
affect₂ = [I ~ I - 1, R ~ R + 1]
2222
j₁ = ConstantRateJump(rate₁,affect₁)
23-
j₂ = VariableRateJump(rate₂,affect₂)
23+
j₂ = ConstantRateJump(rate₂,affect₂)
2424
j₃ = MassActionJump(2*β+γ, [R => 1], [S => 1, R => -1])
2525
js = JumpSystem([j₁,j₂,j₃], t, [S,I,R], [β,γ])
26-
u₀map = [S => 999, I => 1, R => 0]
27-
parammap = [β => .1/1000, γ => .01]
28-
dprob = DiscreteProblem(js2, u₀map, tspan, parammap)
29-
jprob = JumpProblem(js2, dprob, Direct(), save_
30-
3126
```
3227
"""
3328
struct JumpSystem{U <: ArrayPartition} <: AbstractSystem
29+
"""
30+
The jumps of the system. Allowable types are `ConstantRateJump`,
31+
`VariableRateJump`, `MassActionJump`.
32+
"""
3433
eqs::U
34+
"""The independent variable, usually time."""
3535
iv::Variable
36+
"""The dependent variables, representing the state of the system."""
3637
states::Vector{Variable}
38+
"""The parameters of the system."""
3739
ps::Vector{Variable}
40+
"""The name of the system."""
3841
name::Symbol
42+
"""The internal systems."""
3943
systems::Vector{JumpSystem}
4044
end
4145

@@ -123,7 +127,16 @@ function DiffEqBase.DiscreteProblem(sys::AbstractSystem, u0map, tspan,
123127
parammap=DiffEqBase.NullParameters; kwargs...)
124128
```
125129
126-
Generates a DiscreteProblem from an AbstractSystem
130+
Generates a DiscreteProblem from an AbstractSystem.
131+
132+
Continuing the example from the [`JumpSystem`](@ref) definition:
133+
```julia
134+
using DiffEqBase, DiffEqJump
135+
u₀map = [S => 999, I => 1, R => 0]
136+
parammap = [β => .1/1000, γ => .01]
137+
tspan = (0.0, 250.0)
138+
dprob = DiscreteProblem(js, u₀map, tspan, parammap)
139+
```
127140
"""
128141
function DiffEqBase.DiscreteProblem(sys::AbstractSystem, u0map, tspan::Tuple,
129142
parammap=DiffEqBase.NullParameters(); kwargs...)
@@ -141,6 +154,12 @@ function DiffEqBase.JumpProblem(js::JumpSystem, prob, aggregator; kwargs...)
141154
```
142155
143156
Generates a JumpProblem from a JumpSystem.
157+
158+
Continuing the example from the [`DiscreteProblem`](@ref) definition:
159+
```julia
160+
jprob = JumpProblem(js, dprob, Direct())
161+
sol = solve(jprob, SSAStepper())
162+
```
144163
"""
145164
function DiffEqJump.JumpProblem(js::JumpSystem, prob, aggregator; kwargs...)
146165

0 commit comments

Comments
 (0)