netallocation.flow module

Created on Wed Feb 21 12:14:49 2018

@author: fabian

netallocation.flow.average_participation(n, snapshot, dims='all', branch_components=None, aggregated=True, downstream=True, include_self_consumption=True, sparse=False, round=None, dask=False, **kwargs)[source]

Perform a Flow Tracing allocation.

Allocate the network flow in according to the method ‘Average participation’ or ‘Flow tracing’ firstly presented in [1,2]. The algorithm itself is derived from [3]. The general idea is to follow active power flow from source to sink (or sink to source) using the principle of proportional sharing and calculate the partial flows on each line, or to each bus where the power goes to (or comes from).

This method provides two general options:
Downstream:

The flow of each nodal power injection is traced through the network and decomposed the to set of lines/buses on which is flows on/to.

Upstream:

The flow of each nodal power demand is traced (in reverse direction) through the network and decomposed to the set of lines/buses where it comes from.

Note that only one snapshot can be calculated at a time, use flow_allocation to calculate multiple snapshots.

[1] J. Bialek, “Tracing the flow of electricity,”

IEE Proceedings - Generation, Transmission and Distribution, vol. 143, no. 4, p. 313, 1996.

[2] D. Kirschen, R. Allan, G. Strbac, Contributions of individual

generators to loads and flows, Power Systems, IEEE Transactions on 12 (1) (1997) 52–60. doi:10.1109/59.574923.

[3] J. Hörsch, M. Schäfer, S. Becker, S. Schramm, and M. Greiner,

“Flow tracing as a tool set for the analysis of networked large-scale renewable electricity systems,” International Journal of Electrical Power & Energy Systems, vol. 96, pp. 390–397, Mar. 2018.

Parameters
  • n (pypsa.Network) – Network object with valid flow data.

  • snapshot (str, pd.Timestamp) – Specify snapshot which should be investigated. Must be in network.snapshots.

  • branch_components (list) – Components for which the allocation should be calculated. The default is None, which results in n.branch_components.

  • dims (list or string) – list of dimensions to be included, if set to “all”, the full dimensions are calculated [‘source’, ‘branch’, ‘sink’]

  • downstream (Boolean, default True) – Whether to use downstream or upstream method for performing the flow-tracing.

  • aggregated (boolean, defaut True) – Within the aggregated coupling scheme (obtained if set to True), power production and demand are ‘aggregated’ within the corresponding bus. Therefore only the net surplus or net deficit of a bus is allocated to other buses. Within the direct coupling scheme (if set to False), production and demand are considered independent of the bus, therefore the power production and demand are allocated to all buses at the same time. Even if a bus has net deficit, its power production can be allocated to other buses.

  • include_self_consumption (boolean, default True) – Whether to include self consumption of each buses within the aggregated coupling scheme.

  • sparse (boolean, default False) – Whether to compute the allocation with sparse arrays, this can save time for large networks

  • round (float, default None) – Round the resulting allocation to a given precision in decimal digits.

netallocation.flow.equivalent_bilateral_exchanges(n, snapshot=None, branch_components=None, aggregated=True, q=0.5, sparse=False, round=None, dask=False, **kwargs)[source]

Perform a Equivalent Bilateral Exchanges allocation.

Calculate the load flow induced by individual power sources in the network ignoring other sources and scaling down sinks. The sum of the resulting flow of those virtual injection patters is the total network flow. This method matches the ‘Marginal participation’ method for q = 1. Return either Virtual Injection Patterns if vip is set to True, or Virtual Flow Patterns. Note that only one snapshot can be calculated at a time, use flow_allocation to calculate multiple snapshots.

Parameters
  • n (pypsa.Network) – Network object with valid flow data.

  • snapshot (str, pd.Timestamp) – Specify snapshot which should be investigated. Must be in network.snapshots.

  • branch_components (list) – Components for which the allocation should be calculated. The default is None, which results in n.branch_components.

  • aggregated (boolean, defaut True) – Within the aggregated coupling scheme (obtained if set to True), power production and demand are ‘aggregated’ within the corresponding bus. Therefore only the net surplus or net deficit of a bus is allocated to other buses. Within the direct coupling scheme (if set to False), production and demand are considered independent of the bus, therefore the power production and demand are allocated to all buses at the same time. Even if a bus has net deficit, its power production can be allocated to other buses.

  • round (float, default None) – Round the resulting allocation to a given precision in decimal digits.

netallocation.flow.flow_allocation(n, snapshots=None, method='Average participation', to_netcdf=None, round_floats=8, **kwargs)[source]

Allocate or decompose the network flow with different methods.

Available methods are ‘Average participation’ (‘ap’), ‘Marginal participation’ (‘mp’), ‘Virtual injection pattern’ (‘vip’), ‘Zbus transmission’ (‘zbus’).

Parameters
  • n (pypsa.Network) – Network object with valid flow data.

  • snapshots (string or pandas.DatetimeIndex) – (Subset of) snapshots of the network. If None (dafault) all snapshots are taken.

  • per_bus (Boolean, default is False) – Whether to allocate the flow in an peer-to-peeer manner,

  • method (string) –

    Type of the allocation method. Should be one of

    • ’Average participation’/’ap’:

      Trace the active power flow from source to sink (or sink to source) using the principle of proportional sharing and calculate the partial flows on each line, or to each bus where the power goes to (or comes from).

    • ’Marginal participation’/’mp’:

      Allocate line flows according to linear sensitvities of nodal power injection given by the changes in the power transfer distribution factors (PTDF)

    • ’Equivalent bilateral exchanges’/’ebe’

      Sequentially calculate the load flow induced by individual power sources in the network ignoring other sources and scaling down sinks.

    • ’Zbus transmission’/’zbus’

Returns

res – Dataset with allocations depending on the method.

Return type

xr.Dataset

netallocation.flow.marginal_participation(n, snapshot=None, q=0.5, branch_components=None, sparse=False, round=None, aggregated=True, dask=False, **kwargs)[source]

Perform a Marginal Participation allocation.

Allocate line flows according to linear sensitvities of nodal power injection given by the changes in the power transfer distribution factors (PTDF)[1-3]. As the method is based on the DC-approximation, it works on subnetworks only as link flows are not taken into account. This method does not exclude counter flows. Note that only one snapshot can be calculated at a time, use flow_allocation to calculate multiple snapshots.

[1] F. J. Rubio-Oderiz, I. J. Perez-Arriaga, Marginal pricing of

transmission services: a comparative analysis of network cost allocation methods, IEEE Transactions on Power Systems 15 (1) (2000) 448–454. doi:10.1109/59.852158.

[2] M. Schäfer, B. Tranberg, S. Hempel, S. Schramm, M. Greiner,

Decompositions of injection patterns for nodal flow allocation in renewable electricity networks, The European Physical Journal B 90 (8) (2017) 144.

[3] T. Brown, “Transmission network loading in Europe with high

shares of renewables,” IET Renewable Power Generation, vol. 9, no. 1, pp. 57–65, Jan. 2015.

Parameters
  • n (pypsa.Network) – Network object with valid flow data.

  • snapshot (str, pd.Timestamp) – Specify snapshot which should be investigated. Must be in network.snapshots.

  • branch_components (list) – Components for which the allocation should be calculated. The default is None, which results in n.branch_components.

  • q (float, default 0.5) – split between net producers and net consumers. If q is zero, only the impact of net load is taken into account. If q is one, only net generators are taken into account.

  • aggregated (boolean, defaut True) – Within the aggregated coupling scheme (obtained if set to True), power production and demand are ‘aggregated’ within the corresponding bus. Therefore only the net surplus or net deficit of a bus is allocated to other buses. Within the direct coupling scheme (if set to False), production and demand are considered independent of the bus, therefore the power production and demand are allocated to all buses at the same time. Even if a bus has net deficit, its power production can be allocated to other buses.

  • round (float, default None) – Round the resulting allocation to a given precision in decimal digits.

netallocation.flow.marginal_welfare_contribution(n, snapshots=None, formulation='kirchhoff', return_networks=False)[source]
netallocation.flow.post_tracing_power_flow(n, snapshot, branch_components=None, aggregated=True, downstream=True, include_self_consumption=True, sparse=False, round=9, dask=False, **kwargs)[source]

Perform a allocation.

Allocate the source and sinks in according to the method ‘Average participation’ or ‘Flow tracing’. In a second step the flow in calculated by applying the PTDF to the pairs of sinks and sources

This method provides two general options:
Downstream:

The flow of each nodal power injection is traced through the network and decomposed the to set of lines/buses on which is flows on/to.

Upstream:

The flow of each nodal power demand is traced (in reverse direction) through the network and decomposed to the set of lines/buses where it comes from.

Note that only one snapshot can be calculated at a time, use flow_allocation to calculate multiple snapshots.

Parameters
  • n (pypsa.Network) – Network object with valid flow data.

  • snapshot (str, pd.Timestamp) – Specify snapshot which should be investigated. Must be in network.snapshots.

  • branch_components (list) – Components for which the allocation should be calculated. The default is None, which results in n.branch_components.

  • downstream (Boolean, default True) – Whether to use downstream or upstream method for performing the flow-tracing.

  • aggregated (boolean, defaut True) – Within the aggregated coupling scheme (obtained if set to True), power production and demand are ‘aggregated’ within the corresponding bus. Therefore only the net surplus or net deficit of a bus is allocated to other buses. Within the direct coupling scheme (if set to False), production and demand are considered independent of the bus, therefore the power production and demand are allocated to all buses at the same time. Even if a bus has net deficit, its power production can be allocated to other buses.

  • include_self_consumption (boolean, default True) – Whether to include self consumption of each buses within the aggregated coupling scheme.

  • sparse (boolean, default False) – Whether to compute the allocation with sparse arrays, this can save time for large networks

  • round (float, default None) – Round the resulting allocation to a given precision in decimal digits.

netallocation.flow.with_and_without_transit(n, snapshots=None, branch_components=None)[source]

Compute the with-and-without flows and losses.

This function only works with the linear power so far and calculated the loss which would take place accoring to

f²⋅r

which is the loss for directed currents. If links are included their efficiency determines the loss.

Parameters
  • n (pypsa.Network) – Network object with valid flow data.

  • snapshots (pd.Index or list) – Snapshots for which the flows and losses are calculated. Thye must be a subset of n.snapshots. The default is None, which results in n.snapshots.

  • branch_components (list) – Components for which the allocation should be calculated. The default is None, which results in n.passive_branch_components.

Returns

Resulting loss allocation of dimension {branch, country, snapshot} with variables [flow_with, loss_with, flow_without, loss_without].

Return type

xarray.Dataset

netallocation.flow.zbus_transmission(n, snapshot=None, linear=True, downstream=None, branch_components=None, **kwargs)[source]

Perform a Zbus Transmission allocation.

This allocation builds up on the method presented in [1]. However, we provide for non-linear power flow an additional DC-approximated modification, neglecting the series resistance r for lines.

[1] A. J. Conejo, J. Contreras, D. A. Lima, and A. Padilha-Feltrin,

“$Z_{rm bus}$ Transmission Network Cost Allocation,” IEEE Transactions on Power Systems, vol. 22, no. 1, pp. 342–349, Feb. 2007.

Parameters
  • n (pypsa.Network) – Network object with valid flow data.

  • snapshot (str, pd.Timestamp, list, pd.Index) – Specify snapshot(s) for which the allocation should be performed. Must be a suset of n.snapshots.

  • branch_components (list) – Components for which the allocation should be calculated. The default is None, which results in n.branch_components.