Skip to content

Commit f0ce857

Browse files
Merge pull request #2567 from MasonProtter/export-events
Document and export `continuous_events` and `discrete_events`
2 parents 43b5071 + 7c2c81e commit f0ce857

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

docs/src/systems/JumpSystem.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ JumpSystem
1212
- `get_unknowns(sys)` or `unknowns(sys)`: The set of unknowns in the jump system.
1313
- `get_ps(sys)` or `parameters(sys)`: The parameters of the jump system.
1414
- `get_iv(sys)`: The independent variable of the jump system.
15+
- `discrete_events(sys)`: The set of discrete events in the jump system.
1516

1617
## Transformations
1718

docs/src/systems/ODESystem.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ODESystem
1313
- `get_ps(sys)` or `parameters(sys)`: The parameters of the ODE.
1414
- `get_iv(sys)`: The independent variable of the ODE.
1515
- `get_u0_p(sys, u0map, parammap)` Numeric arrays for the initial condition and parameters given `var => value` maps.
16+
- `continuous_events(sys)`: The set of continuous events in the ODE
17+
- `discrete_events(sys)`: The set of discrete events in the ODE
1618

1719
## Transformations
1820

docs/src/systems/SDESystem.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ sde = SDESystem(ode, noiseeqs)
1919
- `get_unknowns(sys)` or `unknowns(sys)`: The set of unknowns in the SDE.
2020
- `get_ps(sys)` or `parameters(sys)`: The parameters of the SDE.
2121
- `get_iv(sys)`: The independent variable of the SDE.
22+
- `continuous_events(sys)`: The set of continuous events in the SDE
23+
- `discrete_events(sys)`: The set of discrete events in the SDE
2224

2325
## Transformations
2426

src/ModelingToolkit.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ using PrecompileTools, Reexport
3535
using RecursiveArrayTools
3636

3737
using SymbolicIndexingInterface
38-
export independent_variables, unknowns, parameters, full_parameters
38+
export independent_variables, unknowns, parameters, full_parameters, continuous_events,
39+
discrete_events
3940
import SymbolicUtils
4041
import SymbolicUtils: istree, arguments, operation, similarterm, promote_symtype,
4142
Symbolic, isadd, ismul, ispow, issym, FnType,

src/systems/callbacks.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ function namespace_callback(cb::SymbolicContinuousCallback, s)::SymbolicContinuo
138138
namespace_affects(affects(cb), s))
139139
end
140140

141+
"""
142+
continuous_events(sys::AbstractSystem)::Vector{SymbolicContinuousCallback}
143+
144+
Returns a vector of all the `continuous_events` in an abstract system and its component subsystems.
145+
The `SymbolicContinuousCallback`s in the returned vector are structs with two fields: `eqs` and
146+
`affect` which correspond to the first and second elements of a `Pair` used to define an event, i.e.
147+
`eqs => affect`.
148+
"""
141149
function continuous_events(sys::AbstractSystem)
142150
obs = get_continuous_events(sys)
143151
filter(!isempty, obs)
@@ -234,6 +242,14 @@ SymbolicDiscreteCallbacks(cb::SymbolicDiscreteCallback) = [cb]
234242
SymbolicDiscreteCallbacks(cbs::Vector{<:SymbolicDiscreteCallback}) = cbs
235243
SymbolicDiscreteCallbacks(::Nothing) = SymbolicDiscreteCallback[]
236244

245+
"""
246+
discrete_events(sys::AbstractSystem) :: Vector{SymbolicDiscreteCallback}
247+
248+
Returns a vector of all the `discrete_events` in an abstract system and its component subsystems.
249+
The `SymbolicDiscreteCallback`s in the returned vector are structs with two fields: `condition` and
250+
`affect` which correspond to the first and second elements of a `Pair` used to define an event, i.e.
251+
`condition => affect`.
252+
"""
237253
function discrete_events(sys::AbstractSystem)
238254
obs = get_discrete_events(sys)
239255
systems = get_systems(sys)

0 commit comments

Comments
 (0)