**3. Solar Photovoltaic (SPV) Control Implementation Adaptive Fractional Order PID Controller Design**

In this section, the three phases of the proposed HHO-AFOPID's execution are shown as a photovoltaic source's interface with the grid system.

$$\mathbf{V} = \frac{2}{3} \left( v\_{aN} + \exp\left(\frac{j2\pi}{3}\right) v\_{bN} + \exp\left(\frac{j4\pi}{3}\right) v\_{cN} \right) \tag{11}$$

*vaN*, *vbN*, and *vcN* are termed as voltages falling between phase and neutral. The grid infrastructure of the grid-interfaced dc-to-ac inverter in a d-q frame may be arranged using the following differential equations [29].

$$\frac{di\_a}{dt} = -\frac{R}{L}i\_a + \frac{1}{L}v\_{aN} - \frac{1}{L}e\_{aN} \tag{12}$$

$$\frac{di\_b}{dt} = -\frac{R}{L}i\_b + \frac{1}{L}v\_{bN} - \frac{1}{L}e\_{bN} \tag{13}$$

$$\frac{di\_c}{dt} = -\frac{R}{L}i\_c + \frac{1}{L}v\_{cN} - \frac{1}{L}e\_{cN} \tag{14}$$

The *dc* end of the inverter can be expressed in the form of a differential equation while disregarding losses that happened in the switches of the inverter. The following diagram illustrates how the inductor's resistance and rate of energy fluctuate [30].

$$\mathbf{C}\frac{dv\_{dc}}{dt} = i\_p - i\_{dc} = i\_p - \frac{e\_d i\_d + e\_q i\_q}{v\_{dc}}\tag{15}$$

*ed*, and *eq* and *id* and *iq* shows the potentials and currents of the grid end in a movable d-q frame. C represents the capacitor of the dc bus, *ip* exhibits the photovoltaic current, *vdc* is the potential of the dc link.

The state equation of the SPV system can be depicted by applying abc-dq transformations in Equation (16) as follows.

$$\begin{cases} \dot{\mathbf{x}}\_1 = -a\_1 \mathbf{x}\_1 + a\_2 \mathbf{x}\_2 - a\_3 + a\_4 \boldsymbol{u}\_1\\ \dot{\mathbf{x}}\_2 = -a\_2 \mathbf{x}\_1 - a\_1 \mathbf{x}\_2 - a\_5 + a\_4 \boldsymbol{u}\_2\\ \dot{\mathbf{x}}\_3 = a\_6 - \frac{a\_7 \mathbf{x}\_1 + a\_8 \mathbf{x}\_2}{a\_9 \mathbf{x}\_3} \end{cases} \tag{16}$$

The notations are provided below.

*x*<sup>1</sup> = *Id*, *x*<sup>2</sup> = *Iq*, *x*<sup>3</sup> = *vdc*, *u*<sup>1</sup> = *vd*, *u*<sup>2</sup> = *vq*, *a*<sup>1</sup> = *<sup>R</sup> <sup>L</sup>* , *<sup>a</sup>*<sup>2</sup> <sup>=</sup> *<sup>ω</sup>*, *<sup>a</sup>*<sup>3</sup> <sup>=</sup> *ed <sup>L</sup>* , *<sup>a</sup>*<sup>4</sup> <sup>=</sup> <sup>1</sup> *<sup>L</sup>* , *<sup>a</sup>*<sup>5</sup> <sup>=</sup> *ed L* , *<sup>a</sup>*<sup>6</sup> <sup>=</sup> *ip <sup>C</sup>* , *a*<sup>7</sup> = *ed*, *a*<sup>8</sup> = *eq*, *a*<sup>9</sup> = *C*.

The non-linear features of solar photovoltaic systems are shown in Equations (17a) and (17b): .

$$
\dot{\mathbf{x}} = \mathbf{f}(\mathbf{x}) + \mathbf{g}\_1(\mathbf{x})\boldsymbol{u}\_1 + \mathbf{g}\_2(\mathbf{x})\boldsymbol{u}\_2 \tag{17a}
$$

$$
\dot{\mathbf{x}} = \begin{pmatrix}
a\_6 & -\frac{a\_7 \mathbf{x}\_1 + a\_8 \mathbf{x}\_2}{a\_9 \mathbf{x}\_3} & 0
\end{pmatrix} \tag{17b}
$$

The suggested controller's main goal is to send the best switching signal possible to the inverter in order to draw the most amount of power possible from the PV source. The maximum power point is followed by the control topology in this article to complete the research component. Table 1 displays the PV parameter, while the attributes of the grid are shown in Table 2.

**Table 1.** Parameter of the PV system.



**Table 2.** Parameters of the grid's infrastructure.

The execution of the three-phase inverter approach in the d-q frame can be analyzed using

$$v\_d = e\_d + \mathbf{R}i\_d + \mathbf{L}\frac{di\_d}{dt} + \omega \mathbf{L}i\_q \tag{18}$$

$$w\_q = e\_q + \text{Ri}\_q + \text{L}\frac{di\_q}{dt} - \omega \text{Li}i\_d \tag{19}$$

*ed*, and *eq*; *id*, and *iq*; and *vd*, and *vq* represent the currents, potentials, and output potentials of a PV-interfaced inverter, respectively. The alternating quantity's frequency is represented by the symbol. The equation for AC and DC power stability is given as follows:

$$e\_d i\_d + e\_q i\_q = v\_{dc} i\_{dc} \tag{20}$$

where *vdc* and *idc* represent the input parameters of the PV-interfaced inverter.

#### *3.1. Design an Adaptive Fractional Order PID Controller*

FOPID controllers with adaptive properties are initiated to generate the output power, which is more prominent and showed robustness [31–34].

$$\alpha.D\_t^{\alpha} = \begin{cases} \frac{d}{dt} \frac{\alpha}{t^{\alpha}} , \alpha > 0\\ 1 , \alpha = 0\\ \int\_{\alpha}^{t} d\tau^{\alpha} , \alpha < 0 \end{cases} \tag{21}$$

For the requirements of the system, the upper and lower boundaries are measured by α and t when α ∈ R with respect to the order of operation. The performance was compared using conventional PID and FOPID and without optimized AFOPID. The suggested controller showed better non-erroneous responses that are applicable to both linear and non-linear loads.

The FOPID is the modified version of a conventional PID controller with two parameters added: fractional integrator order (λ) and fractional derivative order (μ). As a result, it exhibits the outcome's quality [35,36].

$$\mathbf{G(S)} = k\_P + \frac{k\_I}{S^\lambda} + k\_D S^\mu \tag{22}$$

#### *3.2. Computational Formation of the HHO Optimization Algorithm*

Horse herd optimization (HHO) was developed based on the way horses behave in their original habitat. A few common behavioral traits of horses include hierarchy, grazing, imitation, sociability, defense mechanism, and roaming [37,38]. The method is motivated by these six attitudes towards horses of various ages. At each phase, horses are moved in accordance with Equation (23):

$$P\_m^{iter, age} = V e l\_m^{iter, age} + P\_m^{(iter - 1), age} \tag{23}$$

Age = α, β, γ, and δ.

For the above equation, we have the following:


During their life span, the horses show different behaviors. The average life span of a horse is 25–30 years [38]. Where Δ represents horses that age between 0 and 5; γ shows those aged between 5 and 10; β denotes ages between 10 and 15; α denotes those older than 15 years old. Each iteration should have a thorough examination to ascertain the horses' ages. The top 10% of horses in the ordered matrix are picked as horses, with the remaining horses chosen from the remaining 90% of horses in the ordered matrix. In total, 20% of the population after that makes up the group. Moreover, 30% and 40% of the remaining horses belong to the groupings, respectively. The techniques that statistically mimic the six movements of various groups of horses are used to compute the velocity vector.

Considering the following behavioral trends [39], Equations (24)–(27) might be considered the motion vectors of various aged horses throughout every iteration cycle.

$$\text{Vel}\_{m}^{\text{iter},\mathfrak{a}} = \text{Gra}\_{m}^{\text{iter},\mathfrak{a}} + \text{DefenseMec}\_{m}^{\text{iter},\mathfrak{a}} \tag{24}$$

$$\text{Ver}\_{m}^{\text{iter},\beta} = \text{Gra}\_{m}^{\text{iter},\beta} + \text{H}\_{m}^{\text{iter},\beta} + \text{Soc}\_{m}^{\text{iter},\beta} + \text{DefenseMed}\_{m}^{\text{iter},\beta} \tag{25}$$

$$\text{Ver}\_{m}^{\text{iter},\gamma} = \text{Gr}\text{a}\_{m}^{\text{iter},\gamma} + \text{H}\_{m}^{\text{iter},\gamma} + \text{Soc}\_{m}^{\text{iter},\gamma} + \text{Im}\text{i}\_{m}^{\text{iter},\gamma} + \text{Roam}\_{m}^{\text{iter},\gamma} + \text{DefenseMe}\_{m}^{\text{iter},\gamma} \tag{26}$$

$$\text{Vel}\_{m}^{\text{iter},\delta} = \text{Gra}\_{m}^{\text{iter},\delta} + \text{Imi}\_{m}^{\text{iter},\delta} + \text{Roam}\_{m}^{\text{iter},\delta} \tag{27}$$

These are the key stages of a horse's social and individual intelligence.

#### 3.2.1. Grazing (Gra)

Horses are roving creatures that consume fodder such as grasses and plants. With only a few hours of respite, they graze in pastures for 16 to 20 h every day. This kind of progressive grazing is known as continuous eating; you may have observed mares graze in pastures while carrying their foals [38]. The HHO method is used to represent each horse's grazing space. Each horse grazes in a specific spot due to coefficient g. Horses graze throughout their entire lives at any age. Grazing is carried out along a line using mathematical Equations (28) and (29).

$$\text{Gra}\_{m}^{\text{iter,age}} = \text{g}\_{iter}(low + r \ast upp) \left( \text{P}\_{m}^{\text{iter}-1} \right) \text{ : age} = \text{a} \, \beta \, \gamma \, \delta \tag{28}$$

$$\mathbf{g}\_{m}^{iter,age} = \boldsymbol{w}\_{\mathcal{S}} \times \mathbf{g}\_{m}^{(iter-1)age} \tag{29}$$

*Graiter*,*age <sup>m</sup>* indicates the horse's range of motion and shows how well the associated horse can graze. For each cycle, the grazing variable decreases linearly at *wg*.

While "low" and "upp" represent the bottom and higher limits of the grazing space, respectively, variable "r" has an arbitrary value between 0 and 1. It is suggested that "low" and "upp" should be adjusted to 0.95 and 1.05, respectively, for all age groups. In all age ranges, coefficient g's value is set to 1.5.
