Generators
dataclass
ΒΆ
Generators(
ctype: ComponentType,
n: Network | None = None,
names: str | int | Sequence[int | str] | None = None,
suffix: str = "",
)
Bases: Components
Generators components class.
This class is used for generator components. All functionality specific to generators is implemented here. Functionality for all components is implemented in the abstract base class.
See Also
Examples:
>>> n.components.generators
'Generator' Components
----------------------
Attached to PyPSA Network 'AC-DC-Meshed'
Components: 6
Methods:
-
addβAdd new generators.
-
get_bounds_puβGet per unit bounds for generators.
pypsa.components.Generators.add
ΒΆ
add(
name: str | int | Sequence[int | str],
suffix: str = "",
overwrite: bool = False,
return_names: bool | None = None,
**kwargs: Any,
) -> Index | None
Add new generators.
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 generator is attached
-
control(str or SeriesLike[str]) βP,Q,V control strategy for power flow, must be "PQ", "PV" or "Slack". Only relevant for "AC" and "DC" buses.
-
type(str or SeriesLike[str]) βPlaceholder for generator type. Not implemented.
-
p_nom(float or SeriesLike[float]) βNominal power for limits on
pin optimization. Ignored ifp_nom_extendable=True. -
p_nom_mod(float or SeriesLike[float]) βNominal power of the generator module (e.g. fixed unit size of a nuclear power plant). Introduces integer variables if set.
-
p_nom_extendable(bool or SeriesLike[bool]) βSwitch to allow capacity
p_nomto be extended in optimization. -
p_nom_min(float or SeriesLike[float]) βIf
p_nomis extendable in optimization, set its minimum value. -
p_nom_max(float or SeriesLike[float]) βIf
p_nomis extendable in optimization, set its maximum value (e.g. limited by technical potential). -
p_nom_set(float or SeriesLike[float]) βIf
p_nomis extendable in optimization, set its value. -
p_min_pu(float or Series or SeriesLike[float or Series]) βThe minimum output for each snapshot per unit of
p_nomfor the optimization (e.g. a minimal dispatch level for conventional power plants). Note that ifcommittable=Falseandp_min_pu>0, this represents a must-run condition. -
p_max_pu(float or Series or SeriesLike[float or Series]) βThe maximum output for each snapshot per unit of
p_nomfor the optimization (e.g. changing availability of renewable generators due to weather conditions or a de-rating of conventional power plants). -
p_set(float or Series or SeriesLike[float or Series]) βActive power set point (for optimisation and power flow)
-
e_sum_min(float or SeriesLike[float]) βThe minimum total energy produced during a single optimization horizon.
-
e_sum_max(float or SeriesLike[float]) βThe maximum total energy produced during a single optimization horizon.
-
q_set(float or Series or SeriesLike[float or Series]) βReactive power set point (for power flow)
-
sign(float or SeriesLike[float]) βSign denoting the orientation of the dispatch variable (e.g. positive for generation, negative for consumption).
-
carrier(str or SeriesLike[str]) βPrime mover energy carrier (e.g. coal, gas, wind, solar); required for global constraints on primary energy in optimisation
-
marginal_cost(float or Series or SeriesLike[float or Series]) βMarginal cost of production of 1 MWh.
-
marginal_cost_quadratic(float or Series or SeriesLike[float or Series]) βQuadratic marginal cost of production of 1 MWh.
-
active(bool or SeriesLike[bool]) βWhether to consider the component in optimization or not
-
build_year(int or SeriesLike[int]) βBuild year of the generator.
-
lifetime(float or SeriesLike[float]) βLifetime of the generator.
-
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). -
efficiency(float or Series or SeriesLike[float or Series]) βRatio output and primary energy carrier input (e.g. 0.4 MWhelec/MWhfuel). This is required for global constraints on primary energy in optimization.
-
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 generator. Only used if
committable=True. -
shut_down_cost(float or SeriesLike[float]) βCost to shut down the generator. Only used if
committable=True. -
stand_by_cost(float or Series or SeriesLike[float or Series]) βStand-by cost for running the generator. This cost is incurred whenever the status is 1 (including when the dispatch decision is zero).
-
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 generator was online before
n.snapshotsstart. Only used ifcommittable=Trueandmin_up_time>0. Does not consider snapshot weightings. -
down_time_before(int or SeriesLike[int]) βNumber of snapshots that the generator was offline before
n.snapshotsstart. Only used ifcommittable=Trueandmin_down_time>0. Does not consider snapshot weightings. -
ramp_limit_up(float or Series or SeriesLike[float or Series]) βMaximum active power increase from one snapshot to the next, per unit of the nominal power. Ignored if NaN. Does not consider snapshot weightings.
-
ramp_limit_down(float or Series or SeriesLike[float or Series]) βMaximum active power decrease from one snapshot to the next, per unit of the nominal power. Ignored if NaN. Does not consider snapshot weightings.
-
ramp_limit_start_up(float or SeriesLike[float]) βMaximum active power increase at start up, per unit of the nominal power. Only used if
committable=True. -
ramp_limit_shut_down(float or SeriesLike[float]) βMaximum active power decrease at shut down, per unit of the nominal power. Only used if
committable=True. -
weight(float or SeriesLike[float]) βWeighting of a generator. Only used for network clustering.
-
p(Series or SeriesLike[Series] or ArrayLike[Series]) βActive power at bus (positive if net generation)
-
q(Series or SeriesLike[Series] or ArrayLike[Series]) βReactive power (positive if net generation)
-
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_upper(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of upper
p_nomlimit -
mu_lower(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of lower
p_nomlimit -
mu_p_set(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of fixed power generation
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.Generators.get_bounds_pu
ΒΆ
get_bounds_pu(
attr: str = "p",
) -> tuple[DataArray, DataArray]
Get per unit bounds for generators.
Parameters:
-
attr(string, default:'p') βAttribute name for the bounds, e.g. "p"
Returns:
-
tuple[DataArray, DataArray]βTuple of (min_pu, max_pu) DataArrays.