Skip to content

Commit

Permalink
add area in MarginalIncrementalVariableCost, MarginalIncrementalGener…
Browse files Browse the repository at this point in the history
…ator and GenerationIncrementalEmission output files
  • Loading branch information
arght committed Dec 19, 2024
1 parent 2901146 commit 9fa3ab5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Change Log
=============

[4.18.1] - 2024-12-11
[4.18.1] - 2024-12-19
-----------------------
- [CHANGED] add area in MarginalIncrementalVariableCost, MarginalIncrementalGenerator and GenerationIncrementalEmission output files
- [FIXED] fix error in eAdequacyReserveMarginHeat
- [FIXED] some epsilon for heat were wrong
- [CHANGED] add reserve margin for heat demand (new CSV file, and modifications related to it in input data, model formulation and output results)
Expand Down
30 changes: 15 additions & 15 deletions doc/rst/OutputResults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ Period Scenario Load level Generator CO2 emission [MtCO2]

File ``oT_Result_GenerationIncrementalEmission.csv``

============ ========== ========== ============== ===============================================================================================
Identifier Header Description
==================================== ============== ===============================================================================================
Period Scenario Load level Generator Emission rate of the generators with power surplus, except the ESS [tCO2/MWh]
============ ========== ========== ============== ===============================================================================================
============ ========== ========== ====== ============== ===============================================================================================
Identifier Header Description
=========================================== ============== ===============================================================================================
Period Scenario Load level Area Generator Emission rate of the generators with power surplus, except the ESS [tCO2/MWh]
============ ========== ========== ====== ============== ===============================================================================================

File ``oT_Result_TechnologyGeneration.csv``

Expand Down Expand Up @@ -1067,19 +1067,19 @@ Period Scenario Area Marginal of the minimum RES energy [€/MW

File ``oT_Result_MarginalIncrementalVariableCost.csv``

============ ========== ========== ============== ===============================================================================================
Identifier Header Description
==================================== ============== ===============================================================================================
Period Scenario Load level Generator Variable cost (fuel+O&M+emission) of the generators with power surplus, except the ESS [€/MWh]
============ ========== ========== ============== ===============================================================================================
============ ========== ========== ====== ============== ===============================================================================================
Identifier Header Description
============================================ ============== ===============================================================================================
Period Scenario Load level Area Generator Variable cost (fuel+O&M+emission) of the generators with power surplus, except the ESS [€/MWh]
============ ========== ========== ====== ============== ===============================================================================================

File ``oT_Result_MarginalIncrementalGenerator.csv``

============ ========== ========== ===================================================================================================
Identifier Description
==================================== ===================================================================================================
Period Scenario Load level Generator with power surplus, except the ESS, and with the lowest variable cost (fuel+O&M+emission)
============ ========== ========== ===================================================================================================
============ ========== ========== ====== ===================================================================================================
Identifier Description
=========================================== ===================================================================================================
Period Scenario Load level Area Generator with power surplus, except the ESS, and with the lowest variable cost (fuel+O&M+emission)
============ ========== ========== ====== ===================================================================================================

File ``oT_Result_NetworkSRMC.csv``

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 11, 2024
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 19, 2024
"""

# import dill as pickle
Expand Down Expand Up @@ -39,8 +39,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.18.1 - December 11, 2024')
print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.18.1 - December 11, 2024', file=open(f'{_path}/openTEPES_version_{CaseName}.log','w'))
mTEPES = ConcreteModel('Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.18.1 - December 19, 2024')
print( 'Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.18.1 - December 19, 2024', file=open(f'{_path}/openTEPES_version_{CaseName}.log','w'))

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
4 changes: 2 additions & 2 deletions openTEPES/openTEPES_Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@
# For more information on this, and how to apply and follow the GNU AGPL, see
# <https://www.gnu.org/licenses/>.

# Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 11, 2024
# Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 19, 2024
# simplicity and transparency in power systems planning

# Developed by
Expand All @@ -685,7 +685,7 @@
# import pkg_resources
from .openTEPES import openTEPES_run

print('\033[1;32mOpen Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.18.1 - December 11, 2024\033[0m')
print('\033[1;32mOpen Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - Version 4.18.1 - December 19, 2024\033[0m')
print('\033[34m#### Academic research license - for non-commercial use only ####\033[0m \n')

parser = argparse.ArgumentParser(description='Introducing main parameters...')
Expand Down
29 changes: 15 additions & 14 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 10, 2024
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - December 19, 2024
"""

import time
Expand Down Expand Up @@ -1605,22 +1605,23 @@ def MarginalResults(DirName, CaseName, OptModel, mTEPES, pIndPlotOutput):
pEpsilon = 1e-6

#%% outputting the incremental variable cost of each generating unit (neither ESS nor boilers) with power surplus
sPSNG = [(p,sc,n,g) for p,sc,n,g in mTEPES.psng if g not in mTEPES.eh and g not in mTEPES.bo]
OutputToFile = pd.Series(data=[(mTEPES.pLinearVarCost[p,sc,n,g]+mTEPES.pEmissionVarCost[p,sc,n,g]) if OptModel.vTotalOutput[p,sc,n,g].ub - OptModel.vTotalOutput[p,sc,n,g]() > pEpsilon else math.inf for p,sc,n,g in sPSNG], index=pd.Index(sPSNG))
sPSNARG = [(p,sc,n,ar,g) for p,sc,n,ar,g in mTEPES.psn*mTEPES.a2g if g not in mTEPES.eh and g not in mTEPES.bo]
OutputToFile = pd.Series(data=[(mTEPES.pLinearVarCost[p,sc,n,g]+mTEPES.pEmissionVarCost[p,sc,n,g]) if OptModel.vTotalOutput[p,sc,n,g].ub - OptModel.vTotalOutput[p,sc,n,g]() > pEpsilon else math.inf for p,sc,n,ar,g in sPSNARG], index=pd.Index(sPSNARG))
OutputToFile *= 1e3

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(f'{_path}/oT_Result_MarginalIncrementalVariableCost_{CaseName}.csv', sep=',')
IncrementalGens = pd.Series('N/A', index=pd.Index(mTEPES.psn)).to_frame(name='Generating unit')
for p,sc,n in mTEPES.psn:
if len(OutputToFile.loc[(p,sc,n)]) > 1:
IncrementalGens.loc[p,sc,n] = OutputToFile.loc[[(p,sc,n)]].squeeze().idxmin()
else:
IncrementalGens.loc[p,sc,n] = OutputToFile.loc[(p,sc,n)].index[0]
IncrementalGens.rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).to_csv(f'{_path}/oT_Result_MarginalIncrementalGenerator_{CaseName}.csv', index=True, sep=',')
OutputToFile = OutputToFile.to_frame(name='EUR/MWh').reset_index().pivot_table(index=['level_0','level_1','level_2','level_3'], columns='level_4', values='EUR/MWh')
OutputToFile.rename_axis(['Period', 'Scenario', 'LoadLevel', 'Area'], axis=0).rename_axis([None], axis=1).to_csv(f'{_path}/oT_Result_MarginalIncrementalVariableCost_{CaseName}.csv', sep=',')
IncrementalGens = pd.Series('N/A', index=pd.Index(mTEPES.psnar)).to_frame(name='Generating unit')
for p,sc,n,ar in mTEPES.psnar:
if sum(1 for g in mTEPES.g if (ar,g) in mTEPES.a2g):
if len(OutputToFile.loc[(p,sc,n,ar)]) > 1:
IncrementalGens.loc[p,sc,n,ar] = OutputToFile.loc[[(p,sc,n,ar)]].squeeze().idxmin()
else:
IncrementalGens.loc[p,sc,n,ar] = OutputToFile.loc[ (p,sc,n,ar) ].index[0]
IncrementalGens.rename_axis(['Period', 'Scenario', 'LoadLevel', 'Area'], axis=0).to_csv(f'{_path}/oT_Result_MarginalIncrementalGenerator_{CaseName}.csv', index=True, sep=',')

OutputToFile = pd.Series(data=[mTEPES.pEmissionRate[g] for p,sc,n,g in sPSNG], index=pd.Index(sPSNG))
OutputToFile.to_frame(name='tCO2/MWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='tCO2/MWh').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(f'{_path}/oT_Result_GenerationIncrementalEmission_{CaseName}.csv', sep=',')
OutputToFile = pd.Series(data=[mTEPES.pEmissionRate[g] for p,sc,n,ar,g in sPSNARG], index=pd.Index(sPSNARG))
OutputToFile.to_frame(name='tCO2/MWh').reset_index().pivot_table(index=['level_0','level_1','level_2','level_3'], columns='level_4', values='tCO2/MWh').rename_axis(['Period', 'Scenario', 'LoadLevel', 'Area'], axis=0).rename_axis([None], axis=1).to_csv(f'{_path}/oT_Result_GenerationIncrementalEmission_{CaseName}.csv', sep=',')

#%% outputting the LSRMC
sPSSTNND = [(p,sc,st,n,nd) for p,sc,st,n,nd in mTEPES.s2n*mTEPES.nd if sum(1 for g in g2n[nd]) + sum(1 for nf,cc in lout[nd]) + sum(1 for ni,cc in lin[nd]) and (p,sc,n) in mTEPES.psn]
Expand Down

0 comments on commit 9fa3ab5

Please sign in to comment.