Path: blob/main/notebooks/10/05-opf-wind-curtailment.ipynb
663 views
Extra: Two-stage energy dispatch optimization with wind curtailment
Preamble: Install Pyomo and a solver
The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object SOLVER for later use.
Preliminaries
This notebook illustrates a two-stage stochastic optimization problem in the context of energy systems where there are recourse actions that depend on the realization of the uncertain parameters.
The equilibrium point for the European power network, which operates on alternating current, is at a frequency of 50 Hertz with a tolerance threshold of Hertz. Power network operators are responsible for maintaining a constant frequency on the network. The way that operators do this is mainly by perfectly balancing power supply and demand.
But what happens if power supply does not meet demand? When supply exceeds demand, then the electrical frequency increases. If demand exceeds supply, then the frequency drops. Since power plants are designed to operate within a certain frequency range, there is a risk that they will disconnect from the grid after a period of time. If the frequency deviates too much from the 50 Hertz, then there is a risk that the power plants switch off one after another, potentially leading to a complete power blackout.
Using conventional power generators such as coal and gas, power supply and demand are often matched by increasing/decreasing the production rate of their power plants and taking generating units online or offline. With the advent of renewable energy sources, it has become increasingly more difficult to match supply and demand. Besides not being controllable power sources, network operators rely on forecasting models to predict the power generated by renewable sources. In practice, this prediction is fairly accurate for solar energy, but wind energy is particularly difficult to predict correctly.

The goal of this notebook is to ensure that power demand meets supply while taking into account wind fluctuations. We will introduce two optimization problems and solve them as stochastic optimization problems. Read first the energy dispatch problem from the Chapter 4 for the preliminaries on power networks and the Optimal Power Flow (OPF) problem. An important difference from the setting there, is that here we will not assume that the wind generation is a decision variable. Instead, wind generation is a random variable, as will be explained later on. We do assume that solar and hydropower are decision variables, since the former is accurately predicated whereas the latter is controllable.
We now consider another optimization problem relevant for energy systems named the Unit Commitment (UC) problem. UC is an extended version of the OPF problem in which an additional binary decision variable is introduced to decide whether generator should be activated or not. In this formulation we include a fixed cost that is incurred for the activation of a generator , which is also added as a new parameter c_fixed to the network instance.
In practice, the UC problem is often considered as a two-stage problem. Since it takes time to activate gas and coal generators before they can produce energy, this decision must be made in advance, i.e., as here-and-now decision in the first stage. In the second stage, we then decide the power generation levels of the (activated) coal and gas generators. Note that, in particular, we cannot produce from generators we did not already turn on! Lastly, the UC still includes the same physical constraints as the OPF, i.e., power generation limits and line capacity constraints.
All solar and hydro generators are activated by default. Solar power is treated as deterministic in the sense that in the instance that you are given it holds that for solar generators. Hydro generators are still controllable within their nontrivial generation limits.
The uncertainty will be described in terms of the wind speed instead of the wind power. To determine the wind power resulting from a given wind speed, you need to use a so-called power curve for a wind generator , which is an explicit function that maps the wind speed to a wind power . In the network instance that you are given, there are two wind generators, one in node 64 which is an on-shore wind park, and one in node 65 which is a off-shore wind park. Being structurally different, they have different power curves. See below a plot of the power curve function for the on-shore wind generator.

An analytical description of the power curves is given as follows
We now present the two-stage UC problem formulation. In the first stage, we decide which coal and gas generators to activate (all wind, solar and hydro generators are active by default). In the second stage, the exact power output of the wind parks is calculated using the power curves knowing the realization of the two wind speeds and the power outputs of the already activated generators needs to be adjusted to match demand exactly.
where
Package and data import
Network data
This notebook uses the same network as in energy dispatch problem and hence the same data structure. In particular, the nodes and edges of the network are stored in the nodes and edges dataframes, respectively. The edges dataframe contains the following columns:
edge id: the unique identifier of the edge, describing the node pair(i,j)of the edge;f_max: describing the maximum power flow capacity of the edge; andb: the susceptance of the edge.
The network includes 18 generators of different type, which is described in the energy_type field. We distinguish between conventional generators (coal, gas) and renewable generators (hydro, solar, wind). Every conventional generator node has two parameters:
c_fixed, describing the activation cost of the conventional generators;c_var, describing the unit cost of producing energy for each conventional generator
Renewable generators are assumed to have zero marginal cost and zero activation cost. Nodes 64 and 65 correspond to the two wind generators that this notebook focuses on.
Wind turbines risk to break if the wind speed is too high, so wind turbines need to be curtailed (i.e., deactivated) once the wind speed exceeds a specified maximum speed . An additional second stage decision is therefore needed to decide whether to curtail the wind turbines or not. We include this additional requirement in the second-stage formulation, assuming that we have samples available.
Assume that
with scale parameter 15 and shape parameter 2.6.
with scale parameter 18 and shape parameter 3.0.
We sample data points from these two distributions. Using these data points, compute the average wind speeds. Then compute the objective value. Analyze the differences in the objective value and explain the differences.
We sample from two different continuous Weibull distributions with different scale and shape parameters and then solve the problem.
Assessing the quality of the solution
How can we assess the quality of the solution? For example, we could investigate how it performs compared to some baseline solution: we could have assumed 'average' values for the wind speed and solve the problem like a single-stage problem where all the data is known. That would give us some initial here-and-now commitment decisions, for which we could check in how many cases is it not even possible to schedule the production to meet the demand.
To do so, we need a variant of our model building function in which we can fix the initial decisions and seek the best possible decisions for the other variables given an observed wind speed, for each of the scenarios, and see how often is the problem infeasible. The following is a modified version of our function.
Next, we construct our average sample, solve for it, and then optimize for the second stage decisions for each of the simulated scenarios separately.
Now, for each of our scenarios we will solve the problem by fixing the initial decisions to be the one for the 'average' scenario and see in how many of them we cannot obtain a feasible second-stage decision, which we extract using the try-except mechanism of Python catching an error in case we are trying to call a solution that does not exist.
As it turns out, the 'nominal' commitment solution would lead to infeasibility, thus a blackout, in 65% of the cases. Since a blackout is the very last thing a network operator would like to happen, this clearly demonstrates the value of the stochastic solution. It is important to note that a very robust solution that avoids blackouts could be explained by simply assuming very poor performance of the wind turbines. Such a solution, however, could be unnecessarily conservative and expensive, and it is therefore better to prepare for a set of realistic scenarios.