You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/callbacks.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,13 @@
1
-
# Callbacks and Events(@id Callbacks)
1
+
# [Callbacks and Events](@id Callbacks)
2
2
3
3
Callback-functions are a way of handling discontinuities in differential equations.
4
4
In a nutshell, the solver checks for some "condition" (i.e. a zero crossing of some variable)
5
5
and calls some "affect" if the condition is fulfilled.
6
-
In the affect it is safe to modify the integrator, e.g. changing some state or some parameter.
6
+
Within the affect function, it is safe to modify the integrator, e.g. changing some state or some parameter.
7
7
8
8
Since `NetworkDynamics.jl` provides nothing more than a RHS for DifferentialEquations.jl, please check
9
9
[their docs on event handling](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/)
10
10
as a general reference.
11
-
12
11
This page at introducing the general concepts, for a hands on example of a simulation with callbacks
13
12
refer to the [Cascading Failure](@ref) example.
14
13
@@ -84,7 +83,7 @@ add_callback!(vert, vccb)
84
83
85
84
86
85
### Extracting the Callback
87
-
In order to use the callback during simulation, we need to generate a [`SciMLBase.CallbackSet`](@extref) which contains the conditions and affects of all the component based callbacks in the network. For that we use [`get_callbacks(::Network)`](@ref`get_callbacks(::NetworkDynamics.Network)`):
86
+
In order to use the callback during simulation, we need to generate a [`SciMLBase.CallbackSet`](@extref) which contains the conditions and affects of all the component based callbacks in the network. For that we use [`get_callbacks(::Network)`](@ref):
88
87
```julia
89
88
u0 =NWState(u0)
90
89
cbs =get_callbacks(nw)
@@ -105,7 +104,7 @@ To access states and parameters of specific components, we havily rely on the [S
- Symbolic indexing can be costly, and the condition function gets called very
118
-
often. By using [`SII.getu`](@extref`SymbolicIndexingInterface.getu`) we did
117
+
often. By using [`SII.getsym`](@extref`SymbolicIndexingInterface.getsym`) we did
119
118
some of the work *before* the callback by creating the accessor function.
120
119
When handling with "normal states" and parameters consider using
121
120
[`SII.variable_index`](@ref`SymbolicIndexingInterface.variable_index`) and
@@ -150,4 +149,4 @@ Once the `condition` and `affect!` is defined, you can use the [`SciMLBase.Conti
150
149
To extract or plot timeseries of observed states under *time variant
151
150
parameters* (i.e. parameters that are changed in a callback), those changes
152
151
need to be recorded using the [`save_parameters!`](@ref) function whenever `p` is changed.
153
-
When using [ComponentCallback](@ref), NetworkDynamics will automaticially check for changes in `p` and save them if necessary.
152
+
When using [ComponentCallback](@ref NetworkDynamics.ComponentCallback), NetworkDynamics will automaticially check for changes in `p` and save them if necessary.
0 commit comments