Commit 96b409db authored by Alexander Roth's avatar Alexander Roth
Browse files

Initial commit

parents
File added
********************************************************************************
* DIETER MINI
********************************************************************************
$setglobal base_year "'2030'"
********************************************************************************
* DATALOAD
********************************************************************************
*************** SETS *********************************************************
***** Sets used in the model *****
Sets
tech Generation technologies
dis(tech) Dispatchable generation technologies
nondis(tech) Nondispatchable generation technologies
con(tech) Conventional generation technologies
res(tech) Renewable generation technologies
year Base year for temporal data
n Nodes
h Hours
***** Sets used for data upload *****
headers_tech Generation technologies - upload headers
tech_dispatch Generation technologies - dispatchable or nondispatchable
tech_res_con Generation technologies - renewable or "conventional"
headers_time Temporal data - upload headers
;
*************** PARAMETERS ***************************************************
Parameters
***** Generation technologies *****
*--- Variable and fixed costs ---*
eta Efficiency of conventional technologies [0 1]
carbon_content CO2 emissions per fuel unit used [tons per MWh thermal]
c_up Load change costs UP [EUR per MWh]
c_do Load change costs DOWN [EUR per MWh]
c_fix Annual fixed costs [EUR per MW per year]
c_vom Variable O&M costs [EUR per MWh]
CO2price CO2 price in [EUR per ton]
*--- Investment ---*
c_inv_overnight Investment costs: Overnight [EUR per MW]
lifetime Investment costs: technical lifetime [a]
recovery Investment costs: Recovery period according to depreciation tables [a]
interest_rate Investment costs: Interest rate [%]
m_p Investment: maximum installable capacity per technology [MW]
m_e Investment: maximum installable energy [TWh per a]
*--- Flexibility ---*
grad_per_min Maximum load change relative to installed capacity [% of installed capacity per minute]
***** Fuel and CO2 costs *****
fuelprice Fuel price conventionals [EUR per MWh thermal]
***** Renewables *****
c_cu Hourly Curtailment costs for renewables [Euro per MW]
phi_min_res Minimum renewables share [0 1]
***** Storage *****
***** Reservoirs *****
***** Time Data *****
d_y Demand hour h for different years [MWh]
d Demand hour h [MWh]
phi_res_y Renewables availability technology res in hour h for different years [0 1]
phi_res Renewables availability technology res in hour h [0 1]
*************** PARAMETERS FOR DATA UPLOAD ***********************************
technology_data_upload(n,tech,tech_res_con,tech_dispatch,headers_tech)
technology_data(n,tech,headers_tech)
time_data_upload(h,n,year,headers_time)
*************** DERIVED PARAMETERS *******************************************
c_m Marginal production costs for conventional plants including variable O and M costs [EUR per MWh]
c_i Annualized investment costs by conventioanl plant [EUR per MW]
c_i_res Annualized investment costs by renewable plant [EUR per MW]
c_fix_res Annualized fixed costs by renewable plant [EUR per MW per a]
*************** UPLOAD TIME-CONSTANT SETS AND PARAMETERS *********************
$onecho >temp.tmp
se=0
dset=n rng=spatial!M2 rdim=0 cdim=1
dset=tech rng=Technologies!B6 rdim=1 cdim=0
dset=headers_tech rng=Technologies!E5 rdim=0 cdim=1
dset=tech_dispatch rng=Technologies!D6 rdim=1 cdim=0
dset=tech_res_con rng=Technologies!C6 rdim=1 cdim=0
par=technology_data_upload rng=Technologies!A5 rdim=4 cdim=1
$offecho
$call "gdxxrw data_input.xlsx @temp.tmp o=Data_input maxdupeerrors=100";
$GDXin Data_input.gdx
$load n tech headers_tech tech_dispatch tech_res_con
*$load sto headers_sto rsvr headers_reservoir reservoir_data dsm headers_dsm dsm_type
$load technology_data_upload
*************** UPLOAD TIME-SERIES SETS AND PARAMETERS ***********************
$onecho >temp2.tmp
se=0
dset = h rng=basic!A9 rdim=1 cdim=0
dset = headers_time rng=basic!B8 rdim=0 cdim=1
dset = year rng=basic!B7 rdim=0 cdim=1
par = time_data_upload rng=basic!A6 rdim=1 cdim=3
$offecho
$call "gdxxrw time_series.xlsx @temp2.tmp o=time_series";
$GDXin time_series.gdx
$load h headers_time year time_data_upload
;
*************** ASSIGNMENTS **************************************************
***** Aliases *****
alias (h,hh) ;
alias (res,resres) ;
alias (nondis,nondisnondis) ;
*alias (reserves,reservesreserves) ;
***** Derived sets *****
dis(tech)$sum( (n,tech_res_con,headers_tech), technology_data_upload(n,tech,tech_res_con,'dis',headers_tech)) = yes;
nondis(tech)$sum( (n,tech_res_con,headers_tech), technology_data_upload(n,tech,tech_res_con,'nondis',headers_tech)) = yes;
res(tech)$sum( (n,tech_dispatch,headers_tech), technology_data_upload(n,tech,'res',tech_dispatch,headers_tech)) = yes;
***** Parameters *****
*--- Generation technologies ---*
technology_data(n,tech,headers_tech) = sum((tech_res_con,tech_dispatch), technology_data_upload(n,tech,tech_res_con,tech_dispatch,headers_tech)) ;
eta(n,tech) = technology_data(n,tech,'eta_con') ;
carbon_content(n,tech) = technology_data(n,tech,'carbon_content') ;
c_up(n,dis) =technology_data(n,dis,'load change costs up') ;
c_do(n,dis) = technology_data(n,dis,'load change costs down') ;
c_fix(n,tech) = technology_data(n,tech,'fixed_costs') ;
c_vom(n,tech) = technology_data(n,tech,'variable_om') ;
CO2price(n,tech) = technology_data(n,tech,'CO2_price') ;
c_inv_overnight(n,tech) = technology_data(n,tech,'oc') ;
lifetime(n,tech) = technology_data(n,tech,'lifetime') ;
*recovery(n,tech) = technology_data(n,tech,'recovery_period') ;
interest_rate(n,tech) = technology_data(n,tech,'interest_rate') ;
m_p(n,tech) = technology_data(n,tech,'max_installable') ;
*m_e(n,tech) = technology_data(n,tech,'max_energy') ;
*grad_per_min(n,dis) = technology_data(n,dis,'load change flexibility') ;
fuelprice(n,tech) = technology_data(n,tech,'fuel costs') ;
c_cu(n,res) = technology_data(n,res,'curtailment_costs') ;
*--- Temporal data ---*
d_y(n,year,h) = time_data_upload(h,n,year,'demand') ;
d(n,h) = d_y(n,%base_year%,h) ;
phi_res_y(n,year,res,h) = sum(headers_time$(sameas(res,headers_time)), time_data_upload(h,n,year,headers_time));
phi_res(n,res,h) = phi_res_y(n,%base_year%,res,h) ;
*************** CALCULATE DERIVED PARAMETERS *********************************
c_m(n,tech) = fuelprice(n,tech)/eta(n,tech) + carbon_content(n,tech)/eta(n,tech)*CO2price(n,tech) + c_vom(n,tech) ;
c_i(n,tech) = c_inv_overnight(n,tech)*( interest_rate(n,tech) * (1+interest_rate(n,tech))**(lifetime(n,tech)) )
/ ( (1+interest_rate(n,tech))**(lifetime(n,tech))-1 ) ;
********************************************************************************
Set
map_n_tech(n,tech)
*map_n_sto(n,sto)
*map_n_rsvr(n,rsvr)
*map_n_dsm(n,dsm)
*map_n_ev(n,ev)
*map_l(l)
*map_n_sto_pro(n,sto)
*map_n_res_pro(n,tech)
;
map_n_tech(n,tech) = yes$m_p(n,tech) ;
*map_n_sto(n,sto) = yes$m_sto_p(n,sto) ;
*map_n_rsvr(n,rsvr) = yes$m_rsvr_p(n,rsvr) ;
*map_n_dsm(n,dsm_curt) = yes$m_dsm_cu(n,dsm_curt) ;
*map_n_dsm(n,dsm_shift) = yes$m_dsm_shift(n,dsm_shift) ;
*map_n_ev(n,ev) = yes$ev_data(n,ev,'share_ev') ;
*map_l(l) = yes$m_ntc(l) ;
*map_n_sto_pro(n,sto) = yes$(yes$m_sto_pro_p(n,sto)) ;
*map_n_res_pro(n,res) = yes$(yes$m_res_pro(n,res)) ;
********************************************************************************
********************************************************************************
* MODEL
********************************************************************************
*************** VARIABLES ****************************************************
Variables
Z Value objective function [Euro]
*F(l,h) Energy flow over link l in hour h [MWh]
;
Positive Variables
G_L(n,tech,h) Generation level in hour h [MWh]
G_UP(n,tech,h) Generation upshift in hour h [MWh]
G_DO(n,tech,h) Generation downshift in hour h [MWh]
G_RES(n,tech,h) Generation renewables type res in hour h [MWh]
CU(n,tech,h) Renewables curtailment technology res in hour h [MWh]
*STO_IN(n,sto,h) Storage inflow technology sto hour h [MWh]
*STO_OUT(n,sto,h) Storage outflow technology sto hour h [MWh]
*STO_L(n,sto,h) Storage level technology sto hour h [MWh]
*
*
*
N_TECH(n,tech) Technology tech built [MW]
*N_STO_E(n,sto) Storage technology built - Energy [MWh]
*N_STO_P(n,sto) Storage loading and discharging capacity built - Capacity [MW]
*
*
*
*RSVR_OUT(n,rsvr,h) Reservoirs: outflow in hour h [MWh]
*RSVR_L(n,rsvr,h) Reservoirs: level in hour h [MWh]
*N_RSVR_E(n,rsvr) Reservoirs: installed energy capacity [MWh]
*N_RSVR_P(n,rsvr) Reservoirs: installed power capacity [MW]
*
*
*
;
*************** EQUATIONS ****************************************************
*$ontext
Equations
* Objective
obj Objective cost minimization
* Energy balance
con1a_bal Energy Balance
* Load change costs
**con2a_loadlevel Load change costs: Level
**con2b_loadlevelstart Load change costs: Level for first period
* Capacity contraints and flexibility constraints
con3a_maxprod_dispatchable Capacity Constraint conventionals
*con3b_minprod_dispatchable Minimum production conventionals if reserves contracted
*con3c_flex_reserves_spin Flexibility of conventionals for reserves provision
*con3d_flex_reserves_nonspin Flexibility of conventionals for reserves provision
con3e_maxprod_res Capacity constraints renewables
*con3f_minprod_res Minimum production RES if reserves contracted
*
*
*
* Storage constraints
*con4a_stolev_start Storage Level Dynamics Initial Condition
*con4b_stolev Storage Level Dynamics
*con4c_stolev_max Storage Power Capacity
*con4d_maxin_sto Storage maximum inflow
*con4e_maxout_sto Storage maximum outflow
*con4f_resrv_sto Constraint on reserves (up)
*con4g_resrv_sto Constraint on reserves (down)
*con4h_maxout_lev Maximum storage outflow - no more than level of last period
*con4i_maxin_lev Maximum storage inflow - no more than ebergy capacity minus level of last period
*con4j_ending End level equal to initial level
*con4k_PHS_EtoP Maximum E to P ratio for PHS
* Minimum restrictions for renewables and biomass
**con5a_minRES Minimum yearly renewables requirement
**con5b_max_energy Maximum yearly biomass energy
*
*
*
* Maximum installation conditions
con8a_max_I_power Maximum installable capacity: Conventionals
*con8b_max_I_sto_e Maximum installable energy: Storage in MWh
*con8c_max_I_sto_p Maximum installable capacity: Storage inflow-outflow in MW
*
*
*
*con8i_max_I_ntc Maximum installable NTC
*con8j_max_I_rsvr_e Maximum installable energy reservoirs
*con8k_max_I_rsvr_p Maximum installable power reservoirs
*
*
*
* Cross-nodal trade
*con12a_max_f Maximum energy flow limited to positive NTC
*con12b_min_f Minimum energy flow limited to negative NTC
* Resevoirs
*con13a_rsvrlev_start Reservoir level law of motion initial condition
*con13b_rsvrlev Reservoir level law of motion
*con13c_rsvrlev_max Maximum reservoir energy level
*con13d_maxout_rsvr Maximum hourly reservoir outflow in relation to installed power capacity
*con13e_resrv_rsvr Minimum hourly reservoir outflow in relation to provided negativr reserves
*con13f_maxout_lev Maximum hourly reservoir outflow in relation tom installed energy capacity
*con13g_ending Reservoir level law of motion ending condition
*con13h_smooth Smooth reservoir outflow
*con13i_min_level Reservoir minimum level
*con13j_min_FLH
;
********************************************************************************
* ---------------------------------------------------------------------------- *
***** Objective function *****
* ---------------------------------------------------------------------------- *
obj..
Z =E=
sum( (h,map_n_tech(n,dis)) , c_m(n,dis)*G_L(n,dis,h) )
+ sum( map_n_tech(n,tech) , c_i(n,tech)*N_TECH(n,tech) )
+ sum( map_n_tech(n,tech) , c_fix(n,tech)*N_TECH(n,tech) )
;
* Energy balance
con1a_bal(n,hh)..
d(n,hh) =E= sum( map_n_tech(n,dis) , G_L(n,dis,hh))
+ sum( map_n_tech(n,nondis) , G_RES(n,nondis,hh))
;
* ---------------------------------------------------------------------------- *
***** Hourly maximum generation caps and constraints related to reserves *****
* ---------------------------------------------------------------------------- *
con3a_maxprod_dispatchable(n,dis,h)$(map_n_tech(n,dis))..
G_L(n,dis,h) =L= N_TECH(n,dis)
;
con3e_maxprod_res(n,nondis,h)$(map_n_tech(n,nondis))..
G_RES(n,nondis,h) =E= phi_res(n,nondis,h) * N_TECH(n,nondis)
;
* ---------------------------------------------------------------------------- *
***** Maximum installation constraints *****
* ---------------------------------------------------------------------------- *
con8a_max_I_power(n,tech)$(map_n_tech(n,tech))..
N_TECH(n,tech) =L= m_p(n,tech)
********************************************************************************
***** MODEL *****
********************************************************************************
model DIETERmini
/ all /
;
********************************************************************************
solve DIETERmini using LP min Z;
* scenario dict;
********************************************************************************
********************************************************************************
**** Parameters for report file ***********************************************
********************************************************************************
* Set reporting sensitivity. All results below will be reported as zero
*Scalar eps_rep_rel Sensitivity for shares defined between 0 and 1 / 1e-4 / ;
*Scalar eps_rep_abs Sensitivity for absolute values - e.g. hourly / 1e-2 / ;
Scalar
eps_rep_ins Sensitivity for absolute values - e.g. installed MW / 1 / ;
$setenv gdxcompress 1
Parameter
*report
report_tech
*report_tech_hours
report_hours
report_node
*report_line
*report_cost
eps_rep_ins
;
report_hours('demand consumers',n,h) = d(n,h) ;
report_hours('price',n,h) = - con1a_bal.m(n,h) ;
report_node('Total demand',n) = sum( h , d(n,h)) ;
report_tech('Capacity',n,tech) = N_TECH.l(n,tech) + eps ;
*report_tech('Capacity',n,tech)$(report_tech('Capacity',n,tech) < eps_rep_ins) = 0 ;
execute_unload "results", report_tech, report_hours, report_node ;
*report, report_tech, report_node, report_line, report_tech_hours, report_hours, report_cost
DISPLAY
N_TECH.l ;
********************************************************************************
**** Reporting to Excel ********************************************************
********************************************************************************
*epsOut = '0'
Parameter
*excel_cost
*excel_cost_building_heat
*excel_cost_building
*excel_cost_building_heat_other
*excel_heat
excel_capacities
;
excel_capacities('Capacities',n,tech) = report_tech('Capacity',n,tech) ;
*excel_capacities('Capacities',rsvr) = sum( (n,loop_res_share,loop_ev,loop_prosumage) , report_tech('capacities reservoir MW',loop_res_share,loop_ev,loop_prosumage,rsvr,n) ) ;
*excel_capacities('Capacities',sto) = sum( (n,loop_res_share,loop_ev,loop_prosumage) , report_tech('capacities storage MW',loop_res_share,loop_ev,loop_prosumage,sto,n) ) ;
execute_unload "results_excel", excel_capacities
execute 'gdxxrw.exe results_excel.gdx EpsOut=0 par=excel_capacities rng=Capacities!a1'
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment