From d1b111668c0e02fb715d5137c1a42c02bf898edc Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Mon, 16 Oct 2023 13:12:09 +0000 Subject: [PATCH] build based on 646a34d --- v0.8.2/.documenter-siteinfo.json | 2 +- v0.8.2/BasicConstructors/index.html | 2 +- v0.8.2/Library/index.html | 2 +- v0.8.2/Multithreading/index.html | 2 +- v0.8.2/SDEVertex/5474df40.svg | 48 ------- v0.8.2/SDEVertex/9ae22bdd.svg | 48 +++++++ v0.8.2/SDEVertex/dbaa6d16.svg | 48 ------- v0.8.2/SDEVertex/eae58088.svg | 48 +++++++ v0.8.2/SDEVertex/index.html | 4 +- v0.8.2/accessing_edge_variables/index.html | 2 +- .../directed_and_weighted_graphs/f5734236.svg | 132 ++++++++++++++++++ .../directed_and_weighted_graphs/f688b770.svg | 132 ------------------ .../directed_and_weighted_graphs/index.html | 2 +- .../2029525f.svg | 82 ----------- .../9c5f74e2.svg | 62 -------- .../ae78e32c.svg | 62 ++++++++ .../ce4d7524.svg | 82 +++++++++++ .../index.html | 4 +- .../{9b6a91ac.svg => 4cbc5008.svg} | 96 ++++++------- .../{50fddf9e.svg => eb0a525c.svg} | 96 ++++++------- v0.8.2/heterogeneous_system/index.html | 6 +- v0.8.2/index.html | 2 +- .../{3508ce7e.svg => d031c52a.svg} | 88 ++++++------ v0.8.2/kuramoto_delay/index.html | 14 +- v0.8.2/parameters/index.html | 2 +- 25 files changed, 534 insertions(+), 534 deletions(-) delete mode 100644 v0.8.2/SDEVertex/5474df40.svg create mode 100644 v0.8.2/SDEVertex/9ae22bdd.svg delete mode 100644 v0.8.2/SDEVertex/dbaa6d16.svg create mode 100644 v0.8.2/SDEVertex/eae58088.svg create mode 100644 v0.8.2/directed_and_weighted_graphs/f5734236.svg delete mode 100644 v0.8.2/directed_and_weighted_graphs/f688b770.svg delete mode 100644 v0.8.2/getting_started_with_network_dynamics/2029525f.svg delete mode 100644 v0.8.2/getting_started_with_network_dynamics/9c5f74e2.svg create mode 100644 v0.8.2/getting_started_with_network_dynamics/ae78e32c.svg create mode 100644 v0.8.2/getting_started_with_network_dynamics/ce4d7524.svg rename v0.8.2/heterogeneous_system/{9b6a91ac.svg => 4cbc5008.svg} (96%) rename v0.8.2/heterogeneous_system/{50fddf9e.svg => eb0a525c.svg} (96%) rename v0.8.2/kuramoto_delay/{3508ce7e.svg => d031c52a.svg} (95%) diff --git a/v0.8.2/.documenter-siteinfo.json b/v0.8.2/.documenter-siteinfo.json index eabe0aa2..343a500f 100644 --- a/v0.8.2/.documenter-siteinfo.json +++ b/v0.8.2/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.6.7","generation_timestamp":"2023-10-16T13:01:12","documenter_version":"1.1.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.6.7","generation_timestamp":"2023-10-16T13:11:54","documenter_version":"1.1.1"}} \ No newline at end of file diff --git a/v0.8.2/BasicConstructors/index.html b/v0.8.2/BasicConstructors/index.html index 79c7df0c..d960a7fa 100644 --- a/v0.8.2/BasicConstructors/index.html +++ b/v0.8.2/BasicConstructors/index.html @@ -51,4 +51,4 @@ edge = ODEEdge(; f=edgefunction!, dim=1, coupling=:undirected) edgearr = [edge for e in edges(g)] -nd = network_dynamics(vertexarr, edgearr, g)

Now we have an ODEFunction nd that can be solved with the tools provided by DifferentialEquations.jl.

For more details check out the Tutorials section.

+nd = network_dynamics(vertexarr, edgearr, g)

Now we have an ODEFunction nd that can be solved with the tools provided by DifferentialEquations.jl.

For more details check out the Tutorials section.

diff --git a/v0.8.2/Library/index.html b/v0.8.2/Library/index.html index 2421015d..85d780a1 100644 --- a/v0.8.2/Library/index.html +++ b/v0.8.2/Library/index.html @@ -1,2 +1,2 @@ -Library · NetworkDynamics

Library

Public Interface

The following functions are designed for public use

NetworkDynamics.network_dynamicsFunction
network_dynamics(vertices!, edges!, g; parallel = false)

Assembles the the dynamical equations of the network problem into an ODEFunction compatible with the DifferentialEquations.jl solvers. Takes as arguments an array of VertexFunctions vertices!, an array of EdgeFunctions edges! and a Graphs.jl object g. The optional argument parallel is a boolean value that denotes if the central loop should be executed in parallel with the number of threads set by the environment variable JULIA_NUM_THREADS.

source
NetworkDynamics.StaticVertexFunction
StaticVertex(; f, dim, sym)

Wrapper for ODEVertex with 0 mass matrix, i.e. static behaviour / algebraic constraint in mass matrix form.

f describes the local behaviour at a static node and has to respect the following calling syntax

f(v, edges, p, t) -> nothing

Here v, p and t are the usual arguments, while edges is an arrays containing the edges for which the described vertex is the destination (in-edges for directed graphs).

dim is the number of independent variables in the vertex equations and sym is an array of symbols for these variables.

For more details see the documentation.

source
NetworkDynamics.ODEVertexType
ODEVertex(; f, dim, mass_matrix, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a dynamic node and has to respect the following calling syntax

f(dv, v, edges, p, t) -> nothing

Here dv, v, p and t are the usual ODE arguments, while edges is an Array containing the edges for which the vertex is the destination (in-edges for directed graphs).

dim is the number of independent variables in the vertex equations and sym is an array of symbols for these variables. mass_matrix is an optional argument that defaults to the identity matrix I. If a mass matrix M is given the system M * dv = f will be solved.

For more details see the documentation.

source
NetworkDynamics.DDEVertexType
DDEVertex(; f, dim, mass_matrix, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a dynamic node and has to respect the following calling syntax

f(dv, v, edges, h, p, t) -> nothing

Here dv, v, p and t are the usual ODE arguments, while edges is an Arry of incoming edges. h is the history array for v.

  • dim is the number of independent variables in the edge equations and
  • sym is an array of symbols for these variables.
  • mass_matrix is an optional argument that defaults to the identity matrix I. If a mass matrix M is given the system M * de = f will be solved.

For more details see the documentation.

source
NetworkDynamics.StaticEdgeType
StaticEdge(; f, dim, coupling, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a static edge and has to respect the following calling syntax

f(e, v_s, v_t, p, t) -> nothing

Here e, p and t are the usual arguments, while v_s and v_d are arrays containing the vertices which are the source and destination of the described edge.

  • dim is the number of independent variables in the edge equations and
  • sym is an array of symbols for these variables.
  • coupling is a Symbol describing if the EdgeFunction is intended for a directed graph (:directed) or for an undirected graph ({:undirected, :symmetric, :antisymmetric, :fiducial}). :directed is intended for directed graphs. :undirected is the default option and is only compatible with SimpleGraph. In this case f should specify the coupling from a source vertex to a destination vertex. :symmetric and :antisymmetric trigger performance optimizations, if f has that symmetry property. :fiducial lets the user specify both the coupling from src to dst, as well as the coupling from dst to src and is intended for advanced users, i.e. the edge gets passed a vector of 2dim edge states, where the first dim elements will be presented to the dst and the second dim elements will be presented to src,

For more details see the documentation.

source
NetworkDynamics.ODEEdgeType
ODEEdge(; f, dim, mass_matrix, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a dynamic edge and has to respect the following calling syntax

f(de, e, v_s, v_t, p, t) -> nothing

Here de, e, p and t are the usual arguments, while v_s and v_d are arrays containing the vertices which are the source and destination of the described edge.

dim is the number of independent variables in the edge equations and sym is an array of symbols for these variables. For more details see the documentation. mass_matrix is an optional argument that defaults to the identity matrix I. If a mass matrix M is given the system M * de = f will be solved.

For more details see the documentation.

source
NetworkDynamics.StaticDelayEdgeType
StaticDelayEdge(; f, dim, coupling, sym)

Like a static edge but with extra arguments for the history of the source and destination vertices. This is NOT a DDEEdge.

source
NetworkDynamics.sum_coupling!Function
sum_coupling!(e_sum, dst_edges)

A small utility function for writing diffusion dynamics. It provides the sum of all incoming edges.

source
+Library · NetworkDynamics

Library

Public Interface

The following functions are designed for public use

NetworkDynamics.network_dynamicsFunction
network_dynamics(vertices!, edges!, g; parallel = false)

Assembles the the dynamical equations of the network problem into an ODEFunction compatible with the DifferentialEquations.jl solvers. Takes as arguments an array of VertexFunctions vertices!, an array of EdgeFunctions edges! and a Graphs.jl object g. The optional argument parallel is a boolean value that denotes if the central loop should be executed in parallel with the number of threads set by the environment variable JULIA_NUM_THREADS.

source
NetworkDynamics.StaticVertexFunction
StaticVertex(; f, dim, sym)

Wrapper for ODEVertex with 0 mass matrix, i.e. static behaviour / algebraic constraint in mass matrix form.

f describes the local behaviour at a static node and has to respect the following calling syntax

f(v, edges, p, t) -> nothing

Here v, p and t are the usual arguments, while edges is an arrays containing the edges for which the described vertex is the destination (in-edges for directed graphs).

dim is the number of independent variables in the vertex equations and sym is an array of symbols for these variables.

For more details see the documentation.

source
NetworkDynamics.ODEVertexType
ODEVertex(; f, dim, mass_matrix, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a dynamic node and has to respect the following calling syntax

f(dv, v, edges, p, t) -> nothing

Here dv, v, p and t are the usual ODE arguments, while edges is an Array containing the edges for which the vertex is the destination (in-edges for directed graphs).

dim is the number of independent variables in the vertex equations and sym is an array of symbols for these variables. mass_matrix is an optional argument that defaults to the identity matrix I. If a mass matrix M is given the system M * dv = f will be solved.

For more details see the documentation.

source
NetworkDynamics.DDEVertexType
DDEVertex(; f, dim, mass_matrix, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a dynamic node and has to respect the following calling syntax

f(dv, v, edges, h, p, t) -> nothing

Here dv, v, p and t are the usual ODE arguments, while edges is an Arry of incoming edges. h is the history array for v.

  • dim is the number of independent variables in the edge equations and
  • sym is an array of symbols for these variables.
  • mass_matrix is an optional argument that defaults to the identity matrix I. If a mass matrix M is given the system M * de = f will be solved.

For more details see the documentation.

source
NetworkDynamics.StaticEdgeType
StaticEdge(; f, dim, coupling, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a static edge and has to respect the following calling syntax

f(e, v_s, v_t, p, t) -> nothing

Here e, p and t are the usual arguments, while v_s and v_d are arrays containing the vertices which are the source and destination of the described edge.

  • dim is the number of independent variables in the edge equations and
  • sym is an array of symbols for these variables.
  • coupling is a Symbol describing if the EdgeFunction is intended for a directed graph (:directed) or for an undirected graph ({:undirected, :symmetric, :antisymmetric, :fiducial}). :directed is intended for directed graphs. :undirected is the default option and is only compatible with SimpleGraph. In this case f should specify the coupling from a source vertex to a destination vertex. :symmetric and :antisymmetric trigger performance optimizations, if f has that symmetry property. :fiducial lets the user specify both the coupling from src to dst, as well as the coupling from dst to src and is intended for advanced users, i.e. the edge gets passed a vector of 2dim edge states, where the first dim elements will be presented to the dst and the second dim elements will be presented to src,

For more details see the documentation.

source
NetworkDynamics.ODEEdgeType
ODEEdge(; f, dim, mass_matrix, sym)

Wrapper that ensures compatibility of a mutating function f with the key constructor network_dynamics.

f describes the local behaviour at a dynamic edge and has to respect the following calling syntax

f(de, e, v_s, v_t, p, t) -> nothing

Here de, e, p and t are the usual arguments, while v_s and v_d are arrays containing the vertices which are the source and destination of the described edge.

dim is the number of independent variables in the edge equations and sym is an array of symbols for these variables. For more details see the documentation. mass_matrix is an optional argument that defaults to the identity matrix I. If a mass matrix M is given the system M * de = f will be solved.

For more details see the documentation.

source
NetworkDynamics.StaticDelayEdgeType
StaticDelayEdge(; f, dim, coupling, sym)

Like a static edge but with extra arguments for the history of the source and destination vertices. This is NOT a DDEEdge.

source
NetworkDynamics.sum_coupling!Function
sum_coupling!(e_sum, dst_edges)

A small utility function for writing diffusion dynamics. It provides the sum of all incoming edges.

source
diff --git a/v0.8.2/Multithreading/index.html b/v0.8.2/Multithreading/index.html index 6da6b08d..0ecae247 100644 --- a/v0.8.2/Multithreading/index.html +++ b/v0.8.2/Multithreading/index.html @@ -1,2 +1,2 @@ -Multi-Threading · NetworkDynamics

Multi-Threading

Since version 0.3.0 multi-threading via the Threads.@threads macro is possible. This allows julia to integrate different nodes and edges in different threads, and can lead to significant performance gains on parallel architectures. To enable multi-threading call network_dynamics with the keyword argument parallel=true.

network_dynamics(vertices!, edges!, graph; parallel=true)

In order for this to take effect, multiple threads have to be available. This is achieved by setting the environment variable JULIA_NUM_THREADS before starting Julia. To start Julia from a bash shell and with 4 threads use:

$ env JULIA_NUM_THREADS=4 julia

If you are using Juno for the Atom text editor JULIA_NUM_THREADS is set to the number of physical cores of your processor by default. This is also the number of threads we recommend to use.

Note

The thread handling causes an overhead in the order of 20 μs per call to the ODE function which might impair performance on small networks (<100 nodes) or on single core machines. In theses cases network_dynamics can be called without any additional arguments, since parallel defaults to false.

For more information on setting environment varibales see the Julia documentation.

+Multi-Threading · NetworkDynamics

Multi-Threading

Since version 0.3.0 multi-threading via the Threads.@threads macro is possible. This allows julia to integrate different nodes and edges in different threads, and can lead to significant performance gains on parallel architectures. To enable multi-threading call network_dynamics with the keyword argument parallel=true.

network_dynamics(vertices!, edges!, graph; parallel=true)

In order for this to take effect, multiple threads have to be available. This is achieved by setting the environment variable JULIA_NUM_THREADS before starting Julia. To start Julia from a bash shell and with 4 threads use:

$ env JULIA_NUM_THREADS=4 julia

If you are using Juno for the Atom text editor JULIA_NUM_THREADS is set to the number of physical cores of your processor by default. This is also the number of threads we recommend to use.

Note

The thread handling causes an overhead in the order of 20 μs per call to the ODE function which might impair performance on small networks (<100 nodes) or on single core machines. In theses cases network_dynamics can be called without any additional arguments, since parallel defaults to false.

For more information on setting environment varibales see the Julia documentation.

diff --git a/v0.8.2/SDEVertex/5474df40.svg b/v0.8.2/SDEVertex/5474df40.svg deleted file mode 100644 index 7447295e..00000000 --- a/v0.8.2/SDEVertex/5474df40.svg +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0.8.2/SDEVertex/9ae22bdd.svg b/v0.8.2/SDEVertex/9ae22bdd.svg new file mode 100644 index 00000000..763f29fb --- /dev/null +++ b/v0.8.2/SDEVertex/9ae22bdd.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/SDEVertex/dbaa6d16.svg b/v0.8.2/SDEVertex/dbaa6d16.svg deleted file mode 100644 index e5e2da24..00000000 --- a/v0.8.2/SDEVertex/dbaa6d16.svg +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0.8.2/SDEVertex/eae58088.svg b/v0.8.2/SDEVertex/eae58088.svg new file mode 100644 index 00000000..636a748e --- /dev/null +++ b/v0.8.2/SDEVertex/eae58088.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/SDEVertex/index.html b/v0.8.2/SDEVertex/index.html index 0b5d62a9..1b9c8b5d 100644 --- a/v0.8.2/SDEVertex/index.html +++ b/v0.8.2/SDEVertex/index.html @@ -31,10 +31,10 @@ ode_sol = solve(ode_prob, Tsit5()) using Plots, LaTeXStrings -plot(ode_sol; vars=syms_containing(nd, "ω"), ylims=(-1.0, 1.0), ylabel=L"\omega", legend=false, fmt=:png)Example block output

We see that this is in fact a fixpoint solution. We will later use this as an initial condition for the numerical integration of the SDE system.

Adding a Stochastic Layer

For adding the stochastic part of the dynamics we have to define a second graph layer. In our example, the fluctuations at different nodes are independent of each other. Therefore, we define a second graph with the same number of vertices but without any edges.

h = SimpleGraph(4, 0)

The dynamics at the nodes has to have the same dimension as in the deterministic case. In our example we only have fluctuations in the second variable.

function fluctuation!(dx, x, edges, p, t)
+plot(ode_sol; vars=syms_containing(nd, "ω"), ylims=(-1.0, 1.0), ylabel=L"\omega", legend=false, fmt=:png)
Example block output

We see that this is in fact a fixpoint solution. We will later use this as an initial condition for the numerical integration of the SDE system.

Adding a Stochastic Layer

For adding the stochastic part of the dynamics we have to define a second graph layer. In our example, the fluctuations at different nodes are independent of each other. Therefore, we define a second graph with the same number of vertices but without any edges.

h = SimpleGraph(4, 0)

The dynamics at the nodes has to have the same dimension as in the deterministic case. In our example we only have fluctuations in the second variable.

function fluctuation!(dx, x, edges, p, t)
     dx[1] = 0.0
     dx[2] = 0.05
 end

Now we can construct the dynamics of the second layer by using network_dynamics(). Since the graph structure of the stochastic layer has no edges we can take the edge function of the deterministic case as a placeholder.

fluctuation_vertex = ODEVertex(; f=fluctuation!, dim=2)
 nd_noise = network_dynamics(fluctuation_vertex, powerflow_edge, h)
[ Info: Reconstructing EdgeFunction with :undefined coupling type..

Simulating the SDE

Finally, we can create an SDEProblem and solve it with DifferentialEquations.

sde_prob = SDEProblem(nd, nd_noise, u0, (0.0, 500.0), p)
 sde_sol = solve(sde_prob, SOSRA())
-plot(sde_sol; vars=syms_containing(nd, "ω"), ylims=(-1.0, 1.0), ylabel=L"\omega", legend=false, fmt=:png)
Example block output

More details on SDE problems, e.g. how to include correlations or how to define an EnsembleProblem, can be found in the documentation of DifferentialEquations.

+plot(sde_sol; vars=syms_containing(nd, "ω"), ylims=(-1.0, 1.0), ylabel=L"\omega", legend=false, fmt=:png)Example block output

More details on SDE problems, e.g. how to include correlations or how to define an EnsembleProblem, can be found in the documentation of DifferentialEquations.

diff --git a/v0.8.2/accessing_edge_variables/index.html b/v0.8.2/accessing_edge_variables/index.html index a97eac26..63b638e9 100644 --- a/v0.8.2/accessing_edge_variables/index.html +++ b/v0.8.2/accessing_edge_variables/index.html @@ -12,4 +12,4 @@ edgevals end cb = SavingCallback(saving_func, saved_values) -sol = solve(prob, Tsit5(); callback=cb)

The variables saved_values will contain the stored edge values. At the moment this method requires detailed knowledge of the internal data structures. Our plan is to simplify this in a future release.

+sol = solve(prob, Tsit5(); callback=cb)

The variables saved_values will contain the stored edge values. At the moment this method requires detailed knowledge of the internal data structures. Our plan is to simplify this in a future release.

diff --git a/v0.8.2/directed_and_weighted_graphs/f5734236.svg b/v0.8.2/directed_and_weighted_graphs/f5734236.svg new file mode 100644 index 00000000..53eb0165 --- /dev/null +++ b/v0.8.2/directed_and_weighted_graphs/f5734236.svg @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/directed_and_weighted_graphs/f688b770.svg b/v0.8.2/directed_and_weighted_graphs/f688b770.svg deleted file mode 100644 index 7c2789cc..00000000 --- a/v0.8.2/directed_and_weighted_graphs/f688b770.svg +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0.8.2/directed_and_weighted_graphs/index.html b/v0.8.2/directed_and_weighted_graphs/index.html index d13906e3..13c724d6 100644 --- a/v0.8.2/directed_and_weighted_graphs/index.html +++ b/v0.8.2/directed_and_weighted_graphs/index.html @@ -55,4 +55,4 @@ prob = ODEProblem(fhn_network!, x0, tspan, p) sol = solve(prob, AutoTsit5(TRBDF2()));

Plotting

The plot of the excitatory variables shows that they synchronize for this choice of parameters.

using Plots
 
-plot(sol; vars=idx_containing(fhn_network!, :u), legend=false, ylim=(-5, 5), fmt=:png)
Example block output +plot(sol; vars=idx_containing(fhn_network!, :u), legend=false, ylim=(-5, 5), fmt=:png)Example block output diff --git a/v0.8.2/getting_started_with_network_dynamics/2029525f.svg b/v0.8.2/getting_started_with_network_dynamics/2029525f.svg deleted file mode 100644 index 70eb2975..00000000 --- a/v0.8.2/getting_started_with_network_dynamics/2029525f.svg +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0.8.2/getting_started_with_network_dynamics/9c5f74e2.svg b/v0.8.2/getting_started_with_network_dynamics/9c5f74e2.svg deleted file mode 100644 index c33b0e43..00000000 --- a/v0.8.2/getting_started_with_network_dynamics/9c5f74e2.svg +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v0.8.2/getting_started_with_network_dynamics/ae78e32c.svg b/v0.8.2/getting_started_with_network_dynamics/ae78e32c.svg new file mode 100644 index 00000000..7c1929fc --- /dev/null +++ b/v0.8.2/getting_started_with_network_dynamics/ae78e32c.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/getting_started_with_network_dynamics/ce4d7524.svg b/v0.8.2/getting_started_with_network_dynamics/ce4d7524.svg new file mode 100644 index 00000000..1f713fa4 --- /dev/null +++ b/v0.8.2/getting_started_with_network_dynamics/ce4d7524.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/getting_started_with_network_dynamics/index.html b/v0.8.2/getting_started_with_network_dynamics/index.html index 8c1fd9e6..8f26421f 100644 --- a/v0.8.2/getting_started_with_network_dynamics/index.html +++ b/v0.8.2/getting_started_with_network_dynamics/index.html @@ -24,7 +24,7 @@ x0 = randn(N) # random initial conditions ode_prob = ODEProblem(nd, x0, (0.0, 4.0)) sol = solve(ode_prob, Tsit5());

We are solving the diffusion problem on the time interval $[0, 4]$ with the Tsit5() algorithm, which is recommended by the authors of DifferentialEquations.jl for most non-stiff problems.

using Plots
-plot(sol; vars=syms_containing(nd, "v"), fmt=:png)
Example block output

The plotting is straightforward. The vars keyword allows us to pass a list of indices or symbols specifiying the variables we want to plot. Symbols can be thought of as names given to the interal variables of an ODEFunction, much like the variables $x$ or $\phi$ in mathematical notation. The default symbol for vertex variables is v, however we are free to specify other symbols by passing them to the ODEVertex constructor.

syms_containing is a helper function that returns all symbols of an ODEProblem containg a specific string (or symbol).

To illustrate a very simple multi-dimensional case, in the following we simulate two independent diffusions on an identical network. The first uses the symbol x and is started with initial conditions drawn from the standard normal distribution $N(0,1)$, the second uses the symbol ϕ with squared standard normal inital conditions.

The symbols have to be passed with the keyword sym to ODEVertex.

N = 10 # number of nodes
+plot(sol; vars=syms_containing(nd, "v"), fmt=:png)
Example block output

The plotting is straightforward. The vars keyword allows us to pass a list of indices or symbols specifiying the variables we want to plot. Symbols can be thought of as names given to the interal variables of an ODEFunction, much like the variables $x$ or $\phi$ in mathematical notation. The default symbol for vertex variables is v, however we are free to specify other symbols by passing them to the ODEVertex constructor.

syms_containing is a helper function that returns all symbols of an ODEProblem containg a specific string (or symbol).

To illustrate a very simple multi-dimensional case, in the following we simulate two independent diffusions on an identical network. The first uses the symbol x and is started with initial conditions drawn from the standard normal distribution $N(0,1)$, the second uses the symbol ϕ with squared standard normal inital conditions.

The symbols have to be passed with the keyword sym to ODEVertex.

N = 10 # number of nodes
 k = 4  # average degree
 g = barabasi_albert(N, k) # a little more exciting than a bare random graph
 
@@ -39,4 +39,4 @@
 
 
 # Try plotting the variables ϕ_i yourself. [To write ϕ type \phi and press TAB]
-plot(sol_2; vars=syms_containing(nd_2, "x"), fmt=:png)
Example block output

Appendix: The network Laplacian $L$

The diffusion equation on a network can be rewritten as

\[\dot v_i = \sum_{j=1}^N A_{ji} v_j - d_i v_i = e_i^T A v - d_i v_i \]

where $d_i$ is the degree of node $i$ and $e_i^T$ is the $i$-th standard basis vector. Introducing the diagonal matrix $D$ that has the degree of node $i$ in its $i$-th row and the Laplacian matrix $L = D - A$ we arrive at

\[\dot v = e_i^T(A - D) v\]

and finally

\[\dot v = - L v\]

This is a linear system of ODEs and its solution is a matrix exponential. To study the asymptotic behaviour of the system it suffices to analyze the eigenspectrum of $L$. For this reason $L$ is an important construction in network science.

+plot(sol_2; vars=syms_containing(nd_2, "x"), fmt=:png)Example block output

Appendix: The network Laplacian $L$

The diffusion equation on a network can be rewritten as

\[\dot v_i = \sum_{j=1}^N A_{ji} v_j - d_i v_i = e_i^T A v - d_i v_i \]

where $d_i$ is the degree of node $i$ and $e_i^T$ is the $i$-th standard basis vector. Introducing the diagonal matrix $D$ that has the degree of node $i$ in its $i$-th row and the Laplacian matrix $L = D - A$ we arrive at

\[\dot v = e_i^T(A - D) v\]

and finally

\[\dot v = - L v\]

This is a linear system of ODEs and its solution is a matrix exponential. To study the asymptotic behaviour of the system it suffices to analyze the eigenspectrum of $L$. For this reason $L$ is an important construction in network science.

diff --git a/v0.8.2/heterogeneous_system/9b6a91ac.svg b/v0.8.2/heterogeneous_system/4cbc5008.svg similarity index 96% rename from v0.8.2/heterogeneous_system/9b6a91ac.svg rename to v0.8.2/heterogeneous_system/4cbc5008.svg index de891518..7e43c6d4 100644 --- a/v0.8.2/heterogeneous_system/9b6a91ac.svg +++ b/v0.8.2/heterogeneous_system/4cbc5008.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/heterogeneous_system/50fddf9e.svg b/v0.8.2/heterogeneous_system/eb0a525c.svg similarity index 96% rename from v0.8.2/heterogeneous_system/50fddf9e.svg rename to v0.8.2/heterogeneous_system/eb0a525c.svg index d5e3b213..47b4770d 100644 --- a/v0.8.2/heterogeneous_system/50fddf9e.svg +++ b/v0.8.2/heterogeneous_system/eb0a525c.svg @@ -1,62 +1,62 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/heterogeneous_system/index.html b/v0.8.2/heterogeneous_system/index.html index 30dba550..4b8a2b41 100644 --- a/v0.8.2/heterogeneous_system/index.html +++ b/v0.8.2/heterogeneous_system/index.html @@ -24,7 +24,7 @@ tspan = (0.0, 10.0) prob = ODEProblem(nd!, x0, tspan, p) sol = solve(prob, Tsit5()) -plot(sol; ylabel="θ", fmt=:png)Example block output

Heterogeneous dynamics

Two paradigmatic modifications of the node model above are static nodes and nodes with inertia. A static node has no internal dynamics and instead fixes the variable at a constant value. A Kuramoto model with inertia consists of two internal variables leading to more complicated (and for many applications more realistic) local dynamics.

static! = StaticVertex(; f=(θ, edges, c, t) -> θ .= c, dim=1, sym=[:θ])
+plot(sol; ylabel="θ", fmt=:png)
Example block output

Heterogeneous dynamics

Two paradigmatic modifications of the node model above are static nodes and nodes with inertia. A static node has no internal dynamics and instead fixes the variable at a constant value. A Kuramoto model with inertia consists of two internal variables leading to more complicated (and for many applications more realistic) local dynamics.

static! = StaticVertex(; f=(θ, edges, c, t) -> θ .= c, dim=1, sym=[:θ])
 
 
 function kuramoto_inertia!(dv, v, edges, P, t)
@@ -47,7 +47,7 @@
 nodefillc = reshape(nodecolor[membership], 1, N);
 
 vars = syms_containing(nd_hetero!, :θ);
-plot(sol_hetero; ylabel="θ", vars=vars, lc=nodefillc, fmt=:png)
Example block output

Components with algebraic constraints

If one of the network components contains an algebraic as well as dynamical component, then there is the option to supply a mass matrix for the given component. In general this will look as follows:

function edgeA!(de, e, v_s, v_d, p, t)
+plot(sol_hetero; ylabel="θ", vars=vars, lc=nodefillc, fmt=:png)
Example block output

Components with algebraic constraints

If one of the network components contains an algebraic as well as dynamical component, then there is the option to supply a mass matrix for the given component. In general this will look as follows:

function edgeA!(de, e, v_s, v_d, p, t)
     de[1] = f(e, v_s, v_d, p, t) # dynamic variable
     e[2]  = g(e, v_s, v_d, p, t) # static variable
 end
@@ -55,4 +55,4 @@
 M = zeros(2, 2)
 M[1, 1] = 1
 
-nd_edgeA! = ODEEdge(; f=edgeA!, dim=2, coupling=:undirected, mass_matrix=M);

This handles the second equations as 0 = M[2,2] * de[2] = g(e, v_s, v_d, p, t) - e[2].

See the example kuramoto_plasticity.jl and the discussion on github for more details.

This page was generated using Literate.jl.

+nd_edgeA! = ODEEdge(; f=edgeA!, dim=2, coupling=:undirected, mass_matrix=M);

This handles the second equations as 0 = M[2,2] * de[2] = g(e, v_s, v_d, p, t) - e[2].

See the example kuramoto_plasticity.jl and the discussion on github for more details.

This page was generated using Literate.jl.

diff --git a/v0.8.2/index.html b/v0.8.2/index.html index 8b86439d..6c48dcda 100644 --- a/v0.8.2/index.html +++ b/v0.8.2/index.html @@ -1,3 +1,3 @@ General · NetworkDynamics

NetworkDynamics

A package for working with dynamical systems on complex networks. NetworkDynamics.jl provides an interface between Graphs.jl and DifferentialEquations.jl. It allows to define several types of dynamic and static nodes and edges and to link them up in order to create complex network dynamics.

The behavior of a node or an edge can be described by algebraic equations, by differential algebraic equation (DAEs) in mass matrix form, by ordinary differential equations (ODE) or by delay differential equations(DDE). Stochastic ordinary differential equations (SDE) can e.g. be implemented as a two-layer network. For detail see the tutorials section.

Installation

Installation is straightforward with Julia's package manager.

(v1.5) pkg> add NetworkDynamics

PowerDynamics

PowerDynamics.jl is an open-source framework for dynamic power grid modeling and analysis build on top of NetworkDynamics.jl.

Overview

The central construction is the function network_dynamics 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 DifferentialEquations.jl calling syntax.

nd = network_dynamics(vertices!,  edges!, g)
-nd(dx, x, p, t)
+nd(dx, x, p, t) diff --git a/v0.8.2/kuramoto_delay/3508ce7e.svg b/v0.8.2/kuramoto_delay/d031c52a.svg similarity index 95% rename from v0.8.2/kuramoto_delay/3508ce7e.svg rename to v0.8.2/kuramoto_delay/d031c52a.svg index 29b252cc..e9379e5b 100644 --- a/v0.8.2/kuramoto_delay/3508ce7e.svg +++ b/v0.8.2/kuramoto_delay/d031c52a.svg @@ -1,58 +1,58 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.8.2/kuramoto_delay/index.html b/v0.8.2/kuramoto_delay/index.html index 3389ee2e..947526f2 100644 --- a/v0.8.2/kuramoto_delay/index.html +++ b/v0.8.2/kuramoto_delay/index.html @@ -35,13 +35,13 @@ θ₀ = rand(Uniform(0, 2π), N); # initial conditions

Define random initial history function

const past = rand(Uniform(0, 2π), N)
 h(p, t; idxs=nothing) = typeof(idxs) <: Number ? past[idxs] : past;

When constructing the DDEProblem lags may be specified. The solver will then track discontinuities arising from the evaluation of the history function and step to each of the discontinuities. Since each multiplication combination of the lags may be connected to a discontinuity, this may be slow if many different lags are specified.

prob = DDEProblem(nd, θ₀, h, (0.0, 1.0), p; constant_lags=τ)
 @time solve(prob, MethodOfSteps(BS3()); abstol=1e-10, reltol=1e-5); # ~50000 steps because of discontinuities
-@time solve(prob, MethodOfSteps(BS3()); abstol=1e-10, reltol=1e-5);
  4.629521 seconds (15.21 M allocations: 791.631 MiB, 6.30% gc time, 87.17% compilation time)
-  0.496183 seconds (8.79 M allocations: 415.893 MiB, 19.10% gc time)

We recommend to solve with lowered absolute and relative error tolerances, since the Kuramoto system is highly multistable and the simulations may else produce very different results.

The discontinuities arise from the initial history function and quickly get smoothed out (i.e. reduced in order) when the integration time is larger than the maximum lag. If the asymptotic behaviour is more interesting than the correct solution for a specific initial condition, it is possible to trade accuracy for computational speed by leaving the constant_lags undeclared.

fast_prob = DDEProblem(nd, θ₀, h, (0.0, 1.0), p)
+@time solve(prob, MethodOfSteps(BS3()); abstol=1e-10, reltol=1e-5);
  6.367067 seconds (15.20 M allocations: 791.344 MiB, 5.71% gc time, 87.74% compilation time)
+  0.793204 seconds (8.79 M allocations: 415.893 MiB, 20.68% gc time)

We recommend to solve with lowered absolute and relative error tolerances, since the Kuramoto system is highly multistable and the simulations may else produce very different results.

The discontinuities arise from the initial history function and quickly get smoothed out (i.e. reduced in order) when the integration time is larger than the maximum lag. If the asymptotic behaviour is more interesting than the correct solution for a specific initial condition, it is possible to trade accuracy for computational speed by leaving the constant_lags undeclared.

fast_prob = DDEProblem(nd, θ₀, h, (0.0, 1.0), p)
 @time solve(fast_prob, MethodOfSteps(BS3()); abstol=1e-10, reltol=1e-5); # ~200 steps
-@time solve(fast_prob, MethodOfSteps(BS3()); abstol=1e-10, reltol=1e-5);
  2.762453 seconds (4.81 M allocations: 276.193 MiB, 3.56% gc time, 99.65% compilation time)
-  0.009195 seconds (312.64 k allocations: 14.739 MiB)

The MethodOfSteps algortihm extends an ODE solver to DDEs. For an overview of available solvers consult the manual of DifferentialEquations.jl. For example, for stiff systems, such as this one, it might be beneficial to use a stiff solver such as TRBDF2.

@time solve(fast_prob, MethodOfSteps(TRBDF2()); abstol=1e-10, reltol=1e-5);
-@time solve(fast_prob, MethodOfSteps(TRBDF2()); abstol=1e-10, reltol=1e-5);
 10.914104 seconds (18.90 M allocations: 1.290 GiB, 4.57% gc time, 99.87% compilation time)
-  0.010333 seconds (238.61 k allocations: 13.143 MiB)

Some further helpful comments for dealing within initial discontinuities in DDEs may be found in the manual of the Python software JiTCDDE

using Plots
+@time solve(fast_prob, MethodOfSteps(BS3()); abstol=1e-10, reltol=1e-5);
  3.788990 seconds (4.80 M allocations: 275.882 MiB, 4.16% gc time, 99.60% compilation time)
+  0.018751 seconds (312.64 k allocations: 14.739 MiB)

The MethodOfSteps algortihm extends an ODE solver to DDEs. For an overview of available solvers consult the manual of DifferentialEquations.jl. For example, for stiff systems, such as this one, it might be beneficial to use a stiff solver such as TRBDF2.

@time solve(fast_prob, MethodOfSteps(TRBDF2()); abstol=1e-10, reltol=1e-5);
+@time solve(fast_prob, MethodOfSteps(TRBDF2()); abstol=1e-10, reltol=1e-5);
 14.464230 seconds (18.92 M allocations: 1.290 GiB, 4.17% gc time, 99.85% compilation time)
+  0.018264 seconds (238.61 k allocations: 13.143 MiB)

Some further helpful comments for dealing within initial discontinuities in DDEs may be found in the manual of the Python software JiTCDDE

using Plots
 fast_prob = DDEProblem(nd, θ₀, h, (0.0, 10.0), p)
 sol = solve(fast_prob, MethodOfSteps(BS3()); abstol=1e-10, reltol=1e-5, saveat=0.01)
-plot(sol; fmt=:png)
Example block output

This page was generated using Literate.jl.

+plot(sol; fmt=:png)Example block output

This page was generated using Literate.jl.

diff --git a/v0.8.2/parameters/index.html b/v0.8.2/parameters/index.html index beb5c9fa..ad19b5df 100644 --- a/v0.8.2/parameters/index.html +++ b/v0.8.2/parameters/index.html @@ -1,4 +1,4 @@ Parameter handling · NetworkDynamics

Parameter handling

Let nd! be an ODEFunction returned by network_dynamics, e.g.

nd! = network_dynamics(vertices!, edges!, graph)

then the behaviour of nd! has the signature (dx, x, t, p) and its behaviour changes with the type of parameters p being passed.

  • When p is an Array, a Dict, a struct... then the entire object is passed to each VertexFunction and EdgeFunction.
  • When p = (p_v, p_e) is a Tuple of two values, then the first value will be passed to all vertices and the second to all edges.
  • If p = (p_v_arr, p_e_arr) is a Tuple of two Arrays with lengths corresponding to the number of nodes and number of edges respectively, then the edges or nodes receive only the parameter with the corresponding index.
  • If all nodes and/or edges have no internal parameters the value nothing may be passed. Using nothing instead of dummy parameters is usually faster, since then less data are copied.

Another option for specifying heterogeneous parameters is to make each VertexFunction a callable struct with the parameters hardcoded as fields. This approach is used in PowerDynamics.jl. However it provides considerably less flexibility and interoperability with other packages.

For its greater speed and flexibility in modeling we recommend to use the tuple syntax.

Compatability with specific packages

Some other packages from the Julia ecosystem, e.g. DiffEqFlux, assume that the parameters p are a subtype of AbstractArray. Therefore they are not fully compatible with the tuple syntax.

However, wrapping the function in such a way that it accepts arrays of parameters that are later pasted into the tuple syntax sidesteps potential issues. Depending on the use case such a wrapper might look like this:

function nd_wrapper!(dx, x, p, t)
   nd!(dx, x, (p, nothing), t)
-end

At the moment we recommend this way for combining NetworkDynamics and DiffEqFlux.

+end

At the moment we recommend this way for combining NetworkDynamics and DiffEqFlux.