Energy Storage Cost Minimization Problem

Energy Storage Cost Minimization Problem
Slide Note
Embed
Share

A cookie factory with two machines aims to minimize production costs while meeting weekly demand for dark and milk chocolates. By formulating an optimization model, the factory determines the optimal number of working days for each machine to achieve cost efficiency and satisfy the contractual requirements. The solution highlights the minimal cost and the corresponding number of working days for both machines.

  • Optimization
  • Minimization
  • Production Cost
  • Python
  • GAMS

Uploaded on Mar 11, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Energy Storage 5. Python/GAMS exercises Dr.sc. Mirna Gr ani Prof. Hrvoje Pand i mirna.grzanic@fer.hr hrvoje.pandzic@fer.hr 1

  2. Motivation Cookie factory has two machines. The first one can at maximum produce 140 bars of dark chocolate and 60 bars of milk chocolate, while the second one can produce 100 bars of dark, and 140 bars of milk chocolate. Start up costs of the machines are 400 $ and 500 $. If the factory contracted at the weekly level at least 1340 bars of dark chocolate, and 940 of milk chocolate, define how many days will machines work if the factory wants to minimize its production cost? 2 Energy storage

  3. Variables definition x-number of working days of first machine y-number of working days of second machine Number of days is positive and lower than 7: x, y 0 x, y 7 3 Energy storage

  4. Conditions First machine can produce 140 bars of dark chocolate, while second only 100 bars. On weekly basis, it is contracted more than 1340 pieces: 140x+100y 1340 First machine can produce 60 bars of milk chocolate, while second 140 bars. On weekly basis, it is contracted more than 1340 pieces: 60x+140y 940 4 Energy storage

  5. Objective Objective: cost minimization f(x,y)=400x+500y 5 Energy storage

  6. Area x, y 0 x, y 7 140x+100y 1340 60x+140y 940 6 Energy storage

  7. Possible solutions 7 Energy storage

  8. Final result Let c and 400x+500y=c 140x+100y = 1340 60x+140y = 940 x=6.88 x=7 y=3.76 y=4 minimal cost: 4800 $ 8 Energy storage

  9. Python How to add a new model: m=Model( name ) How to add variables: x=m.addVar(lb,ub,vtype,name) Standard: lb=0 ub= vtype=continuous (binary , integer) x=m.addVar(ub=7,vtype=GRB.INTEGER,name= Number of working days of first machine ) y=m.addVar(ub=7,vtype=GRB.INTEGER,name= Number of working days of second machine ) 9 Energy storage

  10. Objective function and constraints How to add objective function: m.setObjective(400*x+500*y, GRB.MINIMIZE) GRB.MAXIMIZE How to add constraints: m.addConstr(60*x+140*y>=940) m.addConstr(140*x+100*y>=1340) 10 Energy storage

  11. Optimization and results Solver calling: m.optimize() Objective value printing: print(m.objVal) Variable results printing: for v in m.getVars(): print(v.varname,v.x) 11 Energy storage

  12. Power plants optimization Power system has 4 generators whose characteristics are provided in the table below. We know that the first generator was producing 200 MWh and the second one 300 MWh at the beginning of the day, while others were shut down. Demand in the observed 5-hour period is 700 MW, 800 MW, 1000 MW, 1200 MW, 1300 MW. What is the minimum operating cost? 12 Energy storage

  13. Characteristics of generators Start-up cost $, , kn Price of produced MW $/W, /kW, kn/MW Price of maintenance $/h, /h Minimal power output MW, kW Maximal power output MW, kW Ramp up MW, kW Ramp down MW, kW 13 Energy storage

  14. Variables Variables: ??,?generator g output at hour t ??,?indicating if generator g is operating at hour t (1 if it is working, 0 otherwise) ????? ??Binary variable indicating start-up of the generator g in hour t (1 if it is started-up in hour t, 0 otherwise) ??,? 14 Energy storage

  15. Start-up cost Only if the generator is started at hour t Indicated with binary variable ??,? ??,? generator is started in hour t ??,? ??,? 1 ??,? ????? ?? ????? ?? compares ??,? and ??,? 1to define if the ????? ?? ??,? ????? ?? ??,? 1 ??,? 0 0 1 1 0 1 0 1 0 0 1 0 15 Energy storage

  16. Ramp up and ramp down Indicate how much the output of a generator can be increased or decreased in hour t compared to the output in hour t-1 ??,? ??,? 1 ????? ??,? 1 ??,? ????? ?? ???? ??,? ? 50 50 175 200 ??,? 100 200 120 70 ????? 100 200 120 70 Ramp up [MW] 100 Ramp down [MW] 100 Max power output [MW] 200 16 Energy storage

  17. Initial conditions Which generators were operating at the beginning of the day and how much they were producing Important because of: Ramp up and ramp down characteristics in the first hour, Start-up cost in the first hour. We know that the first generator was producing 200 MWh and the second one 300 MWh at the beginning of the day, while the others were shut down. ?1,0= 1, ?2,0= 1, ?1,0= 200, ?2,0= 300, ?3,0= 0, ?3,0= 0, ?4,0= 0 ?4,0= 0 17 Energy storage

  18. All constraints Initial conditions ?1,0= 1, ?1,0= 200, ?2,0= 1, ?2,0= 300, ?3,0= 0, ?3,0= 0, ?4,0= 0 ?4,0= 0 Indication of start-up ????? ?? ??,? ??,? 1 ??,? ?? Ramping constraints ??,? ??,? 1 ????? ??,? 1 ??,? ????? ???? Power output constraints ??,? ??,? ????? ??,? ??,? ????? Power balance ?1,?+ ?2,?+ ?3,?+ ?4,?= ????? 18 Energy storage

  19. Objective function Supply load in the 5-hour period at minimum cost Cost minimization: Start-up cost ?????? ?? ??,? Cost of maintenance ???????????? ??,? Production cost ?? ??,? ????? ?? ????? ??+ ???????????? ??,?+ ?? ??,?) (?????? ?? ??,? ? ? ? ? 19 Energy storage

  20. Code from gurobipy import * m.addConstr(x[1,0]==1) m.addConstr(x[2,0]==1) m.addConstr(x[3,0]==0) m.addConstr(x[4,0]==0) for g in range(1,5): for t in range(1,6): m=Model("Generatori") m.addConstr(P[1,t]+P[2,t]+P[3,t]+P[4,t]==load[t]) P={} x={} x_start_up={} P_min=[0,100,50,100,100] P_max=[0,500,500,1000,1000] ramp_up=[0,100,150,130,70] ramp_down=[0,100,150,130,70] load=[0,700,800,1000,1200,1300] def cilj(): suma=0 for g in range(1,5): for t in range(1,6): suma=suma+c_pro[g]*P[g,t]+c_odr[g]*x[g,t]+c_s tar[g]*x_start_up[g,t] return suma m.addConstr(P[1,0]==200) m.addConstr(P[2,0]==300) m.addConstr(P[3,0]==0) m.addConstr(P[4,0]==0) c_pro=[0,100,200,300,350] c_odr=[0,50,60,40,30] c_star=[0,100000,200000,150000,175000] for g in range(1,5): for t in range(6): P[g,t]=m.addVar() x[g,t]=m.addVar(vtype=GRB.BINARY) x_start_up[g,t]=m.addVar(vtype=GRB.BINARY) m.setObjective(cilj()) m.optimize() m.printAttr('X') print(m.objVal) for g in range(1,5): for t in range(1,6): m.addConstr(x[g,t]-x[g,t-1]<=x_start_up[g,t]) m.addConstr(P[g,t]<=x[g,t]*P_max[g]) m.addConstr(P[g,t]>=x[g,t]*P_min[g]) m.addConstr(P[g,t]-P[g,t-1]<=ramp_up[g]) m.addConstr(P[g,t-1]-P[g,t]<=ramp_down[g]) 20 Energy storage

  21. Results Costs: 990670.0 $ Hour 1 2 3 4 5 ?? 300 400 500 500 500 ?? 400 400 400 500 500 ?? 0 0 100 200 300 ?? 0 0 0 0 0 Why was Generator 3 started in hour 3 and not in hour 4? 21 Energy storage

  22. Line model ???= ????? *complex conjugate Complex number a + bj, a2+b2 (cos ? + j sin ?) 22 Energy storage

  23. Power flow equations ??,? Line impedance Line resistance ???= ????? ??? ?? ?? ??? ???= Line reactance ??? ???Line admittance Line conductance 1 ???= ??? ??? ??,?= ???+ ???? ???= ??? ???? Line susceptance ??? Apparent power ??? ??? Active power ??? ??? Reactive power Current ???= ???? ?? 2 ???? ???= ???+ ???? )(???+ ????) ??? = (?? ??? Voltage ?? 23 Energy storage

  24. Power flow equations 2 ???? )(???+ ????) ??? = (?? 2 ???+ ?? 2 ???? ???? ??? ???? ???? ??? =?? ???? ???? ???= (???????(?? ??) + ? ???????(?? ??)) ??? ????= (????????(?? ??) ???????(?? ??)) ??? ???= ???+ ???? 2 ??? ???????(?? ??) ???+ ???????(?? ??) ??? ???= ?? 24 Energy storage

  25. DC power flow Reactive power is neglected ???= ?? Voltages are close to the nominal value ~1 p.u. ???= ??? ???(?? ??) ???+ ???(?? ??) ??? In transmission network r<<x, ??? is negligible ???= ???(?? ??) ??? Voltage angles difference is small, and thus the sin function can be approximated with the angles difference ???= ???(?? ??) Usually used only in transmission network planning and operation 2 ??? ???????(?? ??) ???+ ???????(?? ??) ??? 25 Energy storage

  26. 3-node system Line limits and reactances are given in the tables below. If the max output power of generators is 1.5 and 1 p.u, what is the cost to supply the load in the figure? Line 1-2 2-3 1-3 x 1 1 1 Line limit [p.u.] 0.3 0.4 0.2 Node 1 2 3 Load [p.u.] 0.5 0.4 0.6 26 Energy storage

  27. Constraints Maximum power output: ??1 1.5 ??2 1 Lines capacity: 0.3 ?12 0.3 0.4 ?23 0.4 0.2 ?13 0.2 Objective function: min10 ??1+ 20 ??2 Power on line ??: ???= ???(?? ??) Power balance: ??? ???= ??? Demand at nodes: ? ? ??1= 0.5 ??2= 0.4 ??3= 0.6 ??1 ??1= ?12+ ?13 ??2 ??2= ?12+ ?23 0 ??3= ?23 ?13 Angle constraint: ? ?? ? 27 Energy storage

  28. Code from gurobipy import * m=Model("Studenti") m.addConstr(Pg1-Pt1==line12+line13) m.addConstr(Pg2-Pt2==-line12+line23) m.addConstr(-Pt3==-line13-line23) Pt1=0.5 Pt2=0.4 Pt3=0.6 m.addConstr(Pg1<=1.5) m.addConstr(Pg2<=1) m.addConstr(line12==theta1-theta2) m.addConstr(line13==theta1-theta3) m.addConstr(line23==theta2-theta3) Pg1=m.addVar(name="Generator 1") Pg2=m.addVar(name="Generator 2") line12=m.addVar(lb=-0.3,ub=0.3) line23=m.addVar(lb=-0.4,ub=0.4) line13=m.addVar(lb=-0.2,ub=0.2) theta1=m.addVar(lb=-3.14,ub=3.14) theta2=m.addVar(lb=-3.14,ub=3.14) theta3=m.addVar(lb=-3.14,ub=3.14) m.setObjective(10*Pg1+20*Pg2) m.optimize() for v in m.getVars(): print(v.varname,v.x) print(m.objVal) 28 Energy storage

  29. Results ??1= 0.5 ??2= 1 ?12= 0.2 ?23= 0.4 ?13= 0.2 ?1= 2.94 ?2= 2.74 ?3= 3.14 ???? = 25 $ 29 Energy storage

  30. Battery storage modelling ??? ? = ??? ? 1 + ? ?? ? ????(?) ??? ??? 0 = 0,??? 24 = 0 ???min ??? ? ?????? ??? ?? (?) ?? (?) ?? ??? ????(?) ????(?) ???? ????? + ?? (?) 1 30 Energy storage

  31. EV charging High penetration of EVs leads to an increased demand and possible network problems (congestion and voltage problems) Smart charging: Reduce the cost of EV charging Mitigate network problems V2G mode: EV battery can be discharged when required from the system operator or aggregator If V2G mode is not considered, the goal is to minimize the EV charging cost 31 Energy storage

  32. EV charging modelling If V2G mode is not considered, the goal is to minimize the EV charging cost ????=?= ?????????? ????=?= ?????? ???? ?????? ?? ,? ?? ,??? ?? ,? 0 ????= ???? 1+ ? ?? ,? ?=? ????????? ????????:min ?? ,? ?? ?=? 32 Energy storage

  33. Battery, EV and PV problem PV production and must-serve load of a low-carbon household together with dynamic electricy prices are shown in the Table. We assume that the household has constant network charges during the day 0,45 kn/kWh and pays the cost for peak power 14 kn/kW. The supplier purchases the excess electricity from the household at 90% of the price it charges. The houshold needs to supply the EV which arrives at home at hour 10 (current state of energy 14 kWh) and leaves at hour 18 (desired state of energy 26 kWh). We assume that the household owns a 3.7 kW charger. What are the cost of the household with and without battery storage (3,4 kW, 4 kWh, ? =0,82 and ???= 0,87)? 33 Energy storage

  34. Load (kW) 0.5 0.5 0.6 0.7 0.5 0.5 0.9 1.5 1.5 1 1 0.4 1 1.5 1.6 1.8 2.3 3.5 3.1 2.8 2.5 1.7 0.9 0.5 PV (kW)Energy price (kn/kWh) Hour 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 0 0 0 0 0 0 0 1 1.24 1.14 1.09 1.07 1.09 1.20 1.38 1.58 1.60 1.52 1.51 1.49 1.45 1.35 1.24 1.52 1.34 1.52 1.65 1.65 1.56 1.22 1.16 1.06 1.4 1.8 2.2 3 5 5.4 5.2 4 3.6 2.6 1 0 0 0 0 0 34 Energy storage

  35. Mathematical model Power balance: ?????? ?? ??????= ??????+ ???? ????+ ??? ????? ?? EV constraints: ?? ????=10 ????=18= 26 ?? ?? ,? 3.7 ?? ?? ,? 0 ????= ???? 1+ ?? ,? = 14 ?? Battery constraints: ??? ? = ??? ? 1 + ? ?? ? ????(?) ??? ?? (?) 3.4 ?? (?) ????? 3.4 ????? ????? + ?? (?) 1 ??? 0 = 0,??? 24 = 0 0 ??? ? 4?? 35 Energy storage

  36. Objective function ????????+????????) ?? 0.9 ?? +????? ????? ?????? ?=24(?? ???????? ?? ?????? min ?=1 Peak power: ?????? ????? ?? 36 Energy storage

More Related Content