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
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.
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
namewill 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-paramsfor 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 ife_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_nomto be extended in optimisation. -
e_nom_min(float or SeriesLike[float]) βIf
e_nom_extendable=True, set the minimum value ofe_nom_opt. -
e_nom_max(float or SeriesLike[float]) βIf
e_nom_extendable=True, set the maximum value ofe_nom_opt. -
e_nom_set(float or SeriesLike[float]) βIf
e_nom_extendable=True, set the value ofe_nom_opt. -
e_min_pu(float or Series or SeriesLike[float or Series]) βMinimal value of
erelative toe_nomfor the optimisation. -
e_max_pu(float or Series or SeriesLike[float or Series]) βMaximal value of
erelative toe_nomfor 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
eis set toe_initial. -
e_cyclic(bool or SeriesLike[bool]) βSwitch: if True, then
e_initialis 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_nomby 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_nomlimit -
mu_lower(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of lower
e_nomlimit -
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, otherwiseNone.
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.components.Stores.get_bounds_pu
ΒΆ
get_bounds_pu(
attr: str = "e",
) -> tuple[DataArray, DataArray]
Get per unit bounds for stores.
Parameters:
-
attr(string, default:'e') βAttribute name for the bounds, e.g. "e"
Returns:
-
tuple[DataArray, DataArray]βTuple of (min_pu, max_pu) DataArrays.