Skip to content

Commit

Permalink
Updated precompiled external libraries, documentation, post-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
squoilin committed Jan 19, 2017
1 parent 764c3f3 commit e09113f
Show file tree
Hide file tree
Showing 57 changed files with 12,588 additions and 27 deletions.
Binary file added Dispa-SET/ConfigFiles/Config_EU_short.xlsx
Binary file not shown.
40 changes: 37 additions & 3 deletions Dispa-SET/DispaSET/PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,41 @@ def UnitFuel(Inputs,shrink=True):
fuels[uu[i]] = f[j[0][0]]
return fuels

def GetLoadData(datain,c):
'''
Get the load curve, the residual load curve, and the net residual load curve of a specific country
:param datain: Dispa-SET inputs formatted into a list of dataframes (output of the ds_to_df function)
:param c: Country to consider (e.g. 'BE')
:return out: Dataframe with the following columns:
Load: Load curve of the specified country
ResidualLoad: Load minus the production of variable renewable sources
NetResidualLoad: Residual netted from the interconnections with neightbouring countries
'''
out = pd.DataFrame(index = datain['Demand'].index)
out['Load'] = datain['Demand']['DA',c]
# Listing power plants with non-dispatchable power generation:
VREunits = []
VRE = np.zeros(len(out))
for t in ['WTON','WTOF','PHOT','HROR']:
for u in datain['Technology']:
if datain['Technology'].loc[t,u]:
VREunits.append(u)
VRE = VRE + datain['AvailabilityFactor'][u].values * datain['PowerCapacity'].loc[u,'PowerCapacity']
Interconnections = np.zeros(len(out))
for l in datain['FlowMinimum']:
if l[:2] == c:
Interconnections = Interconnections - datain['FlowMinimum'][l].values
elif l[-2:] == c:
Interconnections = Interconnections + datain['FlowMinimum'][l].values
out['ResidualLoad'] = out['Load'] - VRE
out['NetResidualLoad'] = out['ResidualLoad'] - Interconnections
return out


def GetDemand(Inputs,c):
'''
Get the demand curve of a specific country
Get the load curve and the residual load curve of a specific country
:param Inputs: Dispa-SET inputs
:param c: Country to consider (e.g. 'BE')
Expand All @@ -105,7 +137,6 @@ def GetDemand(Inputs,c):
sys.exit('Inputs variable no valid')
return pd.Series(data,index=index,name=c)



def AggregateByFuel(PowerOutput,Inputs,SpecifyFuels=None):
'''
Expand Down Expand Up @@ -441,7 +472,7 @@ def GetResults(path='.',cache = False, TempPath='.pickle'):
index_long = pd.DatetimeIndex(start=pd.datetime(*StartDate),end=StopDate_long,freq='h')

# Setting the proper index to the result dataframes:
for key in ['OutputPower','OutputSystemCost','OutputCommitted','OutputCurtailedPower','OutputFlow', 'OutputShedLoad','OutputSpillage','OutputStorageLevel','OutputStorageInput','LostLoad_Reserve2U', 'LostLoad_MaxPower','LostLoad_MinPower','LostLoad_RampUp','LostLoad_RampDown','LostLoad_Reserve2D']:
for key in ['OutputPower','OutputSystemCost','OutputCommitted','OutputCurtailedPower','OutputFlow', 'OutputShedLoad','OutputSpillage','OutputStorageLevel','OutputStorageInput','LostLoad_Reserve2U', 'LostLoad_MaxPower','LostLoad_MinPower','LostLoad_RampUp','LostLoad_RampDown','LostLoad_Reserve2D','ShadowPrice']:
if key in results:
if len(results[key]) == len(index_long): # Case of variables for which the look-ahead period recorded (e.g. the lost loads)
results[key].index = index_long
Expand All @@ -457,6 +488,9 @@ def GetResults(path='.',cache = False, TempPath='.pickle'):

#Clean power plant names:
results['OutputPower'].columns = clean_strings(results['OutputPower'].columns.tolist())
# Remove epsilons:
if 'ShadowPrice' in results:
results['ShadowPrice'][results['ShadowPrice'] == 5e300] = 0

for key in results['OutputPower']:
if key not in inputs['units'].index:
Expand Down
17 changes: 13 additions & 4 deletions Dispa-SET/DispaSET/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
import sys
import platform

# Try to import the GAMS api to write gdx files:

# Try to import the GAMS api and gdxcc to write gdx files:
try:
import gams
import gdxcc
gams_ok = True
gdxcc_ok = True
except:
if sys.platform == 'linux2' and platform.architecture()[0] == '64bit':
sys.path.append('../Externals/gdxcc/linux64/')
sys.path.append('../Externals/gams_api/linux64/')
elif sys.platform == 'linux2' and platform.architecture()[0] == '32bit':
sys.path.append('../Externals/gdxcc/linux32/')
elif sys.platform == 'win32' and platform.architecture()[0] == '64bit':
sys.path.append('../Externals/gdxcc/win64/')
sys.path.append('../Externals/gams_api/win64/')
elif sys.platform == 'win32' and platform.architecture()[0] == '32bit':
sys.path.append('../Externals/gdxcc/win32/')
elif sys.platform == 'darwin':
sys.path.append('../Externals/gdxcc/osx64/')
try:
import gams
gams_ok = True
except:
gams_ok = False
try:
import gdxcc
gdxcc_ok = True
except:
gdxcc_ok = False



#from .DispaCheck import *
from .DispaSET_io_data import *
#from .DispaSolve import * # importing dispasolve causes errors if pyomo is not installed
Expand Down
7 changes: 5 additions & 2 deletions Dispa-SET/DispaSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
SimData = ds.BuildSimulation(config)

if simulate:
from DispaSET.DispaSolveGAMS import SolveMILP
r = SolveMILP(config['SimulationDirectory'],config['GAMS_folder'])
if ds.gams_ok:
from DispaSET.DispaSolveGAMS import SolveMILP
r = SolveMILP(config['SimulationDirectory'],config['GAMS_folder'])
else:
print('The gams library is required to run the GAMS versions of Dispa-SET. Please install if from the /apifiles/Python/api/ folder in the GAMS directory')

29 changes: 16 additions & 13 deletions Dispa-SET/GAMS-files/UCM_h.gms
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$Title UCM model

$eolcom //
Option LimRow=0;
Option LimRow=1000;
Option IterLim=1000000000;
Option ResLim = 10000000000;
*Option SolPrint=On;
Expand Down Expand Up @@ -70,32 +70,32 @@ PARAMETERS
AvailabilityFactor(u,h) [%] Availability factor
CommittedInitial(u) [n.a.] Initial committment status
Config
*CostCurtailment(n,h) [�\MW] Curtailment costs
CostFixed(u) [�\h] Fixed costs
CostRampUp(u) [�\MW\h] Ramp-up costs
CostRampDown(u) [�\MW\h] Ramp-down costs
CostShutDown(u) [�] Shut-down costs
CostStartUp(u) [�] Start-up costs
CostVariable(u,h) [�\MW] Variable costs
*CostCurtailment(n,h) [�\MW] Curtailment costs
CostFixed(u) [�\h] Fixed costs
CostRampUp(u) [�\MW\h] Ramp-up costs
CostRampDown(u) [�\MW\h] Ramp-down costs
CostShutDown(u) [�] Shut-down costs
CostStartUp(u) [�] Start-up costs
CostVariable(u,h) [�\MW] Variable costs
Curtailment(n) [n.a] Curtailment allowed or not {1 0} at node n
Demand(mk,n,h) [MW] Demand
Efficiency(u) [%] Efficiency
EmissionMaximum(n,p) [tP] Emission limit
EmissionRate(u,p) [tP\MWh] P emission rate
FlowMaximum(l,h) [MW] Line limits
FlowMinimum(l,h) [MW] Minimum flow
FuelPrice(n,f,h) [�\F] Fuel price
FuelPrice(n,f,h) [�\F] Fuel price
Fuel(u,f) [n.a.] Fuel type {1 0}
LineNode(l,n) [n.a.] Incidence matrix {-1 +1}
LoadShedding(n) [n.a.] Load shedding capacity
Location(u,n) [n.a.] Location {1 0}
Markup(u,h) [�\MW] Markup
Markup(u,h) [�\MW] Markup
OutageFactor(u,h) [%] Outage Factor (100% = full outage)
PartLoadMin(u) [%] Minimum part load
PowerCapacity(u) [MW] Installed capacity
PowerInitial(u) [MW] Power output before initial period
PowerMinStable(u) [MW] Minimum power output
PriceTransmission(l,h) [�\MWh] Transmission price
PriceTransmission(l,h) [�\MWh] Transmission price
StorageChargingCapacity(u) [MW] Storage capacity
StorageChargingEfficiency(u) [%] Charging efficiency
RampDownMaximum(u) [MW\h] Ramp down limit
Expand Down Expand Up @@ -127,7 +127,7 @@ $If %RetrieveStatus% == 1 CommittedCalc(u,z) [n.a.] Committment
*Parameters as used within the loop
PARAMETERS
TimeUpLeft_JustStarted(u,h) [h] Required time up left at hour h if the Unit has just been started
CostLoadShedding(n,h) [�\MW] Value of lost load
CostLoadShedding(n,h) [�\MW] Value of lost load
TimeUp(u,h) [h] Hours up
LoadMaximum(u,h) [%] Maximum load given AF and OF
PowerMustRun(u,h) [MW] Minimum power output
Expand Down Expand Up @@ -867,6 +867,7 @@ OutputSystemCost(h)
OutputSpillage(s,h)
OutputShedLoad(n,h)
OutputCurtailedPower(n,h)
ShadowPrice(n,h)
;

OutputCommitted(u,z)=Committed.L(u,z);
Expand All @@ -880,6 +881,7 @@ OutputSystemCost(z)=SystemCost.L(z);
OutputSpillage(s,z) = Spillage.L(s,z) ;
OutputShedLoad(n,z) = ShedLoad.L(n,z);
OutputCurtailedPower(n,z)=CurtailedPower.L(n,z);
ShadowPrice(n,z) = EQ_Demand_balance_DA.m(n,z);

EXECUTE_UNLOAD "Results.gdx"
OutputCommitted,
Expand All @@ -898,7 +900,8 @@ LostLoad_MinPower,
LostLoad_Reserve2D,
LostLoad_Reserve2U,
LostLoad_RampUp,
LostLoad_RampDown
LostLoad_RampDown,
ShadowPrice
;

$onorder
Expand Down
10 changes: 10 additions & 0 deletions Dispa-SET/Read_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@
bar plots with max demand, installed capacity in each country
line capacities wrong for some countries
'''


#%%

load = ds.GetLoadData(datain,'IE')





2 changes: 1 addition & 1 deletion Docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Welcome to Dispa-SET's documentation!
:Version: |version|
:Date: |today|

The Dispa-SET model is a unit commitment and dispatch model developed within the “Joint Research Centre” and focused on the balancing and flexibility problems in European grids [1]_. It is written in GAMS an Python (Pyomo) and Excel for input/output data handling and visualization. The selected Mixed-Integer Linear Programming (MILP) solver is CPLEX.
The Dispa-SET model is a unit commitment and dispatch model developed within the “Joint Research Centre” and focused on the balancing and flexibility problems in European grids [1]_. It is written in GAMS an Python (Pyomo) and uses csv files for input data handling. The optimisation is defined as a Linear Programming (LP) or Mixed-Integer Linear Programming (MILP) problem, depending on the desired level of accuracy and complexity.



Expand Down
8 changes: 4 additions & 4 deletions Docs/model.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. _model:
.. _model:

Model Description
=================

The model is expressed as a MILP problem. Continuous variables include the individual unit dispatched power, the shedded load and the curtailed power generation. The binary variables are the commitment status of each unit. The main model features can be summarized as follows:
The model is expressed as a MILP or LP problem. Continuous variables include the individual unit dispatched power, the shedded load and the curtailed power generation. The binary variables are the commitment status of each unit. The main model features can be summarized as follows:


Variables
Expand Down Expand Up @@ -65,7 +65,7 @@ Parameters
PowerInitial(u) MW Power output before initial period
PowerMinStable(u) MW Minimum power for stable generation
PowerMustRun(u) MW Minimum power output
PriceTransmission(l,h) €/MWh Price of transmission between zones
PriceTransmission(l,h) €/MWh Price of transmission between zones
RampDownMaximum(u) MW/h Ramp down limit
RampShutDownMaximum(u) MW/h Shut-down ramp limit
RampStartUpMaximum(u) MW/h Start-up ramp limit
Expand Down Expand Up @@ -687,6 +687,6 @@ Since the start-up of individual units is not considered anymore, it is not usef
References
^^^^^^^^^^

.. [1] Hidalgo González, I., Quoilin, S., & Zucker, A. (2014). Dispa-SET 2.0: unit commitment and power dispatch model (EUR 27015 EN). Petten, Netherlands: European Commission.
.. [1] Hidalgo González, I., Quoilin, S., & Zucker, A. (2014). Dispa-SET 2.0: unit commitment and power dispatch model (EUR 27015 EN). Petten, Netherlands: European Commission.
.. [2] Quoilin, S., Nijs, W., Hidalgo, I., & Thiel, C. (2015). Evaluation of simplified flexibility evaluation tools using a unit commitment model. IEEE Digital Library.
.. [3] Quoilin, S., Gonzalez Vazquez, I., Zucker, A., & Thiel, C. (2014). Available technical flexibility for balancing variable renewable energy sources: case study in Belgium. Proceedings of the 9th Conference on Sustainable Development of Energy, Water and Environment Systems.
10 changes: 10 additions & 0 deletions Externals/gams_api/linux64/GAMS-1.0.egg-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: GAMS
Version: 1.0
Summary: GAMS API
Home-page: UNKNOWN
Author: GAMS
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
Binary file added Externals/gams_api/linux64/_gdxcc.so
Binary file not shown.
10 changes: 10 additions & 0 deletions Externals/gams_api/linux64/cfgmcc-1.egg-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: cfgmcc
Version: 1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN

0 comments on commit e09113f

Please sign in to comment.