def create_y(self): self.fb = self.ppc["branch"][:, 0].real.astype(int) self.tb = self.ppc["branch"][:, 1].real.astype(int) with warnings.catch_warnings(): warnings.simplefilter("ignore") y_bus, y_f, y_t = makeYbus(self.baseMVA, self.ppc["bus"], self.ppc["branch"]) # create relevant matrices self.Y_bus = y_bus.toarray() self.Yf = y_f self.Yt = y_t self.G = self.Y_bus.real self.B = self.Y_bus.imag n = len(self.ppc["bus"]) self.G_series = - self.G np.fill_diagonal(self.G_series, 0.) self.B_series = - self.B np.fill_diagonal(self.B_series, 0.) # In case that's becoming relevant later, G_shunt will not be removed self.G_shunt = np.zeros_like(self.G) self.B_shunt = np.zeros((n, n)) from_to = np.concatenate((self.fb, self.tb)) to_from = np.concatenate((self.tb, self.fb)) self.B_shunt[from_to, to_from] = np.tile(0.5 * self.ppc["branch"][:, 4].real, 2)
def _get_Y_bus(ppci, recycle, makeYbus, baseMVA, bus, branch): if recycle["Ybus"] and ppci["internal"]["Ybus"].size: Ybus, Yf, Yt = ppci["internal"]['Ybus'], ppci["internal"]['Yf'], ppci["internal"]['Yt'] else: ## build admittance matrices Ybus, Yf, Yt = makeYbus(baseMVA, bus, branch) if recycle["Ybus"]: ppci["internal"]['Ybus'], ppci["internal"]['Yf'], ppci["internal"]['Yt'] = Ybus, Yf, Yt return ppci, Ybus, Yf, Yt
def _calc_ybus(ppc): Ybus, Yf, Yt = makeYbus(ppc["baseMVA"], ppc["bus"], ppc["branch"]) ppc["internal"]["Yf"] = Yf ppc["internal"]["Yt"] = Yt ppc["internal"]["Ybus"] = Ybus