Skip to content

Edit tutorial contents #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f9d5262
Update index.md
BethProedrou Apr 29, 2025
3f47a4f
Update index.md
BethProedrou Apr 29, 2025
ad9bd53
Further updates to the Update index.md
BethProedrou Apr 30, 2025
0aaf778
Improved the "Where to begin" section
BethProedrou Apr 30, 2025
ffff152
improved Installation section
BethProedrou May 1, 2025
12a4821
added some missing commands to install the package
BethProedrou May 1, 2025
9f92084
added link to DAE
BethProedrou May 1, 2025
02f0868
improved the link
BethProedrou May 1, 2025
31f7f96
Improving Mathematical Model
BethProedrou May 1, 2025
27075a5
Impoved the mathematical model text
May 3, 2025
4810a1e
Merge branch 'main' into edit_tutorial_contents
hexaeder May 12, 2025
334d867
remove "diff style" in index.md
hexaeder May 12, 2025
49f8074
replaced the old style of changes with the new one
BethProedrou May 13, 2025
76cf0b4
half-way save
BethProedrou May 13, 2025
8a34eaf
fixed phrasing
BethProedrou May 14, 2025
65dee53
Fixed phrasing
BethProedrou May 14, 2025
728f0b6
improved phrasing
BethProedrou May 14, 2025
f5ba8de
fixed change I made
BethProedrou May 14, 2025
c780541
placed basic complex network systems information in a blockquote
May 26, 2025
5955040
improved readability in IDE
May 26, 2025
c08ceae
improved readability in IDE
May 26, 2025
1f04988
Fixed and added notes
May 26, 2025
ecfac0c
rearranged code to improve readability (work in progress)
May 28, 2025
2e555c6
working
May 28, 2025
bb3993f
working
May 29, 2025
f9e33db
fixed issues causing it not to run
May 29, 2025
c7749de
Merge branch 'main' into edit_tutorial_contents
May 29, 2025
47dfd31
Getting Started Tutorial v.1
May 31, 2025
84f1f2b
address comments
hexaeder Jun 2, 2025
45b002e
address more comments
hexaeder Jun 2, 2025
5da970c
deleted comment
Jun 23, 2025
f79e169
deleted unneeded comment
Jun 23, 2025
1987454
deleted a comment
Jun 23, 2025
3c66526
Merge branch 'edit_tutorial_contents' of https://github.com/JuliaDyna…
Jun 23, 2025
67584ca
Merge branch 'main' into edit_tutorial_contents
Jun 23, 2025
d8855e9
removed comment about a missing image
Jul 1, 2025
b4426e9
incorporated the changes requested
Jul 1, 2025
3bc5b81
Refactored: added simple network image to the file
Jul 9, 2025
2f02a6e
itermediate state
Jul 14, 2025
a719662
intermediate state
Jul 14, 2025
726fcf4
made changes to improve the readability of the page
Jul 17, 2025
fbd941e
made changes to improve the readability of the page
Jul 17, 2025
95d809e
changed plots to make them more understandable
Jul 18, 2025
5dda53f
improved readability
Jul 18, 2025
961ad26
improved readability
Jul 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
263 changes: 202 additions & 61 deletions docs/examples/getting_started_with_network_dynamics.jl

Large diffs are not rendered by default.

281 changes: 281 additions & 0 deletions docs/src/assets/edgemodel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions docs/src/assets/edgemodel.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
% \documentclass[tikz,convert={outfile=\jobname.svg}]{standalone}
\documentclass[tikz,convert=pdf2svg]{standalone}
%\usetikzlibrary{...}% tikz package already loaded by 'tikz' option
\usetikzlibrary{arrows, arrows.meta}
% \tikzset{
% >=stealth',
% }
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usepackage{xcolor}

\begin{document}
\begin{tikzpicture}
\node[draw, minimum height=1.5cm](n){
Edge Model
};
\draw[->](n.east)++(0,0.4)--++(1.0,0) node[right]{$y^{\mathrm e}_{\mathrm{src}}$}; \draw[->](n.east)++(0,-0.4)--++(1.0,0) node[right]{$y^{\mathrm e}_{\mathrm{dst}}$};

\draw[<-](n.west)++(0,0.4)--++(-1.0,0) node[left]{$y^{\mathrm v}_{i}=i^{\mathrm e}_{\mathrm{src}}$};
\draw[<-](n.west)++(0,-0.4)--++(-1.0,0) node[left]{$y^{\mathrm v}_{j}=i^{\mathrm e}_{\mathrm{dst}}$};

\node[text width=3.5cm, align=center, font=\scriptsize] at ([xshift=-2.7cm, yshift=-1.2cm]n) {mapping of adjecent node outputs as edge inputs};
\end{tikzpicture}
\end{document}
2 changes: 2 additions & 0 deletions docs/src/assets/makelatexfigs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ if ! command_exists pdf2svg; then
fi

latexmk -pdflua -shell-escape mathmodel.tex
latexmk -pdflua -shell-escape edgemodel.tex
latexmk -pdflua -shell-escape nodemodel.tex
latexmk -C
254 changes: 254 additions & 0 deletions docs/src/assets/nodemodel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions docs/src/assets/nodemodel.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
% \documentclass[tikz,convert={outfile=\jobname.svg}]{standalone}
\documentclass[tikz,convert=pdf2svg]{standalone}
%\usetikzlibrary{...}% tikz package already loaded by 'tikz' option
\usetikzlibrary{arrows, arrows.meta}
% \tikzset{
% >=stealth',
% }
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usepackage{xcolor}

\begin{document}
\begin{tikzpicture}
\node[draw](n){
Node Model
};
\draw[->](n.east)--++(1.0,0) node[above, pos=.5]{$y^{\mathrm v}$};

% Draw the accumulator circle
\node[draw, circle] (acc) at ([xshift=-1.5cm]n.west) {$\mathrm{acc}$};

% Connect acc to the node
\draw[->] (acc) -- (n.west) node[pos=.5, above]{$i^{v}$};

% Add three arrows to acc with rectangular corners
\draw[<-] (acc) |- ++(-1.0,0.7) node[left](in){$y^e_i$};
\draw[<-] (acc) -- ++(-1.0,0) node[left]{$y^e_j$};
\draw[<-] (acc) |- ++(-1.0,-0.7) node[left]{$\ldots$};

% Add a label for the accumulation function
\node[text width=3cm, align=center, font=\scriptsize] at ([xshift=-.5cm, yshift=-1.2cm]acc) {accumulation of adjacent edge outputs};

\end{tikzpicture}
\end{document}
20 changes: 9 additions & 11 deletions docs/src/data_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ A [`Network`](@ref) contains a list of vertex and edge models along with a graph
However, in tight numerical loops, it will never access these lists of models directly.
Instead, the network maintains an internal representation that tracks all symbolic indices, defining the precise ordering of states and parameters in a flat array representation. To optimize performance, especially for heterogeneous networks, the network employs specialized data structures that batch identical models together.

This disconnect between the explicit lists and the internal data structures
can be confusing.
This disconnect between the explicit lists and the internal data structures can be confusing.

## Flat Parameter and State Arrays

The vertex and edge models may contain metadata, such as initial values for states and parameters.
Crucially, this metadata is **only** for building and initialization of the
simulation.
The vertex and edge models may contain metadata, such as the initial values for states and parameters.
Crucially, this metadata is **only** for the building and initialization of the simulation.
During actual simulation, the state and parameters are handled as **flat arrays**, i.e., plain `Vector{Float64}` objects.

[`NWState`](@ref) and [`NWParameter`](@ref) serve as wrappers around flat arrays and the [`Network`](@ref) objects, allowing you to inspect and modify those flat arrays by addressing vertices and edges directly.

A typical workflow is:
A typical workflow is the following:

1. Set default values in the models using the metadata (see [Metadata](@ref)).
2. Create a network (see [Network Construction](@ref)).
Expand Down Expand Up @@ -44,26 +42,26 @@ You can access the models using `getindex`/`[]` with `VIndex` or `EIndex`:
```@example data_structure
v1 === nw[VIndex(1)]
```
This can be important when changing metadata of components. i.e., both lines below are equivalent:
This can be important when changing the metadata of components. i.e., both lines below are equivalent:
```@example data_structure
set_position!(v1, (1,0))
set_position!(nw[VIndex(1)], (1,0))
nothing #hide
```

!!! note "Aliasing of component models"
Since components are not copied, multiple entries in vertex and edge lists might point to the same instance of a model.
Since components are not copied, multiple entries in the vertex and edge lists might point to the same instance of a model.
```@example data_structure
nw = Network(complete_graph(3), [v1,v2,v1], e)
v1 === nw[VIndex(1)] === nw[VIndex(3)]
```
Consequently, metadata set for one model might affect another model.
This behavior can be beneficial for performance reasons.
To force copying of components, use the `dealias` keyword:
To force the copying of components, use the `dealias` keyword:
```@example data_structure
nw = Network(complete_graph(3), [v1,v2,v1], e; dealias=true)
nw[VIndex(1)] === nw[VIndex(3)] # neither of them === v1
```

## Extracting `Network`-object from Containers
`NetworkDynamics.jl` provides a [`extract_nw`](@ref) function, to get a reference to the wrapped `Network` object from different containers, such as solution objects or integrator objects.
## Extracting a `Network`-object from Containers
`NetworkDynamics.jl` provides a [`extract_nw`](@ref) function, to get a reference to the wrapped `Network` object from different containers, such as solution objects or [integrator objects](@extref DiffEq.integrator).
64 changes: 49 additions & 15 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# NetworkDynamics

A package for working with dynamical systems on complex networks. NetworkDynamics.jl provides an interface between [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) and [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl).
It allows for high performant simulation of dynamic networks by describing the local dynamics on the edges and vertices of the graph.

The behavior of a node or an edge can be described by algebraic equations, by differential algebraic equation (DAEs) in mass matrix form or by ordinary differential equations (ODE).

The central construction is the function [`Network`](@ref) that receives functions describing the local dynamics on the edges and nodes of
a graph `g` as inputs, and returns a composite function compatible with the
*NetworkDynamics.jl* is a package to simulate dynamical systems within complex networks. It provides an interface
between the [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) and the
[DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl) packages and faciliates the simulation of
highly efficient dynamic networks by describing the local dynamics on the edges and vertices of the graph.

!!! note
Complex network systems are composed by the entities that comprise them (the nodes) and the relationships that connect
each entity with one another (the edges). The graphical depictions of such networks are called graphs. The simplest
network (which can be seen in Figure 1) is composed of two entities (so two nodes) who are only connected to each other.
This connection between the two is the edge of the system. Complex networks are composed of multiple nodes and edges,
with most nodes connected to multiple other nodes with multiple edges *(@Hans: can you created the graph of such a
network and place in here?)*

The behavior of a node or an edge can be described through the use of a) algebraic equations, b) differential algebraic
equation (DAEs) in mass matrix form or c) ordinary differential equations (ODE).

The core of the package is the function [`Network`](@ref). It accepts the functions describing the local dynamics on the
edges and nodes of the graph `g` as inputs, and returns a composite function compatible with the
DifferentialEquations.jl calling syntax.

```julia
Expand All @@ -15,26 +26,48 @@ nd(dx, x, p, t)
```

Main features:
- Clear separation of local dynamics and topology: you can easily change topology of your system or switching out dynamical components.
- High performance when working with heterogeneous models (which means heaving different local dynamics in different parts of your network).
- [Symbolic Indexing](@ref) into solutions and states: NetworkDynamics keeps track of the states of the individual subsystems.
- Different execution schemes: NetworkDynamics exploits the known inter-dependencies between components to auto parallelize execution, even on GPUs!
- Equation based models: use [ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/dev/) to define local dynamics, use `NetworkDynamics.jl` to combine them into large networks!
- Clear separation of local dynamics and topology: you can easily change the topology of your system or switch out
- dynamic components.
- High performance when working with heterogeneous models: you can have different local dynamics in different parts of
- your network.
- [Symbolic Indexing](@ref) into solutions and states: NetworkDynamics keeps track of the states of each individual
- subsystem.
- Diverse execution schemes: NetworkDynamics exploits the known inter-dependencies between components to auto
- parallelize execution, even on GPUs!
- Equation based models: you can model local dynamics using
- [ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/dev/) and them combine them into larger networks by using
- `NetworkDynamics.jl`!


## Where to begin?
Check out the [Mathematical Model](@ref) to understand the underlying modelling ideas of NetworkDynamics followed by the page on [Network Construction](@ref) to learn how to implement you own models.
To learn how to implement your own models and understand the underlying modelling ideas of NetworkDynamics you should
first read the [Mathematical Model](@ref) section, followed by section [Network Construction](@ref).

If you prefer to look at some concrete code first check out the [Getting Started](@ref) tutorial!


## Installation

Installation is straightforward with Julia's package manager.
Install Julia:
- https://julialang.org/install/
- Find your OS and follow the instructions for the installation

Install NetworkDynamics.jl with Julia's package manager:
```julia-repl
(v1.11) pkg> add NetworkDynamics
```

Next you need to install the Julia package Revise:
```julia-repl
import Pkg; Pkg.add("Revise")
```

Last you need to install the Julia package LiveServer:
```julia-repl
import Pkg; Pkg.add("LiveServer")
```



## Reproducibility

Expand Down Expand Up @@ -78,7 +111,8 @@ Pkg.status(; mode = PKGMODE_MANIFEST) # hide
```

## Funding
Development of this project was in part funded by the *German Federal Ministry for Economic Affairs and Climate Action* as part of the *OpPoDyn*-Project (Project ID 01258425/1, 2024-2027).
Development of this project was in part funded by the *German Federal Ministry for Economic Affairs and Climate Action*
as part of the *OpPoDyn*-Project (Project ID 01258425/1, 2024-2027).

```@raw html
<img src="assets/bmwk_logo_en.svg" width="300"/>
Expand Down
Loading
Loading