Skip to content

Commit

Permalink
change names and delete output files
Browse files Browse the repository at this point in the history
  • Loading branch information
arght committed Dec 1, 2023
1 parent 5dd7bb9 commit c85fd57
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 49 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.14.10] - 2023-12-01
----------------------
- [FIXED] delete some duplicated result output files

[4.14.9] - 2023-11-24
----------------------
- [FIXED] values 0 of availability not changed to 1
Expand Down
36 changes: 18 additions & 18 deletions doc/rst/OutputResults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Identifier Identifier Identifier Header Description
Period Scenario Load level Generator Emission rate of the generators with power surplus, except the ESS [tCO2/MWh]
============ ========== ========== ============== ===============================================================================================

File ``oT_Result_TechnologyOutput.csv``
File ``oT_Result_TechnologyGeneration.csv``

============ ========== ========== ========== =================================
Identifier Identifier Identifier Header Description
Expand All @@ -285,22 +285,6 @@ Identifier Identifier Identifier Header Description
Period Scenario Load level Technology Consumption (charge in ESS) [MW]
============ ========== ========== ========== =================================

File ``oT_Result_TechnologyCurtailmentEnergy.csv``

============ ========== ========== ========== ==========================================
Identifier Identifier Identifier Header Description
============ ========== ========== ========== ==========================================
Period Scenario Load level Technology Curtailed energy of VRES [GWh]
============ ========== ========== ========== ==========================================

File ``oT_Result_TechnologyCurtailmentEnergyRelative.csv``

============ ========== ========== ============== ===========================================
Identifier Identifier Identifier Header Description
============ ========== ========== ============== ===========================================
Period Scenario Load level Technology Percentage of energy curtailed of VRES [%]
============ ========== ========== ============== ===========================================

File ``oT_Result_TechnologyGenerationEnergy.csv``

============ ========== ========== ========== =================================
Expand All @@ -317,6 +301,22 @@ Identifier Identifier Identifier Header Description
Period Scenario Load level Technology Energy (discharge in ESS) per area [GWh]
============ ========== ========== ========== ==========================================

File ``oT_Result_TechnologyCurtailmentEnergy.csv``

============ ========== ========== ========== ==========================================
Identifier Identifier Identifier Header Description
============ ========== ========== ========== ==========================================
Period Scenario Load level Technology Curtailed energy of VRES [GWh]
============ ========== ========== ========== ==========================================

File ``oT_Result_TechnologyCurtailmentEnergyRelative.csv``

============ ========== ========== ============== ===========================================
Identifier Identifier Identifier Header Description
============ ========== ========== ============== ===========================================
Period Scenario Load level Technology Percentage of energy curtailed of VRES [%]
============ ========== ========== ============== ===========================================

File ``oT_Result_TechnologyEmission.csv``

============ ========== ========== ========== =================================
Expand Down Expand Up @@ -368,7 +368,7 @@ Period Scenario Load level Technology Spilled energy in ESS wrt the
ESS operation
-------------

File ``oT_Result_ConsumptionOutput.csv``
File ``oT_Result_Consumption.csv``

============ ========== ========== ========== ==========================================
Identifier Identifier Identifier Header Description
Expand Down
6 changes: 3 additions & 3 deletions doc/rst/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
author = 'Andres Ramos'

# The short X.Y version
version = 'version 4.14.9'
version = 'version 4.14.10'
# The full version, including alpha/beta/rc tags
release = ''

Expand Down Expand Up @@ -84,13 +84,13 @@
#
# html_sidebars = {}
html_theme = 'alabaster'
html_title = 'version 4.14.9'
html_title = 'version 4.14.10'
html_logo = '../img/openTEPES.png'
html_last_updated_fmt = ''
html_show_sphinx = False
html_theme_options = {
'analytics_id': 'UA-515200-2', # Provided by Google in your dashboard
'description': 'version 4.14.9',
'description': 'version 4.14.10',
'page_width': 'auto',
'font_family': 'Georgia'
}
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.14.9"
__version__ = "4.14.10"

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) - November 24, 2023
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 01, 2023
"""

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.14.9 - November 24, 2023')
print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.14.9 - November 24, 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.14.10 - December 01, 2023')
print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.14.10 - December 01, 2023', 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
46 changes: 22 additions & 24 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) - November 26, 2023
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 01, 2023
"""

import time
Expand Down Expand Up @@ -475,7 +475,7 @@ def GenerationOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnolo
sPSNGT = [(p,sc,n,gt) for p,sc,n,gt in mTEPES.psngt if sum(1 for g in g2t[gt])]
OutputToFile = pd.Series(data=[sum(OptModel.vTotalOutput[p,sc,n,g]() for g in mTEPES.g if (gt,g) in mTEPES.t2g) for p,sc,n,gt in sPSNGT], index=pd.Index(sPSNGT))
OutputToFile *= 1e3
OutputToFile.to_frame(name='MW').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='MW', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyOutput_'+CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='MW').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='MW', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyGeneration_'+CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
TechnologyOutput = OutputToFile.loc[:,:,:,:]
Expand Down Expand Up @@ -541,11 +541,11 @@ def ESSOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnologyOutpu

OutputToFile = pd.Series(data=[-OptModel.vESSTotalCharge [p,sc,n,eh]() for p,sc,n,eh in mTEPES.psneh], index=pd.Index(mTEPES.psneh))
OutputToFile *= 1e3
OutputToFile.to_frame(name='MW').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='MW', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_ConsumptionOutput_' +CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='MW').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='MW', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_Consumption_' +CaseName+'.csv', sep=',')

if pIndTechnologyOutput == 1 or pIndTechnologyOutput == 2:
OutputToFile = pd.Series(data=[sum(OutputToFile[p,sc,n,eh] for eh in o2e[ot]) for p,sc,n,ot in mTEPES.psnot], index=pd.Index(mTEPES.psnot))
OutputToFile.to_frame(name='MW').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='MW', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyOutputESS_' +CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='MW').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='MW', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumption_' +CaseName+'.csv', sep=',')

OutputToFile = pd.Series(data=[OptModel.vEnergyOutflows [p,sc,n,es]()*mTEPES.pLoadLevelDuration[n]() for p,sc,n,es in mTEPES.psnes], index=pd.Index(mTEPES.psnes))
if pIndTechnologyOutput == 0 or pIndTechnologyOutput == 2:
Expand All @@ -562,14 +562,20 @@ def ESSOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnologyOutpu
if pIndTechnologyOutput == 1 or pIndTechnologyOutput == 2:
sPSNOT = [(p,sc,n,ot) for p,sc,n,ot in mTEPES.psnot if sum(1 for es in o2e[ot])]
OutputToFile = pd.Series(data=[sum(OutputToFile[p,sc,n,eh] for eh in o2e[ot]) for p,sc,n,ot in sPSNOT], index=pd.Index(sPSNOT))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh').rename_axis (['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumptionEnergyESS_' +CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh').rename_axis (['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumptionEnergy_' +CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
TechnologyCharge = OutputToFile.loc[:,:,:,:]
for p,sc in mTEPES.ps:
chart = AreaPlots(p, sc, TechnologyCharge, 'Technology', 'LoadLevel', 'MW', 'sum')
chart.save(_path+'/oT_Plot_TechnologyConsumption_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

if pIndPlotOutput == 1:
OutputToFile *= -1.0
if OutputToFile.sum() < 0.0:
for p,sc in mTEPES.ps:
chart = PiePlots(p, sc, OutputToFile, 'Technology', '%')
chart.save(_path+'/oT_Plot_TechnologyConsumptionEnergyESS_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})
chart.save(_path+'/oT_Plot_TechnologyConsumptionEnergy_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

if sum(1 for ar in mTEPES.ar if sum(1 for eh in e2a[ar])) > 1:
if pIndAreaOutput == 1:
Expand All @@ -578,13 +584,13 @@ def ESSOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnologyOutpu
sPSNOT = [(p,sc,n,ot) for p,sc,n,ot in mTEPES.psnot if sum(1 for eh in e2a[ar] if (ot,eh) in mTEPES.t2g)]
if len(sPSNOT):
OutputToFile = pd.Series(data=[sum(-OptModel.vESSTotalCharge[p,sc,n,eh]()*mTEPES.pLoadLevelDuration[n]() for eh in e2a[ar] if (ot,eh) in mTEPES.t2g) for p,sc,n,ot in sPSNOT], index=pd.Index(sPSNOT))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumptionEnergyESS_'+ar+'_'+CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumptionEnergy_'+ar+'_'+CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
OutputToFile *= -1.0
for p,sc in mTEPES.ps:
chart = PiePlots(p, sc, OutputToFile, 'Technology', '%')
chart.save(_path+'/oT_Plot_TechnologyConsumptionEnergyESS_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})
chart.save(_path+'/oT_Plot_TechnologyConsumptionEnergy_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

# tolerance to consider avoid division by 0
pEpsilon = 1e-6
Expand All @@ -607,22 +613,6 @@ def ESSOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnologyOutpu
OutputToFile = pd.Series(data=[sum(OutputToFile[p,sc,n,es] for es in o2e[ot] if (n,es) in mTEPES.nesc and mTEPES.pMaxCharge[p,sc,n,es] + mTEPES.pMaxPower[p,sc,n,es]) for p,sc,n,ot in ESSTechnologies], index=pd.Index(ESSTechnologies))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologySpillage_'+CaseName+'.csv', sep=',')

OutputToFile = pd.Series(data=[-OptModel.vESSTotalCharge[p,sc,n,eh]() for p,sc,n,eh in mTEPES.psneh], index=pd.Index(mTEPES.psneh))
OutputToFile *= 1e3
OutputToFile = pd.Series(data=[sum(OutputToFile[p,sc,n,eh] for eh in o2e[ot]) for p,sc,n,ot in mTEPES.psnot], index=pd.Index(mTEPES.psnot))
OutputToFile.to_frame(name='MW' ).reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='MW' , aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumption_'+CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
TechnologyCharge = OutputToFile.loc[:,:,:,:]
for p,sc in mTEPES.ps:
chart = AreaPlots(p, sc, TechnologyCharge, 'Technology', 'LoadLevel', 'MW', 'sum')
chart.save(_path+'/oT_Plot_TechnologyConsumption_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

if pIndTechnologyOutput == 1 or pIndTechnologyOutput == 2:
OutputToFile = pd.Series(data=[-OptModel.vESSTotalCharge[p,sc,n,eh]()*mTEPES.pLoadLevelDuration[n]() for p,sc,n,eh in mTEPES.psneh], index=pd.Index(mTEPES.psneh))
OutputToFile = pd.Series(data=[sum(OutputToFile[p,sc,n,eh] for eh in o2e[ot]) for p,sc,n,ot in mTEPES.psnot], index=pd.Index(mTEPES.psnot))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumptionEnergy_'+CaseName+'.csv', sep=',')

OutputToFile1 = pd.Series(data=[(OptModel.vTotalOutput[p,sc,n,es].ub - OptModel.vTotalOutput[p,sc,n,es]())*mTEPES.pLoadLevelDuration[n]() for p,sc,n,es in mTEPES.psnes], index=pd.Index(mTEPES.psnes))
OutputToFile2 = pd.Series(data=[(OptModel.vTotalOutput[p,sc,n,es].ub )*mTEPES.pLoadLevelDuration[n]() for p,sc,n,es in mTEPES.psnes], index=pd.Index(mTEPES.psnes))
for p,sc,n,es in mTEPES.psnes:
Expand Down Expand Up @@ -1205,6 +1195,7 @@ def MarginalResults(DirName, CaseName, OptModel, mTEPES, pIndPlotOutput):
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')
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 @@ -1329,7 +1320,9 @@ 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()
ReserveMargin1 = OutputToFile1 - OutputToFile2
ReserveMargin2 = (OutputToFile1 - OutputToFile2)/OutputToFile2
Expand All @@ -1339,6 +1332,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()

LargestUnit = ReserveMargin1/OutputToFile
Expand Down Expand Up @@ -1664,6 +1658,7 @@ def oT_selecting_data(p,sc,n):

for nd,zn in mTEPES.ndzn:
loc_df['Lon' ][nd] = mTEPES.pNodeLon[nd]
# warnings
loc_df['Zone' ][nd] = zn
loc_df['Demand'][nd] = mTEPES.pDemand[p,sc,n,nd]*1e3

Expand Down Expand Up @@ -1700,7 +1695,9 @@ def oT_selecting_data(p,sc,n):
line_df['utilization'][ni,nf] = max(line_df['vFlow'][ni,nf]/line_df['NTCFrw'][ni,nf],-line_df['vFlow'][ni,nf]/line_df['NTCBck'][ni,nf])*100.0
line_df['lon' ][ni,nf] = (mTEPES.pNodeLon[ni]+mTEPES.pNodeLon[nf]) * 0.5
line_df['lat' ][ni,nf] = (mTEPES.pNodeLat[ni]+mTEPES.pNodeLat[nf]) * 0.5
# warnings
line_df['ni' ][ni,nf] = ni
# warnings
line_df['nf' ][ni,nf] = nf
line_df['cc' ][ni,nf] += 1

Expand All @@ -1717,6 +1714,7 @@ 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 c85fd57

Please sign in to comment.