def _pd2ppc_zero(net): """ Builds the ppc data structure for zero impedance system. Includes the impedance values of lines and transformers, but no load or generation data. For short-circuit calculation, the short-circuit impedance of external grids is also considered. """ # select elements in service (time consuming, so we do it once) net["_is_elements"] = aux._select_is_elements_numba(net) ppc = _init_ppc(net) # init empty ppci ppci = copy.deepcopy(ppc) _build_bus_ppc(net, ppc) _build_gen_ppc(net, ppc) _add_ext_grid_sc_impedance_zero(net, ppc) _build_branch_ppc_zero(net, ppc) # adds auxilary buses for open switches at branches _switch_branches(net, ppc) # add auxilary buses for out of service buses at in service lines. # Also sets lines out of service if they are connected to two out of service buses _branches_with_oos_buses(net, ppc) if hasattr(net, "_isolated_buses"): ppc["bus"][net._isolated_buses, 1] = 4. # generates "internal" ppci format (for powerflow calc) from "external" ppc format and updates the bus lookup # Note: Also reorders buses and gens in ppc ppci = _ppc2ppci(ppc, ppci, net) net._ppc0 = ppc return ppc, ppci
def _recycled_powerflow(net, **kwargs): options = net["_options"] options["recycle"] = kwargs.get("recycle", None) options["init_vm_pu"] = "results" options["init_va_degree"] = "results" algorithm = options["algorithm"] ac = options["ac"] ppci = {"bus": net["_ppc"]["internal"]["bus"], "gen": net["_ppc"]["internal"]["gen"], "branch": net["_ppc"]["internal"]["branch"], "baseMVA": net["_ppc"]["internal"]["baseMVA"], "internal": net["_ppc"]["internal"], } if not ac: # DC recycle result = _run_dc_pf(ppci) _ppci_to_net(result, net) return if algorithm not in ['nr', 'iwamoto_nr'] and ac: raise ValueError("recycle is only available with Newton-Raphson power flow. Choose " "algorithm='nr'") recycle = options["recycle"] ppc = net["_ppc"] ppc["success"] = False ppc["iterations"] = 0. ppc["et"] = 0. if "bus_pq" in recycle and recycle["bus_pq"]: # update pq values in bus _calc_pq_elements_and_add_on_ppc(net, ppc) if "trafo" in recycle and recycle["trafo"]: # update trafo in branch and Ybus lookup = net._pd2ppc_lookups["branch"] if "trafo" in lookup: _calc_trafo_parameter(net, ppc) if "trafo3w" in lookup: _calc_trafo3w_parameter(net, ppc) if "gen" in recycle and recycle["gen"]: # updates the ppc["gen"] part _build_gen_ppc(net, ppc) ppc["gen"] = nan_to_num(ppc["gen"]) ppci = _ppc2ppci(ppc, net, ppci=ppci) ppci["internal"] = net["_ppc"]["internal"] net["_ppc"] = ppc # run the Newton-Raphson power flow result = _run_newton_raphson_pf(ppci, options) ppc["success"] = ppci["success"] ppc["iterations"] = ppci["iterations"] ppc["et"] = ppci["et"] if options["only_v_results"]: _ppci_bus_to_ppc(result, ppc) _ppci_other_to_ppc(result, ppc, options["mode"]) return # read the results from result (==ppci) to net _ppci_to_net(result, net)
def _init_ppc(net): _check_sc_data_integrity(net) _add_auxiliary_elements(net) ppc, _ = _pd2ppc(net) # Init the required columns to nan ppc["bus"][:, [K_G, K_SG, V_G, PS_TRAFO_IX, GS_P, BS_P,]] = np.nan ppc["branch"][:, [K_T, K_ST]] = np.nan # Add parameter K into ppc _add_kt(net, ppc) _add_gen_sc_z_kg_ks(net, ppc) _add_xward_sc_z(net, ppc) ppci = _ppc2ppci(ppc, net) return ppc, ppci