static public double[,] GetMatrixB(int row, int col, LinkedListNetList argList) { Console.WriteLine("MatrixB argList:"); argList.PrintLinkedListNetList(); double[,] returnMatrix = new double[row, col]; // default elements set to zero NetListNode testNode = argList.head; while (testNode != null) { if (testNode.data.getComponentType() == 'V') { // minus one since Matrix index starts from zero Console.WriteLine("Voltage found in MatB arglist"); testNode.data.PrintNetList(); if (testNode.data.Node1 != 0) { returnMatrix[testNode.data.Node1 - 1, testNode.data.Index - 1] = 1; } else { returnMatrix[testNode.data.Node1 - 1, testNode.data.Index - 1] = 0; } if (testNode.data.Node2 != 0) { returnMatrix[testNode.data.Node2 - 1, testNode.data.Index - 1] = -1; } else { returnMatrix[testNode.data.Node1 - 1, testNode.data.Index - 1] = 0; } } testNode = testNode.next; } return(returnMatrix); }
public void PrintLinkedListNetList() { NetListNode testNode = head; Console.WriteLine("List:\n"); while (testNode != null) { testNode.data.PrintNetList(); testNode = testNode.next; } }
public void AddNode(ref NetList argData, int mode) { Console.WriteLine("Adding node {0}", argData.Label); Console.WriteLine("Type : {0}", argData.getComponentType()); NetListNode toAdd = new NetListNode(); toAdd.data.GetNetlist(argData); if (mode == NEW_ENTRY) { NetListCount++; } switch (argData.getComponentType()) { case 'R': if (mode == NEW_ENTRY) { ++ResistorCount; } Console.WriteLine("Index of {0} before GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); toAdd.data.GetIndex(ResistorCount); Console.WriteLine("Index of {0} after GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); break; case 'V': if (mode == NEW_ENTRY) { ++VoltageSourceCount; } Console.WriteLine("Index of {0} before GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); toAdd.data.GetIndex(VoltageSourceCount); Console.WriteLine("Index of {0} after GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); break; case 'C': if (mode == NEW_ENTRY) { ++CurrentSourceCount; } Console.WriteLine("Index of {0} before GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); toAdd.data.GetIndex(CurrentSourceCount); Console.WriteLine("Index of {0} after GetIndex(): {1}", toAdd.data.Label, toAdd.data.Index); break; } if (head == null) { head = toAdd; tail = toAdd; } else { tail.next = toAdd; tail = toAdd; } }
static public double[,] GetMatrixE(int row, int col, LinkedListNetList argList) { double[,] returnMatrix = new double[row, col]; // default elements set to zero NetListNode testNode = argList.head; while (testNode != null) { // minus one since Matrix index starts from zero returnMatrix[testNode.data.Index - 1, 1] = testNode.data.Value; testNode = testNode.next; } return(returnMatrix); }
public int VoltageCount() { NetListNode testElement = this.head; int voltageNum = 0; while (testElement != null) { //need input format voltageNum++; testElement = testElement.next; Console.WriteLine("Counting elements for voltage source count..."); } return(voltageNum); }
public int NodeCount() { NetListNode testNode = this.head; int nodeNum = 0; while (testNode != null) { if (testNode.data.Node1 > nodeNum) { nodeNum = testNode.data.Node1; } if (testNode.data.Node2 > nodeNum) { nodeNum = testNode.data.Node2; } testNode = testNode.next; } return(nodeNum); }
static public double[,] GetMatrixG(int row, int col, LinkedListNetList argList) { Console.WriteLine("MatrixG argList:"); argList.PrintLinkedListNetList(); double[,] returnMatrix = new double[row, col]; // default elements set to zero NetListNode testNode = argList.head; while (testNode != null) { if (testNode.data.getComponentType() == 'R') { // minus one since Matrix index starts from zero Console.WriteLine("Resistor found in MatG arglist"); if (testNode.data.Node1 > 0) { // Console.WriteLine("Value of conductance: {0}", 1 / testNode.data.Value); // Console.WriteLine("Value of resistance: {0}", testNode.data.Value); returnMatrix[testNode.data.Node1 - 1, testNode.data.Node1 - 1] = returnMatrix[testNode.data.Node1 - 1, testNode.data.Node1 - 1] + (1 / testNode.data.Value); } if (testNode.data.Node2 > 0) { // Console.WriteLine("Value of conductance: {0}", 1 / testNode.data.Value); // Console.WriteLine("Value of resistance: {0}", testNode.data.Value); returnMatrix[testNode.data.Node2 - 1, testNode.data.Node2 - 1] = returnMatrix[testNode.data.Node2 - 1, testNode.data.Node2 - 1] + (1 / testNode.data.Value); } if (testNode.data.Node1 > 0 && testNode.data.Node2 > 0) { // Console.WriteLine("Nodes not zero"); // Console.WriteLine("Value of conductance: {0}", 1 / testNode.data.Value); // Console.WriteLine("Value of resistance: {0}", testNode.data.Value); returnMatrix[testNode.data.Node1 - 1, testNode.data.Node2 - 1] -= (1 / testNode.data.Value); returnMatrix[testNode.data.Node2 - 1, testNode.data.Node1 - 1] -= (1 / testNode.data.Value); } } testNode = testNode.next; } return(returnMatrix); }
public LinkedListNetList() { head = null; tail = null; }
public NetListNode() { next = null; data = new NetList(); }