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/symbolic_indexing.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,21 @@
1
1
# Symbolic Indexing
2
2
3
-
Using SciML's [`SymbolicIndexingInterface.jl`](https://github.com/SciML/SymbolicIndexingInterface.jl), `ND.jl` provides numerous methods to access and change variables and parameters.
4
-
5
-
!!! details "Setup code to make following examples work"
6
-
```@example si
7
-
using NetworkDynamics
8
-
using Graphs
9
-
using OrdinaryDiffEqTsit5
10
-
using Plots
11
-
```
3
+
By using SciML's [`SymbolicIndexingInterface.jl`](https://github.com/SciML/SymbolicIndexingInterface.jl), `ND.jl`
4
+
provides numerous methods to access and change variables and parameters.
12
5
13
6
## Provide Symbol Names
14
7
When constructing component models, you can pass symbolic names using the `sym` and `psym` keywords.
The default types for this access are the types [`VIndex`](@ref), [`EIndex`](@ref), [`VPIndex`](@ref) and [`EPIndex`](@ref).
33
-
Each of those symbolic indices consists of 2 elements: a reference to the network component and a reference to the symbol within that component.
30
+
Each of those symbolic indices consists of 2 elements: a reference to the network component and a reference to the
31
+
symbol within that component.
34
32
As such:
35
33
-`VIndex(2, :x)` refers to variable with symbolic name `:x` in vertex number 2.
36
34
-`EPIndex(4, 2)` refers to the *second* parameter of the edge component for the 4th edge.
37
-
-`VPIndex`() refers to (@Hans please fill in this with an example)
38
-
-`EPIndex`() refers to (@Hans please fill in this with an example)
39
35
40
36
!!! details "Setup code to make following examples work"
41
37
```@example si
@@ -55,7 +51,8 @@ plot(sol; idxs=[VIndex(1, :storage), VIndex(5,:storage)]) # plot storage of two
55
51
```
56
52
57
53
## Generate Symbolic Indices
58
-
Often, you need many individual symbolic indices. To achieve this you can use the helper methods [`vidxs`](@ref), [`eidxs`](@ref), [`vpidxs`](@ref) and [`epidxs`](@ref). With their help you can generate arrays of symbolic indices:
54
+
Often, you need many individual symbolic indices. To achieve this you can use the helper methods [`vidxs`](@ref),
55
+
[`eidxs`](@ref), [`vpidxs`](@ref) and [`epidxs`](@ref). With their help you can generate arrays of symbolic indices:
59
56
60
57
```@example si
61
58
vidxs(nw, :, :storage) # get variable "storage" for all vertices
@@ -100,7 +97,8 @@ in these flat arrays corresponds exactly to the order returned by [`variable_sym
100
97
101
98
!!! note
102
99
The `NWState` and `NWParameter` wrappers can be constructed from various objects.
103
-
For example, within a callback you might construct `p = NWParameter(integrator)` to then change the parameters of the network within the callback.
100
+
For example, within a callback you might construct `p = NWParameter(integrator)` to then change the parameters of
101
+
the network within the callback.
104
102
105
103
106
104
## Observables
@@ -113,7 +111,8 @@ It is also possible to define additional Observables manually by using the `obss
113
111
on the `EdgeModel`/`VertexModel` constructors.
114
112
When building models using ModelingToolkit, the reduced algebraic states will be preserved automatically as observables.
115
113
116
-
Observables can be accessed like any other state. For example, the flows in the network don't show up in the state array but can be accessed in all the ways discussed above.
114
+
Observables can be accessed like any other state. For example, the flows in the network don't show up in the state array
115
+
but can be accessed in all the ways discussed above.
117
116
For example:
118
117
```@example si
119
118
plot(sol; idxs=eidxs(nw, :, :flow))
@@ -130,7 +129,8 @@ For example, we can directly plot the storage difference with respect to storage
0 commit comments