Skip to content

Stores dataclass

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

Bases: Components


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

Stores components class.

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

Examples:

>>> n.components.stores
Empty 'Store' Components
See Also

pypsa.Components

Methods:

pypsa.components.Stores.add

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

Add new stores.

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 store is attached.

  • type (str or SeriesLike[str]) –

    Placeholder for store type. Not yet implemented.

  • carrier (str or SeriesLike[str]) –

    Carrier of the store.

  • e_nom (float or SeriesLike[float]) –

    Nominal energy capacity (i.e. limit on e). Ignored if e_nom_extendable=True.

  • e_nom_mod (float or SeriesLike[float]) –

    Nominal energy capacity of the store module. Introduces integer variables if set.

  • e_nom_extendable (bool or SeriesLike[bool]) –

    Switch to allow capacity e_nom to be extended in optimisation.

  • e_nom_min (float or SeriesLike[float]) –

    If e_nom_extendable=True, set the minimum value of e_nom_opt.

  • e_nom_max (float or SeriesLike[float]) –

    If e_nom_extendable=True, set the maximum value of e_nom_opt.

  • e_nom_set (float or SeriesLike[float]) –

    If e_nom_extendable=True, set the value of e_nom_opt.

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

    Minimal value of e relative to e_nom for the optimisation.

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

    Maximal value of e relative to e_nom for the optimisation.

  • e_initial (float or SeriesLike[float]) –

    Energy before the snapshots in the optimisation.

  • e_initial_per_period (bool or SeriesLike[bool]) –

    Switch: if True, then at the beginning of each investment period e is set to e_initial.

  • e_cyclic (bool or SeriesLike[bool]) –

    Switch: if True, then e_initial is ignored and the initial energy is set to the final energy for the group of snapshots in the optimisation.

  • e_cyclic_per_period (bool or SeriesLike[bool]) –

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

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

    Active power set point (for optimisation and power flow)

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

    Reactive power set point (for power flow only)

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

    Fixed energy filling level set point (for optimisation only)

  • sign (float or SeriesLike[float]) –

    Sign denoting orientation of the energy variable (e).

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

    Marginal cost applied to both charging and discharging of 1 MWh.

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

    Quadratic marginal cost of applied to charging and discharging 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 e_nom by 1 MWh (e.g. annuitized investment costs). Used directly unless overnight_cost is specified.

  • overnight_cost (float or SeriesLike[float]) –

    Overnight (upfront) investment cost per MWh. 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 MWh, added to annuitized investment cost.

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

    Losses per hour to energy level.

  • 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

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

    Power at bus (positive if net supply)

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

    Reactive power (positive if net supply)

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

    Energy level of store as calculated by the optimisation.

  • e_nom_opt (float or SeriesLike[float]) –

    Optimised nominal energy capacity outputed by optimisation.

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

    Shadow price of upper e_nom limit

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

    Shadow price of lower e_nom limit

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

    Shadow price of storage consistency equations (i.e. water values)

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

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

Get per unit bounds for stores.

v1.0.0

Parameters:

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

    Attribute name for the bounds, e.g. "e"

Returns:

  • tuple[DataArray, DataArray]

    Tuple of (min_pu, max_pu) DataArrays.