Mastersthesis Teryaev Rostislav
Mastersthesis Teryaev Rostislav
Rostislav Teryaev
Rostislav Teryaev
Keywords: reluctance network method, finite elements method, reluctance, nodal analysis,
mesh analysis, MatLab
This study concentrates on reluctance network method implementation. The main goal of
the thesis was to study algorithm of reluctance network method and its component parts.
The approach for using this method for magnetic structures was developed with respect to
automation. Universal procedure for circuit analysis of big circuits was implemented in
MatLab. High speed of computation is reached. Validation of results showed good
agreement between reluctance network method and finite elements method.
ii
ACKNOWLEDGEMENTS
This thesis was carried out at School of Energy Systems, Lappeenranta University of
Technology. I would like to express my gratitude to my supervisor D.Sc. Rafal Jastrzebski
for his scientific guidance and support and also to D.Sc. Juho Montonen for his advices
and thorough review work. I wish to thank the Professor Yacine Amara from University of
Le Havre for his help and productive discussions. Also I express my gratitude to my
friends – Evgeniy, Yuri and Maxim for listening to my stories about difficulties I faced
during this process.
iii
TABLE OF CONTENTS
1 INTRODUCTION ............................................................................................. 9
REFERENCES...................................................................................................... 55
LIST OF SYMBOLS AND ABBREVIATIONS
SYMBOLS
Chapter 2
Flux
A Area
U Equipotential plane or scalar potential
l Total length of the flux tube
C Material parameter
R Ratio value
Rm Reluctance
RE Resistance
Electric conductivity
B Magnetic flux density (induction)
H Magnetic field strength
J Current density
E Electric field strength
F Magnetic potential drop or flux source
U Electric potential drop
I Current
w Width
h Height
Magnetic permeability
la Active length
Angle
r Radius
Chapter 3
1 Identity matrix
A Matrix of nodal connections
a jk Element of matrix of nodal connections with indices j and k
SUBSCRIPTS
In Inner
ind Induced
j The (row) index related to number of node
k The (column) index related to graph edge
m The (row) index related to tree edge
s The (row) index related to connection edge
out Out/outer
ABBREVIATIONS
EMF Electromotive force
RN Reluctance network
RNM Reluctance network method
1 INTRODUCTION
1.1 Background
The reluctance model (or equivalent magnetic circuit) has been the main tool for
electrical machines design for the last hundred years. Typically the reluctance model had to
be constructed only for the main flux path. It was necessary because all computations were
performed only manually those days. Moreover it assures high speed of the solution.
There is another tool to model electrical machines, which is Finite Elements
Method (FEM). It is a numerical method which allows to calculate fields of any kind with
some discretization. The size of discretization depends on the size of the finite element
mesh. This method results into set of values of field potentials in mesh nodes.
Unfortunately, it requires to perform many similar mathematical operations in a row. Finite
Element method is highly precise and allows to overcome some issue which some other
methods cannot, for example issues related to computation of complicated geometrical
structures. However, the main disadvantage of this method is a huge number of
mathematical operations which is almost impossible to perform manually.
The development of computers started in the 1980's allowed to use Finite Elements
method in practice making time for computing quite acceptable, but still not really fast.
Assuming above, FEM is reasonable to use in the final stages of design of electrical
machines to final validations of a model or its refinement. And it is rather difficult to use
FEM in pre-design stages because a structure of machine can vary in many places which
will require to recompute model every time. Moreover, not only parameters values of the
machine have to be changed every time, but a model geometry also.
It should be noticed that there are a number of many different approaches which
can be used for engineering analysis also. They can be divided into three groups:
Analytical models [1, 2, 3, 4];
Numerical models [4, 5, 6, 7];
Semi-numerical, semi-analytical or hybrid models [8, 9, 10, 11, 12, 13].
Many of these approaches are different combinations of FEM, reluctance network
method (RNM) and formal solution of Maxwell’s equations.
1.2 Goals and delimitations
C x – Material parameter
R – Ratio value, which has different names for different filed types
For magnetic field equations above goes as follows
l
1
Rm dx (2)
0
x A x
Where
– Magnetic permeability
Rm – Reluctance
For electric field
l
1
RE dx (3)
0
x A x
Where
RE – Resistance
– Electric conductivity
Relationship between flux density and field strength for magnetic and electric fields are:
B H (4)
J E (5)
Assuming above table 1 can be written
Table 1. Analogies between magnetic and electric fields
Type of field
Magnetic Electric
Material constant
Field strength H E
l l
F U
Flux or current BdA I JdA
Rm RE
l l
dx dx
Reluctance or Resistance Rm RE
0
x A x 0
x A x
By comparing expressions for magnetic and electric fields the analogies can be noticed.
They are based on the same mathematical principles but with different names of
parameters. It allows to construct a magnetic equivalent circuit that is analogous to a
resistive electrical circuit.
2.2 Reluctance as analogy to resistance
Equation (2) can be expressed in different ways for different shapes of flux tubes.
However, we will consider three most common kind of shapes, which are used in practice
[11].
The radial and circumferential reluctance components for the rectangle (Fig. 2. ):
1 1 h
Rmr l w
a
(6)
R 1 1 w
mc la h
The radial and circumferential reluctance components for the trapezium (Fig. 3. ):
1 1 h w
Rnr ln 2
la w2 w1 w1
1
(7)
1 1 h w2
Rnc l w w ln w
a 2 1 1
Fig. 3. Trapezoidal flux tube
The radial and circumferential reluctance components for the sector (Fig. 4. ):
1 1 rout
1
Rmr ln
la rin
(8)
1 1 rout
Rmc l ln r
a in
Equations:
U 2 U1 Rm s
U 2 U1 Rm m
Equations:
U 2 U1 Rm F
U 2 U1 Rm m
Fig. 6. Magnetomotive force
Where, assuming the shape of reluctance element as, for example, rectangle or F can
be found as follows (v and h indices denotes vertical and horizontal elements)
Фs _ v 0
Фs _ h B h la
Fig. 7. Flux source
For any direction of the current
density J
h
Fv J 2 w
hw
F J
F J h w 2
h
2
After all elements have been defined it is possible to create a reluctance network for a
structure in study. However, it is not as straightforward as it seems to be.
Reluctance network is a magnetic circuit, which has to be formed before analyzing.
Forming this circuit requires two stages:
1. Topological structure of this network has to be set, in other words it is necessary to
describe all branch connections and set this information to computer for further
processing.
2. Values of all reluctances and sources also have to be set.
To do these actions for a small circuit is an easy task: topology structure is easy enough, so
circuit can be analyzed manually. Number of reluctance elements is also small, thus its
values can be set manually again. However, it is necessary to have many values of
magnetic potential in particular areas, for example, in air-gap region to get proper plots.
Therefore, reluctance network will be a big circuit. For big circuits completing mentioned
stages is far more complicated task.
1. To analyze big circuit manually will take infinite amount of time, thus it is
necessary to use a method, which is capable to solve circuits on a computer. There
are several of these methods. Thanks to Kirchhoff's laws it is possible to convert a
problem of analyzing a circuit to a problem of solving system of liner equations.
Algorithms for solving linear equations are well developed. Next chapter contain an
in-depth description of the approach and features of its implementation in MatLab.
2. However, there is no systematic method to work with the task of setting values to
reluctance elements. In general, sizes are different for all reluctance elements in
case of a structure with a complicated shape. Therefore, it is necessary to separately
set values for all elements manually. For big circuits this task is even more
complicated when solving the circuit by hand. However, it is possible to simplify
this stage by assuming same size for all elements. This approach is used in [14].
This approach has its constraints, but it is necessary for partial automation of the
problem. Thus, it is necessary to assign only indices to all reluctance elements,
which describe the type of material. These indices can be easily converted to
magnetic permeability and reluctance is calculated for the elements. However, it is
still not easy to assign material indices to all elements in case of a big network.
Chapter 4 describes how this problem was simplified by the author of this paper.
3 CIRCUIT ANALYSIS
edges and n p q 1 graph connections. These statements are made by taking into
account the definition of tree and graph connection terms, which mean that q nodes can be
connected minimum by q 1 tree edges and graph connections are all remaining edges
which are p q 1 . For example, in separate parts of unconnected graph (Fig. 10. ) we
It is important to notice that it is not possible to state the same for the full
unconnected graph. The full graph has p 14 , q 7 and n 14 7 1 8 while number
q 5 and n 6 .
Fig. 11. Circuit, its graph and some of its trees [16]
Let us note some characteristics of this table. Each column can have only two
nonzero (not empty) cells because one edge can be connected only to two nodes. Sum of
one column values is zero because the arrow of every edge is directed from one node to
another therefore one cell has the value +1 the another one -1. Assuming the previous fact
only q 1 rows can be filled because q-th row always can be derived from others. This
Jds i i
s
1 2 i3 0 (10)
i
k 1
k 0 (11)
This mean that the sum of currents flow from the node of the electrical circuit is
equal to zero. This is a formulation of the Kirchhoff’s current law.
For forming equations in accordance with Kirchhoff’s current law positive branch
directions have to be assumed. In the left part of the equations “plus” sign has to be
employed if the current flows from the node and “minus” sign if the current flows to the
node. For the case depicted on the Fig. 14. one can write Kirchhoff’s current law as
follows
i1 i2 i3 0 (12)
means that current has the same direction as the direction of the arrow, and if the result
value is negative ik 0 this mean that current and arrow have opposite directions.
The second Kirchhoff's law or Kirchhoff's law for loops (voltages) is applied to
electrical circuit loops. For some closed loop we have
Where on the left side voltage drop on all elements and on the right side EMF from
induced and outer sources (for example electromagnetic generator and accumulator
correspondingly). For the circuit with lumped elements we can write previous equation as
follows
k n k n k n k n k n
uk ek ind ek out or
k 1 k 1 k 1
uk ek
k 1 k 1
(14)
where:
k n
u
k 1
k - the sum of voltage drops on all electrical circuit elements (for example resistors,
inductances, capacitors);
k n
e
k 1
k - the sum of all EMF from all sources in electrical circuit.
On the basis of the above, second Kirchhoff’s law claims that sum of voltage drops
in all branches of any closed loop of electrical circuit is equal to the sum of all EMF
sources in this loop.
equation for such closed surface that enclosing these j nodes. It follows from that currents
of branches which are inside the surface but does not go through it are considered in
equations twice: the first one with minus sign, the second – with plus sign. For example,
sum of equations for nodes 1, 2, 3, 4 and 5 of graph on Fig. 15. will define sum of currents
for the surface which enclose these nodes (dashed line depicts this surface boundary).
Fig. 15. Circuit and its part graph [16]
If the surface enclosing q 1 nodes then the sum of currents flows into this surface
is equal with minus sign to the sum of currents for q-th node and therefore q-th equation is
a derivative of previous q 1 equations. With respect to that we will say that circuit (or
a
k 1
i 0, j 1... q 1 ,
jk k (15)
where a jk 1 or a jk 0 .
Let the normal to a closed surface is directed to outer space. If the current of k
branch directed from node j, then it will be included in equation with «plus» sign,
otherwise – with «minus» sign. In the first case a jk 1 , in the second one a jk 1 . If the
In view of the above, for example, for graph on Fig. 15. b (graph of the circuit
diagram on Fig. 12. ), where q 4 the system of three independent equations can be
written
for node 1 i1 i3 i6 0, a11 1, a13 1, a16 1;
for node 2 i1 i2 i4 0, a21 1, a22 1, a24 1; (16)
for node 1 i3 i4 i5 0, a33 1, a33 1, a35 1.
It can be noticed that rules for assigning signs for a jk are the same as we used
i1
p
j a j1 ... a jk ... a jp ik a j1i1 ... a jk ik ... a jp i p a i 0
jk k (18)
matrix 11
k 1
vector 1 p
ip
These matrix equations can be written for all q 1 rows of nodal connections
Ai 0 (19)
For circuit diagram graph (Fig. 12. ) we have
1 2 3 i1 4 5 6
i2
1 1 1 1 i1 i3 i6 0
i
Ai 2 1 1 1 3 i1 i2 i4 0 0 (20)
i4
3 1 1 1 i3 i4 i5 0
i5
3 6 i6 3 1 3 1
6 1
Every row of matrix multiplication Ai determines the equation for the node as
stated by Kirchhoff's current law.
For k-th generalized branch the following equation can be written
ik ik k , (21)
Ai Ai A 0 , (22)
where
i1 i1 1 0
i ; i ; ; 0 ; (23)
ip ip p 0
p 1 p 1 p 1 q 1 1
This equation can also be written as follows
p p
Ai A or a jk ik a jk k , j 1... q 1 .
k 1 k 1
(24)
In this form of the Kirchhof’s current law the current sources are specially
emphasized.
Let us write loop equations for diagram graph. Denote voltages of branches as u k .
Loop equation are numbered accordingly to connection edges. Direction of loop is the
same with the direction of the connection edge. In the loop equations voltages have sign
“plus” if loop and edge direction agrees and with “minus” in opposite case. Algebraically
sign can be taken into account by coefficient csk . Coefficient csk 1 if the k-th edge is
included in the s-th loop with the same direction; csk 1 if k-th edge is included in the s-th
loop but with opposite direction; csk 0 if k-th edge is not included in the s-th loop. By
considering this Kirchhoff's voltage law can be written as follows
c
k 1
sk uk 0, s q... p (25)
In view of the above, for the graph on Fig. 16. the system of three independent
equations can be written
for loop 4 u1 u3 u4 0, c41 1, c43 1, c44 1;
for loop 5 u1 u2 u3 0, c51 1, c52 1, c53 1, c55 1; (26)
for loop 6 u1 u2 u6 0, c61 1, c62 1, c66 1.
Let us form a table with csk coefficients. Rows of this table are numbered
accordingly to connection edges and columns accordingly to graph edges. The rectangle
matrix related to that table is called loop matrix. And coefficients are 0, 1 and -1 if the edge
is correspondingly not included in the loop, is included and has the same direction as the
loop or included and has opposite direction with the loop. Let us denote this matrix by C .
Let us write voltages of graph edges as a matrix with one column and p rows:
u1
u uk , k 1... p. (27)
up
u1
p
s cs1 ... csk ... csp uk cs1u1 ... csk uk ... csp u p c sk uk 0 (28)
matrix 11
k 1
vector 1 p
up
These matrix equations can be written for all n connection edges of the graph (rows
of loop matrix). In matrix form system of these equations is written as follows
Cu 0 (29)
For circuit diagram graph (Fig. 12. c) we have
1 2 3 u1
4 5 6
u2
4 1 1 1 u1 u3 u4 0
u
Cu 5 1 1 1 1 3 u1 u2 u3 u5 0 0 (30)
u4
6 1 1 1 u1 u2 u65 0
u5
3 6 u6 3 1 3 1
6 1
Every row of matrix multiplication Cu determines the equation for the loop as stated by
Kirchhoff's current law.
For kth generalized branch the following equation can be written
uk uk ek , (31)
where u k - voltage on passive element of kth branch, and ek -EMF in kth branch if they are
directed correspondingly to graph edge.
Matrix form of system equations according to Kirchhoff’s voltage law for voltages
and EMF can be written as follows
Cu = Cu + Ce = 0 , (32)
where
u1 u1 e1 0
u ; u ; e ; 0 ; (33)
up up ep 0
p 1 p 1 p 1 n 1
Jds i k 0 (35)
is written will enclose the set of nodes and cut the circuit diagram into two parts. Let us
depict sections on figures as closed dashed lines (for example Fig. 15. and Fig. 18. ). There
can be several sections in the circuit diagram. Each section is related to its equations which
claims that the sum of currents cut by this section is equal to zero. As was stated earlier the
number of independent equations by Kirchhoff’s current law is equal to q 1 . Therefore,
the number of independent equations for sections is also equal to q 1 as each section
equation can be get by summing corresponding node equations for nodes enclosed by
section. To make the process of the sections selecting easier let us assume that the one
section cut only one tree edge. Therefore, the number of section is equal to the number of
tree edges. The sections can be numbered as corresponding tree edges are numbered. Let
us also assume that term edge direction is a synonym to term direction of the branch
current. The surface normal is directed inside or outside section depending on the direction
of the tree edge. Therefore, tree edge current and edges currents are included in the
equations for sections currents with plus sign if they are directed to the section the same
way as tree edge current. All other currents are included with minus sign. Currents which
are not cut by the section boundary are not included in the equation. Algebraically sign can
be taken into account by coefficient d mk . Where m – number of tree edge, which is also
number of the section; k – edge number. d mk 1 if k-th edge is cut by m-th section
boundary, and d mk 0 if k-th edge is not cut by m-th section boundary. By considering this
equation for sections currents can be written as follows
p
d
k 1
i 0, m 1... q 1
mk k (36)
In view of the above, for the graph on Fig. 17. the system of three equations can be
written
for section 1 (Current out) i1 i4 i5 i6 0, d11 1, d14 1, d15 1, d16 1;
for section 2 (Current in) i2 i5 i6 0, d 22 1, d 25 1, d 26 1. (37)
for section 3 (Current in) i3 i4 i5 0, d33 1, d34 1, d35 1.
i1
i ik , k 1... p. (38)
ip
i1
p
m d m1 ... d mk ... d mp ik d m1i1 ... d mk ik ... d mpi p d i 0 (39)
mk k
matrix 11
k 1
vector 1 p
ip
These matrix equations can be written for all q 1 edges of the graph. In matrix
form system of these equations is written as follows
Di 0 (40)
For circuit diagram graph (Fig. 17. ) we have
1 2 3 i1
4 5 6
i2
1 1 1 1 1 i1 i4 i5 i6 0
i
Di 2 1 1 1 3 i2 i5 i6 0 0 (41)
i4
3 1 1 1 i3 i4 i5 0
i5
3 6 i6 3 1 3 1
6 1
Every row of matrix multiplication Di determines the equation for sections
currents as stated by Kirchhoff's current law.
For kth generalized branch the following equation can be written
ik ik k , (42)
where ik - current in passive elements of k-th branch, and k - current of current source in
k-th branch if they are directed from the same node.
Matrix form of system equations for sections currents can be written as follows
Di = Di + D = 0 , (43)
where
i1 i1 1 0
i ; i ; ; 0 ; (44)
ip ip p 0
p 1 p 1 p 1 q 1 1
This equation can also be written as follows
Di = -D . (45)
In this form current sources are specially emphasized.
3.1.7 Interconnection among nodal connections, loops and sections matrices
All three matrices described earlier can be transformed to each another. However to
make it possible graph edges have to be numbered in a certain order. Let us further number
tree edges from 1 to q 1 and graph connection edges from q to p. By considering this
1 1
i1 q 1 1 u1 q 1 1
q 1 q 1
i ; u (49)(50)
q q
i2 n 1 u2 n 1
p p
i1
Ai A1 A2 A1 i1 A 2 i2 0 (51)
i2
Where:
A1 - square submatrix with dimensions q 1 q 1 , which has q 1 columns and
matrix product A1 i1 . The same is right for matrix product A 2 i2 because A 2 has n columns
and i 2 has n rows which are related to number of connection edges in graph.
Similarly this splitting can be performed for C and D matrices.
u1
Cu C1 C2 C1u1 C2u 2 0 (52)
u2
i1
Di D1 D2 D1 i1 D2 i2 0 (53)
i2
where:
i1 and u1 - column submatrices of the tree edges currents and voltages,
i2 and u 2 - column submatrices of the connection edges currents and voltages.
In loop matrix C row number is determined by the number of the connection edge.
Taking into account that there is only one connection edge in the loop therefore it is
obvious that submatrix C2 has only one nonzero element in the row. This element is
placed in the column determined by the number of the connection edge which form this
loop. Considering above all nonzero elements of the submatrix C2 equal to one will be
placed on the main diagonal of C2 submatrix. This kind of matrix is called identity matrix.
have only one nonzero element. These elements will be placed on the main diagonal of D1
Connections edges s and j are included in m-th section with signs d ms 1 and dmj 1
correspondingly. Therefore, for all loops and sections it can be noticed that columns of
submatrix C1 can be formed by rows of the submatrix D2 if all nonzero elements are with
opposite signs. Considering above we can write
C1 DT2 or D2 C1T (56)
Let us make a substitution C1 F . Now loop and section matrices can be written as
follows
C F 1 ; D 1 FT (57)(58)
Therefore, to get matrices C and D it is enough just to form one submatrix F. For
example for graph on the Fig. 19. we have
1 2 3 4 5 6 7 8 9 10
1 1 1 1 1
2 1 1 1 1 1 1
D 1 F T (59)
3 1 1 1 1
4 1 1 1 1 1 1
Therefore,
1 2 3 4
5 1 1 1 1...4, 5...10
6 1 1 1 1
5
7 1 1
F and C F 1 . (60)(61)
8 1 1
10
9 1 1
10 1 1 1
therefore i1 = -D2 i2 .
that A11 A1 1 . Matrix A11 is called inverse. Let us multiply first matrix equation and
equation D2 = A11 A2 and existence of A 2 matrix, it can be noted that inverse matrix A11
also always exists.
Fig. 19. Circuit graph and its sections [16]
3.2 Implementation block
This section describes algorithm of circuit analysis procedure and its
implementation in MatLab. MatLab, which stands for Matrix Laboratory, is a software
developed especially to operate with matrices, thus using it benefits in a very high
computational performance towards this problem.
3.2.1 Algorithm
As was mentioned in 2.1, there are two classical methods for analyzing circuits
based on two Kirchhoff’s laws. The answer on question: «what method is more suitable for
problem?» depends on properties of circuit in study. Saying «more suitable» only
computational performance is considered. Two methods require different number of
equations to be solved by computer, which is q 1 for Nodal Analysis and p q 1
for Mesh Analysis. Therefore, at first these two values have to be compared and the
smallest value determines method which will require less equations for problem solving.
3.2.2 Choose method. Graphs
Topological structure of circuit is fully determined by such entity as graph. There
are several computer representation of graphs. First of them is incidence matrix. Incidence
matrix is a matrix that shows the relationship between two classes of objects. The first
class is nodes and the second is edges, the matrix has one row for each element of nodes
set and one column for each element of edges set. The entry in row i and column j is 1 if i
node and j edge are related (called incident in this context) and 0 if they are not [20].
Building this matrix for graph and eliminating one row will result in Matrix of nodal
connections, which can be used for circuit analysis, in other words, for nodal analysis or
being transformed to mesh matrix - for mesh analysis. Therefore, the first task is to set
incidence matrix of graph. This task can be performed element-wise by iteratively setting
elements of matrix to 1 or 0. However, this approach is not effective because it requires
one to set p q elements of matrix. Despite the necessity of having matrix of nodal
connections (reduced incidence matrix) for future computation, there is no need to set
elements of this table element-wise. There is second approach to store information about
matrix in computer, which is called table of edges (or element-wise input method). In this
approach there should be set only two numbers for each edge, which are the numbers of
nodes. Therefore, using this approach it is much easier to create a graph because it requires
setting only 2 p values in computer. Moreover, exactly this approach is used as default
in MatLab to create a graph. It should be noticed that it is not the only one way to create a
graph in MatLab, but the simplest for graph with many nodes and edges. One more
advantage of this approach is that it operates with such an entity as edge, which represent a
branch of electrical circuit and has its own resistance, EMF and current what is more
straightforward for people than matrix of nodal connections, which is actually a big table
of ones and zeros.
After branch table has been set it can be easily converted to incidence matrix and
further to matrix of nodal connections by elimination of any one row. At this stage nodal
analysis already can be performed. However, mesh analysis requires mesh matrix, which
can be get by some matrix manipulations which was described in previous section in
details. In order to make these manipulations work columns (edges) of matrix of nodal
connections have to be reordered in a certain way. First q 1 columns are related to
q 1 edges of graph tree and last p q columns to graph connections. MatLab has
built-in function minspantree, which extract a tree (as a graph) from the main graph
[21]. In allows us easily number all edges of tree and then number remaining edges, which
are graph connections. After this reordering matrix of nodal connections A can be split into
two submatrices A1 and A 2 :
F = inv(A1)*A2;
And then:
C1 = -F';
C2 = speye(length(A)-sz); % Identity matrix
C = [C1, C2];
For example, for matrix of size 10, 000 50, 000 , which is a matrix for circuit
with 10,000 nodes and 50,000 branches MatLab will allocate 4 Gb of memory. Moreover,
even if matrix will contain less elements circuit analysis methods require to store several
matrix in memory per time, for example, for multiplication. All of that lead to huge
performance decrease or even to inability of MatLab to allocate memory what produces
error.
Let us assume two matrices M1 and M2
1 0 0 1 1 1
M1 0 1 0 M 2 1 1 1
0 0 1 1 1 1
Multiplication of these two matrices requires multiplication every row of first matrix on
every column of second matrix as follows
For example, circuit with 10’000 nodes and 50.000 branches requires
q b 10, 000 50, 000 incidence matrix in which every column contain only two
elements. Therefore, using ordinary matrix we will store nnz 2 50, 000 100, 000
nonzero elements and 10, 000 40, 000 100, 000 399,990,000 zero elements. Sparsity of
100, 000
this matrix is Sparsity 1 0.999,974,9 and it will require 4 Gb of
399,900,000
memory. This matrix can be also stored in sparse matrix data type, which will require
memory 8 8 nnz 8 columns 8 8 8 100, 000 8 50, 000 8 2,000,008 what
is only 2 Mb.
All reasons mentioned above make use of sparse matrix data type crucial in circuit
analysis with nodal or mesh methods.
Fig. 22. a) Circuit, b) Circuit with directed branches, c) graph of the circuit
Moreover, indices of s and t vectors determine the direction of the branches (Fig. 22. b and
c) . For example, for the third branch index is 3 and its nodes are 3 and 1. Therefore, if
current value got from the CircuitAnalysis procedure is 1.58 that means that current
flows from node 1 to node 3 with magnitude of 1.58 .
s [ 5 2 3 4 2 3 6 6 6 ]
t [ 1 1 1 3 4 5 4 5 2 ]
R [ 33 37 6 37 26 4 12 22 39 ]
It has two output variables, which are Nodes and Branches. These variable of
MatLab table type and contain detail information about circuit. For circuit on Fig. 22.
Nodes and Branches tables are presented on Fig. 23. and Fig. 24. accordingly.
All these Name-Value pairs can be used together and in any order.
4.5 Considerations for big circuits and validation of the method
Let us assume a structure to create a reluctance network for it. Fig. 25. Shows the
periodic linear structure and its sizes in mm. Active length is 1 m. Magnetic remanence of
magnets is 1.2 T. Relative permeability of steel is assumed constant and equals to 7500.
Relative air and magnets permeability is 1.
The reluctance network method was studied in this paper and its application to the
linear structure. The procedure for automatic circuit analysis was developed and its code is
presented in the appendix. Without this procedure the method of equivalent circuit seems
to be applicable only to small circuit, which is constructed only for the main flux path.
Results have been validated by comparing with FEM as reference. Regardless, the fully
automated CircuitAnalysis procedure the reluctance network method still require a lot of
manual actions, number of which and its complexness only increase with the size of the
studied structure. Therefore, further research related to this topic can include an attempt to
develop new automation technics in addition to those, which were used in this thesis.
Current approach also gives a possibility to take saturation into account, what was
considered, but have not been implemented. Moreover, assumed constraint of equality of
all elements sizes can also be reconsidered to make the approach more flexible. Finally this
method can be applied to radial structures such as electrical machines. It will require to
generate coordinates of reluctance network and polygons denoting different structure areas
in a shape of circle.
In other words, the core of this thesis is fast procedure capable of solving circuits in
a highly optimized way and a wrapper for particular linear structure. Other wrappers have
to be developed to be able to use this procedure for other structures. This is the main
direction of the future work.
REFERENCES
All the code related to studied structure is presented in next appendices. The last
version of the CircuitAnalysis procedure also can be downloaded from GitHub repository
https://github.com/Rostislaved/CircuitAnalysis. It allows me to timely maintain
code and fix bugs to keep the newest version always available. Data from FEM simulation
to be placed in FEM.txt is presented in appendix 21.
APPENDIX 2. Main.m
clear
close all
clc
tic
global la; % Active length, m
la = 1;
w = 120; % Structure width
h = 51; % Structure height
eW = 0.5; % Element Width
eH = 0.5; % Element Height
c = w / eW; % Number of elements in horizontal (columns)
r = h / eH; % Number of elements in vertical (rows)
% Form E ================================
E = zeros(size(Is));
% Solve =================================
[ Nodes, Branches ] = CircuitAnalysis( s, t, E, Is,
Rvec,'method','nodal','order','nodes');
A = [s1(:) t1(:)];
B = Branches{:,2:3};
[~,ind] = ismember(A,B,'rows');
I(i,:) = Branches{ind,8}';
end
f = dlmread('FEM.txt');
n = length(f);
x = f(1:n,1);
y = f(1:n,3);
xx = linspace(0,n,n*2);
yy = interp1(x,y,xx);
x = eW/2:eW:w-eW/2;
plot(x, I'/(la*eH),...
'k',...
'LineWidth', 0.5,...
'Marker','o')
xlim([0 w])
axis0
cropImg
grid minor
ylabel('Magnetic remanence B, T')
xlabel('Structure length, mm')
legend('FEM','RNM')
set(gca,'FontSize',18)
toc
APPENDIX 3. formST.m
function [s, t] = formST(r, c, varargin)
% Forms two vectors describing branches which connect nodes in
% a rectangle r by n matrix:
% | 1 | 2 | 3 | ... | c |
% | c+1 | c+2 | c+3 | ... | 2c |
% | . | . | . | . | . |
% | . | . | . | . | . |
% | . | . | . | . | . |
% | (r-1)*c+1 | (r-1)*c+2 | (r-1)*c+3 | ... | r*c |
%
% At first horisontal branches are formed:
% . __________ . __________ . __________ . __________ .
% 1 5 9 13
%
%
% . __________ . __________ . __________ . __________ .
% 2 6 10 14
%
%
% . __________ . __________ . __________ . __________ .
% 3 7 11 15
%
%
% . __________ . __________ . __________ . __________ .
% 4 8 12 16
% Then verical branches:
% . __________ . __________ . __________ . __________ .
% | 1 | 5 | 9 | 13 |
% 17| 18| 19| 20| 21|
% | | | | |
% . __________ . __________ . __________ . __________ .
% | 2 | 6 | 10 | 14 |
% 22| 23| 24| 25| 26|
% | | | | |
% . __________ . __________ . __________ . __________ .
% | 3 | 7 | 11 | 15 |
% 27| 28| 29| 30| 31|
% | | | | |
% . __________ . __________ . __________ . __________ .
% 4 8 12 16
%
%
% If there is a third argument in function and its value is 1
% then all nodes of the first column are connected
% to all nodes of the last column correspondingly.
s = [];
t = [];
% Horizontal edges
for i = 1:c-1
s = [s ((1:r)-1)*c+(i+0)];
t = [t ((1:r)-1)*c+(i+1)];
end
% Verctical edges
for i = 1:r-1
s = [s (1:c)+c*(i-1)];
t = [t (1:c)+c*(i-0)];
end
s = s(:);
t = t(:);
APPENDIX 4. getReluctanceMatrix.m
function reluctanceMatrix = getReluctanceMatrixe(s, t)
w = 120;
h = 51;
eW = 0.5;
eH = 0.5;
c = w / eW;
r = h / eH;
% Right
% Steel
% xSr = [0 4 4 15 15 25 25 35 35 45 45 55 55 60 60 0 0]+60;
% ySr = [0 0 20 20 0 0 20 20 0 0 20 20 0 0 30 30 0]+22;
% xS2r = [0 60 60 0 0]+60;
% yS2r = [0 0 10 10 0];
% Magnet
xMr = [2.5 57.5 57.5 2.5 2.5]+60;
yMr = [0 0 10 10 0]+10;
x = [];
y = [];
for i = h-eH/2:-eH:eH/2
for j = eW/2:eW:w-eW/2
x = [x j];
y = [y i];
end
end
for i = 1:length(area)
Color = MaterialTable{find([MaterialTable{:,1}] ==
area(i).Material),3};
h = fill(area(i).x,area(i).y, Color,'LineWidth', 3);
alpha(0.5)
hold on
set(h,'tag','hline','handlevisibility','off');
end
proc = 3;
dx = ( max(x) - min(x) )/100 * proc;
dy = ( max(y) - min(y) )/100 * proc;
xlim([min(x) - dx max(x) + dx])
ylim([min(y) - dy max(y) + dy])
end
lbNode = 19566;
rtNode = 15115;
Direction = 'd2u';
fillValue = -f;
stNew = getST(c, lbNode, rtNode, Direction);
vec = fillValues(vec, s, t, stNew(1,:), stNew(2,:),
fillValue);
end
APPENDIX 6. cropImg.m
function cropImg()
% Crop the image
set(gca,'LooseInset',get(gca,'TightInset'))
end
APPENDIX 7. getST.m
function stNew = getST(c, lbNode, rtNode, Direction)
rightCol = mod(rtNode,c);
topRow = floor(rtNode/c) + 1;
leftCol = mod(lbNode,c);
bottomRow = floor(lbNode/c) + 1;
newM = [];
for i = 1:size(M,1)-1
newM = [newM [M(i,:); M(i+1,:)]];
end
end
if (size(vec) ~= size(sDef))
size(vec)
size(sDef)
error('size(vec) != size(sDef)');
end
APPENDIX 9. axis0.m
function axis0()
yl = ylim;
if (yl(1)<=0) & (yl(2)>=0)
g = ishold;
hold on
xl = xlim;
h = plot([xl(1) xl(2)],[0 0],'color','k');
set(h,'tag','axis0','handlevisibility','off'); % this last
part is so that it doesn't show up on legends
if g==0
hold off
end
end
end
APPENDIX 10. inc2nc.m
function An = inc2nc(B)
% Converts incidence matrix to nodes' conection matrix
An = -B(1:end-1,:);
end
oldOrder = (1:length(s))';
EdgeTable = table([s t], oldOrder, 'VariableNames', {'EndNodes'
'Num'});
G = graph(EdgeTable);
mstG = minspantree(G);
newOrder1 = sort(mstG.Edges.Num);
newOrder2 = setdiff(oldOrder,newOrder1);
newOrder = [newOrder1; newOrder2];
T = EdgeTable{newOrder,1};
s = T(:,1);
t = T(:,2);
Tr = EdgeTable(newOrder1,1);
Con = EdgeTable(newOrder2,1);
if nargout == 3
varargout{1} = newOrder;
elseif nargout == 5
G = digraph([Tr; Con]); % Full digraph
T = digraph(Tr); % Digraph of minspantree
varargout{1} = newOrder;
varargout{2} = G;
varargout{3} = T;
end
end
APPENDIX 12. CircuitAnalysis.m
%% Prepare inputs
========================================================
p = inputParse(varargin{:}); % Parse Name-value pair of arguments
s = s(:);
t = t(:);
E = E(:);
Is = Is(:);
R = R(:);
%
==================================================================
======
%%
==================================================================
=====
% Compute topological matrices of circuit and change order of
% branches: branches of tree first and branches of connections
next
[An, C, ~, newOrder] = topmat(s, t);
s = s(newOrder);
t = t(newOrder);
E = E(newOrder);
Is = Is(newOrder);
R = R(newOrder);
branchesNumbers = (1:length(s))';
branchesNumbers = branchesNumbers(newOrder);
%
==================================================================
======
%% Printing info
=========================================================
if method
disp('- Nodal Analysis')
else
disp('- Mesh Analysis')
end
disp(['- Your circuit has ' num2str( size(An, 1)+1 ) ' nodes and
'...
num2str( size(An, 2) ) '
branches.'])
if isequal(p.ConditionNumber, 'on')
tic
fprintf(['- Condition number of coefficients matrix is ',
numFormat( condest(M) ), '\n']);
time = toc;
fprintf(['- Time for computing condition number is ',
numFormat( time ),' seconds\n']);
% Rcond ================
% 0 - badly conditioned
% 1 - ill conditioned
% Cond(est)=============
% 0 - well conditioned
% 1e16 - ill conditioned
% ======================
end
%% Form output
===========================================================
% Sort nodes
num1 = 1:length(phi)+1;
object1 = [ num1(:), [phi(:); 0] ];
% Sort branches
Branches = [branchesNumbers(:), s(:), t(:), R(:), E(:), Is(:),
U(:), I(:)];
switch p.Order
case 'branches'
[~, finalOrder] = sort(branchesNumbers);
case 'nodes'
EdgeTable = table([s,t], branchesNumbers, 'VariableNames',
{'EndNodes', 'Branch'});
tempG = digraph(EdgeTable);
[~, finalOrder] = ismember(tempG.Edges.Branch,
branchesNumbers);
case 'mst'
finalOrder = branchesNumbers;
end
Branches = Branches(finalOrder,:);
function p = inputParse(varargin)
p = inputParser;
% Method
defaultMethod = 'auto';
validMethods = {'Auto', 'Nodal','Mesh'};
checkMethod = @(x) any(validatestring(x,validMethods));
% Show coefficients?
defaultCoefficients = 'hide';
validCoefficients = {'show', 'hide'};
checkCoefficients = @(x)
any(validatestring(x,validCoefficients));
% Branches order
defaultOrder = 'Branches';
validOrder = {'mst', 'Nodes', 'Branches'};
checkOrder = @(x) any(validatestring(x,validOrder));
addParameter(p,'Method',defaultMethod,checkMethod)
addParameter(p,'ConditionNumber',defaultConditionNumber,checkCondi
tionNumber)
addParameter(p,'Coefficients',defaultCoefficients,checkCoefficient
s)
addParameter(p,'Order',defaultOrder,checkOrder)
parse(p,varargin{:});
p = structfun(@lower, p.Results,'UniformOutput',false);
end
APPENDIX 14. topmat.m
% p = plot(g);
% Labels = 1:length(s);
% labeledge(p,s,t,Labels);
%
% highlight(p,T);
B = st2incidence(s,t);
A = inc2nc(B);
% sz = min(size(A));
sz = size(A, 1);
A1 = A(:,1:sz);
A2 = A(:,sz+1:end);
Q2 = inv(A1)*A2;
Q = [speye(sz) Q2];
C1 = -Q2';
C = [C1 speye(length(A)-sz)];
if nargout == 3
varargout{1} = Q;
elseif nargout == 4
varargout{1} = Q;
varargout{2} = newOrder;
end
end
APPENDIX 15. stSort.m
oldOrder = (1:length(s))';
EdgeTable = table([s t], oldOrder, 'VariableNames', {'EndNodes'
'Num'});
G = graph(EdgeTable);
mstG = minspantree(G);
newOrder1 = sort(mstG.Edges.Num);
newOrder2 = setdiff(oldOrder,newOrder1);
newOrder = [newOrder1; newOrder2];
T = EdgeTable{newOrder,1};
s = T(:,1);
t = T(:,2);
Tr = EdgeTable(newOrder1,1);
Con = EdgeTable(newOrder2,1);
if nargout == 3
varargout{1} = newOrder;
elseif nargout == 5
G = digraph([Tr; Con]); % Full digraph
T = digraph(Tr); % Digraph of minspantree
varargout{1} = newOrder;
varargout{2} = G;
varargout{3} = T;
end
end
APPENDIX 16. st2incidence.m
s = s(:)';
t = t(:)';
vec = (1:max([s,t]))';
s1 = sparse(s) == vec;
t1 = sparse(t) == vec;
B = t1 - s1;
end
E = sparse(E);
J = sparse(J);
R = sparse(R);
% g = sparse(1)./R;
% g_d = diag(g);
%
% G = An*g_d*An'; % Matrix of coefficients
% E = E + R.*Is; % Transfrom current sourse in parralel branch
to emf sourse in serial
% J = -sum((E.*g)'.*An,2); % Right part of the system
% phi = G\J; % Potentials from 1st to n-1 nodes
%
% U = An'*phi; % Potendials without taking sources into
account
% U = (U + E); % Potendials with taking sources into account
% I = U.*g; % Currents
g = sparse(1)./R;
g_d = diag(g);
I = (U + E).*g; % Currents
phi = full(phi);
I = full(I);
U = full(U);
end
APPENDIX 19. MA.m
E = sparse(E);
J = sparse(J);
R = sparse(R);
r_d = diag(R);
phi = full(phi);
I = full(I);
U = full(U);
End
end
APPENDIX 21. content of FEM.txt file
0.262 0.635 1.199 0.733 1.404 1.457 0.739 -0.630 -0.643 -1.169 -0.639 -1.188 -0.697 -1.163
0.263 0.633 1.194 0.719 1.371 1.453 0.760 -0.721 -0.647 -1.170 -0.638 -1.184 -0.687 -1.125
0.266 0.632 1.189 0.706 1.345 1.382 0.792 -0.791 -0.652 -1.171 -0.637 -1.181 -0.679 -1.080
0.272 0.631 1.186 0.697 1.319 1.284 0.826 -0.860 -0.657 -1.173 -0.637 -1.178 -0.672 -1.040
0.278 0.631 1.182 0.687 1.299 1.174 0.881 -0.917 -0.662 -1.175 -0.637 -1.176 -0.665 -0.994
0.288 0.630 1.179 0.680 1.282 1.072 0.940 -0.966 -0.669 -1.177 -0.637 -1.174 -0.660 -0.942
0.299 0.631 1.177 0.672 1.267 0.985 1.020 -1.010 -0.676 -1.180 -0.637 -1.172 -0.655 -0.882
0.314 0.631 1.174 0.667 1.254 0.921 1.112 -1.054 -0.685 -1.184 -0.638 -1.170 -0.651 -0.808
0.331 0.631 1.172 0.661 1.242 0.869 1.216 -1.097 -0.694 -1.187 -0.639 -1.169 -0.647 -0.737
0.354 0.632 1.171 0.657 1.232 0.830 1.316 -1.141 -0.705 -1.192 -0.641 -1.169 -0.644 -0.648
0.381 0.633 1.170 0.653 1.223 0.797 1.312 -1.179 -0.718 -1.196 -0.642 -1.168 -0.641 -0.567
0.414 0.635 1.169 0.650 1.215 0.772 1.307 -1.215 -0.733 -1.202 -0.644 -1.168 -0.639 -0.503
0.459 0.637 1.169 0.647 1.208 0.749 1.268 -1.268 -0.749 -1.208 -0.647 -1.168 -0.637 -0.458
0.504 0.639 1.168 0.644 1.202 0.733 1.215 -1.306 -0.772 -1.215 -0.650 -1.169 -0.635 -0.413
0.570 0.641 1.168 0.642 1.196 0.717 1.184 -1.311 -0.797 -1.223 -0.653 -1.170 -0.633 -0.381
0.650 0.644 1.169 0.641 1.192 0.705 1.135 -1.316 -0.831 -1.232 -0.657 -1.171 -0.632 -0.353
0.730 0.647 1.170 0.639 1.187 0.694 1.097 -1.217 -0.868 -1.242 -0.661 -1.172 -0.631 -0.332
0.814 0.651 1.170 0.638 1.184 0.685 1.056 -1.111 -0.922 -1.254 -0.667 -1.174 -0.631 -0.314
0.879 0.655 1.172 0.637 1.180 0.676 1.007 -1.021 -0.989 -1.267 -0.672 -1.176 -0.631 -0.299
0.943 0.660 1.174 0.637 1.177 0.669 0.964 -0.941 -1.074 -1.282 -0.680 -1.179 -0.630 -0.287
0.994 0.665 1.176 0.637 1.175 0.662 0.914 -0.882 -1.174 -1.299 -0.687 -1.182 -0.631 -0.278
1.042 0.672 1.178 0.637 1.173 0.657 0.857 -0.826 -1.290 -1.319 -0.697 -1.186 -0.631 -0.271
1.083 0.679 1.181 0.637 1.171 0.652 0.793 -0.792 -1.396 -1.345 -0.706 -1.189 -0.632 -0.266
1.124 0.687 1.184 0.638 1.170 0.647 0.715 -0.761 -1.439 -1.371 -0.719 -1.194 -0.633 -0.263
1.163 0.697 1.188 0.639 1.169 0.643 0.639 -0.738 -1.437 -1.404 -0.733 -1.199 -0.635 -0.262
1.205 0.708 1.192 0.640 1.168 0.640 0.544 -0.720 -1.444 -1.426 -0.751 -1.205 -0.637
1.240 0.720 1.197 0.642 1.168 0.637 0.457 -0.704 -1.403 -1.454 -0.771 -1.211 -0.639
1.273 0.736 1.203 0.644 1.167 0.634 0.387 -0.691 -1.380 -1.460 -0.795 -1.219 -0.642
1.325 0.752 1.208 0.647 1.168 0.632 0.335 -0.680 -1.353 -1.438 -0.825 -1.227 -0.644
1.361 0.775 1.216 0.650 1.168 0.630 0.283 -0.671 -1.330 -1.382 -0.862 -1.237 -0.648
1.362 0.800 1.223 0.653 1.169 0.629 0.243 -0.663 -1.306 -1.252 -0.913 -1.247 0.652
1.365 0.834 1.233 0.657 1.170 0.627 0.207 -0.657 -1.288 -1.137 -0.969 -1.260 -0.657
1.261 0.872 1.243 0.661 1.171 0.626 0.177 -0.651 -1.272 -1.051 -1.051 -1.274 -0.663
1.150 0.926 1.254 0.667 1.173 0.625 0.149 -0.646 -1.257 -0.968 -1.132 -1.292 -0.669
1.055 0.992 1.268 0.672 1.175 0.625 0.123 -0.642 -1.245 -0.913 -1.262 -1.310 -0.676
0.971 1.078 1.283 0.680 1.178 0.625 0.101 -0.638 -1.234 -0.861 -1.384 -1.332 -0.685
0.909 1.179 1.300 0.687 1.181 0.625 0.079 -0.635 -1.225 -0.825 -1.439 -1.355 -0.695
0.851 1.295 1.320 0.697 1.184 0.625 0.058 -0.633 -1.217 -0.795 -1.461 -1.381 -0.707
0.815 1.401 1.345 0.706 1.188 0.625 0.038 -0.631 -1.209 -0.770 -1.455 -1.413 -0.721
0.781 1.444 1.371 0.719 1.192 0.626 0.019 -0.629 -1.203 -0.750 -1.427 -1.440 -0.737
0.758 1.442 1.404 0.732 1.197 0.627 0.000 -0.627 -1.197 -0.732 -1.404 -1.463 -0.758
0.738 1.449 1.427 0.750 1.203 0.629 -0.019 -0.626 -1.192 -0.719 -1.371 -1.458 -0.781
0.721 1.408 1.454 0.770 1.209 0.631 -0.038 -0.625 -1.188 -0.706 -1.345 -1.387 -0.815
0.707 1.384 1.460 0.795 1.217 0.633 -0.058 -0.625 -1.184 -0.697 -1.320 -1.288 -0.851
0.695 1.357 1.438 0.825 1.225 0.635 -0.079 -0.625 -1.181 -0.687 -1.300 -1.178 -0.908
0.685 1.333 1.382 0.862 1.235 0.638 -0.101 -0.625 -1.178 -0.680 -1.283 -1.076 -0.971
0.676 1.310 1.253 0.913 1.245 0.642 -0.123 -0.625 -1.175 -0.672 -1.268 -0.988 -1.054
0.669 1.291 1.137 0.969 1.258 0.646 -0.149 -0.625 -1.173 -0.667 -1.254 -0.924 -1.150
0.663 1.275 1.051 1.050 1.271 0.651 -0.177 -0.626 -1.171 -0.661 -1.243 -0.872 -1.260
0.657 1.259 0.968 1.132 1.288 0.657 -0.208 -0.627 -1.170 -0.657 -1.233 -0.833 -1.365
0.652 1.247 0.913 1.261 1.307 0.663 -0.243 -0.629 -1.169 -0.653 -1.223 -0.800 -1.363
0.648 1.236 0.861 1.384 1.328 0.671 -0.284 -0.630 -1.168 -0.650 -1.216 -0.775 -1.361
0.644 1.227 0.825 1.439 1.351 0.680 -0.336 -0.632 -1.168 -0.647 -1.208 -0.752 -1.324
0.642 1.219 0.795 1.461 1.377 0.691 -0.387 -0.634 -1.167 -0.644 -1.203 -0.735 -1.273
0.639 1.211 0.770 1.454 1.408 0.704 -0.460 -0.637 -1.168 -0.642 -1.197 -0.720 -1.245
0.637 1.205 0.750 1.426 1.436 0.720 -0.545 -0.640 -1.168 -0.640 -1.192 -0.708 -1.198