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
To model the vertex dynamics we need to create a `VertexModel` and to model the edge dynamics we need to create an `EdgeModel`.
72
+
## Modelling dynamics in NetworkDynamics.jl
73
+
To model the vertex and edge dynamics we need to create a `VertexModel` and an `EdgeModel`, respectively.
73
74
74
-
First we need to have Julia and the necessary packages (`Graphs`, `Revise`, `LiveServer`, `NetworkDynamics`, `OrdinaryDiffEqTsit5`, `StableRNGs` and `Plots`) installed. Then we need to load the packages:
75
+
As a first step we need to install Julia and the necessary packages (`Graphs`, NetworkDynamics`, `OrdinaryDiffEqTsit5`,
76
+
`StableRNGs` and `Plots`). Then we need to load them:
75
77
=#
76
78
77
79
using Graphs
@@ -81,27 +83,28 @@ using StableRNGs
81
83
using Plots
82
84
nothing#hide
83
85
86
+
84
87
#=
85
88
86
-
#### Defining an `EdgeModel`
89
+
### Defining the `EdgeModel`
90
+
91
+
Then we must define the `EdgeModel`. To define it we use the function `diffusionedge_g!` which takes as inputs
92
+
the current state of the edge `e`, its source vertex `v_src`, its destination vertex `v_dst`, a vector of parameters `p`
93
+
and the time `t`. In order to comply with the syntax of NetworkDynamics.jl we must always define functions for edges
94
+
with exactly these arguments. (In the case of this example, the values for `p` and `t` are not used since there are no
95
+
parameters and there is no explicit time dependency in the system).
87
96
88
-
Then we define the `EdgeModel`.
89
-
To define it we use the function `diffusionedge_g!`. The function takes as inputs the current state of the edge `e`,
90
-
its source vertex `v_src`, its destination vertex `v_dst`, a vector of parameters `p` and the time `t`. In order to
91
-
comply with the syntax of NetworkDynamics.jl we must always define functions for edges with exactly these arguments.
92
-
(In the case of this example, the values for `p` and `t` are not used since there are no parameters and ther is no
93
-
#explicit time dependency in the system).
94
-
After the function call the edge's output value `e` equals the difference between its source and its destination
95
-
vertex (i.e. the discrete gradient along that edge).
97
+
After the function call the edge's output value `e` equals the difference between its source and its destination vertex
98
+
(i.e. the discrete gradient along that edge).
96
99
97
100
!!! note
98
101
`diffusionedge_g!` is called a **mutating** function, because it mutates (modifies) the edge state `e` (which is the
99
102
first of its inputs). (In Julia, names of mutating functions end with an `!`.) We use mutating functions because
100
-
they reduce the computational resource allocations and, therefore, speed up the computations.
103
+
they reduce the computational resource allocations and therefore, speed up the computations.
Next we need to define the `VertexModel`. For undirected graphs, the `edgefunction!` specifies the coupling from a
121
-
source- to a destination vertex. The contributions of the connected edges to a single vertex are "aggregated". By default, the aggregation is the summation of
122
-
all incident edge states. The aggregated edge state is made available via the `esum` argument of the vertex function.
124
+
source to a destination vertex. The contributions of the connected edges to a single vertex are "aggregated".
125
+
By default, the aggregation is the summation of all incident edge states. The aggregated edge state is made available
126
+
via the `esum` argument of the vertex function.
123
127
=#
124
128
125
129
functiondiffusionvertex_f!(dv, v, esum, p, t)
@@ -132,68 +136,67 @@ nothing #hide #md
132
136
#=
133
137
Just like above, the input arguments `v, esum, p, t` are mandatory for the syntax of vertex functions. The additional
134
138
input `dv` corresponding to the derivative of the vertex' state is mandatory for vertices described by ordinary
135
-
differential equations.
136
-
137
-
The outputs of the vertex function are just a subset of the internal states. For that we can use the [`StateMask`](@ref) helper
138
-
function `g = StateMaks(1:1)`
139
+
differential equations. The outputs of the vertex function are just a subset of the internal states. Therefore, we
140
+
can use the [`StateMask`](@ref) helper function `g = StateMaks(1:1)` to access them.
0 commit comments