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:
-
consistency_checkβCheck network for consistency.
-
consistency_check_plotsβCheck network for consistency for plotting functions.
pypsa.Network.consistency_check
ΒΆ
consistency_check(
check_dtypes: bool = False,
strict: Sequence | None = None,
) -> None
Check network for consistency.
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.
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.
Specific checks
ΒΆ
Consistency check functions for PyPSA networks.
Mainly used in the Network.consistency_check() method.
Functions:
-
check_assetsβCheck if assets are only committable or extendable, but not both.
-
check_dtypes_βCheck if the dtypes of the attributes in the component are as expected.
-
check_for_disconnected_busesβCheck if network has buses that are not connected to any component.
-
check_for_missing_carrier_colorsβCheck if carriers are missing colors.
-
check_for_unknown_busesβCheck if buses are attached to component but are not defined in the network.
-
check_for_unknown_carriersβCheck if carriers are attached to component but are not defined in the network.
-
check_for_zero_impedancesβCheck if component has zero impedances. Only checks passive branch components.
-
check_for_zero_s_nomβCheck if component has zero s_nom. Only checks transformers.
-
check_generatorsβCheck the consistency of generator attributes before the simulation.
-
check_investment_periodsβCheck if investment periods are aligned with snapshots.
-
check_line_types_consistencyβCheck that line_types are identical across all scenarios.
-
check_nans_for_component_default_attrsβCheck for missing values in component attributes.
-
check_scenario_invariant_attributesβCheck if invariant component attributes are not changed across scenarios.
-
check_scenarios_sum_to_oneβCheck if scenarios probabilities sum to 1.
-
check_shapesβCheck if shapes are aligned with related components.
-
check_static_power_attributesβCheck static attrs p_now, s_nom, e_nom in any component.
-
check_stochastic_slack_bus_consistencyβCheck that the same bus is chosen as slack across all scenarios in stochastic networks.
-
check_time_seriesβCheck if time series of component are aligned with network snapshots.
-
check_time_series_power_attributesβCheck
p_max_puande_max_punan and infinite values in time series.
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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.