netallocation.cost module

netallocation.cost.allocate_branch_investment_cost(ds, n, proportional=False)[source]

Allocate the branch cost on the basis of an allocation method.

Parameters
  • ds (xarray.Dataset) – Calculated power allocation dataset, i.e. from ntl.allocate_flow.

  • n (pypsa.Network) –

Returns

Allocated branch cost.

Return type

xr.DataArray

netallocation.cost.allocate_branch_operational_cost(ds, n)[source]

Allocate the branch cost on the basis of an allocation method.

Parameters
  • ds (xarray.Dataset) – Calculated power allocation dataset, i.e. from ntl.allocate_flow.

  • n (pypsa.Network) –

Returns

Allocated branch cost.

Return type

xr.DataArray

netallocation.cost.allocate_carrier_attribute(ds, n, attr)[source]

Allocate an carrier attribute on the basis of a peer-to-peer allocation.

Parameters
  • ds (xarray.Dataset) – Calculated power allocation dataset, i.e. from ntl.allocate_flow.

  • n (pypsa.Network) –

  • attr (str/pd.Series/pd.DataFrame) –

Returns

Return type

xr.DataArray

netallocation.cost.allocate_co2_cost(ds, n, dim='source', co2_constr_name=None, co2_attr='co2_emissions', co2_price=None)[source]

Allocate CO2 emission costs on the basis of a peer-to-peer allocation.

Parameters
  • ds (xarray.Dataset) – Calculated power allocation dataset, i.e. from ntl.allocate_flow.

  • n (pypsa.Network) –

  • dim (str, default 'source') – Dimension to which the production costs are associated to, (must contain bus names).

Returns

Allocated generation cost.

Return type

xr.DataArray

netallocation.cost.allocate_cost(n, snapshots=None, method='ap', chunksize=None, **kwargs)[source]

Allocate production cost based on an allocation method.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) –

  • method (str/xarray.Dataset) – Method on which the cost allocation is based. Must be an available method for netallocation.allocate_flow. Alternatively to a string, an calculated allocation xarray.Dataset can be passed.

  • kwargs (dict) – Keyword arguments for flow_allocation(). For operational and capital costs for branches, the allocation default to q=0, meaning that all transmission costs are covered by the sinks. For a 50%-50% split between sinks and sources, set q to 0.5. for transmission cost totally allocated to sources, set q to 1.

Returns

Peer-to-peer cost allocation.

Return type

xarray.DataArray

netallocation.cost.allocate_one_port_investment_cost(ds, n, dim='source', proportional=False)[source]

Allocate investment costs on the basis of a peer-to-peer allocation.

Parameters
  • ds (xarray.Dataset) – Calculated power allocation dataset, i.e. from ntl.allocate_flow.

  • n (pypsa.Network) –

  • dim (str, default 'source') – Dimension to whicht the investment costs are associated to, (must contain bus names).

Returns

Allocated generation cost.

Return type

xr.DataArray

netallocation.cost.allocate_one_port_operational_cost(ds, n, snapshots=None, dim='source')[source]

Allocate production costs on the basis of a peer-to-peer allocation.

Parameters
  • ds (xarray.Dataset) – Calculated power allocation dataset, i.e. from ntl.allocate_flow.

  • n (pypsa.Network) –

  • dim (str, default 'source') – Dimension to whicht the production costs are associated to, (must contain bus names).

Returns

Allocated generation cost.

Return type

xr.DataArray

netallocation.cost.allocate_revenue(n, snapshots=None, chunksize=None, with_cycle_prices=False, **kwargs)[source]

Allocate the market revenue per asset based Average Participation.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) –

  • method (str/xarray.Dataset) – Method on which the revenue allocation is based. Must be an available method for netallocation.allocate_flow. Alternatively to a string, an calculated allocation xarray.Dataset can be passed.

  • kwargs (dict) – Keyword arguments for flow_allocation(). For operational and capital costs for branches, the allocation default to q=0, meaning that all transmission costs are covered by the sinks. For a 50%-50% split between sinks and sources, set q to 0.5. for transmission cost totally allocated to sources, set q to 1.

Returns

Peer-to-peer cost allocation.

Return type

xarray.DataArray

netallocation.cost.congestion_revenue(n, snapshots=None, split=False)[source]

Calculate the congestion revenue (CR) per brnach and snapshot. The CR includes all costs of the transmission system. The sum over all snapshots of this is equal to the capital investments per branch.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

  • split (bool, optional) – If True, two CRs are returned, one indicating the renvenue for extendable branches, one for non-extendable branches.

Returns

Congestion Revenue, dimension {snapshot, branch}.

Return type

xr.DataArray

netallocation.cost.cycle_constraint_cost(n, snapshots=None)[source]

Calculate the cost per branch and snapshot for the cycle constraint

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

Returns

Cycle cost for passive branches, dimension {snapshot, branch}.

Return type

xr.DataArray

netallocation.cost.cycle_constraint_price(n, snapshots=None)[source]

Calculate the cost per branch and snapshot for the cycle constraint

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

Returns

Cycle cost for passive branches, dimension {snapshot, branch}.

Return type

xr.DataArray

netallocation.cost.locational_market_price(n, snapshots=None)[source]

Get the locational market price (LMP) of 1 MWh in a solved network.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

Returns

ma – Marginal Price for dimensions {bus, snapshot}.

Return type

xr.DataArray

netallocation.cost.locational_market_price_diff(n, snapshots=None)[source]
netallocation.cost.nodal_co2_cost(n, snapshots=None, co2_attr='co2_emissions', co2_constr_name=None, split=False)[source]

Calculate the total system cost caused by the CO2 constraint.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

  • co2_attr (str, optional) – Name of the co2 emission attribut in n.carriers. The default is ‘co2_emissions’.

  • co2_constr_name (str, optional) – Name of the CO2 limit constraint in n.global_constraint. The default is None will lead to searching for constraints which contain the strings “CO2” and “Limit”.

netallocation.cost.nodal_co2_price(n, snapshots=None, co2_attr='co2_emissions', co2_constr_name=None, price=None)[source]

Get the CO2 price per MWh_el.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

  • co2_attr (str, optional) – Name of the co2 emission attribut in n.carriers. The default is ‘co2_emissions’.

  • co2_constr_name (str, optional) – Name of the CO2 limit constraint in n.global_constraint. The default is None will lead to searching for constraints which contain the strings “CO2” and “Limit”.

netallocation.cost.nodal_demand_cost(n, snapshots=None)[source]

Calculate the nodal demand cost per bus and snapshot.

This is calculated by the product of power demand times the marginal price.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

netallocation.cost.nodal_production_revenue(n, snapshots=None, split=False, per_carrier=False)[source]

Calculate the nodal production revenue per bus and snapshot.

This is calculated by the product of power production times the marginal price.

Parameters
  • n (pypsa.Network) –

  • snapshots (subset of n.snapshots) – The default None results in taking all snapshots of n.

netallocation.cost.objective_constant(n)[source]