Skip to content

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

pypsa.Components

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.

v0.33.0

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 name will 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-params for 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 in r, x, g, b, s_nom, tap_ratio, tap_side and phase_shift. If the string is empty, values manually provided for r, 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_nom as 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_nom as 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_nom as base power). Ignored if type defined.

  • b (float or SeriesLike[float]) –

    Shunt susceptance (per unit, using s_nom as 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_nom to be extended in optimisation.

  • s_nom_min (float or SeriesLike[float]) –

    If s_nom_extendable=True, set the minimum value of s_nom_opt.

  • s_nom_max (float or SeriesLike[float]) –

    If s_nom_extendable=True, set the maximum value of s_nom_opt.

  • s_nom_set (float or SeriesLike[float]) –

    If s_nom is extendable in optimization, set the value of s_nom_opt.

  • s_max_pu (float or Series or SeriesLike[float or Series]) –

    The maximum allowed absolute flow per unit of s_nom for the oprimisation.

  • capital_cost (float or SeriesLike[float]) –

    Fixed period costs of extending s_nom by 1 MVA (e.g. annuitized investment costs). Used directly unless overnight_cost is specified.

  • overnight_cost (float or SeriesLike[float]) –

    Overnight (upfront) investment cost per MVA. If specified, PyPSA calculates annuity using discount_rate and lifetime. Takes precedence over capital_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 type is set, this is the number of parallel transformers (can also be fractional). If type is 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 from bus0).

  • q0 (Series or SeriesLike[Series] or ArrayLike[Series]) –

    Reactive power at bus0 (positive if branch is withdrawing power from bus0).

  • p1 (Series or SeriesLike[Series] or ArrayLike[Series]) –

    Active power at bus1 (positive if branch is withdrawing power from bus1).

  • q1 (Series or SeriesLike[Series] or ArrayLike[Series]) –

    Reactive power at bus1 (positive if branch is withdrawing power from bus1).

  • x_pu (float or SeriesLike[float]) –

    Per unit series reactance calculated by n.calculate_dependent_values() from x and n.buses.v_nom.

  • r_pu (float or SeriesLike[float]) –

    Per unit series resistance calculated by n.calculate_dependent_values() from r and n.buses.v_nom.

  • g_pu (float or SeriesLike[float]) –

    Per unit shunt conductivity calculated by n.calculate_dependent_values() from g and n.buses.v_nom.

  • b_pu (float or SeriesLike[float]) –

    Per unit shunt susceptance calculated by n.calculate_dependent_values() from b and n.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() from x, tap_ratio for transformers and n.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() from x, tap_ratio for transformers and n.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_nom limit. Always non-negative.

  • mu_upper (Series or SeriesLike[Series] or ArrayLike[Series]) –

    Shadow price of upper s_nom limit. Always non-negative.

Returns:

  • new_names ( index or None ) –

    Names of new components (including suffix) if return_names is True, otherwise None.

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.Network.add

pypsa.components.Transformers.get_bounds_pu

get_bounds_pu(attr: str = 's') -> tuple[DataArray, DataArray]

Get per unit bounds for transformers.

v1.0.0

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

pypsa.Components

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.