Skip to content

StorageUnits dataclass

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

Bases: Components


              flowchart TD
              pypsa.components.StorageUnits[StorageUnits]
              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.StorageUnits
                                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.StorageUnits href "" "pypsa.components.StorageUnits"
              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"
            

StorageUnits components class.

This class is used for storage unit components. All functionality specific to storage units is implemented here. Functionality for all components is implemented in the abstract base class.

See Also

pypsa.Components

Examples:

>>> n.components.storage_units
Empty 'StorageUnit' Components

Methods:

  • add

    Add new storage_units.

  • get_bounds_pu

    Get per unit bounds for storage units.

pypsa.components.StorageUnits.add

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

Add new storage_units.

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:

  • bus (str or SeriesLike[str]) –

    Name of bus to which storage unit is attached.

  • control (str or SeriesLike[str]) –

    P,Q,V control strategy for PF, must be "PQ", "PV" or "Slack".

  • type (str or SeriesLike[str]) –

    Placeholder for storage unit type. Not yet implemented.

  • p_nom (float or SeriesLike[float]) –

    Nominal power for limits on p in optimisation. Ignored if p_nom_extendable=True.

  • p_nom_mod (float or SeriesLike[float]) –

    Nominal power of the storage unit module. Introduces integer variables if set.

  • p_nom_extendable (bool or SeriesLike[bool]) –

    Switch to allow capacity p_nom to be extended in optimisation.

  • p_nom_min (float or SeriesLike[float]) –

    If p_nom_extendable=True, set the minimum value of p_nom_opt.

  • p_nom_max (float or SeriesLike[float]) –

    If p_nom_extendable=True, set the maximum value of p_nom_opt.

  • p_nom_set (float or SeriesLike[float]) –

    If p_nom_extendable=True, set the value of p_nom_opt.

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

    The minimum output for each snapshot per unit of p_nom for the optimisation. Negative sign implies storing mode withdrawing power from bus.

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

    The maximum output for each snapshot per unit of p_nom for the optimisation. Positive sign implies discharging mode injecting power into bus.

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

    Active power set point. Sets p directly in power flow. In LOPF optimisation constrains net power (p_dispatch - p_store)

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

    Reactive power set point (for power flow only)

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

    Active power dispatch set point (for optimisation only)

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

    Active power charging set point (for optimisation only)

  • sign (float or SeriesLike[float]) –

    Sign denoting the orientation of the dispatch variable.

  • carrier (str or SeriesLike[str]) –

    Prime mover energy carrier (e.g. coal, gas, wind, solar); required for global constraints on primary energy in optimisation

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

    Cost of spilling 1 MWh

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

    Marginal cost of production (discharge) of 1 MWh.

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

    Quadratic marginal cost of production (discharge) of 1 MWh.

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

    Marginal cost of energy storage of 1 MWh for one hour.

  • capital_cost (float or SeriesLike[float]) –

    Fixed period costs of extending p_nom by 1 MW (e.g. annuitized investment costs). Used directly unless overnight_cost is specified.

  • overnight_cost (float or SeriesLike[float]) –

    Overnight (upfront) investment cost per MW. If specified, PyPSA calculates annuity using discount_rate and lifetime. Takes precedence over capital_cost.

  • discount_rate (float or SeriesLike[float]) –

    Discount rate for annuity calculation when using overnight_cost. Supports 0% rate (simple depreciation).

  • fom_cost (float or SeriesLike[float]) –

    Fixed period operation and maintenance costs per MW, added to annuitized investment cost.

  • active (bool or SeriesLike[bool]) –

    Whether to consider the component in optimisation or not

  • build_year (int or SeriesLike[int]) –

    Build year

  • lifetime (float or SeriesLike[float]) –

    Lifetime

  • state_of_charge_initial (float or SeriesLike[float]) –

    State of charge before the snapshots in the optimisation.

  • state_of_charge_initial_per_period (bool or SeriesLike[bool]) –

    Switch: if True, the state of charge at the beginning of an investment period is set to state_of_charge_initial.

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

    State of charge set points for snapshots in the optimisation.

  • cyclic_state_of_charge (bool or SeriesLike[bool]) –

    Switch: if True, then state_of_charge_initial is ignored and the initial state of charge is set to the final state of charge for the group of snapshots in the optimisation (soc[-1] = soc[len(snapshots)-1]).

  • cyclic_state_of_charge_per_period (bool or SeriesLike[bool]) –

    Switch: if True, the cyclic constraints are applied to each investment period separately.

  • max_hours (float or SeriesLike[float]) –

    Maximum state of charge capacity in terms of hours at full output power capacity p_nom

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

    Efficiency of storage on the way into the storage.

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

    Efficiency of storage on the way out of the storage.

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

    Losses per hour to state of charge.

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

    Inflow to the state of charge (e.g. due to river inflow in hydro reservoir).

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

    Active power at bus (positive if net generation)

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

    Active power dispatch at bus

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

    Active power charging at bus

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

    Reactive power (positive if net generation)

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

    State of charge as calculated by the optimisation.

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

    Spillage for each snapshot (e.g. hydro-dam letting water flow over the spillway without generating electricity).

  • p_nom_opt (float or SeriesLike[float]) –

    Optimised nominal power.

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

    Shadow price of upper p_nom limit

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

    Shadow price of lower p_nom limit

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

    Shadow price of fixed state of charge state_of_charge_set

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

    Shadow price of storage consistency equations

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.StorageUnits.get_bounds_pu

get_bounds_pu(attr: str = 'p_store') -> tuple[DataArray, DataArray]

Get per unit bounds for storage units.

v1.0.0

Parameters:

  • attr (string, default: 'p_store' ) –

    Attribute name for the bounds, e.g. "p", "p_store", "state_of_charge"

Returns:

  • tuple[DataArray, DataArray]

    Tuple of (min_pu, max_pu) DataArrays.