PowerGIM¶
Module for power grid investment analyses
-
class
powergama.powergim.
SipModel
(M_const=1000)¶ Power Grid Investment Module - Stochastic Investment Problem
Methods
computeAreaCostBranch
(model, c, stage[, …])Investment cost for branches connected to an given area computeAreaCostGen
(model, c)compute capital costs for new generator capacity computeAreaEmissions
(model, c[, stage, cost])compute total emissions from a load/country computeAreaPrice
(model, area, t[, stage])cumpute the approximate area price based on max marginal cost computeAreaRES
(model, j, shareof[, stage])compute renewable share of demand or total generation capacity computeAreaWelfare
(model, c, t[, stage])compute social welfare for a given area and time step computeBranchCongestionRent
(model, b[, stage])Compute annual congestion rent for a given branch computeCostBranch
(model, b[, stage, include_om])Investment cost of single branch NPV computeCostGenerator
(model, g[, stage, …])Investment cost of generator NPV computeCostNode
(model, n[, include_om])Investment cost of single node computeCurtailment
(model, g, t[, stage])compute curtailment [MWh] per generator per hour computeDemand
(model, c, t)compute demand at specified load ant time computeGenerationCost
(model, g, stage)compute NPV cost of generation (+ CO2 emissions) costBranch
(model, b, stage)Expression for cost of branch, investment cost no discounting costGen
(model, g, stage)Expression for cost of generator, investment cost no discounting costInvestments
(model, stage[, includeOM, …])Investment cost, including lifetime O&M costs (NPV) costNode
(model, n, stage)Expression for cost of node, investment cost no discounting costOperation
(model, stage)Operational costs: cost of gen, load shed (NPV) costOperationSingleGen
(model, g, stage)Operational costs: cost of gen, load shed (NPV) createConcreteModel
(dict_data)Create Concrete Pyomo model for PowerGIM createModelData
(grid_data, datafile, …)Create model data in dictionary format createScenarioTreeModel
(num_scenarios[, …])Generate model instance with data. extractResultingGridData
(grid_data[, model, …])Extract resulting optimal grid layout from simulation results loadResults
(filename, sheet)load results from excel into pandas dataframe npvInvestment
(model, stage, investment[, …])NPV of investment cost including lifetime O&M and salvage value plotAreaPrice
(model[, boxplot, areas, …])Show area price(s) TODO: incoporate samplefactor plotBranchData
(model[, stage])Plot branch data plotEnergyMix
(model[, areas, timeMaxMin, …])Plot energy, generation capacity or spilled energy as stacked bars plotInvestments
(filename, variable[, unit])Plot investment bar plots plotWelfare
(model[, areas, timeMaxMin, …])Plot welfare saveDeterministicResults
(model, excel_file)export results to excel file writeStochasticProblem
(path, dict_data)create input files for solving stochastic problem -
computeAreaCostBranch
(model, c, stage, include_om=False)¶ Investment cost for branches connected to an given area
-
computeAreaCostGen
(model, c)¶ compute capital costs for new generator capacity
-
computeAreaEmissions
(model, c, stage=2, cost=False)¶ compute total emissions from a load/country
-
computeAreaPrice
(model, area, t, stage=2)¶ cumpute the approximate area price based on max marginal cost
-
computeAreaRES
(model, j, shareof, stage=2)¶ compute renewable share of demand or total generation capacity
-
computeAreaWelfare
(model, c, t, stage=2)¶ compute social welfare for a given area and time step
- Returns: Welfare, ProducerSurplus, ConsumerSurplus,
- CongestionRent, IMport, eXport
-
computeBranchCongestionRent
(model, b, stage=1)¶ Compute annual congestion rent for a given branch
-
computeCostBranch
(model, b, stage=2, include_om=False)¶ Investment cost of single branch NPV
corresponds to firstStageCost in abstract model
-
computeCostGenerator
(model, g, stage=2, include_om=False)¶ Investment cost of generator NPV
-
computeCostNode
(model, n, include_om=False)¶ Investment cost of single node
corresponds to cost in abstract model
-
computeCurtailment
(model, g, t, stage=2)¶ compute curtailment [MWh] per generator per hour
-
computeDemand
(model, c, t)¶ compute demand at specified load ant time
-
computeGenerationCost
(model, g, stage)¶ compute NPV cost of generation (+ CO2 emissions)
This corresponds to secondStageCost in abstract model
-
costBranch
(model, b, stage)¶ Expression for cost of branch, investment cost no discounting
-
costGen
(model, g, stage)¶ Expression for cost of generator, investment cost no discounting
-
costInvestments
(model, stage, includeOM=True, subtractSalvage=True)¶ Investment cost, including lifetime O&M costs (NPV)
-
costNode
(model, n, stage)¶ Expression for cost of node, investment cost no discounting
-
costOperation
(model, stage)¶ Operational costs: cost of gen, load shed (NPV)
-
costOperationSingleGen
(model, g, stage)¶ Operational costs: cost of gen, load shed (NPV)
-
createConcreteModel
(dict_data)¶ Create Concrete Pyomo model for PowerGIM
Parameters: - dict_data : dictionary
dictionary containing the model data. This can be created with the createModelData(…) method
Returns: - Concrete pyomo model
-
createModelData
(grid_data, datafile, maxNewBranchNum, maxNewBranchCap)¶ Create model data in dictionary format
Parameters: - grid_data : powergama.GridData object
contains grid model
- datafile : string
name of XML file containing additional parameters
- maxNewBranchNum : int
upper limit on parallel branches to consider (e.g. 10)
- maxNewBranchCap : float (MW)
upper limit on new capacity to consider (e.g. 10000)
Returns: - dictionary with pyomo data (in pyomo format)
-
createScenarioTreeModel
(num_scenarios, probabilities=None, stages=[1, 2])¶ Generate model instance with data. Alternative to .dat files
Parameters: - num_scenarios : int
number of scenarios. Each with the same probability
- probabilities : list of float
probabilities of each scenario (must sum to 1). Number of elements determine number of scenarios
- stages : list of stage names
NOTE: Presently only works with default value=[1,2]
Returns: - PySP 2-stage scenario tree model
- This method may be called by “pysp_scenario_tree_model_callback()” in
- the model input file instead of using input .dat files
-
extractResultingGridData
(grid_data, model=None, file_ph=None, stage=1, scenario=None, newData=False)¶ Extract resulting optimal grid layout from simulation results
Parameters: - grid_data : powergama.GridData
grid data class
- model : Pyomo model
concrete instance of optimisation model containing det. results
- file_ph : string
CSV file containing results from stochastic solution
- stage : int
Which stage to extract data for (1 or 2). 1: only stage one investments included (default) 2: both stage one and stage two investments included
- scenario : int
which stage 2 scenario to get data for (only relevant when stage=2)
- newData : Boolean
Choose whether to use only new data (True) or add new data to existing data (False)
- Use either model or file_ph parameter
Returns: - GridData object reflecting optimal solution
-
loadResults
(filename, sheet)¶ load results from excel into pandas dataframe
-
npvInvestment
(model, stage, investment, includeOM=True, subtractSalvage=True)¶ NPV of investment cost including lifetime O&M and salvage value
Parameters: - model : object
Pyomo model
- stage : int
Investment or operation stage (1 or 2)
- investment :
cost of e.g. node, branch or gen
-
plotAreaPrice
(model, boxplot=False, areas=None, timeMaxMin=None, showTitle=False, stage=1)¶ Show area price(s) TODO: incoporate samplefactor
Parameters: - areas (list)
list of areas to show
- timeMaxMin (list) (default = None)
[min, max] - lower and upper time interval
-
plotBranchData
(model, stage=2)¶ Plot branch data
-
plotEnergyMix
(model, areas=None, timeMaxMin=None, relative=False, showTitle=True, variable='energy', gentypes=None, stage=1)¶ Plot energy, generation capacity or spilled energy as stacked bars
Parameters: - areas : list of sting
Which areas to include, default=None means include all
- timeMaxMin : list of two integers
Time range, [min,max]
- relative : boolean
Whether to plot absolute (false) or relative (true) values
- variable : string (“energy”,”capacity”,”spilled”)
Which variable to plot (default is energy production)
- gentypes : list
List of generator types to include. None gives all.
-
plotInvestments
(filename, variable, unit='capacity')¶ Plot investment bar plots
- filename: string
- excel-file generated by ‘saveDeterministicResults’
- variable: string
- dcbranch, acbranch, node, generator
- unit: string
- capacity, monetary
-
plotWelfare
(model, areas=None, timeMaxMin=None, relative=False, showTitle=False, variable='energy', gentypes=None, stage=2)¶ Plot welfare
Parameters: - areas : list of sting
Which areas to include, default=None means include all
- timeMaxMin : list of two integers
Time range, [min,max]
- relative : boolean
Whether to plot absolute (false) or relative (true) values
- variable : string (“energy”,”capacity”,”spilled”)
Which variable to plot (default is energy production)
- gentypes : list
List of generator types to include. None gives all.
-
saveDeterministicResults
(model, excel_file)¶ export results to excel file
Parameters: - model : Pyomo model
concrete instance of optimisation model
- excel_file : string
name of Excel file to create
-
writeStochasticProblem
(path, dict_data)¶ create input files for solving stochastic problem
Parameters: - path : string
Where to put generated files
- dict_data : dictionary
Pyomo data model in dictionary format. Output from createModelData method
Returns: - string that can be written to .dat file (reference model data)
-
-
powergama.powergim.
annuityfactor
(rate, years)¶ Net present value factor for fixed payments per year at fixed rate
-
powergama.powergim.
computeSTOcosts
(grid_data, dict_data, generation=None, include_om=True)¶ Compute costs as in objective function of the optimisation This function is used to analyse optimisation results.
Parameters: - grid_data : powergama.grid_data
grid object
- dict_data : dict
dictionary holding the optimisation input data (as dictionary)
- generation : list of dataframes, one per stage
generator operational costs, dataframe with columns [‘gen’,’time’,’value’]