static void Main(string[] args) { #region MainMWE //Setup a network controller and choose a network definition file // appropriate to the simulator in use NetworkController controller = new NetworkController(new OpenDSSSimulator()); //Set this to the absolute path to the IEEE13mod.dss file, e.g. controller.NetworkFilename = @"C:\temp\IEEE13mod.dss"; //Add our new experiment, with +10% load scaling. controller.ExperimentDriver = new LoadScalingExperimentor(1.1); //Use a DifferenceTransform so that the controller returns the // differences between pre- and post- experiment voltages. controller.ResultsTransformer = new DifferenceTransform(); //Run the simulation controller.Execute(); //Output the change in voltage at every network bus. foreach (var bus in controller.Network.Buses.Values) { Console.WriteLine( "Bus " + bus.ID + " has changed in voltage (pu) by " + bus.VoltagePU.Magnitude); } #endregion #region MainGraphing var graph = new ValueTransformableTreeGraph(); // make a new graph. graph.Network = controller.Network; // assign the output of the experiment to the graph. GraphHostWindow.StartGraphHostWindow(graph); // put the graph in a window and display it. #endregion otherGraph(controller.Network); }
public NetworkModel GetNetwork(String networkName) { NetworkController sim = new NetworkController(new BogusSimulator()); sim.NetworkFilename = networkName; sim.Execute(); return sim.Network; }
//Ex9_5_unbal //Ex9_5 public NetworkModel GetNetwork(String NetworkName) { NetworkController sim = new NetworkController(new OpenDSSSimulator()); string path = AppDomain.CurrentDomain.BaseDirectory; sim.NetworkFilename = path + @"\TestNetworks\"+NetworkName+".dss"; sim.Execute(); return sim.Network; }
/// <summary> /// Generates Voltage Sensitivities to changes in P and Q at each load bus on /// the network. /// </summary> /// <remarks> /// This is a convenience class that uses the functionality supplied by /// <see cref="SensitivityGenerator{T}"/> and <see cref="PerturbAndObserveRunner{T}"/>. /// For other kinds of sensitivities, you may wish to use these classes directly.</remarks> /// <param name="Simulator">The simulator to use for the generation of sensitivities.</param> /// <param name="NetworkMasterFile">The file path of the Network to calculate sensitivities for.</param> /// <param name="CommandString">A command for issuing perturbations. The command should be /// compatible with <see cref="String.Format(String,Object[])"/>-style format strings, and should /// use <c>{0}</c> to represent a random ID, <c>{1}</c> to represent the bus that perturbation should occur /// on, <c>{2}</c> to represent a kW quantity to perturb by and <c>{3}</c> to represent a kVAr quantity to /// perturb by. /// <example> /// As an example, the following string specifies a new generator for perturbation in OpenDSS syntax: /// <code> /// "new Generator.{0} bus1={1} phases=3 model=1 status=fixed kV=11 Vminpu=0.9 Vmaxpu=1.1 kW={2} kvAR={3}"</code></example></param> /// <param name="PerturbationFrac">The fraction of average load size to perturb by.</param> /// <returns>A 2-axis dictionary, in which the X-axis represents the source bus, the Y-axis represents the affected bus, /// and the values are an index of sensitivity information.</returns> public static TwinKeyDictionary<String, String, VoltageSensitivityToPQDataSet> GetVoltageSensitivityToComplexPower(ISimulator Simulator, String NetworkMasterFile, String CommandString, double PerturbationFrac) { PerturbAndObserveRunner<Complex> perturbAndObserve = new PerturbAndObserveRunner<Complex>(Simulator); NetworkController controller = new NetworkController(Simulator); controller.NetworkFilename = NetworkMasterFile; controller.Execute(); var avgLoad = controller.Network.Loads.Select(load=>load.ActualKVA).Aggregate((seed,elem) => seed+elem); avgLoad /= controller.Network.Loads.Count; perturbAndObserve.NetworkFilename = NetworkMasterFile; perturbAndObserve.ObserveElementSelector = network => network.Buses.Values.Where(bus => bus.ConnectedTo.OfType<Load>().Any()); perturbAndObserve.PerturbElementSelector = perturbAndObserve.ObserveElementSelector; perturbAndObserve.PerturbCommands = new []{CommandString}; perturbAndObserve.ObserveElementValuesSelector = elem => ((Bus)elem).Voltage; SensitivityGenerator<Complex> generator = new SensitivityGenerator<Complex>(); //real perturbAndObserve.PerturbElementValuesSelector = bus => new Object[] {"inject-"+bus.ID,bus.ID,PerturbationFrac * avgLoad.Real, 0}; perturbAndObserve.PerturbValuesToRecord = vars => vars[2]; perturbAndObserve.RunPerturbAndObserve(); generator.RecordedPerturbationSelector = x => x; generator.ResultSelector = x => x.Magnitude; var MagnitudeDictionaryReal = generator.GenerateSensitivities(perturbAndObserve); generator.ResultSelector = x => x.Phase; var PhaseDictionaryReal = generator.GenerateSensitivities(perturbAndObserve); //imaginary perturbAndObserve.PerturbElementValuesSelector = bus => new Object[] { "inject-" + bus.ID, bus.ID, 0, PerturbationFrac * avgLoad.Imaginary }; perturbAndObserve.PerturbValuesToRecord = vars => vars[3]; perturbAndObserve.RunPerturbAndObserve(); generator.RecordedPerturbationSelector = x => x; generator.ResultSelector = x => x.Magnitude; var MagnitudeDictionaryImag = generator.GenerateSensitivities(perturbAndObserve); generator.ResultSelector = x => x.Phase; var PhaseDictionaryImag = generator.GenerateSensitivities(perturbAndObserve); // now merge all the dictionaries. return TwinKeyDictionaryMerge(MagnitudeDictionaryReal, MagnitudeDictionaryImag, PhaseDictionaryReal, PhaseDictionaryImag); }
public NetworkModel GetNetwork() { NetworkController sim = new NetworkController(null); sim.Execute(); return sim.Network; }