Skip to content

Commit 30d4923

Browse files
committed
fix typos
1 parent 8001f3f commit 30d4923

File tree

1 file changed

+46
-49
lines changed

1 file changed

+46
-49
lines changed

docs/src/mathematical_model.md

Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# Mathematical Model
22

3-
The core of the `NetworkDynamics.jl` package is the [`Network`](
4-
@ref) function. It accepts the functions describing the
5-
local dynamics on the edges and nodes of the graph `g` as inputs, and returns a composite function compatible with the
3+
The core of the `NetworkDynamics.jl` package is the [`Network`](@ref) function. It accepts the functions describing the
4+
local dynamics on the edges and nodes of the graph `g` as inputs, and returns a composite function compatible with the
65
DifferentialEquations.jl syntax as output.
76

87
```julia
98
nd = Network(g, vertex_dynamics, edge_dynamics)
109
nd(dx, x, p, t)
1110
```
1211

13-
In general the local dynamics on the edges and nodes of a graph can be described through the use of (a) algebraic
12+
In general the local dynamics on the edges and nodes of a graph can be described through the use of (a) algebraic
1413
equations, (b) differential algebraic equation (DAEs) in mass matrix form or (c) ordinary differential equations (ODE).
15-
The `NetworkDynamics.jl` package uses
16-
[Differential-Algebraic-Equation (DAE)](https://mathworld.wolfram.com/Differential-AlgebraicEquation.html) to express
14+
The `NetworkDynamics.jl` package uses
15+
[Differential-Algebraic-Equations (DAE)](https://mathworld.wolfram.com/Differential-AlgebraicEquation.html) to express
1716
the overall network dynamics:
1817
```math
1918
M\,\frac{\mathrm{d}}{\mathrm{d}t}u = f^{\mathrm{nw}}(u, p, t)
@@ -24,7 +23,7 @@ and $t$ is the time. To make this compatible with the solvers used in `OrdinaryD
2423
```
2524
nw(du, u, p, t) # mutates du as an "output"
2625
```
27-
and represents the right-hand-side (RHS) of the equation above. The mass-matrix $M$ is stored in the `Network` object
26+
and represents the right-hand-side (RHS) of the equation above. The mass-matrix $M$ is stored in the `Network` object
2827
as well.
2928

3029
## Modelling the Dynamics of the System
@@ -36,19 +35,19 @@ y^{\mathrm c} &= g^{\mathrm c}(x^\mathrm{c}, i_{\mathrm c}, p_{\mathrm c}, t)
3635
\end{aligned}
3736
```
3837
where $M_{\mathrm{c}}$ is the component mass matrix, $x^{\mathrm c}$ are the component states, $i^{\mathrm c}$ are the
39-
inputs of the component and $y^{\mathrm c}$ is the output of the component. If
38+
inputs of the component and $y^{\mathrm c}$ is the output of the component. If
4039
$\mathrm{dim}(x^{\mathrm{c}}) = 0$, the number of internal states is 0.
4140

4241
The mathematical model of `NetworkDynamics.jl` splits the network system in two parts: the vertex and
4342
the edge components (the nodes and edges, respectively). Instead of defining the $f^{\mathrm{nw}}$ by hand, `ND.jl`
44-
builds it automatically based on a list of decentralized nodal and edge dynamics that the user provides (the
43+
builds it automatically based on a list of decentralized nodal and edge dynamics that the user provides (the
4544
`VertexModel` and `EdgeModel` objects).
4645

47-
In the context of the network, the **output of the edges are flow variables** and the **outputs of vertices are
48-
potential variables**. When the node and edge models are placed on a graph, the inputs and outputs are connected:
49-
the nodes receive the output of the adjacent edges as inputs and the edges receive the output of the adjacent nodes as
50-
inputs. Thus, the *flow* on the edges depends on the *potentials* at both ends as inputs. The *potentials* of the nodes
51-
depend on the incoming *flows* from all connected edges as an input. (Here, flow and potentials are meant in a
46+
In the context of the network, the **output of the edges are flow variables** and the **outputs of vertices are
47+
potential variables**. When the node and edge models are placed on a graph, the inputs and outputs are connected:
48+
the nodes receive the output of the adjacent edges as inputs and the edges receive the output of the adjacent nodes as
49+
inputs. Thus, the *flow* on the edges depends on the *potentials* at both ends as inputs. The *potentials* of the nodes
50+
depend on the incoming *flows* from all connected edges as an input. (Here, flow and potentials are meant in a
5251
conceptual and not necessarily physical way.)
5352

5453
```@raw html
@@ -63,7 +62,7 @@ Above the network, you can see the dynamical systems for both nodes 1 and 2 as w
6362
The figure shows, how the outputs of the edge appears as input of the nodes and the output of the nodes appears as input of the edge models.
6463

6564
### Vertex Models
66-
The equations of a (single-layer) full vertex model are:
65+
The equations of a (single-layer) full vertex model are:
6766
```math
6867
\begin{aligned}
6968
M^{\mathrm v}\,\frac{\mathrm{d}}{\mathrm{d}t}x^{\mathrm v} &= f^{\mathrm v}(x^{\mathrm v}, i^{\mathrm v}, p^{\mathrm v}, t)\\
@@ -83,7 +82,7 @@ end
8382
vertf = VertexModel(; f=fᵥ, g=gᵥ, mass_matrix=Mᵥ, ...)
8483
```
8584

86-
A (single-layer) full vertex model has one input, and one output. Its input is an aggregation/reduction over all the
85+
A (single-layer) full vertex model has one input, and one output. Its input is an aggregation/reduction over all the
8786
*incident edge outputs* which is calculated using:
8887
```math
8988
i^{\mathrm v} = \mathop{\mathrm{agg}}\limits_k^{\text{incident}} y^{\mathrm e}_k \qquad\text{often}\qquad
@@ -97,22 +96,22 @@ The graphical representation of such a model is:
9796
<img src="../assets/nodemodel.svg" width="70%" height="70%"/>
9897
</picture>
9998
```
100-
where $y^e_i$ and $y^e_j$ are two of the $n$ incident edge outputs that are aggregated to produce the model input
101-
$i^u$ and the model output $y^v$ (the vertex model output).
99+
where $y^e_i$ and $y^e_j$ are two of the $n$ incident edge outputs that are aggregated to produce the model input
100+
$i^v$ and the model output $y^v$ (the vertex model output).
101+
102102

103-
104103
### Edge Models
105-
In contrast to the vertex models, edge models in general have *two* inputs and *two* outputs, for both the source and
104+
In contrast to the vertex models, edge models in general have *two* inputs and *two* outputs, for both the source and
106105
the destination end of the edge. We commonly use `src` and `dst` to describe the source and destination end of an edge,
107106
respectively.
108107

109108
!!! note "On the directionality of edges"
110109
Mathematically, in a system defined on an undirected graph there is no difference between edge $(1,2)$ and
111110
edge $(2,1)$, because the edge has no direction. However, from an implementation point of view we always need to
112-
have some kind of ordering. For undirected graphs, the edges are allways defined from `src -> dst` where `src < dst`
113-
(this convention matches the behavior of the `edges` iterator from `Graphs.jl`).
114-
Specifically, the undirectional edge between nodes 1 and 2 always be referenced as `1 -> 2`, never `2 -> 1`.
115-
The **source** and **destination** naming is related to this notion of directionality, rather than to the actual flows, i.e.
111+
have some kind of ordering. For undirected graphs, the edges are always defined from `src -> dst` where `src < dst`
112+
(This convention matches the behavior of the `edges` iterator from `Graphs.jl`).
113+
I.e. the undirectional edge between nodes 1 and 2 will be always referenced as `1 -> 2`, never `2 -> 1`.
114+
The **source** and **destination** naming is related to this notion of directionality, it is not related to the actual flows, i.e.
116115
a system might exist where there is a net flow from destination to source.
117116

118117
The full edge model equations are:
@@ -136,37 +135,35 @@ end
136135
edgef = EdgeModel(; f=fₑ, g=gₑ, mass_matrix=Mₑ, ...)
137136
```
138137

139-
Each edge has:
140-
1. two inputs:
138+
Each edge has:
139+
1. two inputs:
141140
1. the node outputs of the source
142141
2. the destination end of the edge
143142
2. two outputs:
144143
1. the `dst` output (which is used as the input of the vertex at the destination end)
145144
2. the `src` output (which is used as the input of the vertex at the source end)
146145

147-
In general, the two edge outputs $y_{\mathrm{src}}$ and $y_{\mathrm{dst}}$ are **completely independent** because there
146+
In general, the two edge outputs $y_{\mathrm{src}}$ and $y_{\mathrm{dst}}$ are **completely independent** because there
148147
is no implicit conservation law dictating that their values should be identical.
149-
An example for such an unbalanced systems is power lines in an energy grid with losses, where the power flowing into a line
150-
does not match the power flowing out of it, because some of the energy transported is lost in the form of heat.
151-
Another example would be a gas pipeline with some internal pressure: it is entirely possible to push in gas from both
152-
ends simultaneously. It would simply result in increased pressure within the pipe. For the (important) special cases
148+
An example for such an unbalanced systems is power lines in an energy grid with losses, where the power flowing into a line
149+
does not match the power flowing out of it, because some of the energy transported is lost in the form of heat.
150+
Another example would be a gas pipeline with some internal pressure: it is entirely possible to push in gas from both
151+
ends simultaneously. It would simply result in increased pressure within the pipe. For the (important) special cases
153152
where there is a strong correlation between source and destination output see the section on [Single Sided Edge Outputs](@ref) below.
154153

155154
The vertex models connected to the edge do not know whether they are at the 'src' or the 'dst' end of the edge.
156-
Therefore, the sign convention for both outputs of an edge must be identical. Typically, a positive flow represents
155+
Therefore, the sign convention for both outputs of an edge must be identical. Typically, a positive flow represents
157156
a flow *into* the connected vertex, whereas a negative flow represents a flow *out of* the connected vertex.
158157
```
159-
y_src ┌───────────────────┐ y_dst
158+
y_src ┌───────────────────┐ y_dst
160159
V_src o───←───┤ internal dynamics ├───→───o V_dst
161160
└───────────────────┘
162161
```
163162

164163
### Single Sided Edge Outputs
165-
Systems exist, where the edge output functions $g_\mathrm{src}$ and $g_\mathrm{dst}$ are not independent, but rather one
166-
is a function of the other. For example, in a system with a flow conservation law, the flow magnitude at the
167-
source end is equal to the flow magnitude at the destination end (what flows in, must come out). Since the sign
168-
convention on both ends must be identical (e.g. positive flow is a flow towards the vertex) we get antisymmetric
169-
behavior: $y_\mathrm{src} = -y_\mathrm{dst}$.
164+
Often, the edge output functions $g_\mathrm{src}$ and $g_\mathrm{dst}$ are not independent, but rather one of them is a function of the other.
165+
For example, in an edge model with flow conservation without internal storage, the flow magnitude at the source end is equal to the flow magnitude at the destination end (what flows in, must come out).
166+
Since the sign convention on both ends must be identical (e.g. positive flow is a flow towards the vertex) we get anti symmetric behavior: $y_\mathrm{src} = -y_\mathrm{dst}$​.
170167

171168
To accommodate such cases, we can use the concept of **single sided edge output functions**.
172169
A single sided output function only defines a function for one of the outputs:
@@ -181,41 +178,41 @@ end
181178
There are multiple wrappers available to automatically convert them into double-sided edge output functions:
182179
- `Directed(g_single)` builds a double-sided function *which only couples* to the destination side (i.e. $y_{dst}=y$ and $y_{src} = 0$).
183180
- `Symmetric(g_single)` builds a double-sided function in which both ends receive `y` (i.e. $y = y_{src} = y_{dst})$.
184-
- `AntiSymmetric(g_single)` builds a double-sided function where the destination receives `y` and the source receives `-y` (i.e. $y=y_{dst}=-y{src}$).
181+
- `AntiSymmetric(g_single)` builds a double-sided function where the destination receives `y` and the source receives `-y` (i.e. $y=y_{dst}=-y_{src}$).
185182
- `Fiducial(g_single_src, g_single_dst)` builds a double-sided edge output function based on two single sided functions.
186183

187184

188185
## Feed Forward Behavior
189186
!!! warning "Feed Forward Vertices"
190-
As of 11/2024, vertices with feed forward behaviour (FF) are not supported at all. Use [`ff_to_constraint`](@ref) to
187+
As of 11/2024, vertices with feed forward behaviour (FF) are not supported at all. Use [`ff_to_constraint`](@ref) to
191188
transform them into vertex models without FF.
192189

193-
Component models can have a so-called Feed Forward behaviour, which provides a direct link between the input and the
190+
Component models can have a so-called Feed Forward behaviour, which provides a direct link between the input and the
194191
output.
195192

196-
The most generic version of the component models can contain direct FFs from the input to the output. This means that
193+
The most generic version of the component models can contain direct FFs from the input to the output. This means that
197194
the output function $g$ depends directly on the component inputs $i$ rather than just on the component state $x$.
198195

199196
Whenever possible, you should define output functions without FFs in the following way:
200197
```julia
201198
gᵥ_noff(yᵥ, xᵥ, pᵥ, t)
202-
gₑ_noff([y_src,] y_dst, xᵥ, pₑ, t)
199+
gₑ_noff([y_src,] y_dst, xₑ, pₑ, t)
203200
```
204201
instead of the more general
205202
```julia
206203
gᵥ(yᵥ, xᵥ, e_aggr, pᵥ, t)
207-
gₑ([y_src], y_dst, xᵥ, v_src, v_dst, pₑ, t)
204+
gₑ([y_src,] y_dst, xₑ, v_src, v_dst, pₑ, t)
208205
```
209206

210-
NetworkDynamics cannot couple two components with FFs to each other. But, it is always possible to transform
211-
feed forward behaviour to an internal state `x` with mass matrix entry zero to circumvent this problem. This
207+
NetworkDynamics cannot couple two components with FFs to each other. But, it is always possible to transform
208+
feed forward behaviour to an internal state `x` with mass matrix entry zero to circumvent this problem. This
212209
transformation can be performed automatically using [`ff_to_constraint`](@ref).
213210

214-
Concretely, NetworkDynamics distinguishes between 4 types of feed forward behaviours of `g` functions based on the
211+
Concretely, NetworkDynamics distinguishes between 4 types of feed forward behaviours of `g` functions based on the
215212
[`FeedForwardType`](@ref) trait.
216213
The feed forward type is inferred automatically based on the provided function `g` (this is done by inspecting the available
217-
method signatures for `g`, i.e. network dynamics checks how many arguments you `g` function takes)
218-
If the automatic inference of feed forward type fails, the user may specify it explicitly using the `ff` keyword
214+
method signatures for `g`, i.e. network dynamics checks how many arguments your `g` function takes)
215+
If the automatic inference of feed forward type fails, the user may specify it explicitly using the `ff` keyword
219216
argument of the Edge/VertexModel constructor.
220217

221218
The code block below presents the different `g` signatures for the different feed forward types:

0 commit comments

Comments
 (0)