If you look more carefully at the code (and the comments) you’ll see that the generator is turned off temporarily in line 267, and the load is adjusted to include the injection. Later in line 307, the process is reversed, turning the generator back on. Without studying the code in more detail, I don’t remember why it was done this way, but I suspect it has something to do with multiple generators at a bus.
Ray > On Jun 2, 2016, at 10:05 AM, 严超 <1499730...@qq.com> wrote: > > Dear Sir/Madam, > I have a question with the AC power flow calculation. In Matpower > 5.1, when AC power flow is calculated, if the q_limt is used, as the manual > states that "If any generator has a violated reactive power limit, its > reactive injection is fixed at the limit, the corresponding bus is converted > to a PQ bus and the power flow is solved again. This procedure is repeated > until there are no more violations". Obviously, we can find that all > generators violating the reactive power limit will be regared as PQ bus, then > the power flow will be recalculated. However, when I opened the file runpf.m, > I fund that the states of all generators violating the reactive power limit > are set to be zero, that is, "gen(mx, GEN_STATUS) = 0";. That means the > generation is turned off in the next power flow re-calculation. This isn't > included in the manual. It seems unreasonable. So I want to know the reason > why turn off all these generators.