Due to the lack of a physical rotating rotor, the photovoltaic generators (PVG) have no inertia. Therefore, replacing traditional synchronous generators (SG), (source of inertia), with PVG will reduce the inertia of overall power systems. A reduced inertia and damping feature will frequently cause instability issues due to high rate of change of frequency (RoCoF), and less stringent voltage at the nearby point of common coupling (PCC). In this paper, the concept of virtual synchronous generators (VSG) is adopted in to couple the source with the grid frequency in order to provide virtual inertia. This is created by using energy storage for short time, direct current (DC) to alternating current (AC) converter, and a suitable control mechanism. In implementing VSG, the important aspects to focus on are reducing the fluctuation of DC-link voltage, stabilize the frequency and voltage, and power flow. So, the particle swarm optimization (PSO) algorithm was used to adjust the parameters of proportional integral (PI) controller by reducing the error of the current controller and voltage regulator in the VSG controller. The simulation results illustrate the advantages of the PI tuning using PSO, where the overshoot is decreased by 68.9% and the settling time is decreased by 34% due to load fluctuations.