Perturb-and-Observe Style Experiments and Sensitivity GenerationElecNetKit Documentation

One of the core strengths of ElecNetKit lies in data manipulation and transformation. To that effect, the generation of sensitivity data has been found to be incredibly helpful for the purposes of exploring network P-Q-V relationships and planning for the installation of distributed generation, storage, and voltage support systems.

ElecNetKit features a module designed for simplifying perturb-and-observe-style experiments, and for generating sensitivity information from these experiments. This module is introduced in this topic.

This topic contains the following sections.

Perturb-and-Observe Experiments

Perturb-and-Observe Experiments are run using the PerturbAndObserveRunner TObserve  class.

Setting Up a Perturb-and-Observe Experiment

  • Specify the NetworkFilename of the network to run the perturb-and-observe experiment on.

  • Specify selector functions, that take a NetworkModel and return a set of NetworkElements. You should specify a selector function for all elements that are to be perturbed (PerturbElementSelector) and for all elements that are to be observed (ObserveElementSelector). It is common to set the observed elements to the buses in the network, for example:

    myPerturbAndObserveRunner.ObserveElementSelector = network => network.Buses.Values;

    The choice of PerturbElementSelector is a little more arbitrary due to the way that perturbation commands are issued to the simulator (this will be explained later).

  • Specify value selector functions PerturbElementValuesSelector and ObserveElementValuesSelector. These take the network elements selected by PerturbElementSelector and ObserveElementSelector, and obtain values that will be observed or used in the perturbation command. For example, if we wish to observe the bus voltages, we can use the statement:

    myPerturbAndObserveRunner.ObserveElementValuesSelector = networkElement => ((Bus)networkElement).Voltage.Magnitude;

    As an example of pulling data from perturbation elements to be used in the perturbation command, the following two commands specify perturbation on buses, and select some values to populate the perturbation commands:

    myPerturbAndObserveRunner.PerturbElementSelector = network => network.Buses.Values;
    myPerturbAndObserveRunner.PerturbElementValuesSelector = bus => new Object[] {bus.ID};

    In the above example, only the bus ID is selected. The data that needs to be selected depends upon the specific use case and perturbation commands.

  • Specify a set of PerturbCommands. Each command can have optional placeholders that will be filled in with values from the PerturbElementValuesSelector specified earlier. Placeholders are specified as {0}, {1}, {2} etc., where the number between the curly braces is the index in the array of objects returned by the value selector. For example, if the PerturbElementValuesSelector returned {25, "myBus", 11}, the command string

    "new Generator.testgenerator-{1} bus1={1} phases=3 model=1 status=fixed kV={2} Vminpu=0.9 Vmaxpu=1.1 kW={0} kvAR=0"

    would resolve to

    "new Generator.testgenerator-myBus bus1=myBus phases=3 model=1 status=fixed kV=11 Vminpu=0.9 Vmaxpu=1.1 kW=25 kvAR=0"

    You can set up this command string using the code:

    myPerturbAndObserveRunner.PerturbCommands = new String[] { "new Generator.testgenerator-{1} bus1={1} phases=3 model=1 status=fixed kV={2} Vminpu=0.9 Vmaxpu=1.1 kW={0} kvAR=0"};
    Tip Tip

    You can specify multiple commands to be run in sequence by adding a comma and another command immediately before the closing curly brace:

    myPerturbAndObserveRunner.PerturbCommands = new String[] { "command1", "command2"};

  • Now, call RunPerturbAndObserve to run the perturb-and-observe experiment. The perturbations given by the PerturbCommands will be applied at each element in PerturbElementSelector individually. The observed values before and after perturbation will be stored in BeforeValues and AfterValues. See the documentation for each of those members for a description of the way that observed data is stored.

Determining Sensitivities with Perturb-and-Observe Results

Once a Perturb-and-Observe experiment has been run, the PerturbAndObserveRunner TObserve  can be passed to a SensitivityGenerator T  to generate the sensitivities of the observed quantities to the perturbed quantities.

Generating Sensitivity Information from Perturb-and-Observe Results