StorageUnits
dataclass
ΒΆ
StorageUnits(
ctype: ComponentType,
n: Network | None = None,
names: str | int | Sequence[int | str] | None = None,
suffix: str = "",
)
Bases: Components
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
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.
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 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
pin optimisation. Ignored ifp_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_nomto be extended in optimisation. -
p_nom_min(float or SeriesLike[float]) βIf
p_nom_extendable=True, set the minimum value ofp_nom_opt. -
p_nom_max(float or SeriesLike[float]) βIf
p_nom_extendable=True, set the maximum value ofp_nom_opt. -
p_nom_set(float or SeriesLike[float]) βIf
p_nom_extendable=True, set the value ofp_nom_opt. -
p_min_pu(float or Series or SeriesLike[float or Series]) βThe minimum output for each snapshot per unit of
p_nomfor 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_nomfor 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 (for power flow only)
-
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_nomby 1 MW, including periodized investment costs and periodic fixed O&M costs (e.g. annuitized investment costs). -
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_initialis 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, 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.StorageUnits.get_bounds_pu
ΒΆ
get_bounds_pu(
attr: str = "p_store",
) -> tuple[DataArray, DataArray]
Get per unit bounds for storage units.
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.