Networks#

Network#

Constructor#

class pypsa.Network(import_name: str | Path = '', name: str = 'Unnamed Network', ignore_standard_types: bool = False, override_components: DataFrame | None = None, override_component_attrs: Dict | None = None, **kwargs: Any)#

Network container for all buses, one-ports and branches.

General methods#

static(component_name)

Return the DataFrame of static components for component_name.

df(component_name)

Alias for [n.static][pypsa.Network.static].

dynamic(component_name)

Return the dictionary of DataFrames of varying components.

pnl(component_name)

Alias for [n.dynamic][pypsa.Network.dynamic].

to_crs(new)

Convert the network's geometries and bus coordinates to a new crs.

set_snapshots(snapshots[, ...])

Set the snapshots/time steps and reindex all time-dependent data.

set_investment_periods(periods)

Set the investment periods of the network.

add(class_name, name[, suffix, overwrite])

Add components to the network.

madd(class_name, names[, suffix])

Add multiple components to the network, along with their attributes.

remove(class_name, name[, suffix])

Remove a single component or a list of components from the network.

mremove(class_name, names)

Remove multiple components from the network.

copy([snapshots, investment_periods, ...])

Return a deep copy of Network object.

equals(other[, log_mode])

Check for equality of two networks.

branches()

Get branches.

passive_branches()

Get passive branches.

controllable_branches()

Get controllable branches.

determine_network_topology([...])

Build sub_networks from topology.

iterate_components([components, skip_empty])

Iterate over components.

consistency_check([check_dtypes, strict])

Check network for consistency.

Attributes#

meta

Dictionary of the network meta data.

crs

Coordinate reference system of the network's geometries.

srid

Spatial reference system identifier of the network's geometries.

snapshots

Snapshots dimension of the network.

snapshot_weightings

Weightings applied to each snapshots during the optimization (LOPF).

investment_periods

Periods level of snapshots dimension.

investment_period_weightings

Weightings applied to each investment period during the optimization (LOPF).

Input and output methods#

merge(other[, components_to_skip, inplace, ...])

Merge the components of two networks.

import_from_csv_folder(path[, encoding, ...])

Import network data from CSVs in a folder.

export_to_csv_folder(path[, encoding, ...])

Export network and components to a folder of CSVs.

import_from_excel(path[, skip_time, engine])

Import network data from an Excel file.

export_to_excel(path[, ...])

Export network and components to an Excel file.

import_from_hdf5(path[, skip_time])

Import network data from HDF5 store at path.

export_to_hdf5(path[, export_standard_types])

Export network and components to an HDF store.

import_from_netcdf(path[, skip_time])

Import network data from netCDF file or xarray Dataset at path.

export_to_netcdf([path, ...])

Export network and components to a netCDF file.

import_from_pypower_ppc(ppc[, ...])

Import network from PYPOWER PPC dictionary format version 2.

import_from_pandapower_net(net[, ...])

Import PyPSA network from pandapower net.

import_components_from_dataframe(dataframe, ...)

Import components from a pandas DataFrame.

import_series_from_dataframe(dataframe, ...)

Import time series from a pandas DataFrame.

Power flow methods#

Also see Power Flow for all power flow functions.

calculate_dependent_values()

Calculate per unit impedances and append voltages to lines and shunt impedances.

lpf([snapshots, skip_pre])

Linear power flow for generic network.

pf([snapshots, skip_pre, x_tol, use_seed, ...])

Full non-linear power flow for generic network.

Contingency analysis#

See Contingency Analysis.

Clustering methods#

See Clustering.

Optimization methods#

See Optimisation.

Statistics methods#

See Statistics.

Plotting methods#

See Plots.

Graph methods#

graph([branch_components, weight, ...])

Build NetworkX graph.

adjacency_matrix([branch_components, ...])

Construct a sparse adjacency matrix (directed).

incidence_matrix([branch_components, busorder])

Construct a sparse incidence matrix (directed).

Descriptor methods#

get_committable_i(c)

Getter function.

get_extendable_i(c)

Getter function.

get_switchable_as_dense(component, attr[, ...])

Return a Dataframe for a time-varying component attribute .

get_non_extendable_i(c)

Getter function.

get_active_assets(c[, investment_period])

Get active components mask of component type in investment period(s).

Sub-Network#

Constructor#

class pypsa.SubNetwork(n: Network, name: str)#

SubNetwork for electric buses (AC or DC).

SubNetworks are generated by n.determine_network_topology() for electric buses with passive flows or isolated non-electric buses.

methods#

adjacency_matrix([branch_components, ...])

Construct a sparse adjacency matrix (directed).

branches()

Get the branches in the sub-network.

branches_i([active_only])

Get the index of the branches in the sub-network.

buses()

Get the buses in the sub-network.

buses_i()

Get the index of the buses in the sub-network.

calculate_BODF([skip_pre])

Calculate the Branch Outage Distribution Factor (BODF) for sub_network.

calculate_B_H([skip_pre])

Calculate B and H matrices for AC or DC sub-networks.

calculate_PTDF([skip_pre])

Calculate the Power Transfer Distribution Factor (PTDF) for sub_network.

calculate_Y([skip_pre, active_branches_only])

Calculate bus admittance matrices for AC sub-networks.

find_bus_controls()

Find slack and all PV and PQ buses for a sub_network.

find_slack_bus()

Find the slack bus in a connected sub-network.

generators()

Get the generators in the sub-network.

generators_i()

Get the index of the generators in the sub-network.

graph([branch_components, weight, ...])

Build NetworkX graph.

incidence_matrix([branch_components, busorder])

Construct a sparse incidence matrix (directed).

iterate_components([components, skip_empty])

Iterate over components of the sub-network.

lines_i()

Get the index of the lines in the sub-network.

loads()

Get the loads in the sub-network.

loads_i()

Get the index of the loads in the sub-network.

lpf([snapshots, skip_pre])

Linear power flow for connected sub-network.

pf([snapshots, skip_pre, x_tol, use_seed, ...])

Non-linear power flow for connected sub-network.

shunt_impedances()

Get the shunt impedances in the sub-network.

shunt_impedances_i()

Get the index of the shunt impedances in the sub-network.

storage_units()

Get the storage units in the sub-network.

storage_units_i()

Get the index of the storage units in the sub-network.

stores_i()

Get the index of the stores in the sub-network.

transformers_i()

Get the index of the transformers in the sub-network.