sets t hours /1*24/ e emissions /co2,so2,nox/ *s scenarios /s1*s10/ ev electric vehicle /ev1*ev12/ hv hydrogen vehicle /hv1*hv12/ *utsev unavailability times for each ev/8*24/ ; $ontext l(t)=yes; l("1")=no; k(t)=yes; k("24")=no; $offtext parameters ec(e) externality cost /co2 0.014,so2 0.99,nox 4.2/ efg(e) externality cost /co2 1.432,so2 0.454,nox 21.8/ efb(e) externality cost /co2 1.755,so2 0.011,nox 0.62/ efchp(e) externality cost /co2 1.596,so2 0.008,nox 0.44/ ep_export(t) ; $ontext mps(t) Maximum power shed at time t // mcs(t) Maximum cooling shed at time t // mts(t) Maximum thermal shed at time t // ; $offtext scalars mpeg Maximum purchasable electricity from grid(kw) /400 / mpng Maximum purchasable NG maximum imported power from gas grid(kw) /600 / *-------------------------------------------------------------importing carriers ped Peak electrical demand(kw) /720/ pthd Peak thermal demand(kw) /350/ pcd Peak cooling demand(kw) /150/ *pngd Peak NG demand(kw) /180/ *-------------------------------------------------------------------------demand pvc pv capacity(kw) /400/ pvce PV converter efficiency(%) /0.95/ *--------------------------------------------------------pv(photovoltaic panels) et efficiency of transformer(%) /0.95/ *--------------------------------------------------------------------transformer vlel value of lost electric load ($ per kwh) /1/ vlthl value of lost thermal load ($ per kwh) /0.5/ vlcl value of lost cooling load ($ per kwh) /0.5/ vlhyl value of lost hydrogen load ($ per kwh) /0.5/ *----------------------------------------------------------penealy for loss heat mincpach minimum cooling power of absorption chiller(kw) /20/ maxcpach maximum cooling power of absorption chiller(kw) /45/ copach cop of absorption chiller /0.75/ ruach ramped-up of absorption chiller(kw per h) /30/ rdach ramped-down of absorption chiller(kw per h) /45/ sucach start-up cost of absorption chiller($) /3/ shdcach shut down cost of absorption chiller($) /4/ *-------------------------------------------------------------absorption chiller minhehp minimum heat of electric heat pump(kw) /20/ maxhehp maximum heat of electric heat pump(kw) /110/ mincehp minimum cooling of electric heat pump(kw) /20/ maxcehp maximum cooling of electric heat pump(kw) /110/ ehphcop ehp thermal cop /3.5/ ehpccop ehp cooling cop /3.5/ hruehp heat ramped-up of electric heat pump(kw per h) /110/ hrdehp heat ramped-down of electric heat pump(kw per h) /110/ cruehp cooling ramped-up of electric heat pump(kw per h) /40/ crdehp cooling ramped-down of electric heat pump(kw per h) /110/ sucehp start-up cost of electric heat pump($) /4/ shdcehp shut down cost of electric heat pump($) /4/ *--------------------------------------------------------ehp(electric heat pump) eb efficiency of boiler(%) /0.85/ rub ramped-up rate limit of boiler(kw per h) /50/ rdb ramped-down rate limit of boiler(kw per h) /220/ sucb start-up cost of boiler($) /10/ shdcb shut down cost of boiler($) /10/ minhb minimum heat of boiler(kw) /50/ maxhb maximum heat of boiler(kw) /220/ *-------------------------------------------------------------------------boiler hechp heat efficiency of chp(%) /0.3/ pechp power efficiency of chp(%) /0.45/ succhp start-up cost of chp($) /10/ shdcchp shut-down cost of chp($) /10/ minpchp minimum power of chp(kw) /60/ maxpchp maximum power of chp(kw) /300/ minhchp minimum heat of chp(kw) /40/ maxhchp maximum heat of chp(kw) /200/ eruchp electricity ramped-up rate limit of chp(kw per h) /50/ erdchp elcetricity ramped-down rate limit of chp(kw per h) /300/ thruchp thermal ramped-up rate limit of chp(kw per h) /40/ thrdchp thermal ramped-down of chp(kw per h) /200/ *-----------------------------------------------chp(co-generated heat and power) cheb charging efficiency of battery(%) /0.95/ discheb discharging efficiency of battery(%) /0.95/ rcb replacement cost of battery($) /20000/ tchdischb total charging or discharging of battery(kw) /4000000/ slfb storage loss factor of battery /0.01/ iebs initial energy of battery storage(kwh) /20/ minebs minimum energy of battery storage(kwh) /20/ maxebs maximum energy of battery storage(kwh) /150/ maxchpbs maximum power charging of battery storage(kw) /40/ minchpbs minimum power charging of battery storage(kw) /10/ maxdischpbs maximum power discharging of battery storage(kw) /40/ mindischpbs minimum power discharging of battery storage (kw) /10/ *-------------------------------------------------------------electrical storage chehs charging efficiency of heat storage(%) /0.9/ dischehs discharging efficiency of heat storage(%) /0.9/ rchs replacement cost of heat storage($) /5000/ tchdischhs total charging or discharging capcity of heat storage(kw) /4000000/ slfhs storage loss factor of heat storage /0.01/ iehs initial energy of heat storage(kwh) /20/ minehs minimum energy of heat storage(kwh) /20/ maxehs maximum energy of heat storage(kwh) /150/ maxchphs maximum power charging of heat storage(kw) /40/ minchphs minimum power charging of heat storage(kw) /10/ maxdischphs maximum power discharging of heat storage(kw) /40/ mindischphs minimum power discharging of heat storage(kw) /10/ *-------------------------------------------------------------------heat storage copcs cop of cooling storage for charging /2/ dischecs discharging efficiency of cooling storage(%) /0.95/ rccs replacement cost of cooling storage($) /5000/ tchdischcs total charging or discharging capcity of cooling storage(kw) /4000000/ slfcs storage loss factor of cooling storage /0.01/ iecs initial energy of cooling storage(kwh) /20/ minecs minimum energy of cooling storage(kwh) /20/ maxecs maximum energy of cooling storage(kwh) /100/ maxchpcs maximum power charging of cooling storage(kw) /30/ minchpcs minimum power charging of cooling storage(kw) /10/ maxdischpcs maximum power discharging of cooling storage(kw) /30/ mindischpcs minimum power discharging of cooling storage(kw) /10/ *----------------------------------------------------------------cooling storage chehys charging efficiency hydrogen storage (%) /0.96/ dischehys discharging efficiency of hydrogen storage(%) /0.96/ rchys replacement cost of hydrogen storage($) /5000/ tchdischhys total charging or discharging capcity of hydrogen storage(kw) /4000000/ slfhys storage loss factor of hydrogen storage /0.001/ iehys initial energy of hydrogen storage(kwh) /30/ minehys minimum energy of hydrogen storage(kwh) /20/ maxehys maximum energy of hydrogen storage(kwh) /200/ maxchphys maximum power charging of hydrogen storage(kw) /50/ minchphys minimum power charging of hydrogen storage(kw) /10/ maxdischphys maximum power discharging of hydrogen storage(kw) /50/ mindischphys minimum power discharging of hydrogen storage(kw) /10/ *---------------------------------------------------------------hydrogen storage ieev initial energy of ev batteries(kwh) / 20/ iehv initial energy of hydrogen vehicle(kwh) /20/ ; parameters cheev(ev) charging efficiency of evs(%) /ev1*ev12 0.95/ discheev(ev) discharging efficiency of evs(%) /ev1*ev12 0.95/ tchdischev(ev) total charging or discharging capcity of ev(kw) /ev1*ev12 4000000/ slfev(ev) storage loss factor of electric vehicle /ev1*ev12 0.01/ mineev(ev) minimum energy of electric vehicle(kwh) /ev1*ev12 15/ maxeev(ev) maximum energy of electric vehicle(kwh) /ev1*ev12 75/ maxchpev(ev) maximum power charging allowed of electric vehicle(kw) /ev1*ev12 40/ minchpev(ev) minimum power charging allowed of electric vehicle(kw) /ev1*ev12 10/ maxdischpev(ev) maximum power discharging allowed of electric vehicle(kw) /ev1*ev12 40/ mindischpev(ev) minimum power discharging allowed of electric vehicle(kw) /ev1*ev12 10/ rcev(ev) replacement cost of ev($) /ev1*ev12 20000/ *--------------------------------------------------ev(electric vehicle) batteris chehv(hv) charging efficiency of hvs(%) /hv1*hv12 0.96/ dischehv(hv) discharging efficiency of hvs(%) /hv1*hv12 0.96/ tchdischhv(hv) total charging or discharging capcity of hv(kw) /hv1*hv12 4000000/ slfhv(hv) storage loss factor of hydrogen vehicle /hv1*hv12 0.01/ minehv(hv) minimum energy of hydrogen vehicle(kwh) /hv1*hv12 10/ maxehv(hv) maximum energy of hydrogen vehicle(kwh) /hv1*hv12 80/ maxchphv(hv) maximum power charging allowed of hydrogen vehicle(kw) /hv1*hv12 50/ minchphv(hv) minimum power charging allowed of hydrogen vehicle(kw) /hv1*hv12 10/ maxdischphv(hv) maximum power discharging allowed of hydrogen vehicle(kw) /hv1*hv12 50/ mindischphv(hv) minimum power discharging allowed of hydrogen vehicle(kw) /hv1*hv12 10/ rchv(hv) replacement cost of hv($) /hv1*hv12 20000/ *-----------------------------------------------------hv(hydrogen vehicle) tanks ; scalars edri Demand response incentive for electric demand($ per kwh) /0.01/ cdri Demand response incentive for cooling demand($ per kwh) /0.003/ thdri Demand response incentive for thermal demand($ per kwh) /0.005/ edpfshu Electric demand participation factor for shift-up /0.2/ edpfshd Electric demand participation factor for shift-down /0.2/ cdpfshu cooling demand participation factor for shift-up /0.2/ cdpfshd cooling demand participation factor for shift-down /0.2/ thdpfshu thermal demand participation factor for shift-up /0.2/ thdpfshd thermal demand participation factor for shift-down /0.2/ *----------------------------------------------------------------demand response ehe efficiency of hydrogen electrolyzer(%) /0.85/ ruhe ramped-up rate limit of hydrogen electrolyzer(kw per h) /200/ rdhe ramped-down rate limit of hydrogen electrolyzer(kw per h) /200/ suche start-up cost of hydrogen electrolyzer($) /10/ shdche shut down cost of hydrogen electrolyzer($) /10/ minhhe minimum hydrogen of hydrogen electrolyzer(kw) /0/ maxhhe maximum hydrogen of hydrogen electrolyzer(kw) /200/ *----------------------------------------------------------hydrogen electrolyzer ehfc efficiency of hydrogen fuel cell(%) /0.85/ ruhfc ramped-up rate limit of hydrogen fuel cell(kw per h) /200/ rdhfc ramped-down rate limit of hydrogen fuel cell(kw per h) /200/ suchfc start-up cost of hydrogen fuel cell($) /10/ shdchfc shut down cost of hydrogen fuel cell($) /10/ minphfc minimum power of hydrogen fuel cell(kw) /0/ maxphfc maximum power of hydrogen fuel cell(kw) /200/ *-------------------------------------------------------------hydrogen fuel cell M "Big-M constant (large value, e.g., > max possible surplus)" /1300/ penalty_slack "Penalty for NZEB slack variable ($/kWh)" /0.5/ epsilon /0.0001/ *ep_export "Export price for renewables ($/kWh)" /0.5/ ; $ontext pehyf power efficiency of fuel cell /--------/ hehfc heat efficiency of fuel cell /-------/ eruhfc electric ramped-up rate limit of fuel cell/---/ erdhfc electric ramped-down rate limit of fuel cell/---/ hruhfc heat ramped-up rate limit of fuel cell/---/ hrdhfc heat ramped-down rate limit of fuel cell/---/ suchfc start-up cost of fuel cell /----/ sdchfc shut down cost of fuel cell /----/ $offtext parameter ed(t) electricity demand; $ call gdxxrw xxx.xlsx par ed rng=sheet1!a2:b25 rdim=1 cdim=0 $ gdxin xxx.gdx $ load ed $ gdxin parameter hd(t) heat demand; $ call gdxxrw xxx.xlsx par hd rng=sheet1!c1:d25 rdim=1 cdim=0 $ gdxin xxx.gdx $ load hd $ gdxin parameter cd(t) cooling demand; $ call gdxxrw xxx.xlsx par cd rng=sheet1!e1:f25 rdim=1 cdim=0 $ gdxin xxx.gdx $ load cd $ gdxin $ontext parameter gd(t) gas demand; *$ call gdxxrw xxx.xlsx par gd rng=sheet1!g1:h25 rdim=1 cdim=0 *$ gdxin xxx.gdx *$ load gd *$ gdxin $offtext parameter apv(t) available pv power; $ call gdxxrw xxx.xlsx par apv rng=sheet1!i1:j25 rdim=1 cdim=0 $ gdxin xxx.gdx $ load apv $ gdxin parameter ggp(t) gas gird price; $ call gdxxrw xxx.xlsx par ggp rng=sheet1!m1:n25 rdim=1 cdim=0 $ gdxin xxx.gdx $ load ggp $ gdxin parameter ep(t) electricicty price; $ call gdxxrw xxx.xlsx par ep rng=sheet1!k1:l25 rdim=1 cdim=0 $ gdxin xxx.gdx $ load ep $ gdxin parameter awp(t) available wind power; $ call gdxxrw xxx.xlsx par awp rng=sheet1!q1:r25 rdim=1 cdim=0 $ gdxin xxx.gdx $ load awp $ gdxin ep_export(t)=4*ep(t); ******************************************************************************** variable z ; positive variable ip(t) Imported power from grid at time t(kw) ing(t) Imported NG from grid at time t(kw) ipv(t) Injected PV power to EH at time t(kw) edsh(t) Electric demand shed at time t(kw) cdsh(t) Cooling demand shed at time t(kw) thdsh(t) Thermal demand shed at time t(kw) hydsh(t) Hydrogen demand shed at time t(kw) dcbss Degradation cost of BSS($) dctss Degradation cost of TSS($) dccss Degradation cost of CSS($) dchss Degradation cost of HSS($) dcevfleet Degradation cost of EV fleet($) dchvfleet Degradation cost of HV fleet($) *---------------------------------------------------------------degredation cost drc Demand response cost($) tie Total incentive paid to responsive electric demands($) tic Total incentive paid to responsive cooling demands($) tith Total incentive paid to responsive thermal demands($) *----------------------------------------------------------------demand response hb(t) Heat of boiler at time t(kw) *-------------------------------------------------------------------------boiler cpach(t) Cooling power of absorption chiller at time t(kw) *-------------------------------------------------------------absorption chiller thpehp(t) Thermal power of EHP at time t(kw) cpehp(t) Cooling power of EHP at time t(kw) *----------------------------------------------------------------------------ehp epchp(t) Electric power of chp at time t(kw) thpchp(t) Thermal power of chp at time t(kw) *----------------------------------------------------------------------------chp chpbss(t) Charging power of BSS at time t(kw) dischpbss(t) discharging power of BSS at time t(kw) schbss(t) State of charge of BSS at time t(kwh) fschbss final State of charge of BSS at time t(kwh) *----------------------------------------------------------------------------bss chpcss(t) Charging power of CSS at time t(kw) dischpcss(t) discharging power of CSS at time t(kw) schcss(t) State of charge of CSS at time t(kwh) fschcss final State of charge of CSS at time t(kwh) *----------------------------------------------------------------------------css chptss(t) Charging power of TSS at time t(kw) dischptss(t) discharging power of TSS at time t(kw) schtss(t) State of charge of TSS at time t(kwh) fschtss final State of charge of TSS(kwh) *----------------------------------------------------------------------------tss chphss(t) Charging power of hSS at time t(kw) dischphss(t) discharging power of hSS at time t(kw) schhss(t) State of charge of hSS at time t(kwh) fschhss final State of charge of hSS(kwh) *----------------------------------------------------------------------------hss chpev(t,ev) Charging power of evth ev at time t(kw) dischpev(t,ev) discharging power of evth ev at time t(kw) schev(t,ev) State of charge of evth ev at time t(kwh) fschev(ev) final State of charge of evth ev(kwh) *----------------------------------------------------------------------------evs chphv(t,hv) Charging power of hvth hv at time t(kw) dischphv(t,hv) discharging power of hvth hv at time t(kw) schhv(t,hv) State of charge of hvth hv at time t(kwh) fschhv(hv) final State of charge of hvth hv(kwh) *----------------------------------------------------------------------------hvs shued(t) Shift-up electric demand at time t(kw) shded(t) Shift-down electric demand at time t(kw) shuthd(t) Shift-up thermal demand at time t(kw) shdthd(t) Shift-down thermal demand at time t(kw) shucd(t) Shift-up cooling demand at time t(kw) shdcd(t) Shift-down cooling demand at time t(kw) *----------------------------------------------------------------demand response hchfc(t) hydrogen consumed by fuel cell(kw) pphfc(t) power produced by fuel cell(kw) *-------------------------------------------------------------hydrogen fuel cell pche(t) power consumed by hydrogen electrolyzer(kw) hphe(t) hydrogen produced by hydrogen electrolyzer(kw) *----------------------------------------------------------hydrogen electrolyzer iwp(t) Injected wind power power to EH at time t(kw) *---------------------------------------------------------------------wind power fedshc final electric demand shed cost($) fcdshc final cooling demand shed cost($) fthdshc final thermal demand shed cost($) pc final power cost($) gc final gas cost($) fsucb final start-up cost of boiler($) fshdcb final shut-down cost of boiler($) fsucfc final start-up cost of chp($) fshdcfc final shut-down cost of chp($) fsucehp final start-up cost of ehp($) fshdcehp final shut-down cost of ehp($) fsucach final start-up cost of absorption chiller($) fshdcach final shut-down cost of absorption chiller($) fsuche final start-up cost of electrolyzer($) fshdche final shut-down cost of electrolyzer($) fsuchfc final start-up cost of fuel cell($) fshdchfc final shut-down cost of fuel cell($) fhydshc final hydrogen demand shed cost($) *--------------------------------------------------------------------------costs z2 z3 exp_renew(t) "Exported renewable energy to grid at time t (kW)" slack_nzeb "Slack variable for flexible NZEB constraint (kWh)" ; *------------- NEW: demand tiers ---------------------------------- parameter ed_ren(t) "Mandatory share of the data-centre load that must be supplied by renewables (kW)" ed_non(t) "Residual share that can be covered by any source (kW)"; scalar ren_share /0.5/; ed_ren(t) = ren_share * ed(t); ed_non(t) = (1 - ren_share) * ed(t); free variable surplus(t) "Surplus renewable energy after local use at time t (kW)"; *exp_renew.up(t)=400; binary variables shused(t) Shift-up status of electric demand response at time t shdsed(t) Shift-down status of electric demand response at time t shuscd(t) Shift-up status of cooling demand response at time t shdscd(t) Shift-down status of cooling demand response at time t shusthd(t) Shift-up status of thermal demand response at time t shdsthd(t) Shift-down status of thermal demand response at time t *----------------------------------------------------------------demand response csb(t) Commitment status of boiler at time t sub(t) Boiler’s start-up indicator at time t shdb(t) Boiler’s shut-down indicator at time t *-------------------------------------------------------------------------boiler csach(t) Commitment status of absorption chiller at time t suach(t) absorbing chiller’s start-up indicator at time t shdach(t) absorbing chiller’s shut-down indicator at time t *-------------------------------------------------------------absorption chiller csehp(t) Commitment status of ehp at time t suehp(t) ehp’s start-up indicator at time t shdehp(t) ehp’s shut-down indicator at time t hmehp(t) heating mode of ehp at time t cmehp(t) cooling mode of ehp at time t *----------------------------------------------------------------------------ehp cschp(t) Commitment status of chp at time t suchp(t) chp’s start-up indicator at time t shdchp(t) chp’s shut-down indicator at time t *----------------------------------------------------------------------------chp chsbss(t) Charging status of BSS at time t dischsbss(t) Discharging status of BSS at time t *----------------------------------------------------------------------------bss chscss(t) Charging status of CSS at time t dischscss(t) Discharging status of CSS at time t *----------------------------------------------------------------------------css chstss(t) Charging status of TSS at time t dischstss(t) Discharging status of TSS at time t *----------------------------------------------------------------------------tss chshss(t) Charging status of hSS at time t dischshss(t) Discharging status of hSS at time t *----------------------------------------------------------------------------hss chsev(t,ev) Charging status of evth ev at time t dischsev(t,ev) Discharging status of evth ev at time t *----------------------------------------------------------------------------evs chshv(t,hv) Charging status of hvth hv at time t dischshv(t,hv) Discharging status of hvth hv at time t *----------------------------------------------------------------------------hvs cshe(t) Commitment status of he at time t suhe(t) he’s start-up indicator at time t shdhe(t) he’s shut-down indicator at time t *----------------------------------------------------------hydrogen electrolyzer cshfc(t) Commitment status of hfc at time t suhfc(t) hfc’s start-up indicator at time t shdhfc(t) hfc’s shut-down indicator at time t *-------------------------------------------------------------hydrogen fuel cell export_f(t) binary variable for export export_g(t) binary variable for export ; equations obj cost function obj2 emission function obj3 balance function con2 degredation cost of bss con3 degredation cost of tss con4 degredation cost of css con5 degredation cost of ev fleet con6 totla demand response con7 boiler equations con8 boiler equations con9 boiler equations con10 boiler equations con11 boiler equations con12 boiler equations con13 boiler equations con14 boiler equations con15 chp equations con16 chp equations con17 chp equations con18 chp equations con19 chp equations con20 chp equations con21 chp equations con22 chp equations con23 chp equations con24 chp equations con25 chp equations con26 chp equations con27 ehp equations con28 ehp equations con29 ehp equations con30 ehp equations con31 ehp equations con32 ehp equations con33 ehp equations con34 ehp equations con35 ehp equations con36 ehp equations con37 ehp equations con38 ehp equations con39 ehp equations con40 absorption chiller equations con41 absorption chiller equations con42 absorption chiller equations con43 absorption chiller equations con44 absorption chiller equations con45 absorption chiller equations con46 absorption chiller equations con47 absorption chiller equations con48 EVs equations con49 EVs equations con50 EVs equations con51 EVs equations con52 EVs equations con53 EVs equations con54 EVs equations con55 EVs equations con56 EVs equations con57 EVs equations con59 t and utsev should be connect together con60 BSS equations con61 BSS equations con62 BSS equations con63 BSS equations con64 BSS equations con65 BSS equations con66 BSS equations con67 BSS equations con68 BSS equations con69 BSS equations con70 TSS equations con71 TSS equations con72 TSS equations con73 TSS equations con74 TSS equations con75 TSS equations con76 TSS equations con77 TSS equations con78 TSS equations con79 CSS equations con80 CSS equations con81 CSS equations con82 CSS equations con83 CSS equations con84 CSS equations con85 CSS equations con86 CSS equations con87 CSS equations con88 CSS equations con89 demand responce equations con90 demand responce equations con91 demand responce equations con92 demand responce equations con93 demand responce equations con94 demand responce equations con95 demand responce equations con96 demand responce equations con97 demand responce equations con98 demand responce equations con99 demand responce equations con100 demand responce equations con101 demand responce equations con102 demand responce equations con103 demand responce equations con104 demand responce equations con105 demand-supply balance con106 demand-supply balance con107 demand-supply balance con108 technical limitations con109 technical limitations con110 technical limitations con111 technical limitations *con112 technical limitations *con113 technical limitations *con114 con115 hydrogen electrolyzer con116 hydrogen electrolyzer con117 hydrogen electrolyzer con118 hydrogen electrolyzer con119 hydrogen electrolyzer con120 hydrogen electrolyzer con121 hydrogen electrolyzer con122 hss equations con123 hss equations con124 hss equations con125 hss equations con126 hss equations con127 hss equations con128 hss equations con129 hss equations con130 hss equations con131 hss equations con132 HVs equations con133 HVs equations con134 HVs equations con135 HVs equations con136 HVs equations con137 HVs equations con138 HVs equations con139 HVs equations con140 HVs equations con141 HVs equations con151 technical limitations 2 *con142 con143 con144 con145 con146 con147 con148 con149 con150 con152 technical limitations 2 con153 technical limitations 2 con154 technical limitations 2 con155 technical limitations 2 con156 con157 hydrogen electrolyzer *con158 technical limitations 2 **con159 ehp equations con160 con161 con162 con163 con164 con165 con166 con167 con168 con169 con170 con171 con172 con173 con174 con175 con176 con177 surplus_def(t) "Define surplus as renewables minus local use" * exp_renew_pos(t) "Big-M lower bound for positive surplus case" * exp_renew_zero(t) "Big-M upper bound for zero/negative surplus case" * exp_renew_upper(t) "Additional upper bound to prevent over-exporting" * exp_renew_bound(t) "Non-negativity bound for exports" * force_positive(t) "Explicit link: Force is_positive=1 if surplus > 0" con_nzeb_flex "Flexible NZEB: Exports + slack >= Imports over all t" limitation_for_export(t) con101a *export1(t) *export2(t) *export3(t) linear1(t) linear2(t) linear3(t) linear4(t); **objectivefunction .. oc=e=sum(s,pr(s)*oc(s)) obj .. z=e= sum(t,ep(t)*ip(t))+ sum(t,ing(t)*ggp(t))+sum(t,sub(t)*sucb) + sum(t,shdb(t)*shdcb) + sum(t,suchp(t)*succhp) + sum(t,shdchp(t)*shdcchp) + sum(t,suehp(t)*sucehp) + sum(t,shdehp(t)*shdcehp) + sum(t,suhe(t)*suche) + sum(t,shdhe(t)*shdche)+ sum(t,suhfc(t)*suchfc) + sum(t,shdhfc(t)*shdchfc) +sum(t,shdach(t)*shdcach) + sum(t,suach(t)*sucach) + sum(t,edsh(t)*vlel) + sum(t,cdsh(t)*vlcl) +sum(t,thdsh(t)*vlthl) + dcbss+dctss+dccss+ dcevfleet + drc + dchvfleet + dchss + sum(t,hydsh(t)*vlhyl)- sum(t, exp_renew(t) * ep_export(t))+ penalty_slack * slack_nzeb ; obj2 .. z2=e=sum((t,e),(ip(t)*ec(e)*efg(e)+hb(t)*ec(e)*efb(e)+(epchp(t)+thpchp(t))*ec(e)*efchp(e))); obj3 .. z3=e=sum(t,edsh(t)/ed(t) + cdsh(t)/cd(t) + thdsh(t)/hd(t)); *------------------------------------------------------------objective functions con2 .. dcbss=e=sum(t,chpbss(t)+dischpbss(t))*rcb/tchdischb; con3 .. dctss=e=sum(t,chptss(t)+dischptss(t))*rchs/tchdischhs; con4 .. dccss=e=sum(t,chpcss(t)+dischpcss(t))*rccs/tchdischcs; con5 .. dcevfleet=e=sum(ev,sum(t,chpev(t,ev)+dischpev(t,ev))*(rcev(ev)/tchdischev(ev))); *--------------------------------------------------------------degredation costs con6 .. drc =e= tie+tith+tic; *----------------------------------------------------------------demand response con7 .. sub("1")=e=csb("1"); con8 .. shdb("1")=e=0; con9(t)$(ord(t)>1 and ord(t)<25).. sub(t)-shdb(t)=e=csb(t)-csb(t-1); con10(t) .. sub(t)+shdb(t)=l=1; con11(t) .. hb(t)=g=csb(t)*minhb; con12(t) .. hb(t)=l=csb(t)*maxhb; con13(t)$(ord(t)>0 and ord(t)<24) .. hb(t+1)-hb(t)=l=rub; con14(t)$(ord(t)>1 and ord(t)<25) .. hb(t-1)-hb(t)=l=rdb; *-------------------------------------------------------------------------boiler con15(t)$(ord(t)>1 and ord(t)<25) .. suchp(t)- shdchp(t) =e= cschp(t)-cschp(t-1); con16 .. shdchp('1')=e=0; con17 .. suchp('1')=e=cschp('1'); con18(t) .. suchp(t)+shdchp(t)=l=1; con19(t) .. epchp(t)=g=cschp(t)*minpchp; con20(t) .. epchp(t)=l=cschp(t)*maxpchp; con21(t)$(ord(t)>0 and ord(t)<24) .. epchp(t+1)-epchp(t)=l=eruchp; con22(t)$(ord(t)>1 and ord(t)<25) .. epchp(t-1)-epchp(t)=l=erdchp; con23(t) .. thpchp(t)=g=cschp(t)*minhchp; con24(t) .. thpchp(t)=l=cschp(t)*maxhchp; con25(t)$(ord(t)>0 and ord(t)<24) .. thpchp(t+1)-thpchp(t)=l=thruchp; con26(t)$(ord(t)>1 and ord(t)<25) .. thpchp(t-1)-thpchp(t)=l=thrdchp; *----------------------------------------------------------------------------chp con27(t) .. hmehp(t)+cmehp(t)=e= csehp(t); con28(t)$(ord(t)>1 and ord(t)<25) .. suehp(t)- shdehp(t) =e= csehp(t)-csehp(t-1); con29 .. shdehp('1')=e=0; con30 .. suehp('1')=e=csehp('1'); con31(t) .. suehp(t)+shdehp(t)=l=1; con32(t) .. thpehp(t)=g=hmehp(t)*minhehp; con33(t) .. thpehp(t)=l=hmehp(t)*maxhehp; con34(t) .. cpehp(t)=g=cmehp(t)*mincehp; con35(t) .. cpehp(t)=l=cmehp(t)*maxcehp; con36(t)$(ord(t)>0 and ord(t)<24) .. thpehp(t+1)-thpehp(t)=l=hruehp; con37(t)$(ord(t)>1 and ord(t)<25) .. thpehp(t-1)-thpehp(t)=l=hrdehp; con38(t)$(ord(t)>0 and ord(t)<24) .. cpehp(t+1)-cpehp(t)=l=cruehp; con39(t)$(ord(t)>1 and ord(t)<25) .. cpehp(t-1)-cpehp(t)=l=crdehp; **con159(t) ..hmehp(t)+cmehp(t)=l= 1; *----------------------------------------------------------------------------ehp con40(t)$(ord(t)>1 and ord(t)<25) .. suach(t)- shdach(t) =e= csach(t)-csach(t-1); con41 .. shdach('1')=e=0; con42 .. suach('1')=e=csach('1'); con43(t) .. suach(t)+shdach(t)=l=1; con44(t) .. cpach(t)=g=csach(t)*mincpach; con45(t) .. cpach(t)=l=csach(t)*maxcpach ; con46(t)$(ord(t)>0 and ord(t)<24) .. cpach(t+1)-cpach(t)=l=ruach ; con47(t)$(ord(t)>1 and ord(t)<25) .. cpach(t-1)-cpach(t)=l=rdach; *-------------------------------------------------------------absorption chiller con48(t,ev) .. chpev(t,ev)=g=chsev(t,ev)*minchpev(ev); con49(t,ev) .. chpev(t,ev)=l=chsev(t,ev)*maxchpev(ev) ; con50(t,ev) .. dischpev(t,ev)=g=dischsev(t,ev)*mindischpev(ev); con51(t,ev) .. dischpev(t,ev)=l=dischsev(t,ev)*maxdischpev(ev); con52(t,ev) .. schev(t,ev)=g= mineev(ev); con53(t,ev) .. schev(t,ev)=l= maxeev(ev); con54(t,ev)$(ord(t)>6 and ord(t)<17) .. dischsev(t,ev)+ chsev(t,ev)=l=1; con55(ev) .. 20 =e= schev('14',ev); con56(ev,t)$(ord(t)>7 and ord(t)<17) .. schev(t,ev) =e= schev(t-1,ev) - dischpev(t,ev)/discheev(ev)+ chpev(t,ev)*cheev(ev)-((schev(t,ev)+schev(t-1,ev))/2)*slfev(ev); con57(ev) .. schev('6',ev)=e= 20 - dischpev('6',ev)/discheev(ev) + chpev('6',ev)*cheev(ev)-((schev('6',ev)+20)/2)*slfev(ev); con59(t,ev)$(ord(t)>16 and ord(t)<8) .. chsev(t,ev)+dischsev(t,ev)=e=0 ; **con114(t,ev)$(ord(t)>0 and ord(t)<8) .. chsev(t,ev)+dischsev(t,ev)=e=0 ; *----------------------------------------------------------------------------evs con60(t) .. chpbss(t)=g=minchpbs*chsbss(t) ; con61(t) .. chpbss(t)=l=maxchpbs*chsbss(t) ; con62(t) .. dischpbss(t)=g=mindischpbs*dischsbss(t) ; con63(t) .. dischpbss(t)=l=maxdischpbs*dischsbss(t) ; con64(t) .. schbss(t)=g=minebs ; con65(t) .. schbss(t)=l=maxebs ; con66(t) .. chsbss(t)+dischsbss(t)=l=1 ; con67 .. iebs=e=fschbss ; con68(ev,t)$(ord(t)>1 and ord(t)<25) .. schbss(t)=e= schbss(t-1) - dischpbss(t)/discheb + chpbss(t)*cheb-((schbss(t)+schbss(t-1))/2)*slfb ; con69 .. schbss('1') =e= iebs - dischpbss('1')/discheb + chpbss('1')*cheb -((schbss('1')+iebs)/2)*slfb ; *----------------------------------------------------------------------------bss con70(t) .. chptss(t) =g=chstss(t)*minchphs ; con71(t) .. chptss(t) =l=chstss(t)*maxchphs ; con72(t) .. dischptss(t) =g=dischstss(t)*mindischphs ; con73(t) .. dischptss(t) =l=dischstss(t)*maxdischphs ; con74(t) .. schtss(t)=g=minehs ; con75(t) .. schtss(t)=l=maxehs ; con76 .. iehs =e= fschtss ; con77(t)$(ord(t)>1 and ord(t)<25) .. schtss(t)=e= schtss(t-1) - dischptss(t)/dischehs + chptss(t)*chehs - ((schtss(t)+schtss(t-1))/2)*slfhs; con78 .. schtss('1') =e= iehs - dischptss('1')/dischehs + chptss('1')*chehs -((schtss('1')+iehs)/2)*slfhs ; *----------------------------------------------------------------------------tss con79(t) .. chpcss(t) =g=chscss(t)*minchpcs ; con80(t) .. chpcss(t) =l=chscss(t)*maxchpcs ; con81(t) .. dischpcss(t) =g=dischscss(t)*mindischpcs ; con82(t) .. dischpcss(t) =l=dischscss(t)*maxdischpcs ; con83(t) .. schcss(t)=g=minecs ; con84(t) .. schcss(t)=l=maxecs ; con85(t) .. dischscss(t)+chscss(t)=l=1 ; con86 .. iecs =e= fschcss ; con87(t)$(ord(t)>1 and ord(t)<25) .. schcss(t)=e= schcss(t-1) - dischpcss(t)/dischecs + chpcss(t)*copcs - ((schcss(t)+schcss(t-1))/2)*slfcs ; con88 .. schtss('1') =e= iecs - dischpcss('1')/dischecs + chpcss('1')*copcs - ((schtss('1')+iecs)/2)*slfcs ; *----------------------------------------------------------------------------css con89(t) .. shued(t) =l= ed(t)*shused(t)*edpfshu ; con90(t) .. shded(t) =l= ed(t)*shdsed(t)*edpfshd ; con91(t) .. shused(t) + shdsed(t)=l=1 ; con92 ..sum(t,shued(t))=e=sum(t,shded(t)) ; con93(t) .. shucd(t) =l= cd(t)*shuscd(t)*cdpfshu ; con94(t) .. shdcd(t) =l= cd(t)*shdscd(t)*cdpfshd ; con95(t) .. shuscd(t) + shdscd(t) =l=1 ; con96 ..sum(t,shucd(t))=e=sum(t,shdcd(t)) ; con97(t) .. shuthd(t) =l= hd(t)*shusthd(t)*thdpfshu ; con98(t) .. shdthd(t) =l= hd(t)*shdsthd(t)*thdpfshd ; con99(t) .. shusthd(t) + shdsthd(t) =l=1 ; con100 .. sum(t,shdthd(t))=e=sum(t,shuthd(t)) ; con101(t) .. et*ip(t) + epchp(t) + pvce*apv(t) + edsh(t) + dischpbss(t) + shded(t)+ sum(ev,dischpev(t,ev)) + awp(t) + pphfc(t) =g= ed_ren(t) + ed_non(t) + shued(t) + sum(ev,chpev(t,ev))+ chpbss(t)+ chpcss(t) + thpehp(t)/ehphcop + cpehp(t)/ehpccop + hphe(t)/ehe + exp_renew(t) ; con102 .. tie=e=sum(t,edri*(shded(t)+shued(t))) ; con103 .. tic=e=sum(t,cdri *(shucd(t)+shdcd(t))) ; con104 .. tith=e=sum(t,thdri *(shuthd(t)+shdthd(t))) ; *----------------------------------------------------------------demand response con105(t) .. hb(t)+ thpchp(t)+ thdsh(t)+ dischptss(t) + thpehp(t)+ shdthd(t) =g= hd(t)+ shuthd(t)+ chptss(t) + cpach(t)/copach ; con106(t) .. cpach(t)+ cdsh(t) +dischpcss(t)+ cpehp(t) + shdcd(t) =g= cd(t)+shucd(t) ; con107(t) .. ing(t)=e= hb(t)/eb + epchp(t)/pechp ; *----------------------------------------------------------demand-supply balance con108(t) .. ip(t)=l=mpeg ; con109(t) .. ing(t)=l=mpng ; con110(t) .. epchp(t)/pechp =e= thpchp(t)/hechp ; con111(t) .. dischstss(t)+chstss(t)=l=1 ; *con112(t) .. ipv(t)=l=apv(t); **con113(t) .. (epfc(t)/pefc)* hechp =e=thpfc(t); *--------------------------------------------------------technical limitations 1 con157 .. suhe("1")=e=cshe("1"); con115 .. shdhe("1")=e=0; con116(t)$(ord(t)>1 and ord(t)<25).. suhe(t)-shdhe(t)=e=cshe(t)-cshe(t-1); con117(t) .. suhe(t)+shdhe(t)=l=1; con118(t) .. hphe(t)=g=cshe(t)*minhhe; con119(t) .. hphe(t)=l=cshe(t)*maxhhe; con120(t)$(ord(t)>0 and ord(t)<24) .. hphe(t+1)-hphe(t)=l=ruhe; con121(t)$(ord(t)>1 and ord(t)<25) .. hphe(t-1)-hphe(t)=l=rdhe; *----------------------------------------------------------hydrogen electrolyzer con122(t) .. chphss(t) =g=chshss(t)*minchphys ; con123(t) .. chphss(t) =l=chshss(t)*maxchphys ; con124(t) .. dischphss(t) =g=dischshss(t)*mindischphys ; con125(t) .. dischphss(t) =l=dischshss(t)*maxdischphys ; con126(t) .. schhss(t)=g= minehys ; con127(t) .. schhss(t)=l= maxehys ; con128(t) .. dischshss(t)+chshss(t)=l=1 ; con129 .. iehys =e= fschhss ; con130(t)$(ord(t)>1 and ord(t)<25) .. schhss(t)=e= schhss(t-1) - dischphss(t)/dischehys + chphss(t)*chehys - ((schhss(t)+schhss(t-1))/2)*slfhys ; con131 .. schhss('1') =e= iehys - dischphss('1')/dischehys + chphss('1')*chehys -((schhss('1')+iehys)/2)*slfhys ; *----------------------------------------------------------------------------hss con132(t,hv) .. chphv(t,hv)=g=chshv(t,hv)*minchphv(hv); con133(t,hv) .. chphv(t,hv)=l=chshv(t,hv)*maxchphv(hv) ; con134(t,hv) .. dischphv(t,hv)=g=dischshv(t,hv)*mindischphv(hv); con135(t,hv) .. dischphv(t,hv)=l=dischshv(t,hv)*maxdischphv(hv); con136(t,hv) .. schhv(t,hv)=g= minehv(hv); con137(t,hv) .. schhv(t,hv)=l= maxehv(hv); con138(t,hv)$(ord(t)>7 and ord(t)<17) .. dischshv(t,hv)+ chshv(t,hv)=l=1; con139(hv) .. iehv=e= schhv('14',hv); con140(hv,t)$(ord(t)>7 and ord(t)<17) .. schhv(t,hv) =e= schhv(t-1,hv) - dischphv(t,hv)/dischehv(hv)+ chphv(t,hv)*chehv(hv)-((schhv(t,hv)+schhv(t-1,hv))/2)*slfhv(hv); con141(hv) .. schhv('6',hv)=e= iehv - dischphv('6',hv)/dischehv(hv) + chphv('6',hv)*chehv(hv)-((schhv('6',hv)+iehv)/2)*slfhv(hv); con156(t,hv)$(ord(t)>16 and ord(t)<8) .. chshv(t,hv)+dischshv(t,hv)=e=0 ; **con142(t,hv)$(ord(t)>0 and ord(t)<8) .. chshv(t,hv)+dischshv(t,hv)=e=0 ; *----------------------------------------------------------------------------hvs con143 .. suhfc("1")=e=cshfc("1"); con144 .. shdhfc("1")=e=0; con145(t)$(ord(t)>1 and ord(t)<25).. suhfc(t)-shdhfc(t)=e=cshfc(t)-cshfc(t-1); con146(t) .. suhfc(t)+shdhfc(t)=l=1; con147(t) .. pphfc(t)=g=cshfc(t)*minphfc; con148(t) .. pphfc(t)=l=cshfc(t)*maxphfc; con149(t)$(ord(t)>0 and ord(t)<24) .. pphfc(t+1)-pphfc(t)=l=ruhfc; con150(t)$(ord(t)>1 and ord(t)<25) .. pphfc(t-1)-pphfc(t)=l=rdhfc; *-------------------------------------------------------------hydrogen fuel cell con151 .. dchvfleet=e=sum(hv,sum(t,chphv(t,hv)+dischphv(t,hv))*(rchv(hv)/tchdischhv(hv))); con152(t) .. pphfc(t) =e= ehfc*hchfc(t); con153(t) .. hphe(t) =e= ehe * pche(t); con154(t) .. hphe(t) + sum(hv,dischphv(t,hv)) + dischphss(t)+ hydsh(t) =g= pphfc(t)/ehfc + sum(hv,chphv(t,hv)) + chphss(t) ; con155 .. dchss =e= sum(t,dischphss(t)+ chphss(t) )*rchys/tchdischhys ; *con158(t) .. iwp(t)=l= awp(t) ; *--------------------------------------------------------technical limitations 2 con160 .. pc =e= sum(t,ep(t)*ip(t)) ; con161 .. gc =e= sum(t,ing(t)*ggp(t)) ; con162 .. fsucb =e= sum(t,sub(t)*sucb) ; con163 .. fshdcb =e= sum(t,shdb(t)*shdcb) ; con164 .. fsucfc =e= sum(t,suchp(t)*succhp) ; con165 .. fshdcfc =e= sum(t,shdchp(t)*shdcchp) ; con166 .. fsucehp =e= sum(t,suehp(t)*sucehp) ; con167 .. fshdcehp =e= sum(t,shdehp(t)*shdcehp) ; con168 .. fsucach =e= sum(t,suach(t)*sucach) ; con169 .. fshdcach =e= sum(t,shdach(t)*shdcach) ; con170 .. fedshc =e= sum(t,edsh(t)*vlel) ; con171 .. fcdshc =e= sum(t,cdsh(t)*vlcl) ; con172 .. fthdshc =e= sum(t,thdsh(t)*vlthl) ; con173 .. fsuche =e= sum(t,suhe(t)*suche) ; con174 .. fshdche =e= sum(t,shdhe(t)*shdche) ; con175 .. fsuchfc =e= sum(t,suhfc(t)*suchfc) ; con176 .. fshdchfc =e= sum(t,shdhfc(t)*shdchfc) ; con177 .. fhydshc =e= sum(t,hydsh(t)*vlhyl) ; surplus_def(t) .. surplus(t) =e= pvce*apv(t) + awp(t) + pphfc(t)+ dischpbss(t)+ sum(ev,dischpev(t,ev)) - (ed_ren(t) + sum(ev,chpev(t,ev)) + chpbss(t) + chpcss(t) + thpehp(t)/ehphcop + cpehp(t)/ehpccop + pche(t) ); *exp_renew_pos(t) .. exp_renew(t) =g= surplus(t) - M*(1 - is_positive(t)); *exp_renew_zero(t) .. exp_renew(t) =l= M * is_positive(t); *exp_renew_upper(t) .. exp_renew(t) =l= surplus(t) + M*(1 - is_positive(t)); *exp_renew_bound(t) .. exp_renew(t) =g= 0; *force_positive(t) .. surplus(t) =l= M * is_positive(t); con_nzeb_flex .. sum(t, exp_renew(t)) + slack_nzeb =e= sum(t, ip(t)) ; limitation_for_export(t) .. exp_renew(t) =l= 400; *export1(t) .. surplus(t) =g= epsilon*export_f(t) - m*export_g(t); *export2(t).. exp_renew(t) =e= surplus(t)*export_f(t); *export3(t) .. export_f(t) + export_g(t) =e= 1; con101a(t) .. pvce*apv(t) + awp(t) + pphfc(t) + dischpbss(t) + sum(ev,dischpev(t,ev)) =g= ed_ren(t)+ sum(ev,chpev(t,ev)) + chpbss(t) + chpcss(t) + thpehp(t)/ehphcop + cpehp(t)/ehpccop + pche(t) ; linear1(t) .. exp_renew(t) =l= m*export_f(t); linear2(t) .. exp_renew(t) =g= -1*m*export_f(t); linear3(t) .. exp_renew(t) =l= surplus(t)+m*(1-export_f(t)); linear4(t) .. exp_renew(t) =g= surplus(t)-m*(1-export_f(t)); model energy_hub /all/; option optcr=0,optca=0,reslim=3600000; option MIP=CPLEx; option THREADS=20; option limrow=20, limcol=20; * show up to 20 rows and 20 columns in equation/variable listing to help debugging option profile=1, profiletol=0.1; * activates profiling and only prints lines taking more than 0.1 seconds solve energy_hub using mip min z; display slack_nzeb.l,ed_ren,exp_renew.l,export_f.l, ed_non, pche.l, surplus.l ,ip.l,epchp.l, pc.l,edsh.l,dischpbss.l,shded.l,dischpev.l,pphfc.l,ed,shued.l,chpev.l,chpbss.l,chpcss.l,thpehp.l,cpehp.l,hphe.l,exp_renew.l, gc.l,z.l, drc.l, dcbss.l, dctss.l, dccss.l, dcevfleet.l,pc.l, gc.l, fsucb.l, fshdcb.l, fsucfc.l, fshdcfc.l, fsucehp.l, fshdcehp.l, fsucach.l, fshdcach.l, tic.l,tie.l, tith.l,fsuche.l ,fshdche.l,fsuchfc.l ,fshdchfc.l,dchvfleet.l ,dchss.l,pphfc.l,hphe.l,dischphv.l,chphv.l,dischphss.l,chphss.l,hydsh.l ;