def governor(self, Xgov, Pgov, Vgov):
        governors = self.governors
        omegas = 2 * pi * self.freq
        F = zeros(Xgov.shape)
        typ1 = [g.generator._i for g in governors if g.model == CONST_POWER]
        typ2 = [g.generator._i for g in governors if g.model == GENERAL_IEEE]
        F[typ1, 0] = 0
        Pm = Xgov[typ2, 0]
        P = Xgov[typ2, 1]
        x = Xgov[typ2, 2]
        z = Xgov[typ2, 3]
        K = Pgov[typ2, 0]
        T1 = Pgov[typ2, 1]
        T2 = Pgov[typ2, 2]
        T3 = Pgov[typ2, 3]
        Pup = Pgov[typ2, 4]
        Pdown = Pgov[typ2, 5]
        Pmax = Pgov[typ2, 6]
        Pmin = Pgov[typ2, 7]
        P0 = Pgov[typ2, 8]
        omega = Vgov[typ2, 0]
        dx = K * (-1 / T1 * x + (1 - T2 / T1) * (omega - omegas))
        dP = 1 / T1 * x + T2 / T1 * (omega - omegas)
        y = 1 / T3 * (P0 - P - Pm)
        y2 = y
        if sum(flatnonzero(y > Pup)) >= 1:
            y2 = (1 - flatnonzero(y > Pup)) * y2 + flatnonzero(y > Pup) * Pup
        if sum(flatnonzero(y < Pdown)) >= 1:
            y2 = (1 - flatnonzero(y<Pdown)) * y2 + flatnonzero(y<Pdown) * Pdown
        dz = y2
        dPm = y2
        if sum(flatnonzero(z > Pmax)) >= 1:
            dPm = (1 - flatnonzero(z > Pmax)) * dPm + flatnonzero(z > Pmax) * 0
        if sum(flatnonzero(z < Pmin)) >= 1:
            dPm = (1 - flatnonzero(z < Pmin)) * dPm + flatnonzero(z < Pmin) * 0
        F[typ2, :] = c_[dPm, dP, dx, dz]
        return F