Flexible loads

They are a special type of power loads: instead of being constant, the power will depend on the voltage measured at the load and the control applied to the load.

Equations

The equations are the following (star loads):

\[\begin{split}\left\{ \begin{aligned} \underline{I_{\mathrm{abc}}} &= \left(\frac{ \underline{S_{\mathrm{abc}}}(\underline{V_{\mathrm{abc}}}-\underline{V_{\mathrm{n}}}) }{\underline{V_{\mathrm{abc}}}-\underline{V_{\mathrm{n}}}}\right)^{\star} \\ \underline{I_{\mathrm{n}}} &= -\sum_{p\in\{\mathrm{a},\mathrm{b},\mathrm{c}\}}\underline{I_{p}} \end{aligned} \right.\end{split}\]

And the following (delta loads):

\[\begin{split}\left\{ \begin{aligned} \underline{I_{\mathrm{ab}}} &= \left(\frac{\underline{S_{\mathrm{ab}}}(\underline{V_{\mathrm{a}}}-\underline {V_{\mathrm{b}}})}{\underline{V_{\mathrm{a}}}-\underline{V_{\mathrm{b}}}}\right)^{\star} \\ \underline{I_{\mathrm{bc}}} &= \left(\frac{\underline{S_{\mathrm{bc}}}(\underline{V_{\mathrm{b}}}-\underline {V_{\mathrm{c}}})}{\underline{V_{\mathrm{b}}}-\underline{V_{\mathrm{c}}}}\right)^{\star} \\ \underline{I_{\mathrm{ca}}} &= \left(\frac{\underline{S_{\mathrm{ca}}}(\underline{V_{\mathrm{c}}}-\underline {V_{\mathrm{a}}})}{\underline{V_{\mathrm{c}}}-\underline{V_{\mathrm{a}}}}\right)^{\star} \end{aligned} \right.\end{split}\]

The expression \(\underline{S}(U)\) depends on four parameters:

  • The theoretical power \(\underline{S^{\mathrm{th.}}}\) that the load would have if no control is applied.

  • The maximal power \(S^{\max}\) that can be injected/consumed by the load. For a PV installation, this is usually the rated power of the inverter.

  • The type of control (see here).

  • The type of projection (see here).

Detailed pages

All these elements are detailed in the following sections:

Available Results

In addition to the results available for all loads, as described here, the following results are available for flexible loads:

Result Accessor

Default Unit

Type

Description

res_flexible_powers

\(V\!A\)

complex array

The powers in the inner components of the load

API Reference

class Control(type, u_min, u_down, u_up, u_max, alpha=_DEFAULT_ALPHA, epsilon=_DEFAULT_EPSILON)

Control class for flexible loads.

This class contains the information needed to formulate the control equations. This includes the control type, control limits, and other factors.

The control for a PowerLoad instance can be of four possible types:
  • "constant": no control is applied. In this case, a simple PowerLoad without flexible_params could have been used instead.

  • "p_max_u_production": control the maximum production active power of the load (inverter) based on the voltage \(P^{\max}_{\mathrm{prod}}(U)\).

  • "p_max_u_consumption": control the maximum consumption active power of the load based on the voltage \(P^{\max}_{\mathrm{cons}}(U)\).

  • "q_u": control the reactive power based on the voltage \(Q(U)\).

Control constructor.

Parameters:
  • type (ControlType) –

    The type of the control:
    • "constant": no control is applied;

    • "p_max_u_production": control the maximum production active power of the load (inverter) based on the voltage \(P^{\max}_{\mathrm{prod}}(U)\);

    • "p_max_u_consumption": control the maximum consumption active power of the load based on the voltage \(P^{\max}_{\mathrm{cons}}(U)\);

    • "q_u": control the reactive power based on the voltage \(Q(U)\).

  • u_min (Float | Q_[Float]) – The minimum voltage i.e. the one the control reached the maximum action.

  • u_down (Float | Q_[Float]) – The voltage which starts to trigger the control (lower value).

  • u_up (Float | Q_[Float]) – The voltage which starts to trigger the control (upper value).

  • u_max (Float | Q_[Float]) – The maximum voltage i.e. the one the control reached its maximum action.

  • alpha (Float) – An approximation factor used by the family function (soft clip). The bigger the factor is the closer the function is to the non-differentiable function.

  • epsilon (Float) – This value is used to make a smooth inverse function. It is only useful for P control.

property type: ControlType

The type of the control.

Return type:

ControlType

property u_min: Q_[float]

The minimum voltage i.e. the one the control reached the maximum action.

Return type:

Q_[float]

property u_down: Q_[float]

The voltage which starts to trigger the control (lower value).

Return type:

Q_[float]

property u_up: Q_[float]

TThe voltage which starts to trigger the control (upper value).

Return type:

Q_[float]

property u_max: Q_[float]

The maximum voltage i.e. the one the control reached its maximum action.

Return type:

Q_[float]

property alpha: float

An approximation factor used by the family function (soft clip).

The bigger the factor is the closer the function is to the non-differentiable function.

Return type:

float

property epsilon: float

This value is used to make a smooth inverse function.

Return type:

float

classmethod constant()

Create a constant control i.e no control.

Return type:

Self

classmethod p_max_u_production(u_up, u_max, alpha=_DEFAULT_ALPHA, epsilon=_DEFAULT_EPSILON)

Create a control of the type "p_max_u_production".

Parameters:
  • u_up (Float | Q_[Float]) – The voltage norm that triggers the control. A voltage higher than this value signals to the controller to start to reduce the production active power. On the figure, a normalised version \(U^{\mathrm{up}\,\mathrm{norm.}}\) is used.

  • u_max (Float | Q_[Float]) – The maximum norm voltage i.e. the one the control reached its maximum action. A voltage higher than this value signals to the controller to set the production active power to its minimal value. On the figure, a normalised version \(U^{\max\,\mathrm{norm.}}\) is used.

  • alpha (Float) – A factor used to soften the control function (soft clip) to make it more differentiable. The bigger alpha is, the closer the function is to the non-differentiable function. This parameter is noted \(\alpha\) on the figure.

  • epsilon (Float) – This value is used to make a smooth inverse function.

Returns:

The "p_max_u_production" control using the provided parameters.

Return type:

Self

classmethod p_max_u_consumption(u_min, u_down, alpha=_DEFAULT_ALPHA, epsilon=_DEFAULT_EPSILON)

Create a control of the type "p_max_u_consumption".

Parameters:
  • u_min (Float | Q_[Float]) – The minimum voltage norm i.e. the one the control reached its maximum action. A voltage lower than this value signals to the controller to set the consumption active power to its minimal value. On the figure, a normalised version \(U^{\min\,\mathrm{norm.}}\) is used.

  • u_down (Float | Q_[Float]) – The voltage norm that triggers the control. A voltage lower than this value signals to the controller to start to reduce the consumption active power. On the figure, a normalised version \(U^{\mathrm{down}\,\mathrm{norm.}}\) is used.

  • alpha (Float) – A factor used to soften the control function (soft clip) to make it more differentiable. The bigger alpha is, the closer the function is to the non-differentiable function. This parameter is noted \(\alpha\) on the figure.

  • epsilon (Float) – This value is used to make a smooth inverse function.

Returns:

The "p_max_u_consumption" control using the provided parameters.

Return type:

Self

classmethod q_u(u_min, u_down, u_up, u_max, alpha=_DEFAULT_ALPHA)

Create a control of the type "q_u".

Parameters:
  • u_min (Float | Q_[Float]) – The minimum voltage norm i.e. the one the control reached its maximum action. A voltage lower than this value signals to the controller to set the reactive power to its maximal capacitive value. On the figure, a normalised version \(U^{\min\,\mathrm{norm.}}\) is used.

  • u_down (Float | Q_[Float]) – The voltage that triggers the capacitive reactive power control. A voltage lower than this value signals to the controller to start to increase the capacitive reactive power. On the figure, a normalised version \(U^{\mathrm{down}\,\mathrm{norm.}}\) is used.

  • u_up (Float | Q_[Float]) – The voltage that triggers the inductive reactive power control. A voltage higher than this value signals to the controller to start to increase the inductive reactive power. On the figure, a normalised version \(U^{\mathrm{up}\,\mathrm{norm.}}\) is used.

  • u_max (Float | Q_[Float]) – The minimum voltage i.e. the one the control reached its maximum action. A voltage lower than this value signals to the controller to set the reactive power to its maximal inductive value. On the figure, a normalised version \(U^{\max\,\mathrm{norm.}}\) is used.

  • alpha (Float) – A factor used to soften the control function (soft clip) to make it more differentiable. The bigger alpha is, the closer the function is to the non-differentiable function. This parameter is noted \(\alpha\) on the figure.

Returns:

The "q_u" control using the provided parameters.

Return type:

Self

classmethod from_dict(data, *, include_results=True, copy=True)

Create an instance from a dictionary created with to_dict().

Parameters:
  • data (JsonDict) – The dictionary containing the data.

  • include_results (bool) – If True (default) and the results of the load flow are included in the dictionary, the results are also loaded.

  • copy (bool) – If True (default), the input dictionary is deep-copied before processing so the original is never modified. Pass False when the dictionary is a throwaway (e.g. freshly parsed from JSON) to avoid the copy overhead.

Returns:

The constructed instance.

Return type:

Self

classmethod from_json(path, *, include_results=True)

Construct an instance from a JSON file created with to_json().

Parameters:
  • path (StrPath) – The path to the data file.

  • include_results (bool) – If True (default) and the results of the load flow are included in the file, the results are also loaded.

Returns:

The constructed instance.

Return type:

Self

to_dict(*, include_results=True)

Convert the element to a dictionary.

Parameters:

include_results (bool) – If True (default), the results of the load flow are included in the dictionary. If no results are available, this option is ignored.

Returns:

A JSON serializable dictionary with the element’s data.

Return type:

JsonDict

to_json(path, *, include_results=True, indent=True)

Save this element to a JSON file.

Note

The path is expanded then resolved before writing the file.

Warning

If the file exists, it will be overwritten.

Parameters:
  • path (StrPath) – The path to the output file to write the network to.

  • include_results (bool) – If True (default), the results of the load flow are included in the JSON file. If no results are available, this option is ignored.

  • indent (bool) – If True (default), the JSON output is pretty-printed with 2-space indentation. Set to False for compact output.

Returns:

The expanded and resolved path of the written file.

Return type:

Path

results_to_dict(full=False)

Return the results of the element as a dictionary.

The results dictionary of an element contains the ID of the element, its phases, and the result. For example, bus.results_to_dict() returns a dictionary with the form:

{"id": "bus1", "phases": "an", "potentials": [[230.0, 0.0], [0.0, 0.0]]}

Note that complex values (like potentials in the example above) are stored as list of [real part, imaginary part] so that it is JSON-serializable

Using the full argument, bus.results_to_dict(full=True) leads to the following results:

{"id": "bus1", "phases": "an", "potentials": [[230.0, 0.0], [0.0, 0.0]], "voltages": [[230.0, 0.0]]}

The results dictionary of the network contains the results of all of its elements grouped by the element type. It has the form:

{
    "buses": [bus1_dict, bus2_dict, ...],
    "lines": [line1_dict, line2_dict, ...],
    "transformers": [transformer1_dict, transformer2_dict, ...],
    "switches": [switch1_dict, switch2_dict, ...],
    "loads": [load1_dict, load2_dict, ...],
    "sources": [source1_dict, source2_dict, ...],
    "grounds": [ground1_dict, ground2_dict, ...],
    "potential_refs": [p_ref1_dict, p_ref2_dict, ...],
}

where each dict is produced by the element’s results_to_dict() method.

Parameters:

full (bool) – If True, all the results are added in the resulting dictionary. False by default.

Returns:

The dictionary of results.

Return type:

JsonDict

results_to_json(path, *, full=False, indent=True)

Write the results of the load flow to a json file.

Note

The path is expanded then resolved before writing the file.

Warning

If the file exists, it will be overwritten.

Parameters:
  • path (StrPath) – The path to the output file to write the results to.

  • full (bool) – If True, all the results are added in the resulting dictionary, including results computed from other results (such as voltages that could be computed from potentials). False by default.

  • indent (bool) – If True (default), the JSON output is pretty-printed with 2-space indentation. Set to False for compact output.

Returns:

The expanded and resolved path of the written file.

Return type:

Path

class Projection(type, alpha=_DEFAULT_ALPHA, epsilon=_DEFAULT_EPSILON)

This class defines the projection on the feasible circle for a flexible load.

The three possible projection types are:
  • "euclidean": for a Euclidean projection on the feasible space;

  • "keep_p": for maintaining a constant P;

  • "keep_q": for maintaining a constant Q.

Projection constructor.

Parameters:
  • type (ProjectionType) –

    The type of the projection. It can be:
    • "euclidean": for an Euclidean projection on the feasible space;

    • "keep_p": for maintaining a constant P;

    • "keep_q": for maintaining a constant Q.

  • alpha (Float) – This value is used to make soft sign function and to build a soft projection function.

  • epsilon (Float) – This value is used to make a smooth sqrt function.

type: ProjectionType
property alpha: float

This value is used to make soft sign function and to build a soft projection function.

Return type:

float

property epsilon: float

This value is used to make a smooth sqrt function. It is only used in the Euclidean projection.

Return type:

float

classmethod from_dict(data, *, include_results=True, copy=True)

Create an instance from a dictionary created with to_dict().

Parameters:
  • data (JsonDict) – The dictionary containing the data.

  • include_results (bool) – If True (default) and the results of the load flow are included in the dictionary, the results are also loaded.

  • copy (bool) – If True (default), the input dictionary is deep-copied before processing so the original is never modified. Pass False when the dictionary is a throwaway (e.g. freshly parsed from JSON) to avoid the copy overhead.

Returns:

The constructed instance.

Return type:

Self

classmethod from_json(path, *, include_results=True)

Construct an instance from a JSON file created with to_json().

Parameters:
  • path (StrPath) – The path to the data file.

  • include_results (bool) – If True (default) and the results of the load flow are included in the file, the results are also loaded.

Returns:

The constructed instance.

Return type:

Self

to_dict(*, include_results=True)

Convert the element to a dictionary.

Parameters:

include_results (bool) – If True (default), the results of the load flow are included in the dictionary. If no results are available, this option is ignored.

Returns:

A JSON serializable dictionary with the element’s data.

Return type:

JsonDict

to_json(path, *, include_results=True, indent=True)

Save this element to a JSON file.

Note

The path is expanded then resolved before writing the file.

Warning

If the file exists, it will be overwritten.

Parameters:
  • path (StrPath) – The path to the output file to write the network to.

  • include_results (bool) – If True (default), the results of the load flow are included in the JSON file. If no results are available, this option is ignored.

  • indent (bool) – If True (default), the JSON output is pretty-printed with 2-space indentation. Set to False for compact output.

Returns:

The expanded and resolved path of the written file.

Return type:

Path

results_to_dict(full=False)

Return the results of the element as a dictionary.

The results dictionary of an element contains the ID of the element, its phases, and the result. For example, bus.results_to_dict() returns a dictionary with the form:

{"id": "bus1", "phases": "an", "potentials": [[230.0, 0.0], [0.0, 0.0]]}

Note that complex values (like potentials in the example above) are stored as list of [real part, imaginary part] so that it is JSON-serializable

Using the full argument, bus.results_to_dict(full=True) leads to the following results:

{"id": "bus1", "phases": "an", "potentials": [[230.0, 0.0], [0.0, 0.0]], "voltages": [[230.0, 0.0]]}

The results dictionary of the network contains the results of all of its elements grouped by the element type. It has the form:

{
    "buses": [bus1_dict, bus2_dict, ...],
    "lines": [line1_dict, line2_dict, ...],
    "transformers": [transformer1_dict, transformer2_dict, ...],
    "switches": [switch1_dict, switch2_dict, ...],
    "loads": [load1_dict, load2_dict, ...],
    "sources": [source1_dict, source2_dict, ...],
    "grounds": [ground1_dict, ground2_dict, ...],
    "potential_refs": [p_ref1_dict, p_ref2_dict, ...],
}

where each dict is produced by the element’s results_to_dict() method.

Parameters:

full (bool) – If True, all the results are added in the resulting dictionary. False by default.

Returns:

The dictionary of results.

Return type:

JsonDict

results_to_json(path, *, full=False, indent=True)

Write the results of the load flow to a json file.

Note

The path is expanded then resolved before writing the file.

Warning

If the file exists, it will be overwritten.

Parameters:
  • path (StrPath) – The path to the output file to write the results to.

  • full (bool) – If True, all the results are added in the resulting dictionary, including results computed from other results (such as voltages that could be computed from potentials). False by default.

  • indent (bool) – If True (default), the JSON output is pretty-printed with 2-space indentation. Set to False for compact output.

Returns:

The expanded and resolved path of the written file.

Return type:

Path

class FlexibleParameter(control_p, control_q, projection, s_max, q_min=None, q_max=None)

Flexible parameters of a flexible load.

This class encapsulate single-phase flexibility information of a flexible load:

  • The active power Control to apply;

  • The reactive power Control to apply;

  • The Projection to use when dealing with voltage violations;

  • The apparent power of the flexible load (VA). This is the maximum power the load can consume/produce. It is the radius of the feasible circle used by the projection

For multi-phase loads, you need to use a FlexibleParameter instance per phase.

FlexibleParameter constructor.

Parameters:
  • control_p (Control) – The control to apply on the active power.

  • control_q (Control) – The control to apply on the reactive power.

  • projection (Projection) – The projection to use to have a feasible result.

  • s_max (Float | Q_[Float]) – The apparent power of the flexible load (VA). It is the radius of the feasible circle.

  • q_min (Float | Q_[Float] | None) – The minimum reactive power of the flexible load (VAr). By default it is equal to -s_max, but it can be further constrained.

  • q_max (Float | Q_[Float] | None) – The maximum reactive power of the flexible load (VAr). By default it is equal to s_max, but it can be further constrained.

control_p
control_q
projection
property s_max: Q_[float]

The apparent power of the flexible load (VA). It is the radius of the feasible circle.

Return type:

Q_[float]

property q_min: Q_[float]

The minimum reactive power of the flexible load (VAr).

Return type:

Q_[float]

property q_max: Q_[float]

The maximum reactive power of the flexible load (VAr).

Return type:

Q_[float]

classmethod constant()

Build flexible parameters for a constant control with a Euclidean projection.

Returns:

A constant control i.e. no control at all. It is an equivalent of the constant power load.

Return type:

Self

classmethod p_max_u_production(u_up, u_max, s_max, alpha_control=Control._DEFAULT_ALPHA, epsilon_control=Control._DEFAULT_EPSILON, type_proj=Projection._DEFAULT_TYPE, alpha_proj=Projection._DEFAULT_ALPHA, epsilon_proj=Projection._DEFAULT_EPSILON)

Build flexible parameters for production P(U) control with a Euclidean projection.

Parameters:
  • u_up (Float | Q_[Float]) – The voltage upper limit value that triggers the control. If the voltage is greater than this value, the production active power is reduced.

  • u_max (Float | Q_[Float]) – The maximum voltage i.e. the one the control reached its maximum action. If the voltage is greater than this value, the production active power is reduced to zero.

  • s_max (Float | Q_[Float]) – The apparent power of the flexible inverter (VA). It is the radius of the feasible circle.

  • alpha_control (Float) – An approximation factor used by the family function (soft clip). The greater, the closer the function are from the non-differentiable function.

  • epsilon_control (Float) – This value is used to make a smooth inverse function for the control.

  • type_proj (ProjectionType) – The type of the projection to use.

  • alpha_proj (Float) – This value is used to make soft sign function and to build a soft projection function (see the diagram above).

  • epsilon_proj (Float) – This value is used to make a smooth sqrt function. It is only used in the Euclidean projection.

Returns:

A flexible parameter which performs “p_max_u_production” control.

Return type:

Self

classmethod p_max_u_consumption(u_min, u_down, s_max, alpha_control=Control._DEFAULT_ALPHA, epsilon_control=Control._DEFAULT_EPSILON, type_proj=Projection._DEFAULT_TYPE, alpha_proj=Projection._DEFAULT_ALPHA, epsilon_proj=Projection._DEFAULT_EPSILON)

Build flexible parameters for consumption P(U) control with a Euclidean projection.

Parameters:
  • u_min (Float | Q_[Float]) – The minimum voltage i.e. the one the control reached the maximum action.

  • u_down (Float | Q_[Float]) – The voltage which starts to trigger the control (lower value).

  • s_max (Float | Q_[Float]) – The apparent power of the flexible load (VA). It is the radius of the feasible circle.

  • alpha_control (Float) – An approximation factor used by the family function (soft clip). The greater, the closer the function are from the non-differentiable function.

  • epsilon_control (Float) – This value is used to make a smooth inverse function for the control.

  • type_proj (ProjectionType) – The type of the projection to use.

  • alpha_proj (Float) – This value is used to make soft sign function and to build a soft projection function.

  • epsilon_proj (Float) – This value is used to make a smooth sqrt function. It is only used in the Euclidean projection.

Returns:

A flexible parameter which performs “p_max_u_consumption” control.

Return type:

Self

classmethod q_u(u_min, u_down, u_up, u_max, s_max, q_min=None, q_max=None, alpha_control=Control._DEFAULT_ALPHA, type_proj=Projection._DEFAULT_TYPE, alpha_proj=Projection._DEFAULT_ALPHA, epsilon_proj=Projection._DEFAULT_EPSILON)

Build flexible parameters for Q(U) control with a Euclidean projection.

Parameters:
  • u_min (Float | Q_[Float]) – The minimum voltage i.e. the one the control reached the maximum action.

  • u_down (Float | Q_[Float]) – The voltage which starts to trigger the control (lower value).

  • u_up (Float | Q_[Float]) – The voltage which starts to trigger the control (upper value).

  • u_max (Float | Q_[Float]) – The maximum voltage i.e. the one the control reached its maximum action.

  • s_max (Float | Q_[Float]) – The apparent power of the flexible load (VA). It is the radius of the feasible circle.

  • q_min (Float | Q_[Float] | None) – The minimum reactive power of the flexible load (VAr). By default, it is equal to -s_max, but it can be further constrained.

  • q_max (Float | Q_[Float] | None) – The maximum reactive power of the flexible load (VAr). By default, it is equal to s_max, but it can be further constrained.

  • alpha_control (Float) – An approximation factor used by the family function (soft clip). The greater, the closer the function are from the non-differentiable function.

  • type_proj (ProjectionType) – The type of the projection to use.

  • alpha_proj (Float) – This value is used to make soft sign function and to build a soft projection function.

  • epsilon_proj (Float) – This value is used to make a smooth sqrt function. It is only used in the Euclidean projection.

Returns:

A flexible parameter which performs “q_u” control.

Return type:

Self

classmethod pq_u_production(up_up, up_max, uq_min, uq_down, uq_up, uq_max, s_max, q_min=None, q_max=None, alpha_control=Control._DEFAULT_ALPHA, epsilon_control=Control._DEFAULT_EPSILON, type_proj=Projection._DEFAULT_TYPE, alpha_proj=Projection._DEFAULT_ALPHA, epsilon_proj=Projection._DEFAULT_EPSILON)

Build flexible parameters for production P(U) control and Q(U) control with a Euclidean projection.

Parameters:
  • up_up (Float | Q_[Float]) – The voltage which starts to trigger the control on the production (upper value).

  • up_max (Float | Q_[Float]) – The maximum voltage i.e. the one the control (of production) reached its maximum action.

  • uq_min (Float | Q_[Float]) – The minimum voltage i.e. the one the control reached the maximum action (reactive power control)

  • uq_down (Float | Q_[Float]) – The voltage which starts to trigger the reactive power control (lower value).

  • uq_up (Float | Q_[Float]) – The voltage which starts to trigger the reactive power control (upper value).

  • uq_max (Float | Q_[Float]) – The maximum voltage i.e. the one the reactive power control reached its maximum action.

  • s_max (Float | Q_[Float]) – The apparent power of the flexible load (VA). It is the radius of the feasible circle.

  • q_min (Float | Q_[Float] | None) – The minimum reactive power of the flexible load (VAr). By default, it is equal to -s_max, but it can be further constrained.

  • q_max (Float | Q_[Float] | None) – The maximum reactive power of the flexible load (VAr). By default, it is equal to s_max, but it can be further constrained.

  • alpha_control (Float) – An approximation factor used by the family function (soft clip). The greater, the closer the function are from the non-differentiable function.

  • epsilon_control (Float) – This value is used to make a smooth inverse function for the control.

  • type_proj (ProjectionType) – The type of the projection to use.

  • alpha_proj (Float) – This value is used to make soft sign function and to build a soft projection function.

  • epsilon_proj (Float) – This value is used to make a smooth sqrt function. It is only used in the Euclidean projection.

Returns:

A flexible parameter which performs “p_max_u_production” control and a “q_u” control.

Return type:

Self

See also

p_max_u_production() and q_u() for more details.

classmethod pq_u_consumption(up_min, up_down, uq_min, uq_down, uq_up, uq_max, s_max, q_min=None, q_max=None, alpha_control=Control._DEFAULT_ALPHA, epsilon_control=Control._DEFAULT_EPSILON, type_proj=Projection._DEFAULT_TYPE, alpha_proj=Projection._DEFAULT_ALPHA, epsilon_proj=Projection._DEFAULT_EPSILON)

Build flexible parameters for consumption P(U) control and Q(U) control with a Euclidean projection.

Parameters:
  • up_min (Float | Q_[Float]) – The minimum voltage i.e. the one the active power control reached the maximum action.

  • up_down (Float | Q_[Float]) – The voltage which starts to trigger the active power control (lower value).

  • uq_min (Float | Q_[Float]) – The minimum voltage i.e. the one the control reached the maximum action (reactive power control)

  • uq_down (Float | Q_[Float]) – The voltage which starts to trigger the reactive power control (lower value).

  • uq_up (Float | Q_[Float]) – The voltage which starts to trigger the reactive power control (upper value).

  • uq_max (Float | Q_[Float]) – The maximum voltage i.e. the one the reactive power control reached its maximum action.

  • s_max (Float | Q_[Float]) – The apparent power of the flexible load (VA). It is the radius of the feasible circle.

  • q_min (Float | Q_[Float] | None) – The minimum reactive power of the flexible load (VAr). By default, it is equal to -s_max, but it can be further constrained.

  • q_max (Float | Q_[Float] | None) – The maximum reactive power of the flexible load (VAr). By default, it is equal to s_max, but it can be further constrained.

  • alpha_control (Float) – An approximation factor used by the family function (soft clip). The greater, the closer the function are from the non-differentiable function.

  • epsilon_control (Float) – This value is used to make a smooth inverse function for the control.

  • type_proj (ProjectionType) – The type of the projection to use.

  • alpha_proj (Float) – This value is used to make soft sign function and to build a soft projection function.

  • epsilon_proj (Float) – This value is used to make a smooth sqrt function. It is only used in the Euclidean projection.

Returns:

A flexible parameter which performs “p_max_u_consumption” control and “q_u” control.

Return type:

Self

See also

p_max_u_consumption() and q_u() for more details.

compute_powers(voltages, power)

Compute the flexible powers for different voltages (norms)

Parameters:
  • voltages (ComplexArrayLike1D) – The array of voltage norms to test with this flexible parameter.

  • power (Complex | Q_[Complex]) – The input theoretical power of the load.

Returns:

The flexible powers really consumed taking into account the control. One value per provided voltage norm.

Return type:

Q_[ComplexArray]

plot_pq(voltages, power, ax=None, voltages_labels_mask=None)

Plot the “trajectory” of the flexible powers (in the (P, Q) plane) for the provided voltages and theoretical power.

Parameters:
  • voltages (FloatArrayLike1D) – Array-like of voltage norms to test with this flexible parameter.

  • power (Complex | Q_[Complex]) – The input theoretical power of the load.

  • ax (Axes | None) – The optional axis to use for the plot. The current axis is used by default.

  • voltages_labels_mask (numpy.typing.NDArray[numpy.bool_] | None) – A mask to activate the plot of voltages labels. By default, no voltages annotations.

Returns:

The axis on which the plot has been drawn and the resulting flexible powers (the input if not None else the computed values).

Return type:

tuple[Axes, Q_[ComplexArray]]

plot_control_p(voltages, power, ax=None)

Plot the flexible active power consumed (or produced) for the provided voltages and theoretical power.

Parameters:
  • voltages (FloatArrayLike1D) – Array-like of voltage norms to test with this flexible parameter.

  • power (Complex | Q_[Complex]) – The input theoretical power of the load.

  • ax (Axes | None) – The optional axis to use for the plot. The current axis is used by default.

Returns:

The axis on which the plot has been drawn and the resulting flexible powers (the input if not None else the computed values).

Return type:

tuple[Axes, Q_[ComplexArray]]

plot_control_q(voltages, power, ax=None)

Plot the flexible reactive power consumed (or produced) for the provided voltages and theoretical power.

Parameters:
  • voltages (FloatArrayLike1D) – Array-like of voltage norms to test with this flexible parameter.

  • power (Complex | Q_[Complex]) – The input theoretical power of the load.

  • ax (Axes | None) – The optional axis to use for the plot. The current axis is used by default.

Returns:

The axis on which the plot has been drawn and the resulting flexible powers (the input if not None else the computed values).

Return type:

tuple[Axes, Q_[ComplexArray]]

classmethod from_dict(data, *, include_results=True, copy=True)

Create an instance from a dictionary created with to_dict().

Parameters:
  • data (JsonDict) – The dictionary containing the data.

  • include_results (bool) – If True (default) and the results of the load flow are included in the dictionary, the results are also loaded.

  • copy (bool) – If True (default), the input dictionary is deep-copied before processing so the original is never modified. Pass False when the dictionary is a throwaway (e.g. freshly parsed from JSON) to avoid the copy overhead.

Returns:

The constructed instance.

Return type:

Self

classmethod from_json(path, *, include_results=True)

Construct an instance from a JSON file created with to_json().

Parameters:
  • path (StrPath) – The path to the data file.

  • include_results (bool) – If True (default) and the results of the load flow are included in the file, the results are also loaded.

Returns:

The constructed instance.

Return type:

Self

to_dict(*, include_results=True)

Convert the element to a dictionary.

Parameters:

include_results (bool) – If True (default), the results of the load flow are included in the dictionary. If no results are available, this option is ignored.

Returns:

A JSON serializable dictionary with the element’s data.

Return type:

JsonDict

to_json(path, *, include_results=True, indent=True)

Save this element to a JSON file.

Note

The path is expanded then resolved before writing the file.

Warning

If the file exists, it will be overwritten.

Parameters:
  • path (StrPath) – The path to the output file to write the network to.

  • include_results (bool) – If True (default), the results of the load flow are included in the JSON file. If no results are available, this option is ignored.

  • indent (bool) – If True (default), the JSON output is pretty-printed with 2-space indentation. Set to False for compact output.

Returns:

The expanded and resolved path of the written file.

Return type:

Path

results_to_dict(full=False)

Return the results of the element as a dictionary.

The results dictionary of an element contains the ID of the element, its phases, and the result. For example, bus.results_to_dict() returns a dictionary with the form:

{"id": "bus1", "phases": "an", "potentials": [[230.0, 0.0], [0.0, 0.0]]}

Note that complex values (like potentials in the example above) are stored as list of [real part, imaginary part] so that it is JSON-serializable

Using the full argument, bus.results_to_dict(full=True) leads to the following results:

{"id": "bus1", "phases": "an", "potentials": [[230.0, 0.0], [0.0, 0.0]], "voltages": [[230.0, 0.0]]}

The results dictionary of the network contains the results of all of its elements grouped by the element type. It has the form:

{
    "buses": [bus1_dict, bus2_dict, ...],
    "lines": [line1_dict, line2_dict, ...],
    "transformers": [transformer1_dict, transformer2_dict, ...],
    "switches": [switch1_dict, switch2_dict, ...],
    "loads": [load1_dict, load2_dict, ...],
    "sources": [source1_dict, source2_dict, ...],
    "grounds": [ground1_dict, ground2_dict, ...],
    "potential_refs": [p_ref1_dict, p_ref2_dict, ...],
}

where each dict is produced by the element’s results_to_dict() method.

Parameters:

full (bool) – If True, all the results are added in the resulting dictionary. False by default.

Returns:

The dictionary of results.

Return type:

JsonDict

results_to_json(path, *, full=False, indent=True)

Write the results of the load flow to a json file.

Note

The path is expanded then resolved before writing the file.

Warning

If the file exists, it will be overwritten.

Parameters:
  • path (StrPath) – The path to the output file to write the results to.

  • full (bool) – If True, all the results are added in the resulting dictionary, including results computed from other results (such as voltages that could be computed from potentials). False by default.

  • indent (bool) – If True (default), the JSON output is pretty-printed with 2-space indentation. Set to False for compact output.

Returns:

The expanded and resolved path of the written file.

Return type:

Path