Network
A Network is a system consisting of connected systems. That is, a Network is actually modelled 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.Network — TypeNetwork(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,
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}.
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"#23#27"{Int64,Float64,Int64,Int64,Array{Float64,2}},typeof(Jusdl.Components.Systems.DynamicSystems.allstates),Array{Float64,1},Array{Float64,1},Solver{OrdinaryDiffEq.Tsit5,Any}},1}:
LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.7274835213045412, 0.14593127475235756, 0.6189567024088121], 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.2757172958397869, 0.6060072782012913, 0.06820973409796527], 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.7305023361935938, 0.021274538271592203, 0.3770357110839815], 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.3063960499267533, 0.2435871923636288, 0.5681713314875976], 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.9763993397680202, 0.3218343166547919, 0.2521268857088039], 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.0and 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.0Now 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("414f4bc6-d355-49ab-aa96-def51be7470b"), AbstractSystem[LorenzSystem(sigma:10.0, beta:2.6666666666666665, rho:28.0, gamma:1.0, state:[0.7274835213045412, 0.14593127475235756, 0.6189567024088121], 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.2757172958397869, 0.6060072782012913, 0.06820973409796527], 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.7305023361935938, 0.021274538271592203, 0.3770357110839815], 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.3063960499267533, 0.2435871923636288, 0.5681713314875976], 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.9763993397680202, 0.3218343166547919, 0.2521268857088039], 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.topology — Functiontopology(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.
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 -10Jusdl.Components.Systems.SubSystems.cgsconnectivity — Functioncgsconnectivity(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.8References
- 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.
Jusdl.Components.Systems.SubSystems.clusterconnectivity — Functionclusterconnectivity(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.0References
- 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.
Plotting of Network
It is also possible to plot the networks. Use gplot function for this purpose.
GraphPlot.gplot — Functiongplplot(net::Network, args...; kwargs...)Plots net.
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.
Jusdl.Components.Systems.SubSystems.changeweight — Functionchangeweight(net::Network, src::Int, dst::Int, weight)Changes the weight of the coupling between the nodes src and dst with weight.
Jusdl.Components.Systems.SubSystems.deletelink — Functiondeletelink(net::Network, src::Int, dst::Int)Changes the strength of the link between src and dst to zero.
Full API
Jusdl.Components.Systems.SubSystems.nodes — Methodnodes(net::Network)Returns the nodes of net. nodes are the dynamical system components of net.
Jusdl.Components.Systems.SubSystems.numnodes — Methodnumnodes(net::Network)Returns the number of nodes in net.
Jusdl.Components.Systems.SubSystems.dimnodes — Methoddimnodes(net::Network)Returns the dimension of nodes in net.
Jusdl.Components.Systems.SubSystems.coupling — Functioncoupling(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.0Jusdl.Components.Systems.SubSystems.maketimevarying — Functionmaketimevarying(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