Energy storage optimisation problem - separate charge and discharge constraint
Show older comments
Hi all!
I am currently working on an optimization problem to maximize the revenue from a combined wind turbine and energy storage system. With the code below, the system charges and discharges simultaneously at certain times. I am able to change the charge and discharge variables to a single variable with the lowerbound as a negative and positive number corresponding to discharging and charging, respectively. But in doing this, I cannot accurately apply the charge and discharge efficiencies of the storage device.
prob = optimproblem;
% Decision variables
% Energy storage system decision variables
ESS_ch = optimvar('ESS_ch',T,'LowerBound',0,'UpperBound',ESS_Pmax);
ESS_disch = optimvar('ESS_disch',T,'LowerBound',0,'UpperBound',ESS_Pmax);
ESS_SOC = optimvar('ESS_SOC',T,'LowerBound',0,'UpperBound',ESS_Cmax);
% Output power to the grid variables
Grid_E = optimvar('Grid_E',T,'LowerBound',0);
% Energy storage operational constraints
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_disch(1:T-1)/eff + ESS_ch(1:T-1)*eff;
% Energy balance constraint (WT_E = wind turbine power output as vector of
% length T)
prob.Constraints.EnergyBalance = Grid_E == WT_E + ESS_disch - ESS_ch;
prob.ObjectiveSense = 'maximize';
prob.Objective = sum(Grid_E.*Price);
I have also attempted to apply a constraint that dictates the charge power multilied by the discharge power of the storage device is equal to zero at any single time step, see below.
prob.Constraints.chargeonoff = optimconstr(T);
for i = 1:T
prob.Constraints.chargeonoff(i) = ESS_disch(i)*ESS_ch(i) == 0;
end
However, when I add this the following error occurs.
Error using optim.problemdef.OptimizationProblem/solve
SOLVE requires a non-empty initial point structure to solve a nonlinear problem.
Any assistance or insight on how to force the program to either charge or discharge at each time step would be greatly appreciated.
5 Comments
Shehbaz Aslam
on 15 Aug 2020
Hope you are fine I need help on optimization toolbox. engrshehbaz174@gmail.com
Thanks
James Cresswell
on 23 Aug 2020
Hi James,
I am working on microgrid optimization with solar and energy storage.I am also checking the Matlab example file Microgrid EMS optimization as a reference
https://www.mathworks.com/matlabcentral/fileexchange/73139-microgrid-energy-management-system-ems-using-optimization?s_tid=srchtitle
There are some queries which I didn't 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 a few queries which I like to ask.
In the Matlab example, they load a file PvLoadPrice.I understand the load details are for variable load given in the system.PV has clear and cloudy data. Can I know how do we use such data?in which format? From which website we download it for research purposes?Also, how do we separate such data against each parameter? How do I forecast those data, say for the price how do I compare price details before and after a load variation(i have load fluctuation event in my model ) ? should I do forecasting of the price? I want to minimize the price of grid net exchange.plz advice. Can I have any resources to understand the code written in this example file?
The energy storage charges and discharges as per the power availability in the grid. So how can I model the optimization problem? and what should be the constraints? I have already modeled a microgrid with charging and discharging energy storage mechanism as per the load availability. So how can I link the model with the optimization code?
I request James, ALi and Alan Weiss to look into thsi matter and help .
Thanks in advance.
Joan Ernesto
on 19 Apr 2023
How did you manage to make it continuous? I'm trying to do something similar to minimize the grid cost, but at some timesteps the optimizer decides to discharge the battery at random timestep instead of continuously discharging it.
flora
on 12 Jun 2025
i u have answer please help me
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!