Ejemplo n.º 1
0
        /// <summary>
        /// Obtains all loads in the Active Circuit.
        /// </summary>
        /// <param name="Buses">A Dictionary of buses indexed by ID.
        /// Used for determining which buses the loads are on.</param>
        /// <returns>All loads in the Active Circuit.</returns>
        private Collection<Load> GetLoads(Dictionary<String, Bus> Buses)
        {
            Collection<Load> results = new Collection<Load>();
            String[] loads = dss.ActiveCircuit.Loads.AllNames;

            //more OpenDSS quirk handling. if there are no loads, OpenDSS returns
            // an array of length 1 with the item "NONE". go figure.
            if (loads[0] == "NONE")
            {
                return results;
            }

            //loop through the loads, connect the appropriate buses and add them.
            foreach (String loadName in loads)
            {
                var dssLoad = dss.ActiveCircuit.CktElements["load." + loadName];
                if (!dssLoad.Enabled)
                    continue;
                var rawPowers = (double[])dssLoad.Powers;
                var powers = new PhasedValues<Complex>();
                for (int i = 0; i < dssLoad.NumPhases; i++)
                {
                    powers[i + 1] = new Complex(rawPowers[2*i], rawPowers[2*i + 1]);
                }

                Load load = new Load(loadName, powers);

                var busConnectionInfo = ResolveOpenDSSBusString((String)dssLoad.BusNames[0], dssLoad.NumPhases);
                if (Buses.ContainsKey(busConnectionInfo.Item1))
                {
                    load.ConnectWye(Buses[busConnectionInfo.Item1],powers.Keys,busConnectionInfo.Item2);
                }
                results.Add(load);
            }
            return results;
        }
Ejemplo n.º 2
0
        public void PrepUnbalanced()
        {
            Dictionary<String, Bus> buses = new Dictionary<string, Bus>();
            buses["b1"] = new Bus("b1", pc3pr(130770, 0.4, 132860, -120.8, 134130, 120.6), 132.79, new Point(0, 0));
            buses["b2"] = new Bus("b2", pc3pr(866380, 99.9, 83445, -21.2, 86499, -142.5), 132.79, new Point(0, 0));
            buses["b3"] = new Bus("b3", pc3pr(94825, 14.5, 96205, -107.4, 98249, 134.2), 132.79, new Point(0, 0));
            buses["b4"] = new Bus("b4", pc3pr(67374, 68.6, 65606, -54, 69131, -174), 132.79, new Point(0, 0));

            var lb1b2 = new Line("b1b2", 1);
            lb1b2.Connect(buses["b1"], new[] { 1, 2, 3 }, buses["b2"], new[] { 2, 3, 1 });
            var lb1b3 = new Line("b1b3", 2);
            lb1b3.Connect3Phase(buses["b1"], buses["b3"]);
            var lb2b4 = new Line("b2b4", 3);
            lb2b4.Connect3Phase(buses["b2"], buses["b4"]);
            var lb3b4 = new Line("b3b4", 4);
            lb3b4.Connect(buses["b3"], buses["b4"], new[] { 1, 2 });

            Collection<Line> lines = new Collection<Line>();
            lines.Add(lb1b2);
            lines.Add(lb1b3);
            lines.Add(lb2b4);
            lines.Add(lb3b4);

            Generator g = new Generator("g4", pc3(106000, 0.9797, 106000, -1.3930, 106000, 0.4265));

            g.ConnectWye(buses["b4"]);
            Collection<Generator> generators = new Collection<Generator>();
            generators.Add(g);

            Collection<Load> loads = new Collection<Load>();
            var l1 = new Load("l1", pc3(16382, 10280, 16852, 10108, 16766, 10601));
            l1.ConnectWye(buses["b1"], 1, 2, 3);
            var l2 = new Load("l2", pcV(2, 85000, 52674, 3, 85000, 52675));
            l2.ConnectWye(buses["b2"], 2, 3);
            var l3 = new Load("l3", pcV(1, 200000, 12940));
            l3.ConnectWye(buses["b3"], 1, 2);
            var l4 = new Load("l4", pc3(26666, 16527, 26666, 16527, 26666, 16527));
            l4.ConnectWye(buses["b4"], 1, 2, 3);
            loads.Add(l1);
            loads.Add(l2);
            loads.Add(l3);
            loads.Add(l4);

            model = new NetworkModel(buses, lines, loads, generators, new Complex(140424, 692575), buses["b1"]);
        }