/// <summary> /// Obtains a list of all buses from OpenDSS. /// </summary> /// <returns>A Dictionary of Buses, indexed by ID String. /// This is required in order to link the other network elements. /// </returns> private Dictionary <String, Bus> GetBuses() { Dictionary <String, Bus> results = new Dictionary <String, Bus>(); OpenDSSengine.Circuit circuit = dss.ActiveCircuit; for (int busIdx = 0; busIdx < circuit.NumBuses; busIdx++) { var bus = circuit.Buses[busIdx]; // voltages are stored in OpenDSS as a double[2n], where n is the number of phases. // the numbers are stored in complex pairs per phase. var rawVoltage = bus.Voltages; String busID = bus.Name; var phases = (int[])bus.Nodes; PhasedValues <Complex> voltages = new PhasedValues <Complex>(); for (int i = 0; i < phases.Length; i++) { voltages[phases[i]] = new Complex(rawVoltage[2 * i], rawVoltage[2 * i + 1]); } //NOTE NEGATIVE FOR THE BUS Y AXIS. The Y coordinate used // by openDSS is opposite to that used in .net. So flip // it here. results.Add(busID, new Bus(busID, voltages, bus.kVBase * 1000, bus.Coorddefined ? (Point?)new Point(bus.x, -bus.y) : null ) ); } return(results); }
public Phased<Complex> pc3pr(double M1, double A1, double M2, double A2, double M3, double A3) { var p = new PhasedValues<Complex>(); p[1] = pr(M1, A1); p[2] = pr(M2, A2); p[3] = pr(M3, A3); return p; }
public Phased<Complex> pc3(double R1, double I1, double R2, double I2, double R3, double I3) { var p = new PhasedValues<Complex>(); p[1] = new Complex(R1, I1); p[2] = new Complex(R2, I2); p[3] = new Complex(R3, I3); return p; }
public Phased<Complex> pcV(params double[] p) { var retVal = new PhasedValues<Complex>(); for (int i = 0; i < p.Length; i += 3) { retVal[(int)p[i]] = new Complex(p[i + 1], p[i + 2]); } return retVal; }
public Phased <Complex> pc3(double R1, double I1, double R2, double I2, double R3, double I3) { var p = new PhasedValues <Complex>(); p[1] = new Complex(R1, I1); p[2] = new Complex(R2, I2); p[3] = new Complex(R3, I3); return(p); }
public Phased <Complex> pc3pr(double M1, double A1, double M2, double A2, double M3, double A3) { var p = new PhasedValues <Complex>(); p[1] = pr(M1, A1); p[2] = pr(M2, A2); p[3] = pr(M3, A3); return(p); }
public Phased <Complex> pcV(params double[] p) { var retVal = new PhasedValues <Complex>(); for (int i = 0; i < p.Length; i += 3) { retVal[(int)p[i]] = new Complex(p[i + 1], p[i + 2]); } return(retVal); }
/// <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); }
/// <summary> /// Obtains all generators 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 generators in the Active Circuit.</returns> private Collection <Generator> GetGenerators(Dictionary <String, Bus> Buses) { Collection <Generator> results = new Collection <Generator>(); String[] generators = dss.ActiveCircuit.Generators.AllNames; //more OpenDSS quirk handling. if there are no generators, OpenDSS returns // an array of length 1 with the item "NONE". go figure. if (generators[0] == "NONE") { return(results); } //loop through the generators, connect the appropriate buses and add them. foreach (String generatorName in generators) { var dssGenerator = dss.ActiveCircuit.CktElements["generator." + generatorName]; if (!dssGenerator.Enabled) { continue; } var rawPowers = (double[])dssGenerator.Powers; var powers = new PhasedValues <Complex>(); for (int i = 0; i < dssGenerator.NumPhases; i++) { powers[i + 1] = new Complex(-rawPowers[2 * i], -rawPowers[2 * i + 1]); } Generator gen = new Generator(generatorName, powers); var busConnectionInfo = ResolveOpenDSSBusString((String)dssGenerator.BusNames[0], dssGenerator.NumPhases); if (Buses.ContainsKey(busConnectionInfo.Item1)) { gen.ConnectWye(Buses[busConnectionInfo.Item1], powers.Keys, busConnectionInfo.Item2); } results.Add(gen); } return(results); }
/// <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; }
/// <summary> /// Obtains all generators 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 generators in the Active Circuit.</returns> private Collection<Generator> GetGenerators(Dictionary<String, Bus> Buses) { Collection<Generator> results = new Collection<Generator>(); String[] generators = dss.ActiveCircuit.Generators.AllNames; //more OpenDSS quirk handling. if there are no generators, OpenDSS returns // an array of length 1 with the item "NONE". go figure. if (generators[0] == "NONE") { return results; } //loop through the generators, connect the appropriate buses and add them. foreach (String generatorName in generators) { var dssGenerator = dss.ActiveCircuit.CktElements["generator." + generatorName]; if (!dssGenerator.Enabled) continue; var rawPowers = (double[])dssGenerator.Powers; var powers = new PhasedValues<Complex>(); for (int i = 0; i < dssGenerator.NumPhases; i++) { powers[i + 1] = new Complex(-rawPowers[2 * i], -rawPowers[2 * i + 1]); } Generator gen = new Generator(generatorName, powers); var busConnectionInfo = ResolveOpenDSSBusString((String)dssGenerator.BusNames[0], dssGenerator.NumPhases); if (Buses.ContainsKey(busConnectionInfo.Item1)) { gen.ConnectWye(Buses[busConnectionInfo.Item1], powers.Keys, busConnectionInfo.Item2); } results.Add(gen); } return results; }
/// <summary> /// Obtains a list of all buses from OpenDSS. /// </summary> /// <returns>A Dictionary of Buses, indexed by ID String. /// This is required in order to link the other network elements. /// </returns> private Dictionary<String, Bus> GetBuses() { Dictionary<String, Bus> results = new Dictionary<String, Bus>(); OpenDSSengine.Circuit circuit = dss.ActiveCircuit; for (int busIdx = 0; busIdx < circuit.NumBuses; busIdx++) { var bus = circuit.Buses[busIdx]; // voltages are stored in OpenDSS as a double[2n], where n is the number of phases. // the numbers are stored in complex pairs per phase. var rawVoltage = bus.Voltages; String busID = bus.Name; var phases = (int[])bus.Nodes; PhasedValues<Complex> voltages = new PhasedValues<Complex>(); for (int i = 0; i < phases.Length; i++) { voltages[phases[i]] = new Complex(rawVoltage[2 * i], rawVoltage[2 * i + 1]); } //NOTE NEGATIVE FOR THE BUS Y AXIS. The Y coordinate used // by openDSS is opposite to that used in .net. So flip // it here. results.Add(busID, new Bus(busID, voltages, bus.kVBase * 1000, bus.Coorddefined ? (Point?)new Point(bus.x, -bus.y) : null ) ); } return results; }
public EvaluatedPhasedTests() { values = new PhasedValues <Complex>(); values.Add(1, new Complex(10, 5)); eval = new PhasedEvaluated <Complex, Complex>(c => c / 5, c => c * 5, values); }
public EvaluatedPhasedTests() { values = new PhasedValues<Complex>(); values.Add(1, new Complex(10, 5)); eval = new PhasedEvaluated<Complex, Complex>(c => c / 5, c => c * 5, values); }