Links
dataclass
ΒΆ
Links(
ctype: ComponentType,
n: Network | None = None,
names: str | int | Sequence[int | str] | None = None,
suffix: str = "",
)
Bases: Components
Links components class.
This class is used for link components. All functionality specific to links is implemented here. Functionality for all components is implemented in the abstract base class.
See Also
Examples:
>>> n.components.links
'Link' Components
-----------------
Attached to PyPSA Network 'AC-DC-Meshed'
Components: 4
Methods:
-
addβAdd new links.
-
get_bounds_puβGet per unit bounds for links.
Attributes:
-
additional_ports(list[str]) βIdentify additional link ports (bus connections) beyond predefined ones.
pypsa.components.Links.additional_ports
property
ΒΆ
additional_ports: list[str]
Identify additional link ports (bus connections) beyond predefined ones.
Returns:
-
list of stringsβList of additional link ports. E.g. ["2", "3"] for bus2, bus3.
Also see
pypsa.Components.ports
Examples:
>>> n = pypsa.Network()
>>> n.add("Link", "link1", bus0="bus1", bus1="bus2", bus2="bus3")
Index(['link1'], dtype='object')
>>> n.components.links.additional_ports
['2']
pypsa.components.Links.add
ΒΆ
add(
name: str | int | Sequence[int | str],
suffix: str = "",
overwrite: bool = False,
return_names: bool | None = None,
**kwargs: Any,
) -> Index | None
Add new links.
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:
-
bus0(str or SeriesLike[str]) βName of origin bus to which link is attached.
-
bus1(str or SeriesLike[str]) βName of first destination bus to which link is attached. Further destination buses (
bus2,bus3, etc.) are automatically expanded as needed. -
type(str or SeriesLike[str]) βPlaceholder for link type. Not implemented.
-
carrier(str or SeriesLike[str]) βCarrier of the link describing its technology (e.g. gas boiler, electrolyser, HVDC link).
-
efficiency(float or Series or SeriesLike[float or Series]) βEfficiency of energy transfer from
bus0tobus1. Can be time-dependent (e.g. to represent temperature-dependent heat pump COP). Further efficiency attributes for further buses (e.g.bus2,bus3, etc.) are automatically expanded as needed (e.g.efficiency2,efficiency3, etc.). -
active(bool or SeriesLike[bool]) βWhether to consider the component in basic functionality or not
-
build_year(int or SeriesLike[int]) βBuild year
-
lifetime(float or SeriesLike[float]) βLifetime
-
p_nom(float or SeriesLike[float]) βLimit of power which can pass through link (in units of
bus0). Ignored ifp_nom_extendable=True. -
p_nom_mod(float or SeriesLike[float]) βUnit size of link module (e.g. fixed blocks of 100 MW).
-
p_nom_extendable(bool or SeriesLike[bool]) βSwitch to allow capacity
p_nomto be extended. -
p_nom_min(float or SeriesLike[float]) βIf
p_nom_extendable=True, set its minimum value. -
p_nom_max(float or SeriesLike[float]) βIf
p_nom_extendable=True, set its maximum value. -
p_nom_set(float or SeriesLike[float]) βIf
p_nomis extendable in optimization, set its value. -
p_set(float or Series or SeriesLike[float or Series]) βThe dispatch set point for
p0of the link (for optimisation and power flow). -
p_min_pu(float or Series or SeriesLike[float or Series]) βMinimal dispatch per unit of
p_nomfor the link. Can also be negative. -
p_max_pu(float or Series or SeriesLike[float or Series]) βMaximal dispatch per unit of
p_nomfor the link. Can also be negative. -
capital_cost(float or SeriesLike[float]) βFixed period costs of extending
p_nomby 1 MW (unit ofbus0), including periodized investment costs and periodic fixed O&M costs (e.g. annuitized investment costs). Anylengthfactor must already be included here. -
marginal_cost(float or Series or SeriesLike[float or Series]) βMarginal cost of 1 MWh consumption from
bus0(e.g. including variable operation and maintenance costs of an electrolyser but excluding electricity costs). -
marginal_cost_quadratic(float or Series or SeriesLike[float or Series]) βQuadratic marginal cost for 1 MWh of consumption from
bus0. -
stand_by_cost(float or Series or SeriesLike[float or Series]) βStand-by cost for operating the link. This cost is incurred whenever the status is 1 (including when dispatch decision is zero).
-
length(float or SeriesLike[float]) βLength of the link. Useful for calculating
capital_costfor HVDC connections. -
terrain_factor(float or SeriesLike[float]) βTerrain factor for increasing
capital_costcalculated fromlength. -
committable(bool or SeriesLike[bool]) βApply unit commitment constraints. This is only possible with
p_nom_extendable=False. -
start_up_cost(float or SeriesLike[float]) βCost to start up the link. Only used if
committable=True. -
shut_down_cost(float or SeriesLike[float]) βCost to shut down the link. Only used if
committable=True. -
min_up_time(int or SeriesLike[int]) βMinimum number of snapshots for status to be 1. Only used if
committable=True. Does not consider snapshot weightings. -
min_down_time(int or SeriesLike[int]) βMinimum number of snapshots for status to be 0. Only used if
committable=True. Does not consider snapshot weightings. -
up_time_before(int or SeriesLike[int]) βNumber of snapshots that the link was online before network.snapshots start. Only read if
committable=Trueandmin_up_time>0. Does not consider snapshot weightings. -
down_time_before(int or SeriesLike[int]) βNumber of snapshots that the link was offline before network.snapshots start. Only read if
committable=Trueandmin_down_time>0. Does not consider snapshot weightings. -
ramp_limit_up(float or Series or SeriesLike[float or Series]) βMaximum increase from one snapshot to the next, per unit of
p_nom. Ignored if NaN. Does not consider snapshot weightings. -
ramp_limit_down(float or Series or SeriesLike[float or Series]) βMaximum decrease from one snapshot to the next, per unit of
p_nom. Ignored if NaN. Does not consider snapshot weightings. -
ramp_limit_start_up(float or SeriesLike[float]) βMaximum increase at start up, per unit of
p_nom. Only used ifcommittable=True. -
ramp_limit_shut_down(float or SeriesLike[float]) βMaximum decrease at shut down, per unit of
p_nom. Only used ifcommittable=True. -
p0(Series or SeriesLike[Series] or ArrayLike[Series]) βPower at
bus0(positive if link is withdrawing frombus0). -
p1(Series or SeriesLike[Series] or ArrayLike[Series]) βPower at
bus1(positive if link is withdrawing frombus1). -
p_nom_opt(float or SeriesLike[float]) βOptimised nominal capacity.
-
status(Series or SeriesLike[Series] or ArrayLike[Series]) βStatus in the snapshot (1 is on, 0 is off). Only returned if
committable=True. -
start_up(Series or SeriesLike[Series] or ArrayLike[Series]) βWhether the unit was started in the snapshot (1 is yes, 0 is no). Only returned if
committable=True. -
shut_down(Series or SeriesLike[Series] or ArrayLike[Series]) βWhether the unit was shut down in the snapshot (1 is yes, 0 is no). Only returned if
committable=True. -
mu_lower(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of lower
p_nomlimit \(-F \\leq f\). Always non-negative. -
mu_upper(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of upper
p_nomlimit \(f \\leq F\). Always non-negative. -
mu_p_set(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of fixed dispatch
p_set -
mu_ramp_limit_up(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of upper ramp up limit
-
mu_ramp_limit_down(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of lower ramp down limit
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.Links.get_bounds_pu
ΒΆ
get_bounds_pu(
attr: str = "p",
) -> tuple[DataArray, DataArray]
Get per unit bounds for links.
Parameters:
-
attr(string, default:'p') βAttribute name for the bounds, e.g. "p"
Returns:
-
tuple[DataArray, DataArray]βTuple of (min_pu, max_pu) DataArrays.