Battery storage -optimisation problem_charge and discharge

I have seperate decision variables for charge and discharge cosntraints for battery optimisation problem, but i am getting proper value as optimised outputs.
Below is the code :
% initial conditions, battery constraints
batteryMinMax.Pmin = -500e3;
batteryMinMax.Pmax = 500e3;
battEnergy = 3.6e6*upsBattCap;
batteryMinMax.Emax = 0.8*battEnergy;
batteryMinMax.Emin = 0.2*battEnergy;
%Decision variables
PbattchV = optimvar('PbattchV',N,'LowerBound',0,'UpperBound',batteryMinMax.Pmax);
EbattchV = optimvar('EbattchV',N,'LowerBound',0,'UpperBound',batteryMinMax.Emax);
PbattDchV = optimvar('PbattDchV',N,'LowerBound',0,'UpperBound',batteryMinMax.Pmin);
EbattDchV = optimvar('EbattDchV',N,'LowerBound',0,'UpperBound',batteryMinMax.Emin);
Please advice if i made any mistake.

13 Commenti

These two lines are inconsistent:
batteryMinMax.Pmin = -500e3;
PbattDchV = optimvar('PbattDchV',N,'LowerBound',0,'UpperBound',batteryMinMax.Pmin);
You cannot sensibly have a lower bound of 0 and an upper bound of a negative number.
Alan Weiss
MATLAB mathematical toolbox documentation
Ok. understood the mistake .Thank you very much Sir
i changed the variables and
PbattDchV = optimvar('PbattDchV',N,'LowerBound',-500e3,'UpperBound',0);
But it gives zero output .
Please advice
Sorry, I don't know what you mean "But it gives zero output." Does it report an error? If so, please copy and paste the entire error message, everything in red. If not, then what is the problem exactly? Does it return a value of zero when you are expecting a nonzero output, or is there something else going on?
Alan Weiss
MATLAB mathematical toolbox documentation
yes , it return a value of zero when i expect it to be -500e3
Please see the below code :It returns a value of zero ,and i am expecting and output of 500e3 for Pbattups.Please advice.
function [Pd,Pbattups,Ebattups] = battSolarOptimizetrial3(N,dt,Ppv,Pload,Einit,Cost,FinalWeight,upsbatteryMinMax)
prob = optimproblem;
% Decision variables
PdV = optimvar('PdV',N);
PbattupsV = optimvar('PbattupsV',N,'LowerBound',0,'UpperBound'500e3);
EbattupsV = optimvar('EbattupsV',N,'LowerBound',upsbatteryMinMax.Emin,'UpperBound',upsbatteryMinMax.Emax);
% Maximise the profit from the usage of battery and PV
prob.ObjectiveSense = 'minimize';
%prob.Objective = var1 -dt*DayaheadCost'*Ppv-FinalWeight*EbattupsV(N)-FinalWeight*Ebatt1V(N)-FinalWeight*Ebatt2V(N);
prob.Objective =dt*Cost'*PbattupsV- dt*Cost'*Ppv-FinalWeight*EbattupsV(N);
% Power input/output to battery
prob.Constraints.energyBalance = optimconstr(N);
prob.Constraints.energyBalance(1) = EbattupsV(1) == Einit;
prob.Constraints.energyBalance(2:N) = EbattupsV(2:N) == EbattupsV(1:N-1) - PbattupsV(1:N-1)*dt
% Satisfy power load with power from PV, grid and battery
prob.Constraints.loadBalance = Ppv + PdV + PbattupsV == Pload;
%prob.Constraints.battpower = PbattupsV<=500e3;
% Solve the linear program
options = optimoptions(prob.optimoptions,'Display','none');
[values,~,exitflag] = solve(prob,'Options',options);
% Parse optmization results
if exitflag <= 0
Pd = zeros(N,1);
Pbattups = zeros(N,1);
Ebattups = zeros(N,1);
else
Pd = values.PdV;
Pbattups = values.PbattupsV;
Ebattups = values.EbattupsV;
end
We do not have the value of the input variables to test with.
Which exact file? initial_conditions.m ? If so then are you using the same .mat that is loaded there?
battsolar file I have edited according to my model and trying to use
but the files in it which are initial conditions and battsolar can be sued to verify
You are going to need to tell me which files or data to load and what to pass to battSolarOptimizetrial3
I would suggest writing a script that does the necessary steps.
The model there is not compatible with the function at https://www.mathworks.com/matlabcentral/answers/891877-battery-storage-optimisation-problem_charge-and-discharge#comment_1693172 -- the function has fewer inputs than the Simulink model is passing in.

Accedi per commentare.

Risposte (0)

Categorie

Richiesto:

NN
il 4 Ago 2021

Commentato:

il 22 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by