Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_calc_ybus(ppci)
try:
_calc_zbus(ppci)
except Exception as e:
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci)
_add_kappa_to_ppc(net, ppci)
_calc_ikss(net, ppci)
if net["_options"]["ip"]:
_calc_ip(net, ppci)
if net["_options"]["ith"]:
_calc_ith(net, ppci)
if net._options["branch_results"]:
_calc_branch_currents(net, ppci)
ppc = _copy_results_ppci_to_ppc(ppci, ppc, "sc")
_extract_results(net, ppc, ppc_0=None)
_clean_up(net)
except Exception as e:
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci)
_add_kappa_to_ppc(net, ppci)
# zero seq bus impedance
ppc_0, ppci_0 = _pd2ppc_zero(net)
_calc_ybus(ppci_0)
try:
_calc_zbus(ppci_0)
except Exception as e:
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci_0)
_calc_ikss_1ph(net, ppci, ppci_0)
ppc_0 = _copy_results_ppci_to_ppc(ppci_0, ppc_0, "sc")
ppc = _copy_results_ppci_to_ppc(ppci, ppc, "sc")
_extract_results(net, ppc, ppc_0)
_clean_up(net)
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci)
_add_kappa_to_ppc(net, ppci)
# zero seq bus impedance
ppc_0, ppci_0 = _pd2ppc_zero(net)
_calc_ybus(ppci_0)
try:
_calc_zbus(ppci_0)
except Exception as e:
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci_0)
_calc_ikss_1ph(net, ppci, ppci_0)
ppc_0 = _copy_results_ppci_to_ppc(ppci_0, ppc_0, "sc")
ppc = _copy_results_ppci_to_ppc(ppci, ppc, "sc")
_extract_results(net, ppc, ppc_0)
_clean_up(net)
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci)
_add_kappa_to_ppc(net, ppci)
# zero seq bus impedance
ppc_0, ppci_0 = _pd2ppc_zero(net)
_calc_ybus(ppci_0)
try:
_calc_zbus(ppci_0)
except Exception as e:
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci_0)
_calc_ikss_1ph(net, ppci, ppci_0)
ppc_0 = _copy_results_ppci_to_ppc(ppci_0, ppc_0, "sc")
ppc = _copy_results_ppci_to_ppc(ppci, ppc, "sc")
_extract_results(net, ppc, ppc_0)
_clean_up(net)
""" # 2 ext_grids Fix: Instead of the generator index, bus indices of the generators are used"""
eg_bus_idx_ppc = np.real(ppci1["gen"][eg_idx_ppc, GEN_BUS]).astype(int)
ppci0["gen"][eg_idx_ppc, PG] = s_012_res[0, eg_bus_idx_ppc].real
ppci1["gen"][eg_idx_ppc, PG] = s_012_res[1, eg_bus_idx_ppc].real
ppci2["gen"][eg_idx_ppc, PG] = s_012_res[2, eg_bus_idx_ppc].real
ppci0["gen"][eg_idx_ppc, QG] = s_012_res[0, eg_bus_idx_ppc].imag
ppci1["gen"][eg_idx_ppc, QG] = s_012_res[1, eg_bus_idx_ppc].imag
ppci2["gen"][eg_idx_ppc, QG] = s_012_res[2, eg_bus_idx_ppc].imag
ppc0 = net["_ppc0"]
ppc1 = net["_ppc1"]
ppc2 = net["_ppc2"]
# ppci doesn't contain out of service elements, but ppc does -> copy results accordingly
ppc0 = _copy_results_ppci_to_ppc(ppci0, ppc0, mode=mode)
ppc1 = _copy_results_ppci_to_ppc(ppci1, ppc1, mode=mode)
ppc2 = _copy_results_ppci_to_ppc(ppci2, ppc2, mode=mode)
_extract_results_3ph(net, ppc0, ppc1, ppc2)
# Raise error if PF was not successful. If DC -> success is always 1
if not ppci0["success"]:
net["converged"] = False
_clean_up(net, res=False)
raise LoadflowNotConverged("Power Flow {0} did not converge after\
{1} iterations!".format("nr", count))
else:
net["converged"] = True
_clean_up(net)
def _calc_sc_single(net, bus):
_add_auxiliary_elements(net)
ppc, ppci = _pd2ppc(net)
_calc_ybus(ppci)
try:
_calc_zbus(ppci)
except Exception as e:
_clean_up(net, res=False)
raise(e)
_calc_rx(net, ppci)
_calc_ikss(net, ppci)
_calc_single_bus_sc(net, ppci, bus)
ppc = _copy_results_ppci_to_ppc(ppci, ppc, "sc")
_extract_single_results(net, ppc)
_clean_up(net)
eg_bus_idx_ppc = np.real(ppci1["gen"][eg_idx_ppc, GEN_BUS]).astype(int)
ppci0["gen"][eg_idx_ppc, PG] = s_012_res[0, eg_bus_idx_ppc].real
ppci1["gen"][eg_idx_ppc, PG] = s_012_res[1, eg_bus_idx_ppc].real
ppci2["gen"][eg_idx_ppc, PG] = s_012_res[2, eg_bus_idx_ppc].real
ppci0["gen"][eg_idx_ppc, QG] = s_012_res[0, eg_bus_idx_ppc].imag
ppci1["gen"][eg_idx_ppc, QG] = s_012_res[1, eg_bus_idx_ppc].imag
ppci2["gen"][eg_idx_ppc, QG] = s_012_res[2, eg_bus_idx_ppc].imag
ppc0 = net["_ppc0"]
ppc1 = net["_ppc1"]
ppc2 = net["_ppc2"]
# ppci doesn't contain out of service elements, but ppc does -> copy results accordingly
ppc0 = _copy_results_ppci_to_ppc(ppci0, ppc0, mode=mode)
ppc1 = _copy_results_ppci_to_ppc(ppci1, ppc1, mode=mode)
ppc2 = _copy_results_ppci_to_ppc(ppci2, ppc2, mode=mode)
_extract_results_3ph(net, ppc0, ppc1, ppc2)
# Raise error if PF was not successful. If DC -> success is always 1
if not ppci0["success"]:
net["converged"] = False
_clean_up(net, res=False)
raise LoadflowNotConverged("Power Flow {0} did not converge after\
{1} iterations!".format("nr", count))
else:
net["converged"] = True
_clean_up(net)
ppci0["gen"][eg_idx_ppc, PG] = s_012_res[0, eg_bus_idx_ppc].real
ppci1["gen"][eg_idx_ppc, PG] = s_012_res[1, eg_bus_idx_ppc].real
ppci2["gen"][eg_idx_ppc, PG] = s_012_res[2, eg_bus_idx_ppc].real
ppci0["gen"][eg_idx_ppc, QG] = s_012_res[0, eg_bus_idx_ppc].imag
ppci1["gen"][eg_idx_ppc, QG] = s_012_res[1, eg_bus_idx_ppc].imag
ppci2["gen"][eg_idx_ppc, QG] = s_012_res[2, eg_bus_idx_ppc].imag
ppc0 = net["_ppc0"]
ppc1 = net["_ppc1"]
ppc2 = net["_ppc2"]
# ppci doesn't contain out of service elements, but ppc does -> copy results accordingly
ppc0 = _copy_results_ppci_to_ppc(ppci0, ppc0, mode=mode)
ppc1 = _copy_results_ppci_to_ppc(ppci1, ppc1, mode=mode)
ppc2 = _copy_results_ppci_to_ppc(ppci2, ppc2, mode=mode)
_extract_results_3ph(net, ppc0, ppc1, ppc2)
# Raise error if PF was not successful. If DC -> success is always 1
if not ppci0["success"]:
net["converged"] = False
_clean_up(net, res=False)
raise LoadflowNotConverged("Power Flow {0} did not converge after\
{1} iterations!".format("nr", count))
else:
net["converged"] = True
_clean_up(net)
return net["converged"]