Optimal Power Flow
Optimal power flow (OPF) is a well studied optimisation problem in power systems. This problem was first introduced by Carpentier1 in 1962. The objective of optimal power flow problems is to find a steady state operating point that minimizes the cost of electric power generation while satisfying operating constraints and meeting demand.
Keywords: operational research, mathematical modelling, optimisation
Below I present only the most interesting parts of the project. The whole project repository is available here.
1. Introduction
In this report I attempt to model electricity network with electricity and heat storage over multiple periods. First, I write down the mathematical model and then try to solve that model using Mosel XPress. After building model in mosel, I will try to use that approach to solve for the three different cases:
- with carbon tax and no PAR
- with carbon tax and PAR on one of the lines
- with carbon tax and one extra line along one of the original lines
The idea here is to explore the effect of carbon tax on generation of electrical power. Then, to find how PAR and extra lines can affect the generation and distribution of energy along lines.
2. Model formulation
Since I am using the ”DC approximation” to model the power flow I have to assume the following:
- line resistances to be negligible compared to the line reactances in order to simplify the parameters;
- voltage magnitudes to be normalized to 1;
- voltage angle differences between the neighbouring buses to be ”small” (taking advantage of the fact that the $\sin x = x$ and $\cos x = 1$ for small angle $x$).
Then, the first step in mathematical modelling is to introduce sets of indices. This is important as the following parameters and variables will be indexed using these indices. For example, let me denote $G$ to be a set of generators, indexed by $g=1,\dotsc,\lvert G \rvert$ or $L$ be a set of lines, indexed by $l=1,\dotsc,\lvert L \rvert$.
Using the above indices we can proceed to the formulation of the parameters. As previously stated, in OPF problems we wish find a steady state operating point that minimizes the cost of electric power generation while satisfying operating constraints and meeting demand. Hence, in this step we need to take into consideration parameters that will capture the following: maximum power flow in line $l$, maximum generation from generator $g$, reactance of line $l$, efficiency of generator $g$, the lenght of each period, how high the carbon tax is set to and many, many others.
And finally, we move on to the decision variables which will include: power flow into line $l$ at any period $t$ from its start bus, power generated by generator $g$ at period $t$ or voltage phase angle at any bus.
The point of the exercise is to minimize the operating cost while ensuring all the constraints hold. Here the operating cost consists of: the cost of power generation from each of generators and the carbon tax multiplied by tonnes of CO2 emissions that is a byproduct of energy generation process. I start formulating model with the objective function is given by:
\[\min \sum_{g\in G}\sum_{t \in T} C_g^G \cdot H_t \cdot p_{gt}^G + \sum_{g\in G}\sum_{t \in T} tax \cdot H_t \cdot p_{gt}^G \cdot \frac{W_f}{E_g^G}\]where:
- $C_g^G$ is the cost of power generation from generator $g$
- $H_t$ is the length of period $t$
- $p_{gt}^G$ is the power generated by generator $g$ at period $t$
- $tax$ is the value of the carbon tax
- $W_f$ is the emission from generator working on fuel $f$
- $E_g^G$ is the efficiency of generator $g$
The objective function is subject to a number of physical constraints. For example,
\[X_lp_{lt}^L + \sum_{b \in B} a_{bl}\delta_b^B = 0 \;\;\; \forall l \in L, t \in T\]where:
- $X_l$ is the reactance of line $l$
- $p_{lt}^L$ is the power flow into line $l$ at period $t$ from its start bus
- $a_{bl}$ is the element of bus/line, $−1$ if $b$ is the start bus of $l$, $1$ if $b$ is the end point of $l$, $0$ otherwise
- $\delta_b^B$ is the voltage phase angle at bus $b$.
This constraint corresponds to the Kirchhoff’s Voltage Law.
3. Mosel Xpress
Below I present part of the Mosel Xpress implementation based on the brief introduction to the model I presented above.
model OPF_with_storage
uses "mmxprs"
uses "mmsystem"
declarations
nT: integer ! Number of periods
end-declarations
initialisations from "data.dat"
nT
end-initialisations
declarations
!! sets
setG: set of string ! Set of generators
setB: set of string ! Set of buses
setL: set of string ! Set of lines
setT = 1..nT ! Set of periods
!! parameters
Ht: integer ! Duration of period [h]
tax: integer ! Carbon tax [$]
PbtD: array(setT,setB) of real ! Load in period [GW]
PlLplus: array(setL) of real ! Maximum load in a line [GW]
PgGplus: array(setG) of real ! Maximum generation [GW]
abl: array(setB,setL) of real ! Element of bus/line
CgG: array(setG) of real ! Generation cost [$]
betag: array(setG) of string ! Bus to which generator is connected
Xl: array(setL) of real ! Reactance
emissions: array(setG) of real ! Emissions from fuel [tCO2/GWh]
efficiency: array(setG) of real ! Generator's efficiency
!! variables
pltL: array(setL, setT) of mpvar ! Power flow in line l
pgtG: array(setG, setT) of mpvar ! Generation from generator g
deltaB: array(setB, setT) of mpvar ! Phase angle at bus b
end-declarations
!! function for cyclic model
function nxt(t,T:integer):integer
returned:= t mod T + 1
end-function
!! declare pollution in period t
forall(t in setT) pollution(t):= sum(g in setG) Ht*(pgtG(g,t)*emissions(g))/efficiency(g)
!! objective function:
total_cost:= sum(g in setG, t in setT) CgG(g) * Ht * pgtG(g,t) + sum(t in setT) tax*pollution(t)
4. Conclusion
Having implemented the above model in Mosel Xpress, I was able to solve for the three scenarios given in the assignment. Here the operating cost consists of: the cost of power generation from each of generators and the carbon tax multiplied by tonnes of $\mathrm{CO}_2$ emissions that is a byproduct of energy generation process. In other words, we take into consideration the external cost imposed on others by energy generation.
For the full model description, please see the full report here.
-
J. Carpentier, “Contribution a l’etude du dispacting economique,” Bull. Soc. Francaise des Electriciens, vol. 3, pp. 431–447, 1962. ↩