soft4pes.control.common#

Common control system components.

Submodules#

Classes#

ControlSystem

ControlSystem class to manage and execute a set of control loops. The class accepts any number

Controller

Base class for controllers.

FirstOrderFilter

General first-order filter.

Functions#

wrap_theta(theta)

Wrap the angle theta to the range [-pi, pi].

get_modulating_signal(v_ref, v_dc)

Convert a voltage reference to a modulating signal.

magnitude_limiter(input_signal, limit)

Limit the input in to maximum magnitude. The input can be in alpha-beta or dq-frame, and given

Package Contents#

class soft4pes.control.common.ControlSystem(control_loops, ref_seq, Ts, pwm=None)[source]#

ControlSystem class to manage and execute a set of control loops. The class accepts any number of control loops and combines them to a complete control system.

Parameters:
  • control_loops (list) – List of controller instances. The control loops are executed in the order they appear in the list.

  • ref_seq (SimpleNamespace) – Reference sequences for the control system. The sequences must be of class Sequence. The references are given to the first control loop in the list.

  • Ts (float) – Sampling interval [s].

  • pwm (modulator, optional) – Modulator for generating three-phase switch positions.

ref_seq#

Reference sequences for the control system. The sequences must be of class Sequence.

Type:

SimpleNamespace

data#

Data storage for the control system.

Type:

SimpleNamespace

Ts#

Sampling interval [s].

Type:

float

pwm#

Modulator for generating three-phase switch positions.

Type:

modulator, optional

control_loops#

List of controller instances.

Type:

list

__call__(sys, kTs)[source]#

Execute the control system for a given discrete time step. The control system 1. Gets the references for the current time step. 2. Executes the control loops in the order they appear in the list. 3. Generates the three-phase switch position if modulator is used.

Parameters:
  • sys (object) – System model.

  • kTs (float) – Current discrete time instant [s].

Returns:

u_abc – Three-phase switch position or modulating signal.

Return type:

ndarray

get_references(kTs)[source]#

Get the references for the current time step. A new SimpleNamespace object is created and the ‘_seq’ subscript is removed from the attribute names.

Parameters:

kTs (float) – Current discrete time instant [s].

Returns:

ref – References for the first control loop of the control system.

Return type:

SimpleNamespace

save_data(kTs)[source]#

Save the current time step to the control system data.

Parameters:

kTs (float) – Current discrete time instant [s].

get_control_system_data()[source]#

Fetch and save the data of the individual control loops. The data is saved with the name of the control loop class.

class soft4pes.control.common.Controller[source]#

Bases: abc.ABC

Base class for controllers.

data#

Data storage for the controller, containing input and output namespaces.

Type:

SimpleNamespace

input#

Namespace for storing input data.

Type:

SimpleNamespace

output#

Namespace for storing output data.

Type:

SimpleNamespace

Ts#

Sampling interval [s].

Type:

float

set_sampling_interval(Ts)[source]#

Set the sampling interval.

This method can be extended to set and/or calculate additional parameters.

Parameters:

Ts (float) – Sampling interval [s].

abstract execute(sys, kTs)[source]#

Execute the controller.

Parameters:
  • sys (object) – System model.

  • kTs (float) – Current discrete time instant [s].

Returns:

output – The output of the controller after execution.

Return type:

SimpleNamespace

save_data()[source]#

Save controller data.

The method saves the current input and output data to the data storage.

soft4pes.control.common.wrap_theta(theta)[source]#

Wrap the angle theta to the range [-pi, pi].

Parameters:

theta (float) – The angle in radians.

Returns:

The wrapped angle in radians.

Return type:

float

soft4pes.control.common.get_modulating_signal(v_ref, v_dc)[source]#

Convert a voltage reference to a modulating signal.

Parameters:
  • v_ref (ndarray) – The reference voltage in alpha-beta frame.

  • v_dc (float) – The dc-link voltage.

Returns:

The modulating signal in abc-frame.

Return type:

ndarray

soft4pes.control.common.magnitude_limiter(input_signal, limit)[source]#

Limit the input in to maximum magnitude. The input can be in alpha-beta or dq-frame, and given as a vector or complex number.

Parameters:
  • limit (float) – Maximum magnitude [p.u.].

  • input_signal (1 x 2 ndarray of floats or complex) – Unlimited input [p.u.].

Returns:

Limited output [p.u.].

Return type:

1 x 2 ndarray of floats

class soft4pes.control.common.FirstOrderFilter(w_bw, size)[source]#

General first-order filter.

Parameters:
  • w_bw (float) – The bandwidth of the filter [p.u.].

  • size (int) – The size of the signal to be filtered, i.e. the length of the input vector.

w_bw#

The bandwidth of the filter [p.u.].

Type:

float

output#

The filtered signal.

Type:

ndarray

update(value_in, Ts, base)[source]#

Update the filter with a new input signal of the defined size.

Parameters:
  • value_in (ndarray) – The input signal to be filtered.

  • Ts (float) – The sampling interval [s].

  • base (object) – The base values object containing the base angular frequency.