From c85fd57d6b2795ef6f8b19ad6b8178e73e46f0c6 Mon Sep 17 00:00:00 2001 From: Andres Ramos <61053256+arght@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:07:51 +0100 Subject: [PATCH] change names and delete output files --- CHANGELOG.rst | 4 +++ doc/rst/OutputResults.rst | 36 +++++++++++----------- doc/rst/conf.py | 6 ++-- openTEPES/__init__.py | 2 +- openTEPES/openTEPES.py | 6 ++-- openTEPES/openTEPES_OutputResults.py | 46 +++++++++++++--------------- 6 files changed, 51 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f0e32708..36d0831e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/doc/rst/OutputResults.rst b/doc/rst/OutputResults.rst index 9fc680f5..49d2aefd 100644 --- a/doc/rst/OutputResults.rst +++ b/doc/rst/OutputResults.rst @@ -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 @@ -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`` ============ ========== ========== ========== ================================= @@ -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`` ============ ========== ========== ========== ================================= @@ -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 diff --git a/doc/rst/conf.py b/doc/rst/conf.py index 590ac692..84bbe839 100644 --- a/doc/rst/conf.py +++ b/doc/rst/conf.py @@ -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 = '' @@ -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' } diff --git a/openTEPES/__init__.py b/openTEPES/__init__.py index c9782737..2a9c4885 100644 --- a/openTEPES/__init__.py +++ b/openTEPES/__init__.py @@ -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 * diff --git a/openTEPES/openTEPES.py b/openTEPES/openTEPES.py index ab3712da..abf8168f 100644 --- a/openTEPES/openTEPES.py +++ b/openTEPES/openTEPES.py @@ -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 @@ -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] diff --git a/openTEPES/openTEPES_OutputResults.py b/openTEPES/openTEPES_OutputResults.py index 53acc6bf..0798bf91 100644 --- a/openTEPES/openTEPES_OutputResults.py +++ b/openTEPES/openTEPES_OutputResults.py @@ -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 @@ -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[:,:,:,:] @@ -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: @@ -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: @@ -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 @@ -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: @@ -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=',') @@ -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 @@ -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 @@ -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 @@ -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 @@ -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]