Skip to content

Buses dataclass ΒΆ

Buses(ctype: ComponentType, n: Network | None = None, names: str | int | Sequence[int | str] | None = None, suffix: str = '')

Bases: Components


              flowchart TD
              pypsa.components.Buses[Buses]
              pypsa.components.components.Components[Components]
              pypsa.components.components.ComponentsData[ComponentsData]
              pypsa.components.descriptors.ComponentsDescriptorsMixin[ComponentsDescriptorsMixin]
              pypsa.components.transform.ComponentsTransformMixin[ComponentsTransformMixin]
              pypsa.components.index.ComponentsIndexMixin[ComponentsIndexMixin]
              pypsa.components.array.ComponentsArrayMixin[ComponentsArrayMixin]
              pypsa.components.abstract._ComponentsABC[_ComponentsABC]

                              pypsa.components.components.Components --> pypsa.components.Buses
                                pypsa.components.components.ComponentsData --> pypsa.components.components.Components
                
                pypsa.components.descriptors.ComponentsDescriptorsMixin --> pypsa.components.components.Components
                                pypsa.components.abstract._ComponentsABC --> pypsa.components.descriptors.ComponentsDescriptorsMixin
                

                pypsa.components.transform.ComponentsTransformMixin --> pypsa.components.components.Components
                
                pypsa.components.index.ComponentsIndexMixin --> pypsa.components.components.Components
                                pypsa.components.abstract._ComponentsABC --> pypsa.components.index.ComponentsIndexMixin
                

                pypsa.components.array.ComponentsArrayMixin --> pypsa.components.components.Components
                                pypsa.components.abstract._ComponentsABC --> pypsa.components.array.ComponentsArrayMixin
                




              click pypsa.components.Buses href "" "pypsa.components.Buses"
              click pypsa.components.components.Components href "" "pypsa.components.components.Components"
              click pypsa.components.components.ComponentsData href "" "pypsa.components.components.ComponentsData"
              click pypsa.components.descriptors.ComponentsDescriptorsMixin href "" "pypsa.components.descriptors.ComponentsDescriptorsMixin"
              click pypsa.components.transform.ComponentsTransformMixin href "" "pypsa.components.transform.ComponentsTransformMixin"
              click pypsa.components.index.ComponentsIndexMixin href "" "pypsa.components.index.ComponentsIndexMixin"
              click pypsa.components.array.ComponentsArrayMixin href "" "pypsa.components.array.ComponentsArrayMixin"
              click pypsa.components.abstract._ComponentsABC href "" "pypsa.components.abstract._ComponentsABC"
            

Buses components class.

This class is used for bus components. All functionality specific to buses is implemented here. Functionality for all components is implemented in the abstract base class.

See Also

pypsa.Components

Examples:

>>> n.components.buses
'Bus' Components
----------------
Attached to PyPSA Network 'AC-DC-Meshed'
Components: 9

Methods:

  • add –

    Add new buses.

  • add_missing_buses –

    Add buses that are referenced by components but not yet defined.

pypsa.components.Buses.add ΒΆ

add(name: str | int | Sequence[int | str], suffix: str = '', overwrite: bool = False, return_names: bool | None = None, **kwargs: Any) -> Index | None

Add new buses.

v0.33.0

Handles addition of single and multiple components along with their attributes. Pass a list of names to add multiple components at once or pass a single name to add a single component.

When a single component is added, all non-scalar attributes are assumed to be time-varying and indexed by snapshots. When multiple components are added, all non-scalar attributes are assumed to be static and indexed by names. A single value sequence is treated as scalar and broadcasted to all components. It is recommended to explicitly pass a scalar instead. If you want to add time-varying attributes to multiple components, you can pass a 2D array/ DataFrame where the first dimension is snapshots and the second dimension is names.

Any attributes which are not specified will be given the default value from Components.

Parameters:

  • name (str or int or list of str or list of int) –

    Component name(s)

  • suffix (str, default: "" ) –

    All components are named after name with this added suffix.

  • overwrite (bool, default: False ) –

    If True, existing components with the same names as in name will be overwritten. Otherwise only new components will be added and others will be ignored.

  • return_names (bool | None, default: None ) –

    Whether to return the names of the new components. Defaults to module wide option (default: False). See https://go.pypsa.org/options-params for more information.

  • kwargs (Any, default: {} ) –

    Component attributes to add. See Other Parameters for list of default attributes but any attribute could be added.

Other Parameters:

  • v_nom (float or SeriesLike[float]) –

    Nominal voltage

  • type (str or SeriesLike[str]) –

    Placeholder for bus type. Not implemented.

  • x (float or SeriesLike[float]) –

    Longitude; the Spatial Reference System Identifier (SRID) is set in n.srid.

  • y (float or SeriesLike[float]) –

    Latitude; the Spatial Reference System Identifier (SRID) is set in n.srid.

  • carrier (str or SeriesLike[str]) –

    Carrier, such as "AC", "DC", "heat" or "gas".

  • unit (str or SeriesLike[str]) –

    Unit of the bus' carrier if the implicitly assumed unit ("MW") is inappropriate (e.g. "t/h"). Only descriptive. Does not influence any PyPSA functions.

  • location (str or SeriesLike[str]) –

    Location of the bus. Does not influence the optimisation model but can be used for aggregation with n.statistics.

  • v_mag_pu_set (float or Series or SeriesLike[float or Series]) –

    Voltage magnitude set point, per unit of v_nom.

  • v_mag_pu_min (float or SeriesLike[float]) –

    Minimum desired voltage, per unit of v_nom. Placeholder attribute not currently used by any functions.

  • v_mag_pu_max (float or SeriesLike[float]) –

    Maximum desired voltage, per unit of v_nom. Placeholder attribute not currently used by any functions.

  • control (str or SeriesLike[str]) –

    P,Q,V control strategy for power flow, must be "PQ", "PV" or "Slack". Note that this attribute is an output inherited from the controls of the generators attached to the bus. Do not set by hand.

  • generator (str or SeriesLike[str]) –

    Name of slack generator attached to slack bus.

  • sub_network (str or SeriesLike[str]) –

    Name of connected sub-network to which bus belongs. This attribute is set by n.determine_network_topology(). Do not set by hand.

  • p (Series or SeriesLike[Series] or ArrayLike[Series]) –

    active power at bus (positive if net generation at bus)

  • q (Series or SeriesLike[Series] or ArrayLike[Series]) –

    reactive power (positive if net generation at bus)

  • v_mag_pu (Series or SeriesLike[Series] or ArrayLike[Series]) –

    Voltage magnitude, per unit of v_nom

  • v_ang (Series or SeriesLike[Series] or ArrayLike[Series]) –

    Voltage angle

  • marginal_price (Series or SeriesLike[Series] or ArrayLike[Series]) –

    Shadow price from energy balance constraint

Returns:

  • new_names ( index or None ) –

    Names of new components (including suffix) if return_names is True, otherwise None.

Examples:

The example is shown for Generator component, but the same applies to all component types.

>>> n = pypsa.Network()
>>> c = n.components.generators
>>> c
Empty 'Generator' Components

Add a single component:

>>> c.add("my-generator-1", carrier="AC")

A new generator is added to the components instance:

>>> c
'Generator' Components
----------------------
Attached to PyPSA Network 'Unnamed Network'
Components: 1

With static data (and default values for all attributes):

>>> c.static[["carrier", "p_nom"]]
               carrier  p_nom
name
my-generator-1      AC    0.0

Add multiple components with static attributes:

>>> c.add(["my-generator-2", "my-generator-3"],
...       carrier=["AC", "DC"],
...       p_nom=10)

A new generator is added to the components instance:

>>> c
'Generator' Components
----------------------
Attached to PyPSA Network 'Unnamed Network'
Components: 3

With static data:

>>> c.static[["carrier", "p_nom"]]
           carrier  p_nom
name
my-generator-1      AC    0.0
my-generator-2      AC   10.0
my-generator-3      DC   10.0

The single value for p_nom is broadcasted to all components. So you could also pass [10, 10] instead of 10.

See Also

pypsa.Network.add

pypsa.components.Buses.add_missing_buses ΒΆ

add_missing_buses(**kwargs: Any) -> Index

Add buses that are referenced by components but not yet defined.

v1.1.0

Parameters:

  • **kwargs (Any, default: {} ) –

    Additional keyword arguments for new buses (e.g., v_nom, carrier).

Returns:

  • Index –

    Index of newly added bus names.

Examples:

>>> n = pypsa.Network()
>>> n.components.generators.add("my_gen", bus="my_bus")
>>> n.components.buses.add_missing_buses(v_nom=100.0)
Index(['my_bus'], dtype='object')

Buses are added without needing to call n.add separately:

>>> n.components.buses.static
        v_nom type    x    y  ...
name                          ...
my_bus  100.0       0.0  0.0  ...
...