GridModel

class pomato.grid.GridModel(wdir, grid, data, option)

GridRepresentation of POMATO, represents the network in the market model.

The GridRepresentation creates a grid representation to be used in the market model based on the chosen options. This module acts as a combinator of the data and grid modules and allow to easily change grid representation for the market model.

Its main feature is a minimal nodal/zonal N-1 grid representation which is achieved through a redundancy removal algorithm based on the “Clarkson” algorithm.

For a more comprehensive documentation note that the ptdf matrix, regardless if with/without contingencies or representing nodal/zonal sensitivities, is denoted as matrix A in this module and the line limits as vector b. Therefore the resulting power flow problem is simply written in the form of a linear problem Ax <= b. The redundancy reduction algorithm finds the smallest set of constraints, essential set, that fully defines the problem. The indices, i.e. the rows in A or cbco’s, are called essential indices.

The the class attributes are divided into core attributes, with grid_representation as the mein outout/result and additional attributes that are used to facilitate the redundancy removal algorithm.

Parameters:
wdirpathlib.Path

Working directory

dataDataManagement

An instance of the DataManagement class with processed input data.

gridGridTopology

An instance of the GridModel class.

optionsdict

The options from POMATO main module.

Attributes:
wdir, julia_dirpathlib.Path

Working directory, Sub-directory for temporary files related with the redundancy removal algorithm.

optionsdict

The options from DataManagement persist in the InputProcessing.

gridGridTopology

Instance of the GridTopology class. Provides functionality to create N-0 and (filtered) N-1 ptdf.

dataDataManagement

Instance of the DataManagement class with processed input data.

grid_representationtypes.SimpleNamespace

Containing the grid representation to be used in the market model and the determination of the economic dispatch. Depends on the chosen configuration in the options file.

julia_instanceJuliaDaemon

Julia process that is initialized when used the first time and then kept to be able to easily re-run the redundancy algorithm without restarting a julia process.

Methods

create_grid_representation([...])

Create grid representation based on model type.

process_ntc()

Process grid information for NTC representation.

create_scopf_grid_parameters()

Process grid information for nodal N-1 representation.

create_nodal_grid_parameters()

Process grid information for nodal N-0 representation.

create_cnec_data([sensitivity, preprocess, gsk])

Create all relevant N-1 PTDFs in the form of Ax<b (PTDF x < ram).

add_redispatch_grid()

Add nodal N-0 grid representation as redispatch grid.

clarkson_algorithm([args])

Run the redundancy removal algorithm.

create_nodal_injection_limits()

Create nodal injection limits.

create_ntc([default_ntc])

Create NTC data.

return_cbco(cbco_info, cbco_index)

Return only the cbco's of the info attribute DataFrame.

write_cbco_info(folder, suffix, **kwargs)

Write cbco information to disk to run the redundancy removal algorithm.

add_redispatch_grid()

Add nodal N-0 grid representation as redispatch grid.

Depending on the optional argument grid_representation.redispatch_grid will reflect N-0 or N-1, i.e. including contingencies, grid representation.

clarkson_algorithm(args={'file_suffix': 'py'}, **kwargs)

Run the redundancy removal algorithm.

The redundancy removal algorithm is run by writing the necessary data to disk with “_py” suffix, starting a julia instance and running the algorithm. After (successful) completion the resulting file with the non-redundant cbco indices is read and returned.

Returns:
cbcolist

List of the essential indices, i.e. the indices of the non-redundant cbco’s.

create_cnec_data(sensitivity=0.05, preprocess=False, gsk=None)

Create all relevant N-1 PTDFs in the form of Ax<b (PTDF x < ram).

This uses the method create_filtered_n_1_ptdf() to generate a filtered ptdf matrix, including outages with a higher impact of the argument sensitivity.

Parameters:
sensitivityfloat, optional

The sensitivity defines the threshold from which outages are considered critical. A outage that can impact the lineflow, relative to its maximum capacity, more than the sensitivity is considered critical.

preprocessbool, optional

Performing a light preprocessing by removing duplicate constraints.

gsknp.ndarray, optional

When gsk is an argument, this method creates a zonal ptdf matrix with it.

Returns:
Anp.ndarray

ptdf matrix, nodal or zonal depending of gsk argument, containing all lines under outages with significant impact.

bnp.ndarray

Line capacities of the cbco in A.

infopd.DataFrame

DataFrame containing the ptdf, ram and information which cbco each row corresponds to.

create_grid_representation(flowbased_parameters=None)

Create grid representation based on model type.

Options are: uniform, ntc, opf, scopf, fbmc.

grid_representation contains the following:
  • option: The chosen option of grid representation.

  • multiple_slack: Bool indicator if there are multiple slacks.

  • slack_zones: dict to map each node to a slack/reference node.

  • grid: DataFrame including the ptdf for each line/outage, depending on chosen option, including line capacities and regional information.

  • redispatch_grid: DataFrame including the ptdf for the redispatch. As default this is nodal but could also be an N-1 ptdf, similar to grid.

  • ntc: DataFrame with the zonal commercial exchange capacities.

All values are set according the chosen option and might remain empty. If flow based parameters are supplied, the grid representation will be generated accordingly.

Parameters:
flowbased_parametersoptional, pandas.DataFrame

Flowbased parameters, derived using FBMCModule

create_nodal_grid_parameters()

Process grid information for nodal N-0 representation.

Here grid_representation.grid consists of the N-0 ptdf.

There is the option to try to reduce this ptdf, however the number of redundant constraints is expected to be very low.

create_nodal_injection_limits()

Create nodal injection limits.

For each node the nodal injection limits depend on the installed capacity and availability/load timeseries. Additionally, each node can have a slack variables/infeasibility variables, DC-line injections and storage charge/discharge.

Because a nodal injection can impact a line positively/negatively depending on the (arbitrary) definition of the incidence matrix, only the max(positive bound, abs(negative bound)) is considered.

TODO Rewrite without for n in nodes loop (takes 7s for the ieee network and 8760t)

Returns:
nodal_injection_limitsnp.ndarray

Contains the abs maximum power injected/load at each node.

create_ntc(default_ntc=100000.0)

Create NTC data.

The ntc generated in this method are high (10.000) or zero. This is useful to limit commercial exchange to connected zones or when the model uses a simplified line representation.

Parameters:
default_ntcfloat, optional

NTC value, defaults to 1e5.

Returns
——-
ntcpd.DataFrame

DataFrame that contains dummy ntc which are the default_ntc when market areas are connected and zero otherwise.

create_scopf_grid_parameters()

Process grid information for nodal N-1 representation.

Based on chosen sensitivity and GSK the return of create_cnec_data() runs the redundancy removal algorithm to reduce the number of constraints to a minimal set. The redundancy removal algorithm can take long to conclude, e.g. about 2 hours for the DE case study which comprises of ~450 nodes and ~1000 lines. Therefore is useful to keep the resulting file with if the relevant cbco’s and just read it in when needed. This is done by specifying the cbco fil in options[“grid”][“precalc_filename”].

There are multiple options to pick, where one is the obvious best conditional_redundancy_removal. This runs the redundancy removal algorithm including bounds on the nodal injections, which are calculated based on installed capacity and availability/load timeseries. The other options are: redundancy_removal redundancy removal without bounds on nodal injections and “save” saving the relevant files for the RedundancyRemoval algorithm so that it can be run separately from the python POMATO.

process_flowbased_grid_representation(flowbased_parameters)

Process grid information for flow based grid representation.

The flow based parameters reflect a zonal ptdf, including contingencies, for a preselected set of critical branches under critical outages (cbco) and available capacities (RAM) depending on the chosen basecase. Therefore the optimization type has to be fbmc, for the model to account for a zonal, timedependant ptdf.

Parameters:
flowbased_parameterspandas.DataFrame

Flowbased parameters, derived using FBMCModule

process_ntc()

Process grid information for NTC representation.

This only includes assigning ntc data. However if no data is available, dummy data is generated.

return_cbco(cbco_info, cbco_index)

Return only the cbco’s of the info attribute DataFrame.

Returns:
cbco_infoDataFrame

Slice of the full info attribute, containing filtered contingency ptdfs, based on the cbco indices resulting from the redundancy removal algorithm.

write_cbco_info(folder, suffix, **kwargs)

Write cbco information to disk to run the redundancy removal algorithm.

Parameters:
folderpathlib.Path

Save file to the specified folder.

suffixstr

A suffix for each file, to make it recognizable.