Transformer
Transformers
dataclass
ΒΆ
Transformers(ctype: ComponentType, n: Network | None = None, names: str | int | Sequence[int | str] | None = None, suffix: str = '')
Bases: Components
flowchart TD
pypsa.components.Transformers[Transformers]
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.Transformers
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.Transformers href "" "pypsa.components.Transformers"
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"
Transformers components class.
This class is used for transformer components. All functionality specific to transformers is implemented here. Functionality for all components is implemented in the abstract base class.
See Also
Examples:
>>> n.components.transformers
Empty 'Transformer' Components
Methods:
-
addβAdd new transformers.
-
get_bounds_puβGet per unit bounds for transformers.
pypsa.components.Transformers.add
ΒΆ
add(name: str | int | Sequence[int | str], suffix: str = '', overwrite: bool = False, return_names: bool | None = None, **kwargs: Any) -> Index | None
Add new transformers.
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 (typically higher voltage) to which transformer is attached.
-
bus1(str or SeriesLike[str]) βName of destination bus (typically lower voltage) to which transformer is attached.
-
type(str or SeriesLike[str]) βName of 2-winding transformer standard type. If this is not an empty string "", the transformer type impedance parameters are taken from the standard type along with
num_parallel. This will override any values set inr,x,g,b,s_nom,tap_ratio,tap_sideandphase_shift. If the string is empty, values manually provided forr,x, etc. are taken. -
model(str or SeriesLike[str]) βModel used for admittance matrix; can be "t" or "pi"; defaults to "t" following physics and DIgSILENT PowerFactory
-
x(float or SeriesLike[float]) βSeries reactance (per unit, using
s_nomas base power); must be non-zero for AC branch in linear power flow. Series impedance \(z = r + jx\) must be non-zero for the non-linear power flow. Ignored if type defined. -
r(float or SeriesLike[float]) βSeries resistance (per unit, using
s_nomas base power); must be non-zero for DC branch in linear power flow. Series impedance \(z = r + jx\) must be non-zero for the non-linear power flow. Ignored if type defined. -
g(float or SeriesLike[float]) βShunt conductivity (per unit, using
s_nomas base power). Ignored if type defined. -
b(float or SeriesLike[float]) βShunt susceptance (per unit, using
s_nomas base power). Ignored if type defined. -
s_nom(float or SeriesLike[float]) βLimit of apparent power which can pass through branch in either direction. Ignored if
s_nom_extendable=True. -
s_nom_mod(float or SeriesLike[float]) βModular unit size of transformer expansion of
s_nom. Introduces integer variables. -
s_nom_extendable(bool or SeriesLike[bool]) βSwitch to allow capacity
s_nomto be extended in optimisation. -
s_nom_min(float or SeriesLike[float]) βIf
s_nom_extendable=True, set the minimum value ofs_nom_opt. -
s_nom_max(float or SeriesLike[float]) βIf
s_nom_extendable=True, set the maximum value ofs_nom_opt. -
s_nom_set(float or SeriesLike[float]) βIf
s_nomis extendable in optimization, set the value ofs_nom_opt. -
s_max_pu(float or Series or SeriesLike[float or Series]) βThe maximum allowed absolute flow per unit of
s_nomfor the oprimisation. -
capital_cost(float or SeriesLike[float]) βFixed period costs of extending
s_nomby 1 MVA (e.g. annuitized investment costs). Used directly unlessovernight_costis specified. -
overnight_cost(float or SeriesLike[float]) βOvernight (upfront) investment cost per MVA. 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, added to annuitized investment cost.
-
num_parallel(float or SeriesLike[float]) βWhen
typeis set, this is the number of parallel transformers (can also be fractional). Iftypeis empty "" this value is ignored. -
tap_ratio(float or SeriesLike[float]) βRatio of per unit voltages at each bus for tap changed. Ignored if type defined.
-
tap_side(int or SeriesLike[int]) βDefines if tap changer is modelled at the primary 0 side (usually high-voltage) or the secondary 1 side (usually low voltage) (must be 0 or 1, defaults to 0). Ignored if type defined.
-
tap_position(int or SeriesLike[int]) βIf the transformer has a
type, determines position relative to the neutral tap position. -
phase_shift(float or SeriesLike[float]) βVoltage phase angle shift. Ignored if type defined.
-
active(bool or SeriesLike[bool]) βWhether to consider the component in optimisation or not
-
build_year(int or SeriesLike[int]) βBuild year of transformer.
-
lifetime(float or SeriesLike[float]) βLifetime of transformer.
-
v_ang_min(float or SeriesLike[float]) βMinimum voltage angle difference across the transformer.Placeholder attribute not currently used.
-
v_ang_max(float or SeriesLike[float]) βMaximum voltage angle difference across the transformer.Placeholder attribute not currently used.
-
sub_network(str or SeriesLike[str]) βName of connected sub-network to which transformer belongs, as calculated by
n.determine_network_topology(). Do not set by hand. -
p0(Series or SeriesLike[Series] or ArrayLike[Series]) βActive power at
bus0(positive if branch is withdrawing power frombus0). -
q0(Series or SeriesLike[Series] or ArrayLike[Series]) βReactive power at
bus0(positive if branch is withdrawing power frombus0). -
p1(Series or SeriesLike[Series] or ArrayLike[Series]) βActive power at
bus1(positive if branch is withdrawing power frombus1). -
q1(Series or SeriesLike[Series] or ArrayLike[Series]) βReactive power at
bus1(positive if branch is withdrawing power frombus1). -
x_pu(float or SeriesLike[float]) βPer unit series reactance calculated by
n.calculate_dependent_values()fromxandn.buses.v_nom. -
r_pu(float or SeriesLike[float]) βPer unit series resistance calculated by
n.calculate_dependent_values()fromrandn.buses.v_nom. -
g_pu(float or SeriesLike[float]) βPer unit shunt conductivity calculated by
n.calculate_dependent_values()fromgandn.buses.v_nom. -
b_pu(float or SeriesLike[float]) βPer unit shunt susceptance calculated by
n.calculate_dependent_values()frombandn.buses.v_nom. -
x_pu_eff(float or SeriesLike[float]) βEffective per unit series reactance for linear power flow, calculated by
n.calculate_dependent_values()fromx,tap_ratiofor transformers andn.buses.v_nom. -
r_pu_eff(float or SeriesLike[float]) βEffective per unit series resistance for linear power flow, calculated by
n.calculate_dependent_values()fromx,tap_ratiofor transformers andn.buses.v_nom. -
s_nom_opt(float or SeriesLike[float]) βOptimised nominal capacity for apparent power.
-
mu_lower(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of lower
s_nomlimit. Always non-negative. -
mu_upper(Series or SeriesLike[Series] or ArrayLike[Series]) βShadow price of upper
s_nomlimit. Always non-negative.
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.Transformers.get_bounds_pu
ΒΆ
get_bounds_pu(attr: str = 's') -> tuple[DataArray, DataArray]
Get per unit bounds for transformers.
For passive branch components, min_pu is the negative of max_pu.
Parameters:
-
attr(string, default:'s') βAttribute name for the bounds, e.g. "s"
Returns:
-
tuple[DataArray, DataArray]βTuple of (min_pu, max_pu) DataArrays.
TransformerTypes
dataclass
ΒΆ
TransformerTypes(ctype: ComponentType, n: Network | None = None, names: str | int | Sequence[int | str] | None = None, suffix: str = '')
Bases: Components
flowchart TD
pypsa.components.TransformerTypes[TransformerTypes]
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.TransformerTypes
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.TransformerTypes href "" "pypsa.components.TransformerTypes"
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"
Transformer types components class.
This class is used for transformer type components. All functionality specific to transformer types is implemented here. Functionality for all components is implemented in the abstract base class.
See Also
Examples:
>>> n.components.transformer_types
'TransformerType' Components
----------------------------
Attached to PyPSA Network 'AC-DC-Meshed'
Components: 14
Methods:
-
addβWrap Components.add() and docstring is patched via decorator.
pypsa.components.TransformerTypes.add
ΒΆ
add(name: str | int | Sequence[int | str], suffix: str = '', overwrite: bool = False, return_names: bool | None = None, **kwargs: Any) -> Index | None
Wrap Components.add() and docstring is patched via decorator.