Skip to content

Stores dataclass ΒΆ

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

Bases: Components

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:

  • add –

    Add new stores.

  • get_bounds_pu –

    Get per unit bounds for stores.

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 power flow only)

  • 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, including periodized investment costs and periodic fixed O&M costs (e.g. annuitized investment costs).

  • 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.