forked from modelica/ModelicaStandardLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LineCmatrix.mo
76 lines (75 loc) · 4.56 KB
/
LineCmatrix.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
within Modelica.Electrical.Analog.Lines.Functions;
function lineCmatrix
"Compute matrix of transverse capacitances per metre of a multi-conductor line"
extends Modelica.Icons.Function;
import Modelica.Constants.epsilon_0;
import Modelica.Constants.pi;
input Integer n "Number of conductors";
input Modelica.Units.SI.Length x[n] "Horizontal abscissas of conductors";
input Modelica.Units.SI.Length y[n] "Vertical abscissas of conductors";
input Modelica.Units.SI.Radius r[n] "Conductors radii (m)";
// output Real Cflat[n, n](each final unit="F/m") "Matrix with capacitances of a network reproducing the behaviour of C";
output Real Ccompact[div(n*(n + 1), 2)](each final unit="F/m") "Vector of capacitances of network of capacitors equivalent to C";
output Real C[n, n](each final unit="F/m") "Capacitance matrix with negative off-diagonal conductances";
protected
constant Complex j = Complex(0, 1) "Imaginary unit";
constant Real K(final unit="F/m") = 1 / (2 * pi * epsilon_0);
Real p[n, n](each final unit="m/F") "Maxwell's potential matrix";
Real Cflat[n, n](each final unit="F/m") "Matrix with capacitances of a network reproducing the behaviour of C";
Modelica.Units.SI.Distance D "Generic larger distance";
Modelica.Units.SI.Distance d "Generic smaller distance";
Integer k;
String sC;
algorithm
// Diagonal elements of the potential matrix:
for i in 1:n loop
p[i, i] := K * log(2 * y[i] / r[i]);
end for;
// Out-of diagonal elements of the potential matrix:
for i in 1:n loop
for jj in 1:i - 1 loop
d := sqrt((x[i] - x[jj]) ^ 2 + (y[i] - y[jj]) ^ 2);
D := sqrt((x[i] - x[jj]) ^ 2 + (y[i] + y[jj]) ^ 2);
p[i, jj] := K * log(D / d);
end for;
end for;
for i in 1:n loop
for jj in i + 1:n loop
p[i, jj] := p[jj, i];
end for;
end for;
// The capacitance function is the inverse of the matrix of potentials
C := Modelica.Math.Matrices.inv(p);
// The off diagonal elements of Cflat are the opposite of corresponding elements of C.
// We first generate the opposite of C, then will redefine its diagonal elements:
Cflat:=-C;
// The diagonal elements of Cflat contain the sum of all the values the corresponding row in C:
for i in 1:n loop
Cflat[i,i]:=sum(C[i,j] for j in 1:n);
end for;
// Select the elements needed by M_Oline in a vector which it can use directly
k := 0;
for i in 1:n loop
for j in i:n loop
k := k + 1;
Ccompact[k] := Cflat[i, j];
end for;
end for;
annotation (
Documentation(info="<html>
<p>This function computes Capacitances of multi-conductor transmission lines, according to the formulas as reported in [<a href=\"modelica://Modelica.Electrical.Analog.UsersGuide.References\">Cerolo2018</a>, Appendix]. The results obtained with this function have been checked with Fig. 4.1 of [<a href=\"modelica://Modelica.Electrical.Analog.UsersGuide.References\">EmtpTheoryBook</a>], with good compliance. </p>
<p>Internally, it computes the <b>C</b> matrix, which corresponds to the formulas <b>V</b> = <b>YI</b>, <b>Y</b> = ω<b>C</b> where </p>
<ul>
<li><b>V</b> is the vector of voltages between conductors and the reference (the return conductor, usually ground), </li>
<li><b>I</b> is the vector of transverse currents (between conductors and the return conductor, usually ground) due to the capacitive coupling between the conductors, </li>
<li><b>Y</b> is the matrix of transverse admittances of the multiconductor line (S/m), </li>
<li>ω is the angular frequency when constant-frequency steady-state operation of the line is considered </li>
</ul>
<p>This matrix <b>C</b>, has always negative off-diagonal values, and positive diagonal values. </p>
<p>From <b>C</b> matrix, the internal <b>Cflat</b> matrix is computed, containing physical capacitors that can be imagined between conductors to model capacitive effects. For instance C12 is the capacitance (per unit length) to be put between conducturors 1 and 2. The output array <b>Ccompact</b> contains the elements of the <b>Cflat</b> matrix ordered as described in the <a href=\"modelica://Modelica.Electrical.Analog.Lines.M_OLine\">M_OLine</a> model, and is used in example <a href=\"modelica://Modelica.Electrical.Analog.Examples.Lines.PowerLineWithFence\">Examples.Lines.PowerLineWithFence</a> in conjunction with M_OLine. </p>
<p>For an example on how to use this function, consider model Electrical.Analog.Examples.Lines.CompareCmatrix. </p>
</html>", revisions="<html>
<p><i>July, 2023</i> </p>
<p>Original implementation by Massimo Ceraolo of the University of Pisa </p>
</html>"));
end lineCmatrix;