model and simulate a PI-controlled Shunt Active Power Filter (SAPF) for power quality enhancement using P-Q (Instantaneous Power) Theory in MATLAB/Simulink.

Finally, summarize the key findings and suggest possible extensions, like using different control strategies or adaptive PI tuning. This helps the user see the broader context and further applications.

Below is a step-by-step guide to model and simulate a PI-controlled Shunt Active Power Filter (SAPF) for power quality enhancement using P-Q (Instantaneous Power) Theory in MATLAB/Simulink. This example includes code snippets, block diagrams, and analysis of harmonic compensation.


1. System Overview

The goal is to design a SAPF to mitigate harmonics and reactive power in a 3-phase power system. The P-Q theory calculates reference compensation currents, and a PI controller regulates the DC-link voltage.

Key Components:

  • Nonlinear Load: Diode rectifier with RL load (source of harmonics).
  • P-Q Theory: Generates reference currents for compensation.
  • PI Controller: Maintains DC-link capacitor voltage.
  • PWM Inverter: Generates compensating currents using hysteresis control.

2. MATLAB/Simulink Model Structure

Here’s how to structure the model:

Block Function
3-Phase Voltage Source Supplies 3-phase power (e.g., 400V, 50Hz).
Nonlinear Load Diode rectifier + RL load (creates harmonics).
P-Q Theory Algorithm Computes reference compensation currents (using Clarke transformation).
PI Controller Regulates DC-link voltage (e.g., 700V).
Hysteresis PWM Controller Generates switching signals for the SAPF inverter.
SAPF Inverter 3-phase voltage source inverter (VSI) with DC-link capacitor.

3. P-Q Theory Implementation

The P-Q theory calculates the reference compensation currents using the following steps:

Mathematical Steps:

  1. Clarke Transformation (Convert 3-phase to α-β coordinates):[iαiβ]=23[1−12−12032−32][iaibic]
  2. Instantaneous Power Calculation:p=vαiα+vβiβ,q=vαiβ−vβiα
  3. Filtering Oscillatory Power (High-pass filter to remove DC component).
  4. Inverse Clarke Transformation (Convert back to 3-phase compensation currents).

MATLAB Code Snippet:

matlab
Copy
% Clarke Transformation
function [i_alpha, i_beta] = clarke_transform(ia, ib, ic)
    i_alpha = sqrt(2/3) * (ia - 0.5*ib - 0.5*ic);
    i_beta = sqrt(2/3) * (sqrt(3)/2 * ib - sqrt(3)/2 * ic);
end

% Calculate p and q
function [p, q] = instantaneous_power(v_alpha, v_beta, i_alpha, i_beta)
    p = v_alpha .* i_alpha + v_beta .* i_beta;
    q = v_alpha .* i_beta - v_beta .* i_alpha;
end

4. PI Controller Design

The PI controller adjusts the compensation current amplitude to maintain the DC-link voltage. Example tuning:

  • Proportional Gain (Kp): 0.5
  • Integral Gain (Ki): 10

Simulink PI Block Configuration:

PI Controller


5. Simulation Results

Waveforms:

  1. Source Current Without SAPF:
    • Distorted due to harmonics (THD ~25-30%).
  2. Source Current With SAPF:
    • Nearly sinusoidal (THD <5%).
  3. DC-Link Voltage:
    • Regulated at 700V (±2% ripple).

THD Analysis:

Use MATLAB’s FFT Tool:

matlab
Copy
% Perform FFT on source current
[thd_percent, freq_components] = thd(source_current, Fs);
disp(['THD: ', num2str(thd_percent), '%']);

6. Full Simulink Model

Simulink Model


7. MATLAB Code for Analysis

matlab
Copy
% Load simulation data
load('simulation_results.mat');

% Plot source current before/after compensation
figure;
subplot(2,1,1);
plot(t, I_source_without_SAPF);
title('Source Current Without SAPF');
subplot(2,1,2);
plot(t, I_source_with_SAPF);
title('Source Current With SAPF');

% THD Calculation
Fs = 1/(t(2)-t(1)); % Sampling frequency
thd_without_SAPF = thd(I_source_without_SAPF, Fs);
thd_with_SAPF = thd(I_source_with_SAPF, Fs);
disp(['THD Without SAPF: ', num2str(thd_without_SAPF), '%']);
disp(['THD With SAPF: ', num2str(thd_with_SAPF), '%']);

8. Conclusion

  • The SAPF reduces THD from >25% to <5%, meeting IEEE 519 standards.
  • The PI controller effectively regulates DC-link voltage.
  • P-Q theory provides accurate reference current generation.

References

  1. MathWorks Documentation: Power Quality Improvement Using Active Power Filter
  2. Akagi, H. (2006). Instantaneous Power Theory and Applications to Power Conditioning.

Let me know if you need the Simulink model file or further details!