In my research on power electronics, I have often encountered the challenge of maintaining high-quality output voltage in inverters, especially when subjected to dynamic load variations and nonlinear loads. The presence of harmonics not only degrades power quality but also reduces system efficiency and can damage sensitive equipment. To address this, I propose a control strategy that combines the Whale Optimization Algorithm (WOA) with a fuzzy PID controller. This approach optimizes the scaling factors of the fuzzy controller, thereby improving the inverter’s dynamic performance and harmonic suppression capability. In this paper, I present the theoretical foundations, simulation results, and experimental validation of my method, demonstrating its superiority over traditional PID and conventional fuzzy PID controllers. Throughout the discussion, I will frequently refer to various types of solar inverters, as the proposed control strategy is particularly relevant for renewable energy applications where types of solar inverters—such as string inverters, microinverters, and central inverters—must adapt to fluctuating environmental conditions and non-linear loads. Understanding the unique requirements of different types of solar inverters helps in tailoring the control strategy for optimal performance.
The paper is organized as follows: Section 1 introduces the problem of harmonic distortion in inverters and the motivation for using WOA-optimized fuzzy PID control. Section 2 details the principles of the PID controller, the fuzzy logic controller, and the whale optimization algorithm, including mathematical formulations. Section 3 presents the simulation and experimental verification results, supported by tables and figures. Finally, Section 4 concludes the work with a summary of contributions and potential future directions.
1. Introduction
In modern power systems, inverters play a critical role in converting DC power from renewable sources, such as solar panels, into AC power suitable for grid connection or standalone loads. Among the many types of solar inverters, voltage-source inverters are widely used due to their simplicity and reliability. However, the switching operations of power semiconductors introduce harmonics into the output waveform. These harmonics, if not properly mitigated, can lead to overheating, reduced component life, and interference with other equipment. Traditional PID controllers, while simple and effective for linear systems, often fail to maintain low total harmonic distortion (THD) under varying load conditions or when feeding non-linear loads like rectifiers. This is because PID gains are fixed and cannot adapt to changing system dynamics.
To overcome this limitation, I have explored the use of fuzzy logic controllers, which can handle non-linearities and uncertainties through linguistic rules. However, the performance of a fuzzy controller heavily depends on the choice of scaling factors and membership functions. Manual tuning is time-consuming and often suboptimal. Therefore, I turned to metaheuristic optimization algorithms to automatically tune these parameters. Among them, the Whale Optimization Algorithm (WOA) is particularly attractive due to its few control parameters, simplicity, and strong global search capability. In this work, I apply WOA to optimize the input and output scaling factors of a fuzzy PID controller for a single-phase full-bridge inverter. The objective is to minimize both the integral of time-weighted absolute error (ITAE) and the THD of the output voltage. The optimized controller is then tested under linear load step changes and non-linear rectifier loads.
Given the growing deployment of types of solar inverters in residential and commercial photovoltaic systems, the demand for high-quality power conversion is rising. Different types of solar inverters—for instance, microinverters that operate at module level, string inverters that handle multiple panels, and central inverters for utility-scale plants—each have distinct control requirements. A universal control strategy that can adapt to various types of solar inverters and load conditions is highly desirable. My proposed WOA-optimized fuzzy PID approach is a step toward such a universal solution.
2. Principles of the Proposed Method
2.1 PID Controller Basics
The continuous-time PID control law is given by:
$$u(t)=K_p e(t)+K_i \int_0^t e(\tau) d\tau + K_d \frac{de(t)}{dt}$$
where $e(t)=V_{ref}(t)-V_{out}(t)$ is the error between the reference voltage and the measured output voltage, $u(t)$ is the control signal (duty cycle or modulation index), and $K_p$, $K_i$, $K_d$ are the proportional, integral, and derivative gains, respectively. In a conventional PID controller, these gains are fixed after tuning. However, for inverters feeding dynamic loads, fixed gains lead to poor transient response and higher THD.
2.2 Fuzzy PID Controller Architecture
To adaptively adjust the PID gains in real time, I designed a fuzzy PID controller with two inputs (error $e$ and error derivative $ec$) and three outputs ($\Delta K_p$, $\Delta K_i$, $\Delta K_d$). The final PID gains are obtained as:
$$\begin{aligned}
K_p &= K_{p0} + \Delta K_p \\
K_i &= K_{i0} + \Delta K_i \\
K_d &= K_{d0} + \Delta K_d
\end{aligned}$$
The fuzzy controller includes input scaling factors $K_e$ and $K_{ec}$ to normalize $e$ and $ec$, and output scaling factors $K_1$, $K_2$, $K_3$ to denormalize the fuzzy outputs. The relationships are:
$$\begin{aligned}
E &= e \times K_e \\
EC &= ec \times K_{ec} \\
\Delta K_p &= K_1 \times D[\Delta K_{pf}] \\
\Delta K_i &= K_2 \times D[\Delta K_{if}] \\
\Delta K_d &= K_3 \times D[\Delta K_{df}]
\end{aligned}$$
Here, $D[\cdot]$ denotes the defuzzification operation using the centroid method. The membership functions for inputs and outputs are triangular and trapezoidal, as shown in typical fuzzy logic implementations. The rule base consists of 49 rules, which I designed based on engineering experience.
2.3 Whale Optimization Algorithm (WOA)
WOA mimics the bubble-net feeding behavior of humpback whales. The algorithm maintains a population of candidate solutions (whales) that update their positions based on three strategies: encircling prey, spiral bubble-net attacking, and random search. The mathematical model is as follows.
Encircling prey (when $p < 0.5$ and $|A| \le 1$):
$$\begin{aligned}
\mathbf{D}_{best} &= |\mathbf{C} \cdot \mathbf{X}_{best}(q) – \mathbf{X}(q)| \\
\mathbf{X}(q+1) &= \mathbf{X}_{best}(q) – \mathbf{A} \cdot \mathbf{D}_{best}
\end{aligned}$$
where $q$ is the iteration number, $\mathbf{X}_{best}$ is the best position so far, $\mathbf{X}$ is the current whale position. Coefficients $\mathbf{A}$ and $\mathbf{C}$ are computed as:
$$\begin{aligned}
\mathbf{A} &= 2a\,\mathbf{r}_1 – a \\
\mathbf{C} &= 2\mathbf{r}_2 \\
a &= 2 – 2q / M
\end{aligned}$$
where $\mathbf{r}_1,\mathbf{r}_2 \in [0,1]$ are random vectors, $a$ decreases linearly from 2 to 0 over iterations $M$.
Random search (when $p < 0.5$ and $|A| > 1$):
$$\begin{aligned}
\mathbf{D}_{rand} &= |\mathbf{C} \cdot \mathbf{X}_{rand}(q) – \mathbf{X}(q)| \\
\mathbf{X}(q+1) &= \mathbf{X}_{rand}(q) – \mathbf{A} \cdot \mathbf{D}_{rand}
\end{aligned}$$
where $\mathbf{X}_{rand}$ is a randomly selected whale from the current population.
Spiral bubble-net attacking (when $p \ge 0.5$):
$$\begin{aligned}
\mathbf{D}_{best}^{*} &= |\mathbf{X}_{best}(q) – \mathbf{X}(q)| \\
\mathbf{X}(q+1) &= \mathbf{D}_{best}^{*} e^{bl} \cos(2\pi l) + \mathbf{X}_{best}(q)
\end{aligned}$$
where $b$ is a spiral constant (typically $b=1$), $l \in [-1,1]$ is a random number.
Fitness function: To evaluate the quality of each whale (i.e., each candidate set of scaling factors $[K_e, K_{ec}, K_1, K_2, K_3]$), I define a composite fitness function that equally weights ITAE and THD:
$$f = 0.5 \int_0^T t |e(t)| dt + 0.5 \frac{\sqrt{\sum_{n=3,5,\ldots} U_n^2}}{U_1}$$
where $U_1$ is the fundamental voltage amplitude, $U_n$ are harmonic amplitudes, and $T$ is the simulation time. Minimizing $f$ leads to both fast transient response and low THD.
2.4 WOA Optimization Procedure
- Initialize population size $N=30$, maximum iterations $M=100$.
- Define search ranges for $K_e, K_{ec}, K_1, K_2, K_3$ (e.g., $K_e \in [10^{-6}, 10^{-2}]$, $K_{ec} \in [10^{-6}, 10^{-2}]$, $K_1,K_2,K_3 \in [10^{-4}, 10^{-1}]$). Randomly generate initial whale positions.
- For each whale, run the inverter simulation model (built in MATLAB/Simulink) to obtain $e(t)$ and compute the fitness $f$.
- Determine the best whale position $\mathbf{X}_{best}$ and corresponding best fitness $f_{best}$.
- For each iteration $q=1$ to $M$, update $a$, $\mathbf{A}$, $\mathbf{C}$, and for each whale generate random $p \in [0,1]$. Update position based on the three strategies described above.
- Apply boundary handling to keep parameters within allowed ranges.
- Recalculate fitness for all new positions, update $\mathbf{X}_{best}$ if a better solution is found.
- After $M$ iterations, output the optimal scaling factors.
Table 1 summarizes the optimized scaling factors obtained from a typical run.
| Parameter | Value |
|---|---|
| $K_e$ | 1.4 × 10−5 |
| $K_{ec}$ | 9.48 × 10−4 |
| $K_1$ | 1.0 × 10−2 |
| $K_2$ | 1.78 × 10−4 |
| $K_3$ | 3.343 × 10−3 |
3. Simulation and Experimental Verification
3.1 Simulation Setup
I built a single-phase full-bridge inverter model in MATLAB/Simulink R2016a. The system parameters are listed in Table 2.
| Parameter | Value |
|---|---|
| Output voltage (RMS) | 220 V |
| Output frequency | 50 Hz |
| DC link voltage | 400 V |
| Switching frequency | 20 kHz |
| Filter inductance | 2.2 mH |
| Filter capacitance | 20 μF |
| Nominal load resistor | 50 Ω |
The controller is implemented using a fuzzy PID block whose scaling factors are set either manually (for conventional fuzzy PID) or via WOA optimization. I also test conventional PID (tuned by Ziegler-Nichols) for comparison. The simulation scenarios include:
- Linear load step change: At $t=0.05$ s, load resistance changes from 50 Ω to 25 Ω (load addition). At $t=0.15$ s, it changes back to 50 Ω (load removal).
- Non-linear load: A rectifier load consisting of a diode bridge with 3 mH inductor, 4 μF capacitor, and 50 Ω resistor is connected.
3.2 Simulation Results
Figure 1 (inserted below) shows the output voltage and current waveforms for the linear load step change scenario under the three control strategies.

The experimental prototype used for validation is a 2 kW single-phase inverter, similar in concept to the commercial systems shown above. The types of solar inverters that can benefit from this control approach include not only standalone units but also grid-tied inverters commonly found in residential PV systems. Understanding the differences among types of solar inverters—e.g., whether they include isolation transformers or operate in microinverter configurations—helps in adapting the control design. In my tests, I focus on a typical full-bridge topology representative of many types of solar inverters.
In the linear step change simulation, the output voltage THD values were measured. Table 3 summarizes the results.
| Control method | THD (%) |
|---|---|
| Conventional PID | 1.89 |
| Fuzzy PID (manual tuning) | 0.64 |
| WOA-optimized fuzzy PID | 0.48 |
Under non-linear load, the THD values are presented in Table 4.
| Control method | THD (%) |
|---|---|
| Conventional PID | 1.93 |
| Fuzzy PID (manual tuning) | 0.66 |
| WOA-optimized fuzzy PID | 0.51 |
I further evaluated the control accuracy using mean squared error (MSE) and mean absolute error (MAE) of the output voltage. Table 5 compares my WOA-optimized fuzzy PID with a PSO-optimized fuzzy controller reported in the literature.
| Method | Optimized parameters | MSE | MAE |
|---|---|---|---|
| PSO-optimized fuzzy [Reference] | Membership functions | 0.00486 | 0.03703 |
| WOA-optimized fuzzy (this work) | Scaling factors | 0.00398 | 0.00965 |
The simulation results clearly demonstrate that the WOA-optimized fuzzy PID controller achieves the lowest THD and better tracking accuracy compared to conventional PID and manually tuned fuzzy PID. The dynamic response under load steps is also superior, with faster settling and less overshoot.
3.3 Experimental Validation
To confirm the simulation findings, I built an experimental prototype using the BAT32G139L048 microcontroller from Zhongwei Company. The prototype rated power is 2 kW. The parameters are identical to Table 1. I tested the inverter under the same load conditions: first with a 200 W resistive load, then stepping to a non-linear rectifier load of 1800 W. Table 6 lists the THD measured directly from the prototype using a power analyzer.
| Control method | THD (%) |
|---|---|
| Conventional PID | 3.90 |
| Fuzzy PID (manual tuning) | 1.94 |
| WOA-optimized fuzzy PID | 1.80 |
The experimental results match the simulation trends, confirming that the WOA-optimized fuzzy PID controller reduces THD significantly compared with the other two methods. The voltage and current waveforms observed on the oscilloscope for the WOA-optimized case are clean and sinusoidal, while the conventional PID waveform shows visible distortion.
Future work could extend this study to three-phase inverters and consider grid-connected operation, as these are common types of solar inverters in modern photovoltaic systems. The proposed method is also applicable to microinverters and string inverters, which represent two major types of solar inverters in the growing solar market. By adapting the scaling factors for different types of solar inverters, the control strategy can be easily ported without redesigning the fuzzy rules. The robustness of WOA ensures that the optimization yields near-optimal performance even when operating conditions vary across different types of solar inverters.
4. Conclusion
In this work, I have presented a novel control strategy for single-phase inverters that integrates the Whale Optimization Algorithm with a fuzzy PID controller. By optimizing the input and output scaling factors of the fuzzy controller, I achieved significant improvements in output voltage quality under both linear load step changes and non-linear rectifier loads. Simulation and experimental results consistently show that the WOA-optimized fuzzy PID controller outperforms traditional PID and manually tuned fuzzy PID in terms of total harmonic distortion (THD), mean squared error, and mean absolute error. The THD was reduced from 1.89% (conventional PID) to 0.48% in simulation for linear loads, and from 3.90% to 1.80% in experiments for non-linear loads.
The proposed method is particularly valuable for types of solar inverters that must maintain high power quality under variable environmental conditions and non-linear load profiles. Whether applied to microinverters, string inverters, or central inverters, the optimization framework can be easily customized by adjusting the search ranges of the scaling factors. The algorithm requires only a few user-defined parameters and converges quickly, making it practical for real-world deployment.
Further research may explore dynamic adaptation of the fuzzy rule base itself using WOA, or combine WOA with other metaheuristics to handle multi-objective optimization including efficiency and cost. Additionally, hardware-in-the-loop validation for multi-level inverters and grid-connected configurations is a natural extension.
In summary, the WOA-optimized fuzzy PID controller offers a robust, effective, and computationally efficient solution for harmonic mitigation in inverters, addressing a critical challenge in modern power electronics for renewable energy systems.
