Network

A Network is a system consisting of connected systems. That is, a Network is actually modeled as a SubSystem.

Construction of Networks

To construct a Network we have to specify the components, the outer connectivity matrix and the inner coupling matrix. Inputs and outputs can be assigned to the Network. See the main constructor.

Jusdl.Components.Systems.SubSystems.NetworkType
Network(nodes, conmat, cplmat; inputnodeidx, outputnodeidx, clusters)

Constructs a Network consisting of nodes with the connection matrix conmat and the coupling matrix cplmat. The dynamics of the Network evolves by,

\[ \dot{x}_i = f(x_i) + \sum_{j = 1}^n \epsilon_{ij} P x_j \quad i = 1, \ldots, n\]

where $n$ is the number of nodes, $f$ is the function corresponding to individual node dynamics, $\epsilon_{ij}$ is the coupling strength between nodes $i$ and $j$. The diagonal matrix $P$ determines the state variables through which the nodes are coupled. In the equation above, we have conmat is eqaul to $E = [\epsilon_{ij}]$ and cplmat is eqaul to $P$.

inputnodeidx and outputnodeidx is the input and output node indices for the input and output, respectively. clusters is the set of indices of node groups in the same cluster. inputnodeidx and outputnodeidx may be of type Nothing, Bus or Vector{<:Link}.

source

Let us continue with examples. We first construct a couple of dynamical systems.

julia> using Jusdl # hide

julia> nodes = [LorenzSystem(Bus(3), Bus(3)) for i = 1 : 5]
5-element Array{LorenzSystem{Bus{Link{Float64}},Bus{Link{Float64}},Link{Float64},Link{Bool},Jusdl.Components.Systems.DynamicSystems.var"#22#26"{Int64,Float64,Int64,Int64,Array{Float64,2}},typeof(Jusdl.Components.Systems.DynamicSystems.allstates),Array{Float64,1},OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5,true,Array{Float64,1},Float64,Interpolant{Array{Jusdl.Components.ComponentsBase.var"#5#6"{Float64,Float64,Float64,Float64},1}},Float64,Float64,Float64,Array{Array{Float64,1},1},DiffEqBase.ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},DiffEqBase.ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Interpolant{Array{Jusdl.Components.ComponentsBase.var"#5#6"{Float64,Float64,Float64,Float64},1}},DiffEqBase.ODEFunction{true,Jusdl.Components.Systems.DynamicSystems.var"#22#26"{Int64,Float64,Int64,Int64,Array{Float64,2}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},OrdinaryDiffEq.Tsit5,OrdinaryDiffEq.InterpolationData{DiffEqBase.ODEFunction{true,Jusdl.Components.Systems.DynamicSystems.var"#22#26"{Int64,Float64,Int64,Int64,Array{Float64,2}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},DiffEqBase.ODEFunction{true,Jusdl.Components.Systems.DynamicSystems.var"#22#26"{Int64,Float64,Int64,Int64,Array{Float64,2}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),DiffEqBase.CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Array{Float64,1},Array{Float64,1},Array{Float64,1}},Array{Float64,1},Float64,Nothing}},1}:
 LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.7283602175442048, 0.36838546953416484, 0.7656752235254665], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false))
 LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.5030713580752599, 0.369420650716761, 0.16721156902938805], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false))
 LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.34370256037453184, 0.43106496937130867, 0.630235908851503], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false))
 LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.5471181968029235, 0.4961780196512342, 0.049464615531085165], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false))
 LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.9741349612423005, 0.8217237965899253, 0.5149559780652102], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false))

Then, we connect the outer coupling matrix

julia> conmat = topology(:star_graph, 5, weight=5.)
5×5 Array{Float64,2}:
 -20.0   5.0   5.0   5.0   5.0
   5.0  -5.0  -0.0  -0.0  -0.0
   5.0  -0.0  -5.0  -0.0  -0.0
   5.0  -0.0  -0.0  -5.0  -0.0
   5.0  -0.0  -0.0  -0.0  -5.0

and we construct the inner coupling matrix

julia> cplmat = coupling(3, 1)
3×3 Array{Float64,2}:
 1.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0

Now we are ready to construct the Network.

julia> net = Network(nodes, conmat, cplmat)
Network{Nothing,Bus{Link{Float64}},Link{Float64},Link{Bool},Array{AbstractSystem,1},Array{Float64,2},Array{Float64,2}}(nothing, Bus(nlinks:15, eltype:Link{Float64}, isreadable:false, iswritable:false), Link(state:open, eltype:Float64, hasmaster:false, numslaves:0, isreadable:false, iswritable:false), Link(state:open, eltype:Bool, hasmaster:false, numslaves:0, isreadable:false, iswritable:false), Callback[], UUID("3d161f94-76c9-4f42-a02f-d955577c3852"), AbstractSystem[LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.7283602175442048, 0.36838546953416484, 0.7656752235254665], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.5030713580752599, 0.369420650716761, 0.16721156902938805], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.34370256037453184, 0.43106496937130867, 0.630235908851503], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.5471181968029235, 0.4961780196512342, 0.049464615531085165], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.9741349612423005, 0.8217237965899253, 0.5149559780652102], t:0.0, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), Coupler(conmat:[-20.0 5.0 5.0 5.0 5.0; 5.0 -5.0 -0.0 -0.0 -0.0; 5.0 -0.0 -5.0 -0.0 -0.0; 5.0 -0.0 -0.0 -5.0 -0.0; 5.0 -0.0 -0.0 -0.0 -5.0], cplmat:[1.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]), Memory(ndelay:3, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), Memory(ndelay:3, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), Memory(ndelay:3, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), Memory(ndelay:3, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false)), Memory(ndelay:3, input:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false), output:Bus(nlinks:3, eltype:Link{Float64}, isreadable:false, iswritable:false))], [-20.0 5.0 … 5.0 5.0; 5.0 -5.0 … -0.0 -0.0; … ; 5.0 -0.0 … -5.0 -0.0; 5.0 -0.0 … -0.0 -5.0], [1.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0], UnitRange{Int64}[1:5])

Connection Matrices

The outer connection matrix determines the topology and the strength of the links between the nodes of the network. There exist some methods for easy construction of outer connection matrices.

Jusdl.Components.Systems.SubSystems.topologyFunction
topology(name::Symbol, args...; weight::Real=1., timevarying::Bool=false)

Returns an outer connectivity matrix whose graph is given by name. weight is the scaling vector of the connection matrix. If timevarying is true, all elements of the connectivity matrix is a function of time t.

Note

See (https://juliagraphs.github.io/LightGraphs.jl/latest/generators/#Graph-Generators-1) for different names.

Example

julia> topology(:path_graph, 5, weight=10)
5×5 Array{Int64,2}:
 -10   10    0    0    0
  10  -20   10    0    0
   0   10  -20   10    0
   0    0   10  -20   10
   0    0    0   10  -10
source
Jusdl.Components.Systems.SubSystems.cgsconnectivityFunction
cgsconnectivity(graph::AbstractGraph; weight::Real=1., timevarying::Bool=false)

Constructs an outer connnectivity matrix corresponding to connection graph stability method. graph is graph of the network, weight scales the connectivity matrix. If timevarying is true, each element of the connnectivity matrix is a function of time t.

cgsconnectivity(adjmat::AbstractMatrix; weight::Real=1.,  timevarying::Bool=false)

Constructs an outer connnectivity matrix corresponding to connection graph stability method. adjmat is the adjacency matrix of the network, weight scales the connectivity matrix. If timevarying is true, each element of the connnectivity matrix is a function of time t.

cgsconnectivity(topology::Symbol, args...; weight::Real=1., timevarying::Bool=false, kwargs...)

Constructs an outer connnectivity matrix corresponding to connection graph stability method. topology is the name of the graph of the network, weight scales the connectivity matrix. If timevarying is true, each element of the connnectivity matrix is a function of time t.

Example

julia> cgsconnectivity(:path_graph, 5)
5×5 Array{Float64,2}:
 -0.8   0.8   0.0   0.0   0.0
  0.8  -2.0   1.2   0.0   0.0
  0.0   1.2  -2.4   1.2   0.0
  0.0   0.0   1.2  -2.0   0.8
  0.0   0.0   0.0   0.8  -0.8

References

  • Belykh, V. N., Belykh, I. V., & Hasler, M. (2004). Connection graph stability method for synchronized coupled chaotic systems. Physica D: nonlinear phenomena, 195(1-2), 159-187.
source
Jusdl.Components.Systems.SubSystems.clusterconnectivityFunction
clusterconnectivity(clusters::AbstractRange...; weight=1., timevarying::Bool=false)

Construct an outer connnectivity matrix using arbitrary clusters method. clusters is the set of node indices in each clusters. weight scales the connectivity matrix. If timevarying is true, all elements of the connectivity matrix is a function of time t.

Example

julia> clusterconnectivity(1:2, 3:6)
6×6 Array{Float64,2}:
 -3.0   3.0  -1.0   1.0   0.0   0.0
  3.0  -3.0   1.0  -1.0   0.0   0.0
 -1.0   1.0  -9.0   3.0   3.0   3.0
  1.0  -1.0   3.0  -9.0   3.0   3.0
  0.0   0.0   3.0   3.0  -9.0   3.0
  0.0   0.0   3.0   3.0   3.0  -9.0

References

  • Ma, Z., Liu, Z., & Zhang, G. (2006). A new method to realize cluster synchronization in connected chaotic networks. Chaos: An Interdisciplinary Journal of Nonlinear Science, 16(2), 023103.
source

Plotting of Network

It is also possible to plot the networks. Use gplot function for this purpose.

Modifying Networks

The Networks can be modified through its connections. For example, the weight of the connection between nodes of the network can be changed or a connection can be deleted.

Full API

Jusdl.Components.Systems.SubSystems.couplingFunction
coupling(d, idx::Vector{Int})

Returns a d-by-d diagonal matrix whose diagonal elements are ones corresponding to idx.

coupling(d, idx::Int)

Returns a d-by-d diagonal matrix whose diagonal element is one corresponding to idx.

Example

julia> coupling(3, [1, 2])
3×3 Array{Float64,2}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  0.0

julia> coupling(3, 1)
3×3 Array{Float64,2}:
 1.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0
source
Jusdl.Components.Systems.SubSystems.maketimevaryingFunction
maketimevarying(mat::AbstractMatrix{<:Real})

Returns a matrix of function of time t corresponding to mat.

Example

julia> a = collect(reshape(1:9, 3, 3))
3×3 Array{Int64,2}:
 1  4  7
 2  5  8
 3  6  9

julia> b = maketimevarying(a);

julia> b[1, 1](0.)
1

julia> b[3, 2](0.)
6
source