Skip to content

Commit ba5b4f3

Browse files
committed
update network cosntruction
1 parent daaec94 commit ba5b4f3

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

docs/src/network_construction.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Building a Network
44
The main type of `NetworkDynamics.jl` is a [`Network`](@ref).
5-
A network bundles various component models (edge and vertex models) together with a graph to form a callable object which represents the right hand side (RHS) of the overall dynamical system, see [Mathematical Model](@ref).
5+
A network bundles various component models (edge and vertex models) together with a graph to form a callable object which represents the right hand side (RHS) of the overall dynamical system, see [Mathematical Model](@ref).
66

77
A `Network` is build by passing a graph `g`, vertex models `vertexm` and edge models `edgem` to the [`Network`](@ref) constructor:.
88
```julia
@@ -11,19 +11,31 @@ nw = Network(g, vertexm, edgem; kwargs...)
1111

1212
Two important keywords for the [`Network`](@ref) constructor are:
1313

14-
- `execution`:
14+
- `execution`:
1515
Defines the [`ExecutionStyle`](@ref) of the coreloop, e.g. `SequentialExecution{true}()`.
16-
A execution style is a special Julia object, which tells the backend how to parallelize (e.g. `ThreadedExecution{true}()` will use native Julia threads to parallelize the RHS call).
16+
A execution style is a special Julia object, which tells the backend how to parallelize (e.g. `ThreadedExecution{true}()` will use native Julia threads to parallelize the RHS call).
1717
A list of available executions styles can be found under [Execution Types](@ref) in the API.
1818

1919
- `aggregator`:
2020
Instructs the backend how to perform the aggregation and which aggregation function to use.
2121
Aggregation is the process of creating a single vertex input by reducing over the outputs of adjecent edges of said vertex. The `aggregator` contains both the function and the algorithm. E.g. `SequentialAggregator(+)` is a sequential aggregation by summation. A list of availabe Aggregators can be found under [`Aggregators`](@ref) in the API.
2222

23+
### Graphless Constructor
24+
If each of the network components has a "graphelement" [metadata](@ref Metadata), we may omit the explicit graph.
25+
```julia
26+
nw = Network(vertexm, edgem)
27+
```
28+
The graphelement metadata can be set using the following syntax:
29+
```julia
30+
VertexModel(; ..., vidx=1) # places vertex at position 1
31+
EdgeModel(; ..., src=1, dst=2) # places edge between 1 and 2
32+
EdgeModel(; ..., src=:v1, dst=:v2) # places edge between vertices with names `:v1` and `:v2`
33+
```
34+
2335
## Building `VertexModel`s
2436
This chapter will walk you through the most important aspects of defining a custom vertex model. For a list of all keyword arguments please check out the docstring of [`VertexModel`](@ref).
2537

26-
As an example, we'll construct an second order kuramoto model, because that is what the package does.
38+
As an example, we'll construct an second order kuramoto model.
2739
```@example construction
2840
using NetworkDynamics #hide
2941
function kuramoto_f!(dv, v, esum, p, t)
@@ -65,7 +77,7 @@ Lastly, we define improved names for our states and parameters as well as assign
6577
Whenever you provide a `sym` keyword the corresponding `dim` keyword stops being neccessary. So, we end up with a relatively short definition
6678
```@example construction
6779
VertexModel(; f=kuramoto_f!, g=1,
68-
sym=[:θ, :ω], psym=[:M=>1, :P=>0.1, :D=>0],
80+
sym=[:θ, :ω], psym=[:M=>1, :P=>0.1, :D=>0],
6981
insym=[:P_nw], name=:swing, vidx=1)
7082
```
7183

@@ -102,7 +114,7 @@ end
102114
EdgeModel(;g=AntiSymmetric(edge_g_ff!), pdim=1, outdim=1)
103115
```
104116
This can also lead to briefer output naming. Available single sided wrappers are:
105-
- [`Directed`](@ref) (no coupling at `src`),
117+
- [`Directed`](@ref) (no coupling at `src`),
106118
- [`AntiSymmetric`](@ref) (same coupling at `src` and `dst`),
107119
- [`Symmetric`](@ref) (inverse coupling at `dst`) and
108120
- [`Fiducial`](@ref) (define separate `g` for both ends).
@@ -114,5 +126,3 @@ function edge_g_s!(ydst, vsrc, vdst, p, t)
114126
end
115127
EdgeModel(;g=AntiSymmetric(edge_g_ff!), psym=:K=>1, outsym=:P, insym=:θ, src=1, dst=4)
116128
```
117-
118-

0 commit comments

Comments
 (0)