Engee documentation
Notebook

Modelling and analysis of AFE active rectifier operation

The case study is devoted to modelling and analysis of an AFE (Active Front End) rectifier, including investigation of its control algorithms, consumption and energy recovery modes. Based on the Engee simulation, the key advantages of AFE are demonstrated: maintaining power factor close to 1, reducing harmonic distortion of current up to 5.8% and stabilising the voltage in the DC link. The results of the work are relevant for designers of power electronics systems, energy-efficient transport and industrial electric drives, where modern approaches to energy flow control and minimising the impact on the grid are required.

Introduction

AFE rectifier (Active Front End) is an active electronic device designed to convert AC to DC with high power factor and minimal harmonic distortion. Its creation is related to the development of power electronics since the 1980s, when Siemens, ABB, Danfoss and others started to introduce IGBT and digital control systems. In contrast to passive diode rectifiers, AFE uses IGBTs operating "on the grid", which ensures bi-directionality of the converter: not only to consume energy from the grid, but also to return it back, for example, during regenerative braking.

AFE rectifiers are used in industrial drives, renewable energy systems, transport (electric trains, subways, electric buses) and energy-intensive industries (rolling mills, data centres). For example, in subways, AFEs enable the recovery of braking energy into the grid, reducing overall energy consumption. The key advantages of such rectifiers are high efficiency, compactness, reduced network noise and the ability to work with unstable voltages. These features make them indispensable in modern systems where intelligent energy management and environmental sustainability are required.

Example model

The model Active_front_end.engee, considered in this example, is recreated from its analogue, the model Active_front_end.slx [1].

image_2.png

The power section consists of the following elements.

  • Three-phase voltage source $U_{ЛИН\, rms}=220\, В$.
  • Units for measuring phase voltages and currents.
  • Cable line with resistance $R_ф=1\, Ом$ and inductance $L_ф=10\, мГн$.
  • Bridge three-phase converter Converter on NPN-IGBT with reverse diodes, the top keys are set by collectors into the three-phase network, and the reverse diodes act as a rectifier set.
  • DC link capacitor with a capacitance of $С_к = 4700\, мкФ$.
  • The minimum active load in the DC link is a resistor with resistance $R_1=100\, Ом$.
  • Connected active load in the DC link - resistor with resistance $R_2=100\, Ом$.
  • Connected counter-EDS in the DC link with a value of $V_{brk}=750\, В$, and a resistor with a resistance of $R_3=10\, Ом$ - braking simulation.
  • Voltmeter in the DC link.

The load $R_2$ is switched on at $1.0\, с$ model time, switched off at $2.0\, с$. The counter-EDS circuit is switched at $3.0\, с$.

The AFE algorithm functions in all modes of rectifier operation.

Description of the AFE operating principle

The IGBT inverter (Converter) receives the PWM control signals from the PWM generator module (PWM Generator). The PWM reference signal is triangular with frequency $f_{PWM}=5\, кГц$. The PWM generator reference signals are phase voltages $V_{abc\,ue}^*$ in three-phase coordinate system $abc$:

$$V_{abc\,ue}^*=\frac{1}{8000}\cdot V_{abc}^*.$$

In turn, $V_{abc}^*$ is obtained by the inverse Park-Gorev transformation from $V_{dq}^*$

$$V_{abc}^* = \left[ \begin{matrix} \sin (\theta) & \cos (\theta) & 1 \\ \sin (\theta-\frac{2\pi}{3}) & \cos (\theta-\frac{2\pi}{3}) & 1 \\ \sin (\theta+\frac{2\pi}{3}) & \cos (\theta+\frac{2\pi}{3}) & 1 \\ \end{matrix} \right]\times V_{dq}^*,$$

where $V_{dq}^*=\left[ \begin{matrix} V_{d}^* \\ V_{q}^* \\ 0 \\ \end{matrix} \right]$ is the set voltage in the rotating coordinate system $dq0$, $\theta$ - rotation angle of the rotating coordinate system calculated by the phase frequency autotuning (PFA) in the block PLL.

In turn, these components are defined by the following expressions:

$$V_{d}^*=V_d + 2 \pi \cdot f_0 \cdot L_ф \cdot I_{q} - V_{PI\,d}^*$$ $$V_{q}^*=V_q - 2 \pi \cdot f_0 \cdot L_ф \cdot I_{d} - V_{PI\,q}^*$$

Here:

  • $f_0=50\,Гц$ - basic harmonic of the supply voltage;
  • $V_d,\,V_q$ - measured voltages in rotating coordinate system $dq0$;
  • $I_{d},\,I_{q}$ - measured phase currents in rotating coordinate system $dq0$;
  • $V_{PI\,d}^*,\,V_{PI\,q}^*$ - output voltages of PI current controllers Current Controller in rotating coordinate system $dq0$;

Voltages $V_d,\,V_q$ and currents $I_{d},\,I_{q}$ are obtained using Park-Gorev direct conversion blocks from measured phase currents and voltages $V_a,\,V_b,\,V_c$ and $I_a,\,I_b,\,I_c$:

$$ \left[ \begin{matrix} V_d \\ V_q \\ 0 \\ \end{matrix} \right] = \frac{2}{3}\cdot \left[ \begin{matrix} \sin (\theta) & \sin (\theta-\frac{2\pi}{3}) & \sin (\theta+\frac{2\pi}{3}) \\ \cos (\theta) & \cos (\theta-\frac{2\pi}{3}) & \cos (\theta+\frac{2\pi}{3}) \\ \frac{1}{2} & \frac{1}{2} & \frac{1}{2} \\ \end{matrix} \right] \times \left[ \begin{matrix} V_a \\ V_b \\ V_c \\ \end{matrix} \right], $$ $$ \left[ \begin{matrix} I_d \\ I_q \\ 0 \\ \end{matrix} \right] = \frac{2}{3}\cdot \left[ \begin{matrix} \sin (\theta) & \sin (\theta-\frac{2\pi}{3}) & \sin (\theta+\frac{2\pi}{3}) \\ \cos (\theta) & \cos (\theta-\frac{2\pi}{3}) & \cos (\theta+\frac{2\pi}{3}) \\ \frac{1}{2} & \frac{1}{2} & \frac{1}{2} \\ \end{matrix} \right] \times \left[ \begin{matrix} I_a \\ I_b \\ I_c \\ \end{matrix} \right]. $$

PI current controllers Current Controller obtain the difference between measured and set current signals in a rotating coordinate system $dq0$:

$$\Delta I_d=I_d^*-I_d,$$ $$\Delta I_q=I_q^*-I_q.$$

The projection of the set current on the axis $D$, $I_d^*$ is the result of regulation of the voltage PI controller Voltage Controller. It receives the difference of the measured and setpoint voltage values in the DC link:

$$\Delta V_{DC}=V_{DC}^*-V_{DC},$$ $$V_{DC}^*=600\,В.$$

The projection of the setpoint current on the axis $Q$, $I_q^*$ is set equal to $0$ to form the $PF=1$

The AFE control system shown above reproduces the above relationships in the form of a block diagram.

Modelling

Using software control, we run the example model and write the results of the simulation to the variable simout.

In [ ]:
модель = engee.load("/user/start/examples/power_systems/active_front_end_rectifier/Active_front_end.engee", force = true);     # Загружаем модель
engee.run(модель);                                           # Выполняем модель и сохраняем данные

After running the model, close it and proceed to signal analysis.

In [ ]:
engee.close(модель; force=true);

Analysis of recorded signals

From the recorded signals of the model, let us extract the signals of simulation time, current and voltage of phase A, voltage in the DC link:

In [ ]:
t = simout["Active_front_end/Va"].time;
Va = simout["Active_front_end/Va"].value;
Ia = simout["Active_front_end/Ia"].value;
Vdc = simout["Active_front_end/Vdc"].value;

Output the oscillograms of phase A current and voltage for different modes of AFE operation: consumption with normal load, consumption with increased load and regeneration.

In [ ]:
using Plots; gr()

start = Int(1e6÷5*0.5);
start_load = Int(1e6÷5);
start_recup = Int(1e6÷5*3); 
stop = Int(1e6÷5/50*5);

usual = start:start+stop
load = start_load:start_load+stop
recup = start_recup:start_recup+stop;

plot_usual = plot(t[usual], [Ia[usual], Va[usual]]; label=["Ia⋅13, А" "Va, В"], title = "Обычная нагрузка")
plot_load = plot(t[load], [Ia[load], Va[load]]; label=["Ia⋅13, А" "Va, В"], title = "Повышенная нагрузка")
plot_recup = plot(t[recup], [Ia[recup], Va[recup]]; label=["Ia⋅13, А" "Va, В"], title = "Рекуперация")

plot(plot_usual, plot_load, plot_recup;
     size=(1200,300), legend = :topright, xlabel = "Время, с", ylabel = "Напряжение, ток", layout=(1,3))
Out[0]:

As can be seen from these oscillograms, the current and voltage coincide in phase in the consumption mode, the shape of the current consumed/generated is close to sinusoidal, while in the regeneration mode the current and voltage phases are inverted. The latter means that the AFE provides regeneration of braking energy into the network (which is simulated by the inclusion of the DC link counter-EDS).

Based on the DC link voltage graph below, it can be concluded that in the different AFE operating modes, the voltage level is stabilised and equal to the set voltage at $V_{DC}^*=600\, В$.

In [ ]:
gr(); plot(t[1:2000:end], Vdc[1:2000:end]; legend=:none, title = "Напряжение в звене постоянного тока")
Out[0]:

Power factor analysis

Install and connect the libraries required for the analysis

In [ ]:
import Pkg; Pkg.add(["FFTW", "LinearAlgebra"]);
using FFTW, LinearAlgebra;

In addition to maintaining the DC link voltage and providing energy recovery to the grid, the AFE rectifier compensates the reactive power consumption, increasing the power factor $(PF,\, \cos\phi)$ to almost 1. From the data obtained (voltage and current of phase A), calculate and analyse the power factor for each voltage period.

In [ ]:
# Подключим функцию расчёта коэффициента мощности для каждого периода входных векторов тока и напряжения
include("/user/start/examples/power_systems/active_front_end_rectifier/pf_calculation.jl");
# Расчет коэффициентов
коэффициенты_мощности = calculate_power_factor(Vector(Va), Vector(Ia));
In [ ]:
# Построим интерактивный график коэффициента мощности
plotlyjs();
plot(0:0.02:3.98, коэффициенты_мощности;
    legend=:none, title="Коэффициент мощности", ylabel="cos(ϕ), о.е.")
Out[0]:

From the obtained power factor graph we can judge the following:

  • in the mode of energy consumption from the grid $(PF > 0)$ AFE provides $PF \approx 1$ regardless of the load level;
  • in the mode of energy recovery to the grid $(PF < 0)$ AFE provides $PF \approx -1$;

Analysis of harmonic distortion during AFE operation

Another undeniable advantage of using an AFE active rectifier is the reduction of harmonic distortion of the current in both consumption and regeneration modes. The current oscillograms above show that in the regeneration mode the signal differs more from the sinusoidal shape than in the consumption mode. In addition, the harmonic distortion will be more pronounced in some periods of the carrier frequency than throughout the entire operating mode. Therefore, to estimate the maximum THD of the current and voltage, we will take a period of one period of the fundamental harmonic of the supply voltage $f_0=50\,Гц$ in regenerative mode.

In [ ]:
# Подключим функцию для расчёта THD и гармонического спектра
# Скрипт также устанавливает и подключает требуемые библиотеки (FFTW.jl, LinearAlgebra.jl)
include("/user/start/examples/power_systems/active_front_end_rectifier/thd_calculation.jl");
In [ ]:
# Зададим начальные условия
start_recup = Int(1e6÷5*3.02);  # Начальная точка анализа
stop = Int(1e6÷5*3.04);         # Конечная точка анализа

sample_rate = Int(1e6÷5)        # Частота дискретизации, Гц
f_base = 50;                    # Частота базовой гармоники, Гц
n_max = 40;                     # Наибольший порядок искажающей гармоники
In [ ]:
# Получим результаты анализа THD и гармонических спектров
result_Ia = calculate_thd(Ia[start_recup:stop], sample_rate, n_max, f_base);
result_Va = calculate_thd(Va[start_recup:stop], sample_rate, n_max, f_base);
In [ ]:
# Построим гармонические спектры тока и напряжения, выведем значения THD
gr();

let
    # График гармонического спектра тока
    plot(result_Ia.frequencies, result_Ia.amplitudes, 
        label="Спектр тока", linewidth=2)

    # График гармонического спектра напряжения
    plot!(result_Va.frequencies, result_Va.amplitudes, 
        label="Спектр напряжения", linewidth=1,
        seriestype=:path, linestyle=:dash, color=:black)

    # Маркер амплитуды базовой гармоники
    scatter!([result_Ia.frequencies[result_Ia.fundamental_idx]], 
            [result_Ia.amplitudes[result_Ia.fundamental_idx]],
            label="Базовая гармоника", markersize=4, color=:red)
    vline!([result_Ia.frequencies[result_Ia.fundamental_idx]], 
            linestyle=:dash, color=:gray, label=:none)

    # Маркеры амплитуд гармоник высших порядков
    if !isempty(result_Ia.frequencies[result_Ia.harmonic_indices])
        scatter!(result_Ia.frequencies[result_Ia.harmonic_indices], 
                result_Ia.amplitudes[result_Ia.harmonic_indices],
                label="Высшие гармоники", markersize=4, color=:green)
        vline!(result_Ia.frequencies[result_Ia.harmonic_indices],
              linestyle=:dash, color=:gray, label=:none)
    end
    
    # Настройки отображения
    xlims!(0, n_max)
    xticks!(1:2:n_max)
    display(plot!(yscale=:log; xlabel="Частота, (Гц)", ylabel="Амплитуда, log(A)",
            title="Гармонический анализ", legend=:bottom,))

    # Вывод значений суммарных гармонических искажений напряжения и тока
    println("THD_v: ", round(result_Va.thd, digits=2), " %")
    println("THD_i: ", round(result_Ia.thd, digits=2), " %")
end
THD_v: 0.01 %
THD_i: 5.8 %

The representation of the harmonic spectrum in the logarithmic amplitude scale is not classical, but it gives the most detailed visual representation of the spectral composition of the analysed signal. From the obtained data we can judge about the following:

  • The total level of harmonic distortions of the current $THD_{I\,\%}=5.82\, \%$, therefore, AFE fully copes with the reduction of harmonic distortions of the current from the uncontrolled rectifier.
  • The harmonics most pronounced on the current spectrum belong to the orders $n=k\cdot m\pm 1,\, k \in\mathbb{N}^*$, where $m=6$ is the pulse rate of the rectifier circuit.

Conclusion

A case study has simulated the operation of an AFE rectifier using Engee, confirming the device's ability to maintain a power factor close to 1 and reduce current harmonic distortion to 5.8% even in regenerative mode. The system is shown to stably hold the DC link voltage at a given level (e.g., 800 V) under varying loads, demonstrating the effectiveness of bidirectional energy management. The results confirm that AFE significantly reduces reactive power and electromagnetic interference, which is critical for energy-intensive applications (subways, industrial drives).

Sources used

  1. Ricardo Palma (2025). Active front end rectifier (https://www.mathworks.com/matlabcentral/fileexchange/63357-active-front-end-rectifier), MATLAB Central File Exchange. Retrieved April 29, 2025.