Ornstein–Uhlenbeck process

AuxiliaryDescription
1"Ornstein–Uhlenbeck"Randomise the electrical network's dynamics

Summary

  • In practicality an energy network is always in flux.
  • The stochastic nature of the the loads and renewable generation can be simulated with ElectricGrid.jl.
  • This example will show you how to add stochastic reference signals via an Ornstein–Uhlenbeck processes.

The Ornstein-Uhlenbeck process is described by the following stochastic differential equation (SDE):

\[ dX_t = κ(γ-X_t)dt + σdW_t\]

Here, $γ$ is the long term mean, $κ$ is the mean reversion parameter, $W_t$ denotes a Wiener process, and $σ$ scales the random impact.

using ElectricGrid;

_______________________________________________________________________________

Network Configuration

The following grid example is configured with

  • Two inverters, a load, and two cables.
  • The one inverter is placed in the familiar PQ mode, while the other is in VSG mode.
  • The active and reactive power set points are specified by an Ornstein–Uhlenbeck processes.
  • The simulation is run for multiple episodes.
t_end    = 0.2     # total run time, seconds
num_eps  = 4       # number of episodes to run   

# Connectivity Matrix
CM = [ 0. 0. 1.
        0. 0. 2.
        -1. -2. 0.]  

# Nominal 3-phase power rating [VA], power factor, nominal rms voltage
R_load, L_load, _, _ = ParallelLoadImpedance(10e3, 0.95, 230) 

parameters = Dict{Any, Any}(
        "source" => Any[
                        Dict{Any, Any}("pwr"       => 200e3,
                                        "mode"     => "VSG")
                        Dict{Any, Any}("pwr"       => 100e3,   
                                        "mode"     => "PQ",    
                                        "p_set"    => -30e3, # Asymptotoic Mean
                                        "q_set"    => 10e3,
                                        "std_asy"  => 2.5e3, # Asymptotic Standard Deviation
                                        "σ"        => 100e3, # Random impact scale
                                        "Δt"       => 0.01,  # Process time Step, seconds
                                        "X₀"       => 0.0,   # Initial Process Value, Watt
                                        "k"        => 0)     # Interpolation degree, {0, 1, 2}
                        ],
        "load"   => Any[
                        Dict{Any, Any}("impedance" => "RL", 
                                        "R"        => R_load, 
                                        "L"        => L_load),
                        ],
        "cable"   => Any[
                        Dict{Any, Any}("R"  => 0.1, 
                                        "L" => 0.25e-3, 
                                        "C" => 0.1e-4),
                        Dict{Any, Any}("R"  => 0.1, 
                                        "L" => 0.25e-3, 
                                        "C" => 0.1e-4),
                        ],
    );

env = ElectricGridEnv(CM = CM, parameters = parameters, t_end = t_end, verbosity = 2);

agents = SetupAgents(env);

hook = Simulate(agents, env, num_episodes = num_eps, );

_______________________________________________________________________________

Rendering

RenderHookResults(hook = hook, 
                    episode = 2,
                    states_to_plot  = [], 
                    actions_to_plot = [],  
                    power_p_inv     = [2],   # Real power [Watts]
                    power_q_inv     = [2],   # Imaginary power [VAi]
                    )

_______________________________________________________________________________

Analysis

  • The active and reactive powers of the PQ load fluctuate around their mean set points.
  • Increasing the interpolation degree to either 1 or 2 will remove the "steps" and smooth the output powers.
  • The user can render all 4 episodes, which will show different dynamics.