## 3 Frequency Deviation Suppression Based on VSG
### Tuning VSG Parameter Based on BSA  
Optimization is a powerful tool which is used by the researchers in various applications over the past few decades in purpose to extract maximum benefits from the system by finding the best values of system parameters through the maximization or minimization of the objective function. As discussed in Section 3.1, the VSG emulates the SG's dynamic characteristic by representing the SG fundamental swing equation to create the virtual inertia and damping factor. Unlike a real synchronous machine, the parameters of VSG can be tuned to improve the dynamic response of the system. In this research, a new evolutionary optimization called BSA is used for online tuning the parameters (\(J\) and \(D\)) of VSG.  
The objective function:  
\[ISE=\int_{T_{start}}^{T_{stop}}(\omega_{ref}-\omega_{m})^{2} \tag{14}\]  
Figure 8: Block diagram of VSG control.  
The design problem can be formulated by minimizing \(ISE\) (Equation (14)) in order to determine the optimum values of \(J\) and \(D\). A brief discussion on BSA is provided below.  
BSA [26] is a new population-based evolutionary algorithms. It tries to minimize the objective function by performing the iterative process. Five evolutionary mechanisms such as \(initialization\), \(selection-I\), \(mutation\), \(crossover\), and \(selection-II\) employed in BSA. The complete process of BSA provides in Figure 9.  
* Initialization: The population \(\text{P}=(P_{i,j})_{(N,M)}\) and \(oldP_{i,j}\) are initialized via a uniform stochastic selection of particles values within the solution space, as shown by Formula (15). The fitness function is first evaluated by using the initialized value of the population. \[P_{ij} =P_{jmin}+rnd(P_{jmax}  
- I: There are three things done in Selection
- I such as update \(P_{best}\) matrix, memorize the previous experience (old\(P\)) and random order based on Equation (16), and generate binary integer-valued matrix (map).  
\[oldP_{ij}=permuting(oldP). \tag{16}\]  
- Mutation: The trial population Mutant is initialized in the Mutation step by following the Equation (17).  
\[mutant_{ij}=P_{ij}+F(P_{bestij}-P_{ij}) \tag{17}\]  
where F is the real number to control the step size of search path or direction.  
- Crossover: Generates the final form of the trial population (\(offspring\)).  
- II checks whether fitness \(offsprings\) gives better fitness value than that obtained so far using initial population or not. If fitness \(offsprings\) gives better results, then update offsprings by fitness offsprings via \(P_{best}\) matrix; otherwise, keep the previous one. Keep doing the same process until termination criterion is met.  
Figure 10 demonstrates the interface between the simulation model and the optimization algorithm (BSA). The BSA embeds in the simulink environment using the Level2 S-function. The parameter \(J\) and \(D\) are set as the tunable parameter. Figure 11 shown a testing case result to observe whether the parameter is properly online tuned. At the time of simulation start, the value of \(J\) and \(D\) are intentionally wrong initialized. As shown in Figure 11, at time \(t\) = 0.5 s, the large loads are connected and the system is unstable as the virtual inertia and damping constant are wrong initialized. Hence, the oscillation cannot be damped during that period. To update the VSG parameter which generates by BSA, it requires to enable update mode from Simulation menu (\(Simulation\to UpdateDiagram\)). One the update diagram is clicked; the VSG parameters are kept updating based on BSA and the system becomes stable as seen in Figure 11 from \(t\) = 3s to the end of the simulation.  
Figure 11: Testing BSA tuning: System frequency.  
Figure 10: BSA-Simulink interfacing.