Skip to content

Commit 2a59c55

Browse files
committed
fix spelling and links
1 parent aac1f65 commit 2a59c55

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

docs/examples/getting_started_with_network_dynamics.jl

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ y^{\mathrm e}_{\mathrm{src}} &= g_\mathrm{src}^{\mathrm e}(u^{\mathrm e}, y^{\ma
7272
## Modelling dynamics in NetworkDynamics.jl
7373
To model the vertex and edge dynamics we need to create a `VertexModel` and an `EdgeModel`, respectively.
7474
75-
As a first step we need to install Julia and the necessary packages (`Graphs`, NetworkDynamics`, `OrdinaryDiffEqTsit5`,
75+
As a first step we need to install Julia and the necessary packages (`Graphs`, `NetworkDynamics`, `OrdinaryDiffEqTsit5`,
7676
`StableRNGs` and `Plots`). Then we need to load them:
7777
=#
7878

@@ -137,7 +137,7 @@ nothing #hide #md
137137
Just like above, the input arguments `v, esum, p, t` are mandatory for the syntax of vertex functions. The additional
138138
input `dv` corresponding to the derivative of the vertex' state is mandatory for vertices described by ordinary
139139
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.
140+
can use the [`StateMask`](@ref) helper function `g = StateMask(1:1)` to access them.
141141
=#
142142

143143
nd_diffusion_vertex = VertexModel(; f=diffusionvertex_f!, g=StateMask(1:1), dim=1)
@@ -180,23 +180,25 @@ ode_prob = ODEProblem(nd, x0, (0.0, 2.0))
180180
# We test all ex styles #src
181181
Main.test_execution_styles(ode_prob) #src
182182

183-
# And then solve the network using ´solve´:
183+
# And then solve the network using `solve`:
184184
sol = solve(ode_prob, Tsit5());
185185
nothing #hide #md
186186

187187
#=
188-
We plot the results using the `plot` command, which takes three parameters as input `sol`, `idxs` and `fmt`.
188+
We plot the results using the `plot` command, which takes two parameters as input `sol` and `idxs`.
189189
The first parameter is the solved network `sol`.
190190
The second parameter is `idxs`, which provides a set of indices. We can use "symbolic" indices, which specify specific
191191
components and their symbols directly (see [Symbolic Indexing](@ref) for more details). In order to collect multiple
192192
indices we can use the helper function [`vidxs`](@ref) and [`eidxs`](@ref), which help us collect all symbolic indices
193-
matching specific criteria. The third and last parameter is `fmt`, which provides the format of the generated plot, in
194-
this case that format being .png.
193+
matching specific criteria.
194+
Here, we want to plot **all** vertex states from the network.
195195
=#
196-
plot(sol; idxs=vidxs(nd, :, :), fmt=:png)
196+
plot(sol; idxs=vidxs(nd, :, :))
197197

198198
#=
199-
(@Hans can you provide a description of what we see in this plot? The y axis is missing so it is unclear to me.)
199+
In the plot we see, how the individual vertex states evolve over time.
200+
We start at a random configuration, and then develop towards an equilibrium where
201+
all nodes have the same state, which is to be expected for a simple diffusion process.
200202
201203
## Two Dimensional Extension
202204
@@ -218,38 +220,30 @@ nd_diffusion_vertex_2 = VertexModel(; f=diffusionvertex_f!, g=1:2, dim=2, sym=[:
218220
nd_diffusion_edge_2 = EdgeModel(; g=AntiSymmetric(diffusionedge_g!), outsym=[:flow_x, :flow_ϕ])
219221
nd_2 = Network(g, nd_diffusion_vertex_2, nd_diffusion_edge_2)
220222

221-
#= We define the first diffusion as x ~ $N(0,1)^\mathrm{2}$ and the second diffusion as ϕ ~ $N(0,1)$. So the propagation
223+
#=
224+
We define the first diffusion as x ~ $N(0,1)^\mathrm{2}$ and the second diffusion as ϕ ~ $N(0,1)$. So the propagation
222225
of the diffusion from node 0 to node 2 is given by creating a vector:
223226
=#
224227
x0_2 = vec(transpose([randn(rng, N) .^ 2 randn(rng, N)]))
225-
#(@Hans: is my explanation correct?)
226228

227-
# We then define the [ODEProblem](@ref)
229+
# We then define the `ODEProblem`:
228230
ode_prob_2 = ODEProblem(nd_2, x0_2, (0.0, 3.0))
229231
Main.test_execution_styles(ode_prob_2) #src
230232

231233
# Then solve the network using:
232234
sol_2 = solve(ode_prob_2, Tsit5());
233235

234236
# To plot the evolution of variables ϕ_i over time we use the command:
235-
plot(sol_2; idxs=vidxs(nd_2, :, :x), fmt=:png)
237+
plot(sol_2; idxs=vidxs(nd_2, :, :x))
236238
# [To write ϕ in the terminal type \phi and press TAB]
237239

238240
# Using the `eidxs` helper function we can also plot the evolution of the flow variables over time:
239-
plot(sol_2; idxs=eidxs(nd_2, :, :flow_x), fmt=:png)
241+
plot(sol_2; idxs=eidxs(nd_2, :, :flow_x))
242+
# As expected, the flows are nonzero first and go towards zero as we reach the equilibrium point.
240243

241244

242245
#=
243246
## Putting it all together
244-
245-
(@Hans: when I am trying to run the script in the "Putting it all together" in a separate .jl file I am getting a
246-
UndefVarError: `AntiSymmetric` not defined in `Main`
247-
Suggestion: check for spelling errors or missing imports.
248-
Stacktrace:
249-
[1] top-level scope
250-
@ REPL[7]:1)
251-
252-
and I have no idea why. Can you please check it? Because if someone copy-pastes it, it will not work for them)
253247
=#
254248

255249
using Graphs
@@ -260,7 +254,7 @@ using Plots
260254
nothing #hide
261255

262256
function diffusionedge_g!(e_dst, v_src, v_dst, p, t)
263-
## e_dst, v_src, v_dst are arrays, hence we use the broadcasting operator
257+
## e_dst, v_src, v_dst are arrays, so we use the broadcasting operator .
264258
e_dst .= v_src .- v_dst
265259
nothing
266260
end
@@ -269,7 +263,7 @@ nothing #hide #md
269263
nd_diffusion_edge = EdgeModel(; g=AntiSymmetric(diffusionedge_g!), outsym=[:flow])
270264

271265
function diffusionvertex_f!(dv, v, esum, p, t)
272-
## dv, v and esum are arrays, hence we use the broadcasting operator .
266+
## dv, v and esum are arrays, so we use the broadcasting operator .
273267
dv .= esum
274268
nothing
275269
end
@@ -300,8 +294,8 @@ x0_2 = vec(transpose([randn(rng, N) .^ 2 randn(rng, N)]))
300294
ode_prob_2 = ODEProblem(nd_2, x0_2, (0.0, 3.0))
301295
Main.test_execution_styles(ode_prob_2) #src
302296
sol_2 = solve(ode_prob_2, Tsit5());
303-
plot(sol_2; idxs=vidxs(nd_2, :, :x), fmt=:png, xlabel = "x", ylabel = "nd_2",)
304-
plot(sol_2; idxs=eidxs(nd_2, :, :flow_x), fmt=:png)
297+
plot(sol_2; idxs=vidxs(nd_2, :, :x), xlabel = "x", ylabel = "nd_2",)
298+
plot(sol_2; idxs=eidxs(nd_2, :, :flow_x))
305299

306300

307301

docs/src/metadata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Special cases for symbol metadata are:
3232
For those, there are special functions `has_*`, `get_*`, `set_*!` and `delete_*!`. See [Per Symbol Metadata API](@ref).
3333

3434

35-
These are closely aligned with the [metadata use in ModelingToolkit](https://docs.sciml.ai/ModelingToolkit/stable/basics/Variable_metadata/). They are automatically copied from the `ODESystem` if you use MTK models to create NetworkDynamics models.
35+
These are closely aligned with the [metadata use in ModelingToolkit](https://docs.sciml.ai/ModelingToolkit/stable/API/variables/#symbolic_metadata). They are automatically copied from the `ODESystem` if you use MTK models to create NetworkDynamics models.
3636

3737
## Metadata Utils
3838
Accessing metadata (especially defaults) of states and parameters is a very

0 commit comments

Comments
 (0)