Skip to content

Consistency ChecksΒΆ

NetworkConsistencyMixin ΒΆ

Mixin class for network consistency checks.

Class inherits to pypsa.Network. All attributes and methods can be used within any Network instance.

Methods:

pypsa.Network.consistency_check ΒΆ

consistency_check(
    check_dtypes: bool = False,
    strict: Sequence | None = None,
) -> None

Check network for consistency.

v0.7.0

Runs a series of checks on the network to ensure that it is consistent, e.g. that all components are connected to existing buses and that no impedances are singular.

Parameters:

  • check_dtypes (bool, default: False ) –

    If True, check the dtypes of the attributes in the components.

  • strict (list, default: None ) –

    If some checks should raise an error instead of logging a warning, pass a list of strings with the names of the checks to be strict about. If 'all' is passed, all checks will be strict. The default is no strict checks.

Raises:

  • ConsistencyError –

    If any of the checks fail and strict mode is activated.

pypsa.Network.consistency_check_plots ΒΆ

consistency_check_plots(
    strict: Sequence | None = None,
) -> None

Check network for consistency for plotting functions.

v0.34.0

Parameters:

  • strict (list, default: None ) –

    If some checks should raise an error instead of logging a warning, pass a list of strings with the names of the checks to be strict about. If 'all' is passed, all checks will be strict. The default is no strict checks.

Raises:

  • ConsistencyError –

    If any of the checks fail and strict mode is activated.

See Also

pypsa.Network.consistency_check, pypsa.consistency.check_for_unknown_buses, pypsa.consistency.check_for_unknown_carriers

Specific checks ΒΆ

Consistency check functions for PyPSA networks.

Mainly used in the Network.consistency_check() method.

Functions:

pypsa.consistency.check_assets ΒΆ

check_assets(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check if assets are only committable or extendable, but not both.

Activate strict mode in general consistency check by passing ['assets'] to the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_dtypes_ ΒΆ

check_dtypes_(
    component: Components, strict: bool = False
) -> None

Check if the dtypes of the attributes in the component are as expected.

Activate strict mode in general consistency check by passing ['dtypes'] to the strict argument.

Parameters:

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_for_disconnected_buses ΒΆ

check_for_disconnected_buses(
    n: NetworkType, strict: bool = False
) -> None

Check if network has buses that are not connected to any component.

Activate strict mode in general consistency check by passing ['disconnected_buses'] the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_for_missing_carrier_colors ΒΆ

check_for_missing_carrier_colors(
    n: Network, strict: bool = False
) -> None

Check if carriers are missing colors.

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

pypsa.consistency.check_for_unknown_buses ΒΆ

check_for_unknown_buses(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check if buses are attached to component but are not defined in the network.

Activate strict mode in general consistency check by passing ['unknown_buses'] to the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_for_unknown_carriers ΒΆ

check_for_unknown_carriers(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check if carriers are attached to component but are not defined in the network.

Activate strict mode in general consistency check by passing ['unknown_carriers'] the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_for_zero_impedances ΒΆ

check_for_zero_impedances(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check if component has zero impedances. Only checks passive branch components.

Activate strict mode in general consistency check by passing ['zero_impedances'] the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_for_zero_s_nom ΒΆ

check_for_zero_s_nom(
    component: Components, strict: bool = False
) -> None

Check if component has zero s_nom. Only checks transformers.

Activate strict mode in general consistency check by passing ['zero_s_nom'] to the strict argument.

Parameters:

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_generators ΒΆ

check_generators(
    component: Components, strict: bool = False
) -> None

Check the consistency of generator attributes before the simulation.

This function performs the following checks on generator components: 1. Ensures that committable generators are not both up and down before the simulation. 2. Verifies that the minimum total energy to be produced (e_sum_min) is not greater than the maximum total energy to be produced (e_sum_max).

Activate strict mode in general consistency check by passing ['generators'] to the the strict argument.

Parameters:

  • component (Component) –

    The generator component to be checked.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_investment_periods ΒΆ

check_investment_periods(
    n: NetworkType, strict: bool = False
) -> None

Check if investment periods are aligned with snapshots.

Activate strict mode in general consistency check by passing ['investment_periods'] to the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_line_types_consistency ΒΆ

check_line_types_consistency(
    n: NetworkType, strict: bool = False
) -> None

Check that line_types are identical across all scenarios.

In stochastic networks, line_types must be identical across all scenarios

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_nans_for_component_default_attrs ΒΆ

check_nans_for_component_default_attrs(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check for missing values in component attributes.

Activate strict mode in general consistency check by passing ['nans_for_component_default_attrs'] the strict argument.

Checks for all attributes if they are nan but have a default value, which is not nan.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_scenario_invariant_attributes ΒΆ

check_scenario_invariant_attributes(
    n: NetworkType, strict: bool = False
) -> None

Check if invariant component attributes are not changed across scenarios.

There are some component attributes that must remain the same across scenarios. These attributes define the topology of the network or the mathematical structure. We raise an error if user attemps to modify them across scenarios. Any difference in values (including NaN vs non-NaN) will trigger an error.

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_scenarios_sum_to_one ΒΆ

check_scenarios_sum_to_one(
    n: NetworkType, strict: bool = False
) -> None

Check if scenarios probabilities sum to 1.

This check verifies that scenario probabilities have not been modified after initialization to break the constraint that they must sum to 1.

Activate strict mode in general consistency check by passing ['scenarios_sum'] to the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_shapes ΒΆ

check_shapes(n: NetworkType, strict: bool = False) -> None

Check if shapes are aligned with related components.

Activate strict mode in general consistency check by passing ['shapes'] to the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_static_power_attributes ΒΆ

check_static_power_attributes(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check static attrs p_now, s_nom, e_nom in any component.

Activate strict mode in general consistency check by passing ['static_power_attrs'] the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_stochastic_slack_bus_consistency ΒΆ

check_stochastic_slack_bus_consistency(
    n: NetworkType, strict: bool = False
) -> None

Check that the same bus is chosen as slack across all scenarios in stochastic networks.

Ensure that the same bus is consistently chosen as the slack bus to maintain mathematical consistency of the optimization problem.

Parameters:

  • n (Network) –

    The network to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_time_series ΒΆ

check_time_series(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check if time series of component are aligned with network snapshots.

Activate strict mode in general consistency check by passing ['time_series'] to the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check

pypsa.consistency.check_time_series_power_attributes ΒΆ

check_time_series_power_attributes(
    n: NetworkType,
    component: Components,
    strict: bool = False,
) -> None

Check p_max_pu and e_max_pu nan and infinite values in time series.

Activate strict mode in general consistency check by passing ['time_series_power_attrs'] the strict argument.

Parameters:

  • n (Network) –

    The network to check.

  • component (Component) –

    The component to check.

  • strict (bool, default: False ) –

    If True, raise an error instead of logging a warning.

See Also

pypsa.Network.consistency_check