MATLAB Answers

Objective function for peak shaving and valley filling of wind turbine electrical load profile

13 views (last 30 days)
James Cresswell
James Cresswell on 13 Aug 2020
Answered: NN on 12 Sep 2020
Hello all,
I am attempting to create an optimization program that models an energy storage unit that peak shaves and valley fills the output of a wind farm. However, I am unsure of how to formulate the objective function to minimize. I have a working variation of the model that maximizes the revenue based on the output of the combined wind turbine and storage system. The constraints on that system are shown below.
prob.Constraints.energyStorage = optimconstr(T);
prob.Constraints.energyStorage(1) = ESS_SOC(1) == 10;
prob.Constraints.energyStorage(2:T) = ESS_SOC(2:T) == ESS_SOC(1:T-1)*(1-d) + ESS_ch(1:T-1) - ESS_disch(1:T-1);
prob.Constraints.EnergyBalance = Grid_E == WT_E - ESS_ch + ESS_disch;
The output of the wind turbine (WT_E) is a predefined vector of length T,1, and is shown by the figure below. Grid_E is considered the energy exported to the grid.
I would really appreciate any guidance on how to formulate an objective function that will use the energy storage to shift the energy from the WT peaks to the valleys (preferably having the lowest valleys filled first).
Thanks in advance.
James

  0 Comments

Sign in to comment.

Answers (2)

Alan Weiss
Alan Weiss on 14 Aug 2020
Perhaps your objective should be a new variable m along with the constraint
m >= f(i) % for all i
where i is the time index and f(i) is whatever power or whatnot that you can control. Along with your energy balance equations, if you minimize m subject to the constraints, then I think that you'll push the system to do what you want. Take this for what it is worth, I don't really understand what you can control here, or what the constraints really are.
Alan Weiss
MATLAB mathematical toolbox documentation

  2 Comments

James Cresswell
James Cresswell on 23 Aug 2020
Hi Alan,
I implemented your suggestions and was able to run the model with promising results. This helped a lot and the model is mostly doing what I need but need to get rid of the "spiking" behaviour (as per the figure below).
I think I understand why the model is doing this since W and Z are conflicting. Essentially, I want the Grid_E output follow the original WT power profile when it is not equal to the top shave level W or the bottom fill level Z (caused by the battery charge and discharge, respectively). The orange is the WT power profile.
I can explain anything if needed and any further advice on this would be great.
Best,
James
M=10;
ESS_ch = optimvar('ESS_ch',T,'LowerBound',0,'UpperBound',M);
ESS_disch = optimvar('ESS_disch',T,'LowerBound',0,'UpperBound',M);
ESS_SOC = optimvar('ESS_SOC',T,'LowerBound',0,'UpperBound',ESS_Cmax);
Grid_E = optimvar('Grid_E',T,'LowerBound',0);
prob.Constraints.energyStorage = optimconstr(T);
prob.Constraints.energyStorage(1) = ESS_SOC(1) == 0;
prob.Constraints.energyStorage(2:T) = ESS_SOC(2:T) == ESS_SOC(1:T-1)*(1-loss) + ESS_ch(1:T-1) - ESS_disch(1:T-1);
prob.Constraints.EnergyBalance = Grid_E == WT - ESS_ch + ESS_disch;
%create binary variables
Z_X = optimvar('Z_X',T,'Type','integer','LowerBound',0,'UpperBound',1); % charging binary variable array
Z_Y = optimvar('Z_Y',T,'Type','integer','LowerBound',0,'UpperBound',1); % discharging binary variable array
% Consraints for binary variables
prob.Constraints.Ch_on = ESS_ch <= M*Z_X;
prob.Constraints.Dis_on = ESS_disch <= M*Z_Y;
prob.Constraints.notPositive = Z_X + Z_Y <= 1;
**************************************************
W = optimvar('W');
Z = optimvar('Z');
prob.Constraints.shave = W >= Grid_E;
prob.Constraints.shaveZ = Z <= Grid_E;
prob.ObjectiveSense = 'minimize';
prob.Objective = W-Z;
**************************************************
Alan Weiss
Alan Weiss on 24 Aug 2020
Again, I am not sure that I know what I am talking about here, so take what I say with appropriate skepticism. It appears to me that you do not charge anything for the spikes. I mean, whenever the solution is away from the "shave" regions, there is no cost for having nonzero charging or discharching.
So perhaps the thing to do is to have some cost for nonzero charging. I would not make the cost large, though.
prob.Objective = W - Z + 1/100*(sum(Z_X + Z_Y));
Alternatively, and maybe better, you might put in constraints that when WT_E < W then ESS_ch = 0 and when WT_E > Z then ESS_disch = 0.
R_X = optimvar('R_X',T,'Type','integer','LowerBound',0,'UpperBound',1);
S_X = optimvar('S_X',T,'Type','integer','LowerBound',0,'UpperBound',1);
-R_X*M <= W_T - W; % Ensures that R_X = 1 whenever W_T < W
Z_X <= 1 - R_X; % No charging when W_T < W; now <=
-S_X*M <= Z - WT_E; % Ensures that S_X = 1 whenever WT_E > Z
Z_Y <= 1 - S_X; % No discharge when WT_E > Z; now <=
Please check that I got the signs of everything right, I am really unsure of myself here.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Edit: I just changed the Z_X and Z_Y commands to inequalities; my first answer had =, which was wrong.

Sign in to comment.


NN
NN on 12 Sep 2020
i am working on microgrid optimisation with solar and energy storage.I am also checking the matlab example file as reference.
https://www.mathworks.com/matlabcentral/fileexchange/73139-microgrid-energy-management-system-ems-using-optimization?s_tid=srchtitle
there are many things which i dont understand.I request you all to help me to understand the code and then only i will be able to do my model.These are few queries which i liek to ask.
In matlab example, they load a file PvLoadPrice.I understand the load detals are for variable laod given in the system.PV has clear and cloudy data.Can i know how do we use such a data?in which format ?From which website for research purpose?Also how do we seperate such a data against each parameter?How do i forecast those data , say for price how do i compare price details before and after a load variation ?should i do forecasting of price?i want to minimise the price of grid net exchange.plz advice.Can i have any resource to understand the code written in this example file?
The energy storage charges and discharges as per the power availabilty in grid.So how can i model the optmisation problem?and what should be the constraints ?I have already modelled a microgrid with charging and discharging energy storage mechanism as per the load availability.So how can i link the model with the optimisation code.

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!