Skip to content

Commit eb4e51a

Browse files
committed
Tutorial.md improved
1 parent 28d307f commit eb4e51a

File tree

1 file changed

+76
-21
lines changed

1 file changed

+76
-21
lines changed

docs/src/Tutorial.md

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ voltage source is modelled with an inner resistor):
1919

2020
### 1.1 Bi-Partite Graph
2121

22-
After simple equations have been removed, this circuit can be
23-
described with 6 equations. The structure of the equations is
24-
displayed in the next figure:
22+
In a first step, the structural information of the low pass filter model is provided as incidence matrix
23+
24+
![Incidence Matrix of Low Pass Filter](../resources/images/LowPassFilter_IncidenceMatrix.png)
2525

26-
![Incidence Matrix of Low Pass Filter](../resources/images/LowPassFilterReduced_IncidenceMatrix.png)
2726

2827
- Every **column** corresponds to one time-varying **variable**.
2928
Parameters, so variables with constant values, are not shown.
@@ -37,36 +36,92 @@ displayed in the next figure:
3736

3837
The matrix above is called the **incidence matrix** or the
3938
**bi-partite graph** of the circuit. In ModiaBase, this matrix is represented
40-
as vector `G` of integer vectors:
39+
as vector `G` of Integer vectors:
4140

4241
```julia
4342
# Bi-partite graph of low pass filter
44-
G = [ [1,2,4], # equation 1 depends on variables 1,2,4
45-
[1,7],
46-
[3,4],
47-
[3,7],
48-
[6,7],
49-
[2] ]
43+
G = [ [25,27], # equation 1 depends on variables 25,27
44+
[6,23],
45+
[4,10],
46+
...,
47+
[27] ]
5048
```
5149

52-
This can be also made more explicit (and a bit more efficient storage
53-
by defining the incidence matrix as):
54-
50+
This can be also made more explicit (and a bit more efficient storage)
51+
by defining the incidence matrix as:
5552

5653
```julia
5754
# Bi-partite graph of low pass filter
55+
G = Vector{Int}[ [25,27], # equation 1 depends on variables 25,27
56+
[6,23],
57+
[4,10],
58+
...,
59+
[27] ]
60+
```
61+
62+
### 1.2 Linear Integer Equations
63+
64+
Object-oriented models consist of a lot of linear Integer equations, especially due to the connect-statements.
65+
The linear integer equations of `G` are identified and the corresponding linear factors
66+
are determined. With function [`simplifyLinearIntegerEquations!`](@ref) this information is used to simplify
67+
the equations by transforming the linear Integer equations with a fraction-free (exact) Gaussian elimination to
68+
a special normalized form and then perform the following simplifications:
69+
70+
- Equations of the form `v = 0` are removed and `v` is replaced by „0“ at all places where
71+
`v` occurs, and these equations are simplified.
72+
73+
- Equations of the form `v1 = v2` and `v1 = -v2` are removed, `v1` is replaced by `v2` (or `-v2`)
74+
at all places where `v1` occurs (so called *alias-variables*), and these equations are simplified.
75+
76+
- *Redundant equations* are removed.
77+
78+
- Variables that appear *only* in the linear Integer equations (and in no other equations) are set to zero, if
79+
they can be *arbitrarily selected*. For example, if an electrical circuit is not
80+
grounded, then one of the electrical potentials is arbitrarily set to zero.
81+
82+
- State constraints are made structurally visible.
83+
84+
After applying [`simplifyLinearIntegerEquations!`](@ref) to the low pass filter circuit,
85+
the incidence matrix is simplified to
86+
87+
![Incidence Matrix of Low Pass Filter](../resources/images/LowPassFilterReduced_IncidenceMatrix.png)
88+
89+
```julia
90+
# Bi-partite graph of simplified low pass filter
5891
G = Vector{Int}[ [1,2,4],
5992
[1,7],
6093
[3,4],
6194
[3,7],
6295
[6,7],
6396
[2] ]
97+
98+
# Eliminated variables
99+
R.i = -(V.p.i)
100+
ground.p.v = 0
101+
R.p.i = -(V.p.i)
102+
R.n.v = C.v
103+
V.n.i = -(V.p.i)
104+
V.n.v = 0
105+
V.p.v = Ri.n.v
106+
Ri.p.i = V.p.i
107+
C.n.v = 0
108+
C.p.v = C.v
109+
Ri.p.v = R.p.v
110+
C.n.i = V.p.i
111+
V.i = V.p.i
112+
R.n.i = V.p.i
113+
C.p.i = -(V.p.i)
114+
ground.p.i = 0
115+
C.i = -(V.p.i)
116+
Ri.i = V.p.i
117+
V.v = Ri.n.v
118+
Ri.n.i = -(V.p.i)
64119
```
65120

66121

67-
### 1.2 Assignment
122+
### 1.3 Assignment
68123

69-
In a first step, an assignment is made (also called matching), to associate
124+
In a follow-up step, an assignment is made (also called matching), to associate
70125
one variable uniquely with one equation:
71126

72127
![Matched IIncidence Matrix of Low Pass Filter](../resources/images/LowPassFilterReduced_Matching.png)
@@ -75,7 +130,7 @@ one variable uniquely with one equation:
75130
- *Blue* marks show if a variable is part of the respective equation
76131

77132
The assignment is computed with function [`ModiaBase.matching`](@ref)
78-
returning a vector **assign**:
133+
returning a vector `assign`:
79134

80135
```julia
81136
using ModiaBase
@@ -94,9 +149,9 @@ The meaning of vector `assign` is that
94149
- etc.
95150

96151

97-
### 1.3 Block Lower Triangular transformation
152+
### 1.4 Block Lower Triangular transformation
98153

99-
In a second step, equations are sorted and algebraic loops determined:
154+
In a follow-up step, equations are sorted and algebraic loops determined:
100155

101156
![Incidence Matrix of sorted equations of Low Pass Filter](../resources/images/LowPassFilterReduced_BLT.png)
102157

@@ -112,8 +167,8 @@ blt = BLT(G, assign)
112167

113168
#=
114169
blt = [ [6],
115-
[3,4,2,1],
116-
[5] ]
170+
[3,4,2,1],
171+
[5] ]
117172
=#
118173
```
119174

0 commit comments

Comments
 (0)