public static List <SimplifiedCircuit> toSimplifiedCir(List <List <Record> > cirlist) //transforms to List<list<Record>> to List <SimplifiedCircuit> { List <SimplifiedCircuit> simplCirList = new List <SimplifiedCircuit>(); for (int i = 0; i < cirlist.Count; i++) { SimplifiedCircuit sCir = new SimplifiedCircuit(); for (int j = 0; j < cirlist.ElementAt(i).Count; j++) { sCir.elements.Add(cirlist.ElementAt(i).ElementAt(j).getName()); int[] nodes = cirlist.ElementAt(i).ElementAt(j).getNodes(); for (int k = 0; k < 4; k++) { if (nodes[k] > 0) { sCir.initialNodes.Add(nodes[k]); } } sCir.initialNodes.Distinct(); simplCirList.Add(sCir); } } return(simplCirList); }
/* This method finds parallel subcircuits in circuit. * To reduce complexity, method checks only not sequential nodes. * At first step method gets an array of not sequential circuits * Then the List< List<Record>> is made. This list contains lists with elements which are connected in concrete not sequential node * For example , List of nodes, which are connected to the 3_d node * After that , in each list of nodes method tries to find sublist of elements, which are connected to the other not serial nodes * If this sublist was found, that means it is parallel subcircuit. * Then, struct SimplifiedCircuit is made from this */ public static List <SimplifiedCircuit> findParallelSubcir(List <Record> testcircuit) { List <SimplifiedCircuit> parallelCirs = new List <SimplifiedCircuit>(); int[] notSerial = Utils.getNotSerialNodes(testcircuit); List <List <Record> > byNodes = new List <List <Record> >(); for (int i = 0; i < notSerial.Length; i++) { List <Record> byNode = getElementsByNode(testcircuit, notSerial[i]); byNodes.Add(byNode); } for (int i = 0; i < notSerial.Length; i++) { for (int j = i + 1; j < notSerial.Length; j++) { List <Record> parallel = getElementsByNode(byNodes.ElementAt(i), notSerial[j]); if (parallel.Count > 1) { SimplifiedCircuit cir = new SimplifiedCircuit(); cir.initialNodes.Add(notSerial[i]); cir.initialNodes.Add(notSerial[j]); for (int n = 0; n < parallel.Count; n++) { cir.elements.Add(parallel.ElementAt(n).getName()); byNodes.ElementAt(i).Remove(parallel.ElementAt(n)); byNodes.ElementAt(j).Remove(parallel.ElementAt(n)); } parallelCirs.Add(cir); } } } return(parallelCirs); }