openTEPES 4.17.6__py3-none-any.whl → 4.17.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
openTEPES/__init__.py CHANGED
@@ -14,7 +14,7 @@ Open Generation, Storage, and Transmission Operation and Expansion Planning Mode
14
14
  >>> import openTEPES as oT
15
15
  >>> oT.routine("9n", "C:\\Users\\UserName\\Documents\\GitHub\\openTEPES", "glpk")
16
16
  """
17
- __version__ = "4.17.6"
17
+ __version__ = "4.17.7"
18
18
 
19
19
  from .openTEPES_Main import main
20
20
  from .openTEPES import *
openTEPES/openTEPES.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """
2
- Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - September 18, 2024
2
+ Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - September 20, 2024
3
3
  """
4
4
 
5
5
  # import dill as pickle
@@ -39,8 +39,8 @@ def openTEPES_run(DirName, CaseName, SolverName, pIndOutputResults, pIndLogConso
39
39
  idxDict['y' ] = 1
40
40
 
41
41
  #%% model declaration
42
- mTEPES = ConcreteModel('Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.17.6 - September 18, 2024')
43
- print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.17.6 - September 18, 2024', file=open(_path+'/openTEPES_version_'+CaseName+'.log','w'))
42
+ mTEPES = ConcreteModel('Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.17.7 - September 20, 2024')
43
+ print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.17.7 - September 20, 2024', file=open(_path+'/openTEPES_version_'+CaseName+'.log','w'))
44
44
 
45
45
  pIndOutputResults = [j for i,j in idxDict.items() if i == pIndOutputResults][0]
46
46
  pIndLogConsole = [j for i,j in idxDict.items() if i == pIndLogConsole ][0]
@@ -81,9 +81,9 @@ def openTEPES_run(DirName, CaseName, SolverName, pIndOutputResults, pIndLogConso
81
81
  mTEPES.del_component(mTEPES.st)
82
82
  mTEPES.del_component(mTEPES.n )
83
83
  mTEPES.del_component(mTEPES.n2)
84
- mTEPES.st = Set(initialize=mTEPES.stt, ordered=True, doc='stages', filter=lambda mTEPES,stt: stt in st == stt and mTEPES.pStageWeight[stt] and sum(1 for (p,sc,st,nn) in mTEPES.s2n))
85
- mTEPES.n = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and (p,sc,st,nn) in mTEPES.s2n)
86
- mTEPES.n2 = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and (p,sc,st,nn) in mTEPES.s2n)
84
+ mTEPES.st = Set(doc='stages', initialize=[stt for stt in mTEPES.stt if st == stt if mTEPES.pStageWeight[stt] and sum(1 for (p,sc,st,nn) in mTEPES.s2n)])
85
+ mTEPES.n = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if (p,sc,st,nn) in mTEPES.s2n ])
86
+ mTEPES.n2 = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if (p,sc,st,nn) in mTEPES.s2n ])
87
87
 
88
88
  # load levels multiple of cycles for each ESS/generator
89
89
  mTEPES.nesc = [(n,es) for n,es in mTEPES.n*mTEPES.es if mTEPES.n.ord(n) % mTEPES.pStorageTimeStep [es] == 0]
@@ -162,9 +162,9 @@ def openTEPES_run(DirName, CaseName, SolverName, pIndOutputResults, pIndLogConso
162
162
  mTEPES.del_component(mTEPES.st)
163
163
  mTEPES.del_component(mTEPES.n )
164
164
  mTEPES.del_component(mTEPES.n2)
165
- mTEPES.st = Set(initialize=mTEPES.stt, ordered=True, doc='stages', filter=lambda mTEPES,stt: stt in mTEPES.stt and mTEPES.pStageWeight[stt] and sum(1 for p,sc,stt,nn in mTEPES.s2n))
166
- mTEPES.n = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n))
167
- mTEPES.n2 = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n))
165
+ mTEPES.st = Set(doc='stages', initialize=[stt for stt in mTEPES.stt if mTEPES.pStageWeight[stt] and sum(1 for p,sc,stt,nn in mTEPES.s2n)])
166
+ mTEPES.n = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n)])
167
+ mTEPES.n2 = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n)])
168
168
 
169
169
  # load levels multiple of cycles for each ESS/generator
170
170
  mTEPES.nesc = [(n,es) for n,es in mTEPES.n*mTEPES.es if mTEPES.n.ord(n) % mTEPES.pStorageTimeStep [es] == 0]
@@ -198,9 +198,9 @@ def openTEPES_run(DirName, CaseName, SolverName, pIndOutputResults, pIndLogConso
198
198
  mTEPES.del_component(mTEPES.st)
199
199
  mTEPES.del_component(mTEPES.n )
200
200
  mTEPES.del_component(mTEPES.n2)
201
- mTEPES.st = Set(initialize=mTEPES.stt, ordered=True, doc='stages', filter=lambda mTEPES,stt: stt in mTEPES.stt and mTEPES.pStageWeight[stt] and sum(1 for p,sc,stt,nn in mTEPES.s2n))
202
- mTEPES.n = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n))
203
- mTEPES.n2 = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n))
201
+ mTEPES.st = Set(doc='stages', initialize=[stt for stt in mTEPES.stt if mTEPES.pStageWeight[stt] and sum(1 for p,sc,stt,nn in mTEPES.s2n)])
202
+ mTEPES.n = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n)])
203
+ mTEPES.n2 = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if sum(1 for p,sc,st in mTEPES.ps*mTEPES.st if (p,sc,st, nn) in mTEPES.s2n)])
204
204
 
205
205
  # load levels multiple of cycles for each ESS/generator
206
206
  mTEPES.nesc = [(n,es) for n,es in mTEPES.n*mTEPES.es if mTEPES.n.ord(n) % mTEPES.pStorageTimeStep [es] == 0]
@@ -1,5 +1,5 @@
1
1
  """
2
- Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - September 18, 2024
2
+ Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - September 20, 2024
3
3
  """
4
4
 
5
5
  import datetime
@@ -203,24 +203,24 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
203
203
  dictSets.load(filename=_path+'/oT_Dict_ZoneToArea_' +CaseName+'.csv', set='znar', format='set')
204
204
  dictSets.load(filename=_path+'/oT_Dict_AreaToRegion_'+CaseName+'.csv', set='arrg', format='set')
205
205
 
206
- mTEPES.pp = Set(initialize=dictSets['p' ], ordered=True, doc='periods', within=PositiveIntegers)
207
- mTEPES.scc = Set(initialize=dictSets['sc' ], ordered=True, doc='scenarios' )
208
- mTEPES.stt = Set(initialize=dictSets['st' ], ordered=True, doc='stages' )
209
- mTEPES.nn = Set(initialize=dictSets['n' ], ordered=True, doc='load levels' )
210
- mTEPES.gg = Set(initialize=dictSets['g' ], ordered=False, doc='units' )
211
- mTEPES.gt = Set(initialize=dictSets['gt' ], ordered=False, doc='technologies' )
212
- mTEPES.nd = Set(initialize=dictSets['nd' ], ordered=False, doc='nodes' )
213
- mTEPES.ni = Set(initialize=dictSets['nd' ], ordered=False, doc='nodes' )
214
- mTEPES.nf = Set(initialize=dictSets['nd' ], ordered=False, doc='nodes' )
215
- mTEPES.zn = Set(initialize=dictSets['zn' ], ordered=False, doc='zones' )
216
- mTEPES.ar = Set(initialize=dictSets['ar' ], ordered=False, doc='areas' )
217
- mTEPES.rg = Set(initialize=dictSets['rg' ], ordered=False, doc='regions' )
218
- mTEPES.cc = Set(initialize=dictSets['cc' ], ordered=False, doc='circuits' )
219
- mTEPES.c2 = Set(initialize=dictSets['cc' ], ordered=False, doc='circuits' )
220
- mTEPES.lt = Set(initialize=dictSets['lt' ], ordered=False, doc='electric line types' )
221
- mTEPES.ndzn = Set(initialize=dictSets['ndzn'], ordered=False, doc='node to zone' )
222
- mTEPES.znar = Set(initialize=dictSets['znar'], ordered=False, doc='zone to area' )
223
- mTEPES.arrg = Set(initialize=dictSets['arrg'], ordered=False, doc='area to region' )
206
+ mTEPES.pp = Set(initialize=dictSets['p' ], doc='periods', within=PositiveIntegers)
207
+ mTEPES.scc = Set(initialize=dictSets['sc' ], doc='scenarios' )
208
+ mTEPES.stt = Set(initialize=dictSets['st' ], doc='stages' )
209
+ mTEPES.nn = Set(initialize=dictSets['n' ], doc='load levels' )
210
+ mTEPES.gg = Set(initialize=dictSets['g' ], doc='units' )
211
+ mTEPES.gt = Set(initialize=dictSets['gt' ], doc='technologies' )
212
+ mTEPES.nd = Set(initialize=dictSets['nd' ], doc='nodes' )
213
+ mTEPES.ni = Set(initialize=dictSets['nd' ], doc='nodes' )
214
+ mTEPES.nf = Set(initialize=dictSets['nd' ], doc='nodes' )
215
+ mTEPES.zn = Set(initialize=dictSets['zn' ], doc='zones' )
216
+ mTEPES.ar = Set(initialize=dictSets['ar' ], doc='areas' )
217
+ mTEPES.rg = Set(initialize=dictSets['rg' ], doc='regions' )
218
+ mTEPES.cc = Set(initialize=dictSets['cc' ], doc='circuits' )
219
+ mTEPES.c2 = Set(initialize=dictSets['cc' ], doc='circuits' )
220
+ mTEPES.lt = Set(initialize=dictSets['lt' ], doc='electric line types' )
221
+ mTEPES.ndzn = Set(initialize=dictSets['ndzn'], doc='node to zone' )
222
+ mTEPES.znar = Set(initialize=dictSets['znar'], doc='zone to area' )
223
+ mTEPES.arrg = Set(initialize=dictSets['arrg'], doc='area to region' )
224
224
 
225
225
  try:
226
226
  import csv
@@ -230,37 +230,37 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
230
230
  num_lines = sum(1 for _ in reader)
231
231
  return num_lines
232
232
 
233
- mTEPES.rs = Set(initialize=[], ordered=False, doc='reservoirs' )
234
- mTEPES.r2h = Set(initialize=[], ordered=False, doc='reservoir to hydro' )
235
- mTEPES.h2r = Set(initialize=[], ordered=False, doc='hydro to reservoir' )
236
- mTEPES.r2r = Set(initialize=[], ordered=False, doc='reservoir to reservoir' )
237
- mTEPES.p2r = Set(initialize=[], ordered=False, doc='pumped-hydro to reservoir')
238
- mTEPES.r2p = Set(initialize=[], ordered=False, doc='reservoir to pumped-hydro')
233
+ mTEPES.rs = Set(initialize=[], doc='reservoirs' )
234
+ mTEPES.r2h = Set(initialize=[], doc='reservoir to hydro' )
235
+ mTEPES.h2r = Set(initialize=[], doc='hydro to reservoir' )
236
+ mTEPES.r2r = Set(initialize=[], doc='reservoir to reservoir' )
237
+ mTEPES.p2r = Set(initialize=[], doc='pumped-hydro to reservoir')
238
+ mTEPES.r2p = Set(initialize=[], doc='reservoir to pumped-hydro')
239
239
 
240
240
  if count_lines_in_csv( _path+'/oT_Dict_Reservoir_' +CaseName+'.csv') > 1:
241
241
  dictSets.load(filename=_path+'/oT_Dict_Reservoir_' +CaseName+'.csv', set='rs' , format='set')
242
242
  mTEPES.del_component(mTEPES.rs)
243
- mTEPES.rs = Set(initialize=dictSets['rs' ], ordered=False, doc='reservoirs' )
243
+ mTEPES.rs = Set(initialize=dictSets['rs' ], doc='reservoirs' )
244
244
  if count_lines_in_csv( _path+'/oT_Dict_ReservoirToHydro_' +CaseName+'.csv') > 1:
245
245
  dictSets.load(filename=_path+'/oT_Dict_ReservoirToHydro_' +CaseName+'.csv', set='r2h', format='set')
246
246
  mTEPES.del_component(mTEPES.r2h)
247
- mTEPES.r2h = Set(initialize=dictSets['r2h'], ordered=False, doc='reservoir to hydro' )
247
+ mTEPES.r2h = Set(initialize=dictSets['r2h'], doc='reservoir to hydro' )
248
248
  if count_lines_in_csv( _path+'/oT_Dict_HydroToReservoir_' +CaseName+'.csv') > 1:
249
249
  dictSets.load(filename=_path+'/oT_Dict_HydroToReservoir_' +CaseName+'.csv', set='h2r', format='set')
250
250
  mTEPES.del_component(mTEPES.h2r)
251
- mTEPES.h2r = Set(initialize=dictSets['h2r'], ordered=False, doc='hydro to reservoir' )
251
+ mTEPES.h2r = Set(initialize=dictSets['h2r'], doc='hydro to reservoir' )
252
252
  if count_lines_in_csv( _path+'/oT_Dict_ReservoirToReservoir_' +CaseName+'.csv') > 1:
253
253
  dictSets.load(filename=_path+'/oT_Dict_ReservoirToReservoir_' +CaseName+'.csv', set='r2r', format='set')
254
254
  mTEPES.del_component(mTEPES.r2r)
255
- mTEPES.r2r = Set(initialize=dictSets['r2r'], ordered=False, doc='reservoir to reservoir' )
255
+ mTEPES.r2r = Set(initialize=dictSets['r2r'], doc='reservoir to reservoir' )
256
256
  if count_lines_in_csv( _path+'/oT_Dict_PumpedHydroToReservoir_'+CaseName+'.csv') > 1:
257
257
  dictSets.load(filename=_path+'/oT_Dict_PumpedHydroToReservoir_'+CaseName+'.csv', set='p2r', format='set')
258
258
  mTEPES.del_component(mTEPES.p2r)
259
- mTEPES.p2r = Set(initialize=dictSets['p2r'], ordered=False, doc='pumped-hydro to reservoir')
259
+ mTEPES.p2r = Set(initialize=dictSets['p2r'], doc='pumped-hydro to reservoir')
260
260
  if count_lines_in_csv( _path+'/oT_Dict_ReservoirToPumpedHydro_'+CaseName+'.csv') > 1:
261
261
  dictSets.load(filename=_path+'/oT_Dict_ReservoirToPumpedHydro_'+CaseName+'.csv', set='r2p', format='set')
262
262
  mTEPES.del_component(mTEPES.r2p)
263
- mTEPES.r2p = Set(initialize=dictSets['r2p'], ordered=False, doc='reservoir to pumped-hydro')
263
+ mTEPES.r2p = Set(initialize=dictSets['r2p'], doc='reservoir to pumped-hydro')
264
264
  except:
265
265
  pass
266
266
 
@@ -559,64 +559,64 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
559
559
  sBrList = [(ni,nf) for n,(ni,nf) in enumerate(sBr) if (ni,nf) not in sBr[:n]]
560
560
 
561
561
  #%% defining subsets: active load levels (n,n2), thermal units (t), RES units (r), ESS units (es), candidate gen units (gc), candidate ESS units (ec), all the electric lines (la), candidate electric lines (lc), candidate DC electric lines (cd), existing DC electric lines (cd), electric lines with losses (ll), reference node (rf), and reactive generating units (gq)
562
- mTEPES.p = Set(initialize=mTEPES.pp, ordered=True , doc='periods' , filter=lambda mTEPES,pp : pp in mTEPES.pp and pPeriodWeight [pp] > 0.0 and sum(pDuration[pp,sc,n] for sc,n in mTEPES.scc*mTEPES.nn))
563
- mTEPES.sc = Set(initialize=mTEPES.scc, ordered=True , doc='scenarios' , filter=lambda mTEPES,scc : scc in mTEPES.scc )
564
- mTEPES.ps = Set(initialize=mTEPES.p*mTEPES.sc, ordered=True , doc='periods/scenarios' , filter=lambda mTEPES,p,sc: (p,sc) in mTEPES.p*mTEPES.sc and pScenProb [p,sc] > 0.0 and sum(pDuration[p,sc,n ] for n in mTEPES.nn))
565
- mTEPES.st = Set(initialize=mTEPES.stt, ordered=True , doc='stages' , filter=lambda mTEPES,stt : stt in mTEPES.stt and pStageWeight [stt] > 0.0)
566
- mTEPES.n = Set(initialize=mTEPES.nn, ordered=True , doc='load levels' , filter=lambda mTEPES,nn : nn in mTEPES.nn and sum(pDuration [p,sc,nn] for p,sc in mTEPES.ps) > 0)
567
- mTEPES.n2 = Set(initialize=mTEPES.nn, ordered=True , doc='load levels' , filter=lambda mTEPES,nn : nn in mTEPES.nn and sum(pDuration [p,sc,nn] for p,sc in mTEPES.ps) > 0)
568
- mTEPES.g = Set(initialize=mTEPES.gg, ordered=True , doc='generating units' , filter=lambda mTEPES,gg : gg in mTEPES.gg and (pRatedMaxPowerElec [gg] > 0.0 or pRatedMaxCharge[gg] > 0.0 or pRatedMaxPowerHeat [gg] > 0.0) and pElecGenPeriodIni[gg] <= mTEPES.p.last() and pElecGenPeriodFin[gg] >= mTEPES.p.first() and pGenToNode.reset_index().set_index(['index']).isin(mTEPES.nd)['Node'][gg]) # excludes generators with empty node
569
- mTEPES.t = Set(initialize=mTEPES.g , ordered=False, doc='thermal units' , filter=lambda mTEPES,g : g in mTEPES.g and pRatedLinearOperCost[g ] > 0.0)
570
- mTEPES.re = Set(initialize=mTEPES.g , ordered=False, doc='RES units' , filter=lambda mTEPES,g : g in mTEPES.g and pRatedLinearOperCost[g ] == 0.0 and pRatedMaxStorage[g] == 0.0 and pProductionFunctionH2[g ] == 0.0 and pProductionFunctionHeat[g ] == 0.0 and pProductionFunctionHydro[g ] == 0.0)
571
- mTEPES.es = Set(initialize=mTEPES.g , ordered=False, doc='ESS units' , filter=lambda mTEPES,g : g in mTEPES.g and (pRatedMaxCharge[g ] > 0.0 or pRatedMaxStorage[g] > 0.0 or pProductionFunctionH2[g ] > 0.0 or pProductionFunctionHeat[g ] > 0.0) and pProductionFunctionHydro[g ] == 0.0)
572
- mTEPES.h = Set(initialize=mTEPES.g , ordered=False, doc='hydro units' , filter=lambda mTEPES,g : g in mTEPES.g and pProductionFunctionH2[g ] == 0.0 and pProductionFunctionHeat[g ] == 0.0 and pProductionFunctionHydro[g ] > 0.0)
573
- mTEPES.el = Set(initialize=mTEPES.es, ordered=False, doc='electrolyzer units' , filter=lambda mTEPES,es : es in mTEPES.es and pProductionFunctionH2[es] > 0.0 and pProductionFunctionHeat[es] == 0.0 and pProductionFunctionHydro[es] == 0.0)
574
- mTEPES.hp = Set(initialize=mTEPES.es, ordered=False, doc='heat pump & elec boiler units' , filter=lambda mTEPES,es : es in mTEPES.es and pProductionFunctionH2[es] == 0.0 and pProductionFunctionHeat[es] > 0.0 and pProductionFunctionHydro[es] == 0.0)
575
- mTEPES.ch = Set(initialize=mTEPES.g , ordered=False, doc='CHP & fuel boiler units' , filter=lambda mTEPES,g : g in mTEPES.g and pRatedMaxPowerHeat[g ] > 0.0 and pProductionFunctionHeat [g ] == 0.0)
576
- mTEPES.bo = Set(initialize=mTEPES.ch, ordered=False, doc=' fuel boiler units' , filter=lambda mTEPES,ch : ch in mTEPES.ch and pRatedMaxPowerElec [ch] == 0.0 and pRatedMaxPowerHeat[ch] > 0.0 and pProductionFunctionHeat [ch] == 0.0)
577
- mTEPES.hh = Set(initialize=mTEPES.bo, ordered=False, doc=' hydrogen boiler units' , filter=lambda mTEPES,bo : bo in mTEPES.bo and pProductionFunctionH2ToHeat[bo] > 0.0)
578
- mTEPES.gc = Set(initialize=mTEPES.g , ordered=False, doc='candidate units' , filter=lambda mTEPES,g : g in mTEPES.g and pGenInvestCost [g ] > 0.0)
579
- mTEPES.gd = Set(initialize=mTEPES.g , ordered=False, doc='retirement units' , filter=lambda mTEPES,g : g in mTEPES.g and pGenRetireCost [g ] > 0.0)
580
- mTEPES.ec = Set(initialize=mTEPES.es, ordered=False, doc='candidate ESS units' , filter=lambda mTEPES,es : es in mTEPES.es and pGenInvestCost [es] > 0.0)
581
- mTEPES.bc = Set(initialize=mTEPES.bo, ordered=False, doc='candidate boiler units' , filter=lambda mTEPES,bo : bo in mTEPES.bo and pGenInvestCost [bo] > 0.0)
582
- mTEPES.br = Set(initialize=sBrList, ordered=False, doc='all input electric branches' )
583
- mTEPES.ln = Set(initialize=dfNetwork.index, ordered=False, doc='all input electric lines' )
584
- mTEPES.la = Set(initialize=mTEPES.ln, ordered=False, doc='all real electric lines' , filter=lambda mTEPES,*ln : ln in mTEPES.ln and pLineX [ln] != 0.0 and pLineNTCFrw[ln] > 0.0 and pLineNTCBck[ln] > 0.0 and pElecNetPeriodIni[ln] <= mTEPES.p.last() and pElecNetPeriodFin[ln] >= mTEPES.p.first())
585
- mTEPES.ls = Set(initialize=mTEPES.la, ordered=False, doc='all real switch electric lines' , filter=lambda mTEPES,*la : la in mTEPES.la and pIndBinLineSwitch [la] )
586
- mTEPES.lc = Set(initialize=mTEPES.la, ordered=False, doc='candidate electric lines' , filter=lambda mTEPES,*la : la in mTEPES.la and pNetFixedCost [la] > 0.0)
587
- mTEPES.cd = Set(initialize=mTEPES.la, ordered=False, doc=' DC electric lines' , filter=lambda mTEPES,*la : la in mTEPES.la and pNetFixedCost [la] > 0.0 and pLineType[la] == 'DC')
588
- mTEPES.ed = Set(initialize=mTEPES.la, ordered=False, doc=' DC electric lines' , filter=lambda mTEPES,*la : la in mTEPES.la and pNetFixedCost [la] == 0.0 and pLineType[la] == 'DC')
589
- mTEPES.ll = Set(initialize=mTEPES.la, ordered=False, doc='loss electric lines' , filter=lambda mTEPES,*la : la in mTEPES.la and pLineLossFactor [la] > 0.0 and pIndBinNetLosses > 0 )
590
- mTEPES.rf = Set(initialize=mTEPES.nd, ordered=True , doc='reference node' , filter=lambda mTEPES,nd : nd in pReferenceNode )
591
- mTEPES.gq = Set(initialize=mTEPES.gg, ordered=False, doc='gen reactive units' , filter=lambda mTEPES,gg : gg in mTEPES.gg and pRMaxReactivePower [gg] > 0.0 and pElecGenPeriodIni[gg] <= mTEPES.p.last() and pElecGenPeriodFin[gg] >= mTEPES.p.first())
592
- mTEPES.sq = Set(initialize=mTEPES.gg, ordered=False, doc='synchr reactive units' , filter=lambda mTEPES,gg : gg in mTEPES.gg and pRMaxReactivePower [gg] > 0.0 and pGenToTechnology[gg] == 'SynchronousCondenser' and pElecGenPeriodIni[gg] <= mTEPES.p.last() and pElecGenPeriodFin[gg] >= mTEPES.p.first())
593
- mTEPES.sqc = Set(initialize=mTEPES.sq, ordered=False, doc='synchr reactive candidate' )
594
- mTEPES.shc = Set(initialize=mTEPES.sq, ordered=False, doc='shunt candidate' )
562
+ mTEPES.p = Set(doc='periods' , initialize=[pp for pp in mTEPES.pp if pPeriodWeight [pp] > 0.0 and sum(pDuration[pp,sc,n] for sc,n in mTEPES.scc*mTEPES.nn)])
563
+ mTEPES.sc = Set(doc='scenarios' , initialize=[scc for scc in mTEPES.scc ])
564
+ mTEPES.ps = Set(doc='periods/scenarios' , initialize=[(p,sc) for p,sc in mTEPES.p*mTEPES.sc if pScenProb [p,sc] > 0.0 and sum(pDuration[p,sc,n ] for n in mTEPES.nn)])
565
+ mTEPES.st = Set(doc='stages' , initialize=[stt for stt in mTEPES.stt if pStageWeight [stt] > 0.0])
566
+ mTEPES.n = Set(doc='load levels' , initialize=[nn for nn in mTEPES.nn if sum(pDuration [p,sc,nn] for p,sc in mTEPES.ps) > 0])
567
+ mTEPES.n2 = Set(doc='load levels' , initialize=[nn for nn in mTEPES.nn if sum(pDuration [p,sc,nn] for p,sc in mTEPES.ps) > 0])
568
+ mTEPES.g = Set(doc='generating units' , initialize=[gg for gg in mTEPES.gg if (pRatedMaxPowerElec [gg] > 0.0 or pRatedMaxCharge[gg] > 0.0 or pRatedMaxPowerHeat [gg] > 0.0) and pElecGenPeriodIni[gg] <= mTEPES.p.last() and pElecGenPeriodFin[gg] >= mTEPES.p.first() and pGenToNode.reset_index().set_index(['index']).isin(mTEPES.nd)['Node'][gg]]) # excludes generators with empty node
569
+ mTEPES.t = Set(doc='thermal units' , initialize=[g for g in mTEPES.g if pRatedLinearOperCost[g ] > 0.0])
570
+ mTEPES.re = Set(doc='RES units' , initialize=[g for g in mTEPES.g if pRatedLinearOperCost[g ] == 0.0 and pRatedMaxStorage[g] == 0.0 and pProductionFunctionH2[g ] == 0.0 and pProductionFunctionHeat[g ] == 0.0 and pProductionFunctionHydro[g ] == 0.0])
571
+ mTEPES.es = Set(doc='ESS units' , initialize=[g for g in mTEPES.g if (pRatedMaxCharge[g ] > 0.0 or pRatedMaxStorage[g] > 0.0 or pProductionFunctionH2[g ] > 0.0 or pProductionFunctionHeat[g ] > 0.0) and pProductionFunctionHydro[g ] == 0.0])
572
+ mTEPES.h = Set(doc='hydro units' , initialize=[g for g in mTEPES.g if pProductionFunctionH2[g ] == 0.0 and pProductionFunctionHeat[g ] == 0.0 and pProductionFunctionHydro[g ] > 0.0])
573
+ mTEPES.el = Set(doc='electrolyzer units' , initialize=[es for es in mTEPES.es if pProductionFunctionH2[es] > 0.0 and pProductionFunctionHeat[es] == 0.0 and pProductionFunctionHydro[es] == 0.0])
574
+ mTEPES.hp = Set(doc='heat pump & elec boiler units' , initialize=[es for es in mTEPES.es if pProductionFunctionH2[es] == 0.0 and pProductionFunctionHeat[es] > 0.0 and pProductionFunctionHydro[es] == 0.0])
575
+ mTEPES.ch = Set(doc='CHP & fuel boiler units' , initialize=[g for g in mTEPES.g if pRatedMaxPowerHeat[g ] > 0.0 and pProductionFunctionHeat [g ] == 0.0])
576
+ mTEPES.bo = Set(doc=' fuel boiler units' , initialize=[ch for ch in mTEPES.ch if pRatedMaxPowerElec [ch] == 0.0 and pRatedMaxPowerHeat[ch] > 0.0 and pProductionFunctionHeat [ch] == 0.0])
577
+ mTEPES.hh = Set(doc=' hydrogen boiler units' , initialize=[bo for bo in mTEPES.bo if pProductionFunctionH2ToHeat[bo] > 0.0])
578
+ mTEPES.gc = Set(doc='candidate units' , initialize=[g for g in mTEPES.g if pGenInvestCost [g ] > 0.0])
579
+ mTEPES.gd = Set(doc='retirement units' , initialize=[g for g in mTEPES.g if pGenRetireCost [g ] > 0.0])
580
+ mTEPES.ec = Set(doc='candidate ESS units' , initialize=[es for es in mTEPES.es if pGenInvestCost [es] > 0.0])
581
+ mTEPES.bc = Set(doc='candidate boiler units' , initialize=[bo for bo in mTEPES.bo if pGenInvestCost [bo] > 0.0])
582
+ mTEPES.br = Set(doc='all input electric branches', initialize=sBrList )
583
+ mTEPES.ln = Set(doc='all input electric lines' , initialize=dfNetwork.index)
584
+ mTEPES.la = Set(doc='all real electric lines' , initialize=[ln for ln in mTEPES.ln if pLineX [ln] != 0.0 and pLineNTCFrw[ln] > 0.0 and pLineNTCBck[ln] > 0.0 and pElecNetPeriodIni[ln] <= mTEPES.p.last() and pElecNetPeriodFin[ln] >= mTEPES.p.first()])
585
+ mTEPES.ls = Set(doc='all real switch electric lines' , initialize=[la for la in mTEPES.la if pIndBinLineSwitch [la] ])
586
+ mTEPES.lc = Set(doc='candidate electric lines' , initialize=[la for la in mTEPES.la if pNetFixedCost [la] > 0.0])
587
+ mTEPES.cd = Set(doc=' DC electric lines' , initialize=[la for la in mTEPES.la if pNetFixedCost [la] > 0.0 and pLineType[la] == 'DC'])
588
+ mTEPES.ed = Set(doc=' DC electric lines' , initialize=[la for la in mTEPES.la if pNetFixedCost [la] == 0.0 and pLineType[la] == 'DC'])
589
+ mTEPES.ll = Set(doc='loss electric lines' , initialize=[la for la in mTEPES.la if pLineLossFactor [la] > 0.0 and pIndBinNetLosses > 0 ])
590
+ mTEPES.rf = Set(doc='reference node' , initialize=[pReferenceNode])
591
+ mTEPES.gq = Set(doc='gen reactive units' , initialize=[gg for gg in mTEPES.gg if pRMaxReactivePower [gg] > 0.0 and pElecGenPeriodIni[gg] <= mTEPES.p.last() and pElecGenPeriodFin[gg] >= mTEPES.p.first()])
592
+ mTEPES.sq = Set(doc='synchr reactive units' , initialize=[gg for gg in mTEPES.gg if pRMaxReactivePower [gg] > 0.0 and pGenToTechnology[gg] == 'SynchronousCondenser' and pElecGenPeriodIni[gg] <= mTEPES.p.last() and pElecGenPeriodFin[gg] >= mTEPES.p.first()])
593
+ mTEPES.sqc = Set(doc='synchr reactive candidate')
594
+ mTEPES.shc = Set(doc='shunt candidate')
595
595
  if pIndHydroTopology == 1:
596
- mTEPES.rn = Set(initialize=mTEPES.rs, ordered=False, doc='candidate reservoirs' , filter=lambda mTEPES,rs : rs in mTEPES.rs and pRsrInvestCost [rs] > 0.0 and pRsrPeriodIni[rs] <= mTEPES.p.last() and pRsrPeriodFin[rs] >= mTEPES.p.first())
596
+ mTEPES.rn = Set(doc='candidate reservoirs' , initialize=[rs for rs in mTEPES.rs if pRsrInvestCost [rs] > 0.0 and pRsrPeriodIni[rs] <= mTEPES.p.last() and pRsrPeriodFin[rs] >= mTEPES.p.first()])
597
597
  else:
598
- mTEPES.rn = Set(initialize=[], ordered=False, doc='candidate reservoirs')
598
+ mTEPES.rn = Set(doc='candidate reservoirs' , initialize=[] )
599
599
  if pIndHydrogen == 1:
600
- mTEPES.pn = Set(initialize=dfNetworkHydrogen.index, ordered=False, doc='all input hydrogen pipes' )
601
- mTEPES.pa = Set(initialize=mTEPES.pn, ordered=False, doc='all real hydrogen pipes' , filter=lambda mTEPES,*pn : pn in mTEPES.pn and pH2PipeNTCFrw [pn] > 0.0 and pH2PipeNTCBck[pn] > 0.0 and pH2PipePeriodIni[pn] <= mTEPES.p.last() and pH2PipePeriodFin[pn] >= mTEPES.p.first())
602
- mTEPES.pc = Set(initialize=mTEPES.pa, ordered=False, doc='candidate hydrogen pipes' , filter=lambda mTEPES,*pa : pa in mTEPES.pa and pH2PipeFixedCost [pa] > 0.0)
600
+ mTEPES.pn = Set(doc='all input hydrogen pipes' , initialize=dfNetworkHydrogen.index )
601
+ mTEPES.pa = Set(doc='all real hydrogen pipes' , initialize=[pn for pn in mTEPES.pn if pH2PipeNTCFrw [pn] > 0.0 and pH2PipeNTCBck[pn] > 0.0 and pH2PipePeriodIni[pn] <= mTEPES.p.last() and pH2PipePeriodFin[pn] >= mTEPES.p.first()])
602
+ mTEPES.pc = Set(doc='candidate hydrogen pipes' , initialize=[pa for pa in mTEPES.pa if pH2PipeFixedCost [pa] > 0.0])
603
603
  # existing hydrogen pipelines (pe)
604
604
  mTEPES.pe = mTEPES.pa - mTEPES.pc
605
605
  else:
606
- mTEPES.pn = Set(initialize=[], ordered=False, doc='all input hydrogen pipes')
607
- mTEPES.pa = Set(initialize=[], ordered=False, doc='all real hydrogen pipes')
608
- mTEPES.pc = Set(initialize=[], ordered=False, doc='candidate hydrogen pipes')
606
+ mTEPES.pn = Set(doc='all input hydrogen pipes' , initialize=[])
607
+ mTEPES.pa = Set(doc='all real hydrogen pipes' , initialize=[])
608
+ mTEPES.pc = Set(doc='candidate hydrogen pipes' , initialize=[])
609
609
 
610
610
  if pIndHeat == 1:
611
- mTEPES.hn = Set(initialize=dfNetworkHeat.index, ordered=False, doc='all input heat pipes' )
612
- mTEPES.ha = Set(initialize=mTEPES.hn, ordered=False, doc='all real heat pipes' , filter=lambda mTEPES,*hn : hn in mTEPES.hn and pHeatPipeNTCFrw [hn] > 0.0 and pHeatPipeNTCBck[hn] > 0.0 and pHeatPipePeriodIni[hn] <= mTEPES.p.last() and pHeatPipePeriodFin[hn] >= mTEPES.p.first())
613
- mTEPES.hc = Set(initialize=mTEPES.ha, ordered=False, doc='candidate heat pipes' , filter=lambda mTEPES,*ha : ha in mTEPES.ha and pHeatPipeFixedCost [ha] > 0.0)
611
+ mTEPES.hn = Set(doc='all input heat pipes' , initialize=dfNetworkHeat.index)
612
+ mTEPES.ha = Set(doc='all real heat pipes' , initialize=[hn for hn in mTEPES.hn if pHeatPipeNTCFrw [hn] > 0.0 and pHeatPipeNTCBck[hn] > 0.0 and pHeatPipePeriodIni[hn] <= mTEPES.p.last() and pHeatPipePeriodFin[hn] >= mTEPES.p.first()])
613
+ mTEPES.hc = Set(doc='candidate heat pipes' , initialize=[ha for ha in mTEPES.ha if pHeatPipeFixedCost [ha] > 0.0])
614
614
  # existing heat pipes (he)
615
615
  mTEPES.he = mTEPES.ha - mTEPES.hc
616
616
  else:
617
- mTEPES.hn = Set(initialize=[], ordered=False, doc='all input heat pipes')
618
- mTEPES.ha = Set(initialize=[], ordered=False, doc='all real heat pipes')
619
- mTEPES.hc = Set(initialize=[], ordered=False, doc='candidate heat pipes')
617
+ mTEPES.hn = Set(doc='all input heat pipes' , initialize=[])
618
+ mTEPES.ha = Set(doc='all real heat pipes' , initialize=[])
619
+ mTEPES.hc = Set(doc='candidate heat pipes' , initialize=[])
620
620
 
621
621
  # non-RES units, they can be committed and also contribute to the operating reserves
622
622
  mTEPES.nr = mTEPES.g - mTEPES.re
@@ -638,7 +638,7 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
638
638
  pStageToLevel = pStageToLevel.loc[pStageToLevel['level_2'].keys().isin(mTEPES.ps*mTEPES.st)]
639
639
  pStageToLevel = pStageToLevel.loc[pStageToLevel['level_2'].isin(mTEPES.n)].reset_index().set_index(['level_0','level_1','Stage','level_2'])
640
640
 
641
- mTEPES.s2n = Set(initialize=pStageToLevel.index, ordered=False, doc='load level to stage')
641
+ mTEPES.s2n = Set(initialize=pStageToLevel.index, doc='load level to stage')
642
642
  # all the stages must have the same duration
643
643
  pStageDuration = pd.Series([sum(pDuration[p,sc,n] for p,sc,st2,n in mTEPES.s2n if st2 == st) for st in mTEPES.st], index=mTEPES.st)
644
644
  # for st in mTEPES.st:
@@ -648,8 +648,8 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
648
648
  # delete all the load level belonging to stages with duration equal to zero
649
649
  mTEPES.del_component(mTEPES.n )
650
650
  mTEPES.del_component(mTEPES.n2)
651
- mTEPES.n = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and sum(pDuration[p,sc,nn] for p,sc in mTEPES.ps) > 0)
652
- mTEPES.n2 = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn: nn in mTEPES.nn and sum(pDuration[p,sc,nn] for p,sc in mTEPES.ps) > 0)
651
+ mTEPES.n = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if sum(pDuration[p,sc,nn] for p,sc in mTEPES.ps) > 0])
652
+ mTEPES.n2 = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if sum(pDuration[p,sc,nn] for p,sc in mTEPES.ps) > 0])
653
653
  # instrumental sets
654
654
  def CreateInstrumentalSets(mTEPES, pIndHydroTopology, pIndHydrogen, pIndHeat) -> None:
655
655
  '''
@@ -782,24 +782,24 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
782
782
  if pIndHeat == 1:
783
783
  pIndBinHeatPipeInvest = pIndBinHeatPipeInvest.map(idxDict)
784
784
 
785
- # define AC existing lines non-switchable
786
- mTEPES.lea = Set(initialize=mTEPES.le, ordered=False, doc='AC existing lines and non-switchable lines', filter=lambda mTEPES,*le: le in mTEPES.le and pIndBinLineSwitch[le] == 0 and not pLineType[le] == 'DC')
785
+ # define AC existing lines non-switchable lines
786
+ mTEPES.lea = Set(doc='AC existing lines and non-switchable lines', initialize=[le for le in mTEPES.le if pIndBinLineSwitch[le] == 0 and not pLineType[le] == 'DC'])
787
787
  # define AC candidate lines and switchable lines
788
- mTEPES.lca = Set(initialize=mTEPES.la, ordered=False, doc='AC candidate lines and switchable lines', filter=lambda mTEPES,*la: la in mTEPES.la and (pIndBinLineSwitch[la] == 1 or pNetFixedCost[la] > 0.0) and not pLineType[la] == 'DC')
788
+ mTEPES.lca = Set(doc='AC candidate lines and switchable lines', initialize=[la for la in mTEPES.la if (pIndBinLineSwitch[la] == 1 or pNetFixedCost[la] > 0.0) and not pLineType[la] == 'DC'])
789
789
 
790
790
  mTEPES.laa = mTEPES.lea | mTEPES.lca
791
791
 
792
- # define DC existing lines non-switchable
793
- mTEPES.led = Set(initialize=mTEPES.le, ordered=False, doc='DC existing lines and non-switchable lines', filter=lambda mTEPES,*le: le in mTEPES.le and pIndBinLineSwitch[le] == 0 and pLineType[le] == 'DC')
792
+ # define DC existing lines non-switchable lines
793
+ mTEPES.led = Set(doc='DC existing lines and non-switchable lines', initialize=[le for le in mTEPES.le if pIndBinLineSwitch[le] == 0 and pLineType[le] == 'DC'])
794
794
  # define DC candidate lines and switchable lines
795
- mTEPES.lcd = Set(initialize=mTEPES.la, ordered=False, doc='DC candidate lines and switchable lines', filter=lambda mTEPES,*la: la in mTEPES.la and (pIndBinLineSwitch[la] == 1 or pNetFixedCost[la] > 0.0) and pLineType[la] == 'DC')
795
+ mTEPES.lcd = Set(doc='DC candidate lines and switchable lines', initialize=[la for la in mTEPES.la if (pIndBinLineSwitch[la] == 1 or pNetFixedCost[la] > 0.0) and pLineType[la] == 'DC'])
796
796
 
797
797
  mTEPES.lad = mTEPES.led | mTEPES.lcd
798
798
 
799
799
  # line type
800
800
  pLineType = pLineType.reset_index().set_index(['level_0','level_1','level_2','LineType'])
801
801
 
802
- mTEPES.pLineType = Set(initialize=pLineType.index, ordered=False, doc='line type')
802
+ mTEPES.pLineType = Set(initialize=pLineType.index, doc='line type')
803
803
 
804
804
  if pAnnualDiscRate == 0.0:
805
805
  pDiscountedWeight = pd.Series([ pPeriodWeight[p] for p in mTEPES.p], index=mTEPES.p)
@@ -814,15 +814,11 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
814
814
  pNodeToGen = pGenToNode.reset_index().set_index('Node').set_axis(['Generator'], axis=1)[['Generator']]
815
815
  pNodeToGen = pNodeToGen.loc[pNodeToGen['Generator'].isin(mTEPES.g)].reset_index().set_index(['Node', 'Generator'])
816
816
 
817
- mTEPES.n2g = Set(initialize=pNodeToGen.index, ordered=False, doc='node to generator')
817
+ mTEPES.n2g = Set(initialize=pNodeToGen.index, doc='node to generator')
818
818
 
819
- pZone2Gen = [(zn,g) for (nd,g,zn ) in mTEPES.n2g*mTEPES.zn if (nd,zn) in mTEPES.ndzn ]
820
- pArea2Gen = [(ar,g) for (nd,g,zn,ar ) in mTEPES.n2g*mTEPES.znar if (nd,zn) in mTEPES.ndzn ]
821
- pRegion2Gen = [(rg,g) for (nd,g,zn,ar,rg) in mTEPES.n2g*mTEPES.znar*mTEPES.rg if (nd,zn) in mTEPES.ndzn and [ar,rg] in mTEPES.arrg]
822
-
823
- mTEPES.z2g = Set(initialize=mTEPES.zn*mTEPES.g, ordered=False, doc='zone to generator', filter=lambda mTEPES,zn,g: (zn,g) in pZone2Gen )
824
- mTEPES.a2g = Set(initialize=mTEPES.ar*mTEPES.g, ordered=False, doc='area to generator', filter=lambda mTEPES,ar,g: (ar,g) in pArea2Gen )
825
- mTEPES.r2g = Set(initialize=mTEPES.rg*mTEPES.g, ordered=False, doc='region to generator', filter=lambda mTEPES,rg,g: (rg,g) in pRegion2Gen)
819
+ mTEPES.z2g = Set(doc='zone to generator', initialize=[(zn,g) for (nd,g,zn ) in mTEPES.n2g*mTEPES.zn if (nd,zn) in mTEPES.ndzn ])
820
+ mTEPES.a2g = Set(doc='area to generator', initialize=[(ar,g) for (nd,g,zn,ar ) in mTEPES.n2g*mTEPES.znar if (nd,zn) in mTEPES.ndzn ])
821
+ mTEPES.r2g = Set(doc='region to generator', initialize=[(rg,g) for (nd,g,zn,ar,rg) in mTEPES.n2g*mTEPES.znar*mTEPES.rg if (nd,zn) in mTEPES.ndzn and [ar,rg] in mTEPES.arrg])
826
822
 
827
823
  # mTEPES.z2g = Set(initialize = [(zn,g) for zn,g in mTEPES.zn*mTEPES.g if (zn,g) in pZone2Gen])
828
824
 
@@ -830,15 +826,15 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
830
826
  pTechnologyToGen = pGenToTechnology.reset_index().set_index('Technology').set_axis(['Generator'], axis=1)[['Generator']]
831
827
  pTechnologyToGen = pTechnologyToGen.loc[pTechnologyToGen['Generator'].isin(mTEPES.g)].reset_index().set_index(['Technology', 'Generator'])
832
828
 
833
- mTEPES.t2g = Set(initialize=pTechnologyToGen.index, ordered=False, doc='technology to generator')
829
+ mTEPES.t2g = Set(initialize=pTechnologyToGen.index, doc='technology to generator')
834
830
 
835
831
  # ESS and RES technologies
836
832
  def Create_ESS_RES_Sets(mTEPES) -> None:
837
- mTEPES.ot = Set(initialize=mTEPES.gt, ordered=False, doc='ESS technologies', filter=lambda mTEPES,gt: gt in mTEPES.gt and sum(1 for es in mTEPES.es if (gt,es) in mTEPES.t2g))
838
- mTEPES.ht = Set(initialize=mTEPES.gt, ordered=False, doc='hydro technologies', filter=lambda mTEPES,gt: gt in mTEPES.gt and sum(1 for h in mTEPES.h if (gt,h ) in mTEPES.t2g))
839
- mTEPES.et = Set(initialize=mTEPES.gt, ordered=False, doc='ESS & hydro technologies', filter=lambda mTEPES,gt: gt in mTEPES.gt and sum(1 for eh in mTEPES.eh if (gt,eh) in mTEPES.t2g))
840
- mTEPES.rt = Set(initialize=mTEPES.gt, ordered=False, doc=' RES technologies', filter=lambda mTEPES,gt: gt in mTEPES.gt and sum(1 for re in mTEPES.re if (gt,re) in mTEPES.t2g))
841
- mTEPES.nt = Set(initialize=mTEPES.gt, ordered=False, doc='non-RES technologies', filter=lambda mTEPES,gt: gt in mTEPES.gt and sum(1 for nr in mTEPES.nr if (gt,nr) in mTEPES.t2g))
833
+ mTEPES.ot = Set(doc='ESS technologies', initialize=[gt for gt in mTEPES.gt if sum(1 for es in mTEPES.es if (gt,es) in mTEPES.t2g)])
834
+ mTEPES.ht = Set(doc='hydro technologies', initialize=[gt for gt in mTEPES.gt if sum(1 for h in mTEPES.h if (gt,h ) in mTEPES.t2g)])
835
+ mTEPES.et = Set(doc='ESS & hydro technologies', initialize=[gt for gt in mTEPES.gt if sum(1 for eh in mTEPES.eh if (gt,eh) in mTEPES.t2g)])
836
+ mTEPES.rt = Set(doc=' RES technologies', initialize=[gt for gt in mTEPES.gt if sum(1 for re in mTEPES.re if (gt,re) in mTEPES.t2g)])
837
+ mTEPES.nt = Set(doc='non-RES technologies', initialize=[gt for gt in mTEPES.gt if sum(1 for nr in mTEPES.nr if (gt,nr) in mTEPES.t2g)])
842
838
 
843
839
  mTEPES.psgt = Set(initialize=[(p,sc, gt) for p,sc, gt in mTEPES.ps *mTEPES.gt if sum(1 for g in mTEPES.g if (p,g ) in mTEPES.pg and (gt,g ) in mTEPES.t2g)])
844
840
  mTEPES.psot = Set(initialize=[(p,sc, ot) for p,sc, ot in mTEPES.ps *mTEPES.ot if sum(1 for es in mTEPES.es if (p,es) in mTEPES.pes and (ot,es) in mTEPES.t2g)])
@@ -859,7 +855,7 @@ def InputData(DirName, CaseName, mTEPES, pIndLogConsole):
859
855
  pExclusiveGenToGen = pGenToExclusiveGen.reset_index().set_index('MutuallyExclusive').set_axis(['Generator'], axis=1)[['Generator']]
860
856
  pExclusiveGenToGen = pExclusiveGenToGen.loc[pExclusiveGenToGen['Generator'].isin(mTEPES.g)].reset_index().set_index(['MutuallyExclusive', 'Generator'])
861
857
 
862
- mTEPES.g2g = Set(initialize=pExclusiveGenToGen.index, ordered=False, doc='mutually exclusive generator to generator', filter=lambda mTEPES,gg,g: (gg,g) in mTEPES.g*mTEPES.g)
858
+ mTEPES.g2g = Set(doc='mutually exclusive generator to generator', initialize=[(gg,g) for gg,g in mTEPES.g*mTEPES.g if (gg,g) in pExclusiveGenToGen])
863
859
 
864
860
  # minimum and maximum variable power, charge, and storage capacity
865
861
  pMinPowerElec = pVariableMinPowerElec.replace(0.0, pRatedMinPowerElec)
@@ -1998,8 +1994,8 @@ def SettingUpVariables(OptModel, mTEPES):
1998
1994
  # activate only period, scenario, and load levels to formulate
1999
1995
  mTEPES.del_component(mTEPES.st)
2000
1996
  mTEPES.del_component(mTEPES.n )
2001
- mTEPES.st = Set(initialize=mTEPES.stt, ordered=True, doc='stages', filter=lambda mTEPES,stt: stt in st == stt and mTEPES.pStageWeight[stt] and sum(1 for (p,sc,st,nn) in mTEPES.s2n))
2002
- mTEPES.n = Set(initialize=mTEPES.nn , ordered=True, doc='load levels', filter=lambda mTEPES,nn : nn in mTEPES.nn and (p,sc,st,nn) in mTEPES.s2n)
1997
+ mTEPES.st = Set(doc='stages', initialize=[stt for stt in mTEPES.stt if st == stt and mTEPES.pStageWeight[stt] and sum(1 for (p,sc,st,nn) in mTEPES.s2n)])
1998
+ mTEPES.n = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if (p,sc,st,nn) in mTEPES.s2n ])
2003
1999
 
2004
2000
  if len(mTEPES.n):
2005
2001
  mTEPES.psn1 = Set(initialize=[(p,sc,n) for p,sc,n in mTEPES.ps*mTEPES.n])
@@ -2047,8 +2043,8 @@ def SettingUpVariables(OptModel, mTEPES):
2047
2043
  # activate all the periods, scenarios, and load levels again
2048
2044
  mTEPES.del_component(mTEPES.st)
2049
2045
  mTEPES.del_component(mTEPES.n )
2050
- mTEPES.st = Set(initialize=mTEPES.stt, ordered=True, doc='stages', filter=lambda mTEPES,stt: stt in mTEPES.stt and mTEPES.pStageWeight[stt] and sum(1 for (p,sc,stt,nn) in mTEPES.s2n))
2051
- mTEPES.n = Set(initialize=mTEPES.nn, ordered=True, doc='load levels', filter=lambda mTEPES,nn : nn in mTEPES.nn and sum(1 for st in mTEPES.st if (p,sc,st, nn) in mTEPES.s2n))
2046
+ mTEPES.st = Set(doc='stages', initialize=[stt for stt in mTEPES.stt if mTEPES.pStageWeight[stt] and sum(1 for (p,sc,stt,nn) in mTEPES.s2n)])
2047
+ mTEPES.n = Set(doc='load levels', initialize=[nn for nn in mTEPES.nn if sum(1 for st in mTEPES.st if (p,sc,st, nn) in mTEPES.s2n)])
2052
2048
 
2053
2049
  # fixing the ESS inventory at the end of the following pStorageTimeStep (daily, weekly, monthly) if between storage limits, i.e.,
2054
2050
  # for daily ESS is fixed at the end of the week, for weekly ESS is fixed at the end of the month, for monthly ESS is fixed at the end of the year
@@ -2125,21 +2121,21 @@ def SettingUpVariables(OptModel, mTEPES):
2125
2121
  # fixing the ENS in nodes with no demand
2126
2122
  for p,sc,n,nd in mTEPES.psnnd:
2127
2123
  if mTEPES.pDemandElec[p,sc,n,nd] == 0.0:
2128
- OptModel.vENS[p,sc,n,nd].fix(0.0)
2124
+ OptModel.vENS [p,sc,n,nd].fix(0.0)
2129
2125
  nFixedVariables += 1
2130
2126
 
2131
2127
  if mTEPES.pIndHydrogen == 1:
2132
2128
  # fixing the H2 ENS in nodes with no hydrogen demand
2133
2129
  for p,sc,n,nd in mTEPES.psnnd:
2134
- if mTEPES.pDemandH2[p,sc,n,nd] == 0.0:
2135
- OptModel.vH2NS[p,sc,n,nd].fix (0.0)
2130
+ if mTEPES.pDemandH2[p,sc,n,nd] == 0.0:
2131
+ OptModel.vH2NS [p,sc,n,nd].fix (0.0)
2136
2132
  nFixedVariables += 1
2137
2133
 
2138
2134
  if mTEPES.pIndHeat == 1:
2139
2135
  # fixing the heat ENS in nodes with no heat demand
2140
2136
  for p,sc,n,nd in mTEPES.psnnd:
2141
- if mTEPES.pDemandHeat[p,sc,n,nd] == 0.0:
2142
- OptModel.vHeatNS[p,sc,n,nd].fix (0.0)
2137
+ if mTEPES.pDemandHeat[p,sc,n,nd] == 0.0:
2138
+ OptModel.vHeatNS [p,sc,n,nd].fix (0.0)
2143
2139
  nFixedVariables += 1
2144
2140
  def AvoidForbiddenInstallationsAndRetirements(mTEPES, OptModel) -> int:
2145
2141
  '''
@@ -660,7 +660,7 @@
660
660
  # For more information on this, and how to apply and follow the GNU AGPL, see
661
661
  # <https://www.gnu.org/licenses/>.
662
662
 
663
- # Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - May 13, 2023
663
+ # Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - September 20, 2024
664
664
  # simplicity and transparency in power systems planning
665
665
 
666
666
  # Developed by
@@ -685,7 +685,7 @@ import time
685
685
  # import pkg_resources
686
686
  from .openTEPES import openTEPES_run
687
687
 
688
- print('\033[1;32mOpen Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.17.6 - September 18, 2024\033[0m')
688
+ print('\033[1;32mOpen Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.17.7 - September 20, 2024\033[0m')
689
689
  print('\033[34m#### Academic research license - for non-commercial use only ####\033[0m \n')
690
690
 
691
691
  parser = argparse.ArgumentParser(description='Introducing main parameters...')
@@ -1,5 +1,5 @@
1
1
  """
2
- Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - July 18, 2024
2
+ Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - September 20, 2024
3
3
  """
4
4
 
5
5
  import time
@@ -1314,8 +1314,8 @@ def NetworkCycles(mTEPES, pIndLogConsole):
1314
1314
  pUniqueCircuits = pUniqueCircuits[pUniqueCircuits['0/1'] == 1]
1315
1315
 
1316
1316
  # unique and parallel circuits of existing lines
1317
- mTEPES.ucte = Set(initialize=mTEPES.lea, ordered=False, doc='unique circuits', filter=lambda mTEPES,ni,nf,cc: (ni,nf,cc) in pUniqueCircuits['0/1' ])
1318
- mTEPES.pct = Set(initialize=mTEPES.br , ordered=False, doc='parallel circuits', filter=lambda mTEPES,ni,nf : (ni,nf ) in pNoCircuits['No.Circuits'])
1317
+ mTEPES.ucte = Set(doc='unique circuits', initialize=[lea for lea in mTEPES.lea if lea in pUniqueCircuits['0/1' ]])
1318
+ mTEPES.pct = Set(doc='parallel circuits', initialize=[br for br in mTEPES.br if br in pNoCircuits['No.Circuits']])
1319
1319
  mTEPES.cye = RangeSet(0,len(mTEPES.nce)-1)
1320
1320
 
1321
1321
  # graph with all AC existing and candidate lines
@@ -1339,10 +1339,10 @@ def NetworkCycles(mTEPES, pIndLogConsole):
1339
1339
  pUniqueCircuits = pUniqueCircuits[pUniqueCircuits['0/1'] == 1]
1340
1340
 
1341
1341
  # unique and parallel circuits of candidate lines
1342
- mTEPES.uctc = Set(initialize=mTEPES.laa, ordered=False, doc='unique circuits', filter=lambda mTEPES,ni,nf,cc: (ni,nf,cc) in pUniqueCircuits['0/1'])
1342
+ mTEPES.uctc = Set(doc='unique circuits', initialize=[laa for laa in mTEPES.laa if laa in pUniqueCircuits['0/1']])
1343
1343
  mTEPES.cyc = RangeSet(0,len(mTEPES.ncd)-1)
1344
1344
  # candidate lines included in every cycle
1345
- mTEPES.lcac = Set(initialize=mTEPES.cyc*mTEPES.lca, ordered=False, doc='AC candidate circuits in a cycle', filter=lambda mTEPES,cyc,ni,nf,cc: (ni,nf) in list(zip(mTEPES.ncd[cyc], mTEPES.ncd[cyc][1:] + mTEPES.ncd[cyc][:1])) or (nf,ni) in list(zip(mTEPES.ncd[cyc], mTEPES.ncd[cyc][1:] + mTEPES.ncd[cyc][:1])))
1345
+ mTEPES.lcac = Set(doc='AC candidate circuits in a cycle', initialize=[(cyc,ni,nf,cc) for cyc,ni,nf,cc in mTEPES.cyc*mTEPES.lca if (ni,nf) in list(zip(mTEPES.ncd[cyc], mTEPES.ncd[cyc][1:] + mTEPES.ncd[cyc][:1])) or (nf,ni) in list(zip(mTEPES.ncd[cyc], mTEPES.ncd[cyc][1:] + mTEPES.ncd[cyc][:1]))])
1346
1346
 
1347
1347
  pBigMTheta = pd.DataFrame(0, index=pd.MultiIndex.from_tuples(mTEPES.cyc*mTEPES.lca, names=('No.Cycle', 'NodeI', 'NodeF', 'Circuit')), columns=['rad'])
1348
1348
  # for cyc,nii,nff,ccc in mTEPES.cyc*mTEPES.lca:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openTEPES
3
- Version: 4.17.6
3
+ Version: 4.17.7
4
4
  Summary: Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES)
5
5
  Home-page: https://pascua.iit.comillas.edu/aramos/openTEPES/index.html
6
6
  Author: IIT-EnergySystemModels
@@ -1,9 +1,9 @@
1
- openTEPES/__init__.py,sha256=fhwOJ-2xGRRdp7yCQNdiqKmoqVEIali-zAANWXPVHho,832
1
+ openTEPES/__init__.py,sha256=938AmMocR2j63IXr6PG95ry5yb9aIe3vQE-PvgoNxTk,832
2
2
  openTEPES/openTEPES.mapbox_token,sha256=xsXNkwGp2vzXqQy2zVkyLhhNcNWniK2BMeOFpc5SZHI,93
3
- openTEPES/openTEPES.py,sha256=IgukztLMugmCa-ozAxZm6dAjd6Oqa-B9jAGGMC-7qrU,21145
4
- openTEPES/openTEPES_InputData.py,sha256=zRfslChwhdqGQlESeISO5k7sYB3EKOyVtDpyQ3bgbeE,212186
5
- openTEPES/openTEPES_Main.py,sha256=XByyTjmoyCLvfYzvJEfD6c54s6V9M8JQOxpGd9T1myM,39834
6
- openTEPES/openTEPES_ModelFormulation.py,sha256=N9UERcDRHmH9hkXaqOLnE7015GAqg9RSdwP4GwtO8ZM,112753
3
+ openTEPES/openTEPES.py,sha256=mvGSFlwWdJqhw7OVuYWR9vAwkPjxO9Xs6UnKMC13wGs,20802
4
+ openTEPES/openTEPES_InputData.py,sha256=F4bJrJJgNeM7lCuwpAigEP9vhyelUYTl9I_PBF1xHVc,207974
5
+ openTEPES/openTEPES_Main.py,sha256=UomHmuMZt0IrshRxaLIiTiQTCwr-tnwC3L9r82MSFXY,39840
6
+ openTEPES/openTEPES_ModelFormulation.py,sha256=QUHA39lNxb6Wfrg23lJ84dcEIrDLRwuErKMiHOM6q98,112645
7
7
  openTEPES/openTEPES_OutputResults.py,sha256=W_oEYQb0L2EYFhbVlMldzXP214mJe6lggzAahrJnYtA,203163
8
8
  openTEPES/openTEPES_ProblemSolving.py,sha256=wsFwr3gyH9vdNHstV7RwB-NRZrtftTBfXzuFf7zEg90,14722
9
9
  openTEPES/openTEPES_gitinfo.py,sha256=6fA1fa-JcyusSc_HcjPiCgnV9zn-fZwdG-kK0a5Fxc8,2004
@@ -335,8 +335,8 @@ openTEPES/sSEP/oT_Dict_Storage_sSEP.csv,sha256=H2rJXZvoMuT-25sI2GpG8IuiNKD-dxuty
335
335
  openTEPES/sSEP/oT_Dict_Technology_sSEP.csv,sha256=MCTpplzz7_eVPKQfOw35c86ib6CTtW6UK6JrbCJ8wls,170
336
336
  openTEPES/sSEP/oT_Dict_ZoneToArea_sSEP.csv,sha256=AUDCs5Bg6sw9f2pVjGP1o4IJjXFF_VrokOGf_V3QsEI,24
337
337
  openTEPES/sSEP/oT_Dict_Zone_sSEP.csv,sha256=TBud-fvbFbiAsuutxTYe8wWlv_x1P8oyWXILMpYiXJc,13
338
- opentepes-4.17.6.dist-info/entry_points.txt,sha256=gNNPrDaTsRuRJXI1FLNgqMX1CiJ45bEp1dEDH7ZB8Oc,49
339
- opentepes-4.17.6.dist-info/LICENSE,sha256=4O7bphXVzRuYavtsWzpLGuM3E-fp3HTRna7F4yIfnS4,35184
340
- opentepes-4.17.6.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
341
- opentepes-4.17.6.dist-info/METADATA,sha256=dNvl75pNhZFvaYEn0zifbz5RjDXquWKC5CIhOCINVqQ,17808
342
- opentepes-4.17.6.dist-info/RECORD,,
338
+ opentepes-4.17.7.dist-info/entry_points.txt,sha256=gNNPrDaTsRuRJXI1FLNgqMX1CiJ45bEp1dEDH7ZB8Oc,49
339
+ opentepes-4.17.7.dist-info/LICENSE,sha256=4O7bphXVzRuYavtsWzpLGuM3E-fp3HTRna7F4yIfnS4,35184
340
+ opentepes-4.17.7.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
341
+ opentepes-4.17.7.dist-info/METADATA,sha256=n9mjU9Av6PJ7Isq3VCcxz22D_uTYxPn1F2YIvN9-VQA,17808
342
+ opentepes-4.17.7.dist-info/RECORD,,