This simulation needs a PLL as the inverter needs to be synchronized to the grid. To know how to simulate a PLL
check out my blog post here.
In the circuit files above, the control code has been removed to avoid any possible legal infringements. Check out
the tutorial on how to write control code. In this post, the results will be posted.
In this case study, the control of the inverter has been implemented in the synchronously rotating reference frame. There are two separate controllers for the in-phase (d) and quadrature (q) axis. Controlling the d axis controls the in-phase (active) component of current injected by the inverter into the grid while the q axis controls the quadrature (reactive) component of current. The results posted here will show how the inverter is initially injecting only reactive power into the grid until 0.25s and after that injects only active power into the grid.
The d axis current is shown in the next figure. To be noted that the reference for the d axis current is 0 until 2.5s and is 50Amps after that. Therefore, tracking is good except for the switching ripple which is unavoidable as the inverter has only an inductor filter.