Institute of Scientific Computing Technische Universität Braunschweig Prof. Hermann G. Matthies, Ph. D. Rainer Niekamp Summer Term 2014 April 15, 2014 Intermediate Programming Analysis of Linear Resistor Networks Exercise Sheet 5 In the following exercises you shall independently — without many templates — implement different solvers for problems in linear circuit analysis. The needed systems of equations are thereby to be set up using two different approaches. The system-matrix is assembled using the so-called Direct Stiffness Method (http://en.wikipedia.org/wiki/Direct_stiffness_method) on the fifth sheet (the current one). Linear networks can be considered as graphs where the edges have a direction (direction of counting of the currents) and a resistance. i1 R2 R7 4 1 R4 R1 R5 R8 R3 2 6 R6 3 5 NODE(1) NODE(2) NODE(3) NODE(4) NODE(5) NODE(6) EDGE(1,2,10.0) EDGE(1,4,10.0) EDGE(2,3,10.0) EDGE(2,4,10.0) EDGE(3,4,100.0) EDGE(3,5,10.0) EDGE(4,6,10.0) EDGE(5,6,10.0) Figure 1: A circuit network. The network from this figure is described by the input file on the right. 1 Summary of the Electrical Engineering Terms In this exercise we use some terms from electrical engineering which are now explained in compact form. incidence matrix Describes the topology of the circuit and contains a row for each node and a column for each edge. Ai,e = +1 , if edge e points out of node i. (1) Ai,e = −1 , if edge e points to node i. (2) Ai,e = 0 , else. (3) branch The terms ”branch” and ”edge” are synonymous. 1 1 admittance = (complex)susceptance = impedance ' Resistance . This applies in the real case with DC, but AC and non-linear components are not to be considered within this tasks. The matrix Y is a diagonal matrix with Yi,i = 1/Ri . Branch impedance matrix Z is a diagonal matrix with Zi,i = Ri . (4) Use of the Graph Interpreter The graph interpreter which was developed on the last exercise sheet shall be used for this task again in order to read in the graph of the depicted network. You can also add a new command which triggers the calculation described later in Exercise 3 on this sheet. Exercise 1: Extending the Matrix Library Until now we have used two-dimensional arrays as matrices. However, in this exercise you are to develop a dedicated matrix class which provides operations such as matrix multiplication and transposition. Thereby one can translate formulas to source code in a simple way. For instance the formula A · B T · v can be implemented as a.multiply(b.transpose()).multiply(v). Internally the class still uses a two-dimensional array, but simplifies its use. Again we provide you with a template in the file Matrix.java, which you can find in the package to this task (http: //www.wire.tu-bs.de/ADV/files/exercise5.zip). We have already implemented the method solve(double[] b) for you. This method solves systems of equations similarly to the algorithm that was implemented on exercise sheet 2. Task a) Implement the methods declared in file Matrix.java (except for the already given method solve). 2 Exercise 2: Matrix-Assembly using the Direct Stiffness Method For computing the resulting voltages with given source-currents at the nodes in a resistor-network, the following system of equations is to be solved: A Y AT un = in | {z } Yn (5) The Direct Stiffness Method (DSM) can be used here to assemble the node-admittance-matrix (A Y AT ) from equation 5 efficiently. The DSM can be derived and understood easily in linear circuits. Task a) The matrix Y n can be computed as the sum of fundamental matrices. For understanding this, compute the matrix for the following simple networks by hand (see equation 5). 2 At first a graph with only one edge and two nodes: Node(1) Node(2) Edge(1, 2, 10.0) Now a graph with only one edge and several nodes: Node(1) ... Node(8) Edge(3, 6, 10.0) And again a graph with only one edge and several nodes: Node(1) ... Node(8) Edge(6, 2, 20.0) and now the combination of the last two examples: Node(1) ... Node(8) Edge(3, 6, 10.0) Edge(6, 2, 20.0) You can see that the node-admittance-matrix of the combined graph is just the sum of the matrices for the graphs with only one edge. The fundamental admittance-matrices can thereby be computed directly from the edge information. Task b) Implement a method which takes a graph as input and computes a node-admittance-matrix for this graph. Therefore use the following routine to implement the assembly. The routine implements the DSM for the present case. Matrix A in the pseudocode represents the already described matrix Y n . 1 2 3 4 5 for all Edges e A[e. source_id ][e. source_id ] A[e. source_id ][e. target_id ] A[e. target_id ][e. source_id ] A[e. target_id ][e. target_id ] += -= -= += ( ( ( ( 1 1 1 1 / / / / e. weight ) e. weight ) e. weight ) e. weight ) Listing 1: Pseudocode assembling the node admittance matrix 2 Exercise 3: Solving the system of equations Task a) Write a program which reads in the graph given on the first page and assembles the respective node-admittance-matrix. Solve the system of equations by using the method solve, thereby use the external currents i1 = 0.1 and i2..6 = 0 as right-hand-side. 2 You see that the algorithm can not solve this system. This is caused by the ill-posedness of this problem, because it does not have a unique solution. This can be understood with a small example (see figure 2): Here the fall of potential over the resistor can be determined to be 1V , but you can not make a i1=1A R=U/I=1Ω Figure 2: Simple ill-posed example conclusion about the absolute voltages at each end of the component. In other words, there are undefined many solutions for the problem. For making the solution unique, you can earth one of the nodes. For doing that in the system of equations you have to eliminate an unknown. Task b) Use the methods: deleteRow(int i) deleteColumn(int i) to eliminate the degree of freedom 6, by eliminating the unknown. 2 The circuit with earthed node 6 and previously defined right-hand-side has relatively to node 6 the following node-voltages: u1 = 1.284, u2 = 0.8581, u3 =???, u4 = 0.7097, u5 = 0.2903 Task c) Verify this voltages with the help of your program and give your value for u3 . 2