netallocation.grid module¶
This module comprises all electricity grid relevant functions.
- netallocation.grid.Cycles(n, branches_i=None)[source]¶
Light-weight function for finding all cycles a given network.
- netallocation.grid.Incidence(n, branch_components=None, sparse=False)[source]¶
Calculate the Incidence matrix for a given networ with given branch components.
- Parameters
n (pypsa.Netowrk) –
branch_components (list, optional) – List of branch components to be included in the Incidence matris. The default is None results in n.branch_components.
sparse (bool, optional) – Whether the resulting data should be sparse or not. The default is False.
- Returns
K – Incidence matrix with dimensions N (#buses) x L (#branches).
- Return type
xr.DataArray
- netallocation.grid.PTDF(n, branch_components=None, snapshot=None, pu_system=True, update=True)[source]¶
Calculate the Power Tranfer Distribution Factors (PTDF)
If branch_component and snapshots is None (default), they are set to n.branch_components and n.snapshots respectively.
If branch_components includes ‘Link’ the time-dependent PTDF matrix is calculated on the basis of the flow-dependent pseudo-impedance (only works for solved networks, see
impedance()
).
- netallocation.grid.Ybus(n, branch_components=None, snapshot=None, pu_system=True, linear=True)[source]¶
Calculate the Ybub matrix (or weighited Laplacian) for a given network for given branch_components.
If branch_component and snapshots is None (default), they are set to n.branch_components and n.snapshots respectively.
If ‘Link’ is included in branch_components, then their weightings are derived from their current pseudo-impedance dependent on the current flow (see
impedance()
).
- netallocation.grid.Zbus(n, branch_components=None, snapshot=None, pu_system=True, linear=True)[source]¶
Calculate the Zbus matrix for given branch_components.
If branch_component and snapshots is None (default), they are set to n.branch_components and n.snapshots respectively.
If branch_components includes ‘Link’ the time-dependent Zbus matrix is calculated on the basis of the flow-dependent pseudo-impedance (only works for solved networks, see
impedance()
).
- netallocation.grid.admittance(n, branch_components=None, snapshot=None, pu_system=True, linear=True)[source]¶
Calculate the series admittance. This is the inverse of the impedance, see
impedance()
for further information.
- netallocation.grid.branch_inflow(n, snapshots=None, branch_components=None, linear=True)[source]¶
Calculate the flow that goes into a branch.
If branch_component and snapshots is None (default), they are set to n.branch_components and n.snapshots respectively.
- netallocation.grid.branch_outflow(n, snapshots=None, branch_components=None, linear=True)[source]¶
Determine the flow that comes out of a branch.
If branch_component and snapshots is None (default), they are set to n.branch_components and n.snapshots respectively.
- netallocation.grid.energy_demand(n, snapshots=None, per_carrier=False, update=False)[source]¶
Calculate the gross energy consumption per bus and optionally carrier.
- Parameters
n (pypsa.Network) –
snapshots (subset of n.snapshots, default None) – If None, all snapshots are taken.
per_carrier (bool, optional) – Whether to calculate the power demand per bus and carrier. The default is False.
update (bool, optional) – Whether to recalculate cashed data. The default is False.
- Returns
- Return type
Energy demand data with dimensions snapshot, bus, carrier (optionally)
- netallocation.grid.energy_production(n, snapshots=None, per_carrier=False, update=False)[source]¶
Calculate the gross energy production per bus (and carrier).
- Parameters
n (pypsa.Network) –
snapshots (subset of n.snapshots, default None) – If None, all snapshots are taken.
per_carrier (bool, optional) – Whether to calculate the power production per bus and carrier. The default is False.
update (bool, optional) – Whether to recalculate cashed data. The default is False.
- Returns
- Return type
Produced energy data with dimensions snapshot, bus, carrier (optionally)
- netallocation.grid.impedance(n, branch_components=None, snapshot=None, pu_system=True, linear=True, skip_pre=False)[source]¶
Calculate the impedance of the network branches.
Naturally the impdance of controllable branches is not existent. However, in https://www.preprints.org/manuscript/202001.0352/v1 a method was presented how to calculate the impendance of controllable branches if they were passive AC lines. If ‘Link’ is included in branch_components, the flow-dependent pseudo-impedance is calculated based on the formulation presented in the paper. Note that in this case the flow must be given for all branches.
- Parameters
n (pypsa.Network) –
branch_components (list, optional) – List of branch components. The default None results in n.passive_branch_components.
snapshot (str/pd.Timestamp, optional) – Only relevant if ‘Link’ in branch_components. The default None results in the first snapshot of n.
pu_system (bool, optional) – Whether the use the per uni system for the impendance. The default is True.
linear (bool, optional) – Whether to use the linear approximation. The default is True.
skip_pre (bool, optional) – Whether to calcuate dependent quantities beforehand. The default is False.
- Returns
z – Impedance for each branch in branch_components.
- Return type
xr.DataArray
- netallocation.grid.network_flow(n, snapshots=None, branch_components=None, ingoing=True, linear=True)[source]¶
Get the flow of the network on given branch_components for given snapshots.
If branch_component and snapshots is None (default), they are set to n.branch_components and n.snapshots respectively.
- netallocation.grid.network_injection(n, snapshots=None, branch_components=None, linear=True)[source]¶
Determine the total network injection including passive and active branches.
If branch_component and snapshots is None (default), they are set to n.branch_components and n.snapshots respectively.
- netallocation.grid.power_demand(n, snapshots=None, per_carrier=False, update=False)[source]¶
Calculate the gross power consumption per bus and optionally carrier.
- Parameters
n (pypsa.Network) –
snapshots (subset of n.snapshots, default None) – If None, all snapshots are taken.
per_carrier (bool, optional) – Whether to calculate the power demand per bus and carrier. The default is False.
update (bool, optional) – Whether to recalculate cashed data. The default is False.
- Returns
prod – Power demand data with dimensions snapshot, bus, carrier (optionally).
- Return type
xr.DataArray
- netallocation.grid.power_production(n, snapshots=None, per_carrier=False, update=False)[source]¶
Calculate the gross power production per bus and optionally carrier.
- Parameters
n (pypsa.Network) –
snapshots (subset of n.snapshots, default None) – If None, all snapshots are taken.
per_carrier (bool, optional) – Whether to calculate the power production per bus and carrier. The default is False.
update (bool, optional) – Whether to recalculate cashed data. The default is False.
- Returns
prod – Power production data with dimensions snapshot, bus, carrier (optionally).
- Return type
xr.DataArray
- netallocation.grid.self_consumption(n, snapshots=None, update=False)[source]¶
Calculate the self consumed power, i.e. power that is not injected in the network and consumed by the bus itself
- netallocation.grid.series_shunt_admittance(n, pu_system=True, branch_components=None)[source]¶
Get the series shunt admittance.