Generators
dataclass
¶
Generators(ctype: ComponentType, n: Network | None = None, names: str | int | Sequence[int | str] | None = None, suffix: str = '')
Bases: Components
flowchart TD
pypsa.components.Generators[Generators]
pypsa.components.components.Components[Components]
pypsa.components.components.ComponentsData[ComponentsData]
pypsa.components.descriptors.ComponentsDescriptorsMixin[ComponentsDescriptorsMixin]
pypsa.components.transform.ComponentsTransformMixin[ComponentsTransformMixin]
pypsa.components.index.ComponentsIndexMixin[ComponentsIndexMixin]
pypsa.components.array.ComponentsArrayMixin[ComponentsArrayMixin]
pypsa.components.abstract._ComponentsABC[_ComponentsABC]
pypsa.components.components.Components --> pypsa.components.Generators
pypsa.components.components.ComponentsData --> pypsa.components.components.Components
pypsa.components.descriptors.ComponentsDescriptorsMixin --> pypsa.components.components.Components
pypsa.components.abstract._ComponentsABC --> pypsa.components.descriptors.ComponentsDescriptorsMixin
pypsa.components.transform.ComponentsTransformMixin --> pypsa.components.components.Components
pypsa.components.index.ComponentsIndexMixin --> pypsa.components.components.Components
pypsa.components.abstract._ComponentsABC --> pypsa.components.index.ComponentsIndexMixin
pypsa.components.array.ComponentsArrayMixin --> pypsa.components.components.Components
pypsa.components.abstract._ComponentsABC --> pypsa.components.array.ComponentsArrayMixin
click pypsa.components.Generators href "" "pypsa.components.Generators"
click pypsa.components.components.Components href "" "pypsa.components.components.Components"
click pypsa.components.components.ComponentsData href "" "pypsa.components.components.ComponentsData"
click pypsa.components.descriptors.ComponentsDescriptorsMixin href "" "pypsa.components.descriptors.ComponentsDescriptorsMixin"
click pypsa.components.transform.ComponentsTransformMixin href "" "pypsa.components.transform.ComponentsTransformMixin"
click pypsa.components.index.ComponentsIndexMixin href "" "pypsa.components.index.ComponentsIndexMixin"
click pypsa.components.array.ComponentsArrayMixin href "" "pypsa.components.array.ComponentsArrayMixin"
click pypsa.components.abstract._ComponentsABC href "" "pypsa.components.abstract._ComponentsABC"
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
-
User Guide
-
Core Design
- Component Types
- Design Energy Balances
- Usage Components Object Features
- Optimization Formulations
-
Core Design
-
API Reference
-
Components
Components
ComponentsData -
Networks
Network
NetworkComponentsMixin
-
Components
Components
- Home Support Frequently Asked Questions Can you model market clearing in PyPSA?
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)
-
p_init(static or SeriesLike[static]) –Active power used as a starting point for limiting the ramp in the very first snapshot (for optimisation)
-
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 (e.g. annuitized investment costs). Used directly in optimization unlessovernight_costis specified. -
overnight_cost(float or SeriesLike[float]) –Overnight (upfront) investment cost per MW. If specified, PyPSA calculates annuity using
discount_rateandlifetime. Takes precedence overcapital_cost. -
discount_rate(float or SeriesLike[float]) –Discount rate for annuity calculation when using
overnight_cost. Supports 0% rate (simple depreciation). -
fom_cost(float or SeriesLike[float]) –Fixed period operation and maintenance costs per MW, added to annuitized investment cost.
-
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.
-
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. Ignored if NaN. -
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. Ignored if NaN. -
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
- User Guide Usage Components Object New Components Class API
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.