Skip to content

Commit

Permalink
avoid some future warnings in output results
Browse files Browse the repository at this point in the history
  • Loading branch information
arght committed Jan 3, 2024
1 parent 177bcb9 commit a2ae28d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
=============

[4.15.1] - 2023-12-27
----------------------
- [CHANGED] avoid some future warnings in output results

[4.15.0] - 2023-12-27
----------------------
- [CHANGED] introduce the variable emission cost file
Expand Down
2 changes: 1 addition & 1 deletion doc/rst/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# -- Project information -----------------------------------------------------

project = 'openTEPES'
copyright = '2023, Universidad Pontificia Comillas'
copyright = '2024, Universidad Pontificia Comillas'
author = 'Andres Ramos'

# The short X.Y version
Expand Down
2 changes: 1 addition & 1 deletion openTEPES/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
>>> import openTEPES as oT
>>> oT.routine("9n", "C:\\Users\\UserName\\Documents\\GitHub\\openTEPES", "glpk")
"""
__version__ = "4.15.0"
__version__ = "4.15.1"

from .openTEPES_Main import main
from .openTEPES import *
Expand Down
6 changes: 3 additions & 3 deletions openTEPES/openTEPES.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 20, 2023
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - January 02, 2024
"""

import math
Expand Down Expand Up @@ -38,8 +38,8 @@ def openTEPES_run(DirName, CaseName, SolverName, pIndOutputResults, pIndLogConso
idxDict['y' ] = 1

#%% model declaration
mTEPES = ConcreteModel('Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.15.0 - December 27, 2023')
print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.15.0 - December 27, 2023', file=open(_path+'/openTEPES_version_'+CaseName+'.log','a'))
mTEPES = ConcreteModel('Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.15.1 - January 02, 2024')
print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.15.1 - January 02, 2024', file=open(_path+'/openTEPES_version_'+CaseName+'.log','a'))

pIndOutputResults = [j for i,j in idxDict.items() if i == pIndOutputResults][0]
pIndLogConsole = [j for i,j in idxDict.items() if i == pIndLogConsole ][0]
Expand Down
21 changes: 8 additions & 13 deletions openTEPES/openTEPES_OutputResults.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 27, 2023
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - January 02, 2024
"""

import time
Expand Down Expand Up @@ -752,7 +752,7 @@ def oT_selecting_data(p,sc,n):

loc_df = pd.Series(data=[mTEPES.pNodeLat[i] for i in mTEPES.nd], index=mTEPES.nd).to_frame(name='Lat')
loc_df['Lon' ] = 0.0
loc_df['Zone' ] = 0.0
loc_df['Zone' ] = ''
loc_df['Demand'] = 0.0
loc_df['Size' ] = 15.0

Expand Down Expand Up @@ -983,7 +983,7 @@ def OperationSummaryResults(DirName, CaseName, OptModel, mTEPES):
OutputToFile05 = pd.Series(data=[a2g[0][g] for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='Area' )
OutputToFile06 = pd.Series(data=[r2g[0][g] for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='Region' )
OutputToFile07 = pd.Series(data=[t2g[0][g] for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='Technology' )
OutputToFile08 = pd.Series(data=[OptModel.vTotalOutput [p,sc,n,g]()*mTEPES.pLoadLevelDuration[n]()*mTEPES.pEmissionVarCost[p,sc,n,g]/mTEPES.pCO2Cost() for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='Emissions [MtCO2]' )
OutputToFile08 = pd.Series(data=[OptModel.vTotalOutput [p,sc,n,g]()*mTEPES.pLoadLevelDuration[n]()*mTEPES.pEmissionVarCost[p,sc,n,g]/mTEPES.pCO2Cost() for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='Emissions [MtCO2]' )
OutputToFile09 = pd.Series(data=[OptModel.vTotalOutput [p,sc,n,g].ub for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='MaxPower [MW]' )
OutputToFile10 = pd.Series(data=[OptModel.vTotalOutput [p,sc,n,g].lb for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='MinPower [MW]' )
OutputToFile11 = pd.Series(data=[mTEPES.pLoadLevelDuration[n]() for p,sc,n,g in mTEPES.psng], index=pd.Index(mTEPES.psng)).to_frame(name='LoadLevelDuration [h]' )
Expand Down Expand Up @@ -1193,9 +1193,8 @@ def MarginalResults(DirName, CaseName, OptModel, mTEPES, pIndPlotOutput):

OutputToFile = OutputToFile.to_frame(name='EUR/MWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='EUR/MWh')
OutputToFile.rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_MarginalIncrementalVariableCost_'+CaseName+'.csv', sep=',')
IncrementalGens = pd.Series(0, index=pd.Index(mTEPES.psn)).to_frame(name='Generating unit')
IncrementalGens = pd.Series('N/A', index=pd.Index(mTEPES.psn)).to_frame(name='Generating unit')
for p,sc,n in mTEPES.psn:
# warnings
IncrementalGens['Generating unit'][p,sc,n] = OutputToFile.loc[[(p,sc,n)]].squeeze().idxmin()
IncrementalGens.rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).to_csv(_path+'/oT_Result_MarginalIncrementalGenerator_'+CaseName+'.csv', index=True, sep=',')

Expand Down Expand Up @@ -1320,10 +1319,8 @@ def ReliabilityResults(DirName, CaseName, OptModel, mTEPES):
OutputToFile1 = pd.Series(data=[0.0 for p,sc in mTEPES.ps], index=mTEPES.ps)
OutputToFile2 = pd.Series(data=[0.0 for p,sc in mTEPES.ps], index=mTEPES.ps)
for p,sc in mTEPES.ps:
# warnings
OutputToFile1[p,sc] = pMaxPower.loc[(p,sc)].reset_index().pivot_table(index=['level_0'], values=0, aggfunc='sum').max()
# warnings
OutputToFile2[p,sc] = pDemand.loc[(p,sc)].reset_index().pivot_table(index=['level_0'], values=0, aggfunc='sum').max()
OutputToFile1[p,sc] = pMaxPower.loc[(p,sc)].reset_index().pivot_table(index=['level_0'], values=0, aggfunc='sum').max().iloc[0]
OutputToFile2[p,sc] = pDemand.loc[(p,sc)].reset_index().pivot_table(index=['level_0'], values=0, aggfunc='sum').max().iloc[0]
ReserveMargin1 = OutputToFile1 - OutputToFile2
ReserveMargin2 = (OutputToFile1 - OutputToFile2)/OutputToFile2
ReserveMargin1.to_frame(name='MW' ).rename_axis(['Period', 'Scenario'], axis=0).to_csv(_path+'/oT_Result_ReserveMarginPower_' +CaseName+'.csv', sep=',')
Expand All @@ -1332,8 +1329,7 @@ def ReliabilityResults(DirName, CaseName, OptModel, mTEPES):
# Determination of the index: Largest Unit
OutputToFile = pd.Series(data=[0.0 for p,sc in mTEPES.ps], index=mTEPES.ps)
for p,sc in mTEPES.ps:
# warnings
OutputToFile[p,sc] = pMaxPower.loc[(p,sc)].reset_index().pivot_table(index=['level_1'], values=0, aggfunc=max).max()
OutputToFile[p,sc] = pMaxPower.loc[(p,sc)].reset_index().pivot_table(index=['level_1'], values=0, aggfunc='sum').max().iloc[0]

LargestUnit = ReserveMargin1/OutputToFile
LargestUnit.to_frame(name='p.u.').rename_axis(['Period', 'Scenario'], axis=0).to_csv(_path+'/oT_Result_LargestUnitPerUnit_'+CaseName+'.csv', index=True, sep=',')
Expand Down Expand Up @@ -1652,7 +1648,7 @@ def oT_selecting_data(p,sc,n):

loc_df = pd.Series(data=[mTEPES.pNodeLat[i] for i in mTEPES.nd], index=mTEPES.nd).to_frame(name='Lat')
loc_df['Lon' ] = 0.0
loc_df['Zone' ] = 0.0
loc_df['Zone' ] = ''
loc_df['Demand'] = 0.0
loc_df['Size' ] = 15.0

Expand Down Expand Up @@ -1714,7 +1710,6 @@ def oT_selecting_data(p,sc,n):
if 50.0 < line_df['utilization'][ni,nf] <= 60.0:
line_df['color'][ni,nf] = colors[5]
if 60.0 < line_df['utilization'][ni,nf] <= 70.0:
# warnings
line_df['color'][ni,nf] = colors[6]
if 70.0 < line_df['utilization'][ni,nf] <= 80.0:
line_df['color'][ni,nf] = colors[7]
Expand Down

0 comments on commit a2ae28d

Please sign in to comment.