Esempio n. 1
0
def _kappa_method_c(net, ppc):
    if net.f_hz == 50:
        fc = 20
    elif net.f_hz == 60:
        fc = 24
    else:
        raise ValueError(
            "Frequency has to be 50 Hz or 60 Hz according to the standard")
    ppc_c = copy.deepcopy(ppc)
    ppc_c["branch"][:, BR_X] *= fc / net.f_hz

    zero_conductance = np.where(ppc["bus"][:, GS] == 0)
    ppc["bus"][zero_conductance, BS] *= net.f_hz / fc

    conductance = np.where(ppc["bus"][:, GS] != 0)
    z_shunt = 1 / (ppc_c["bus"][conductance, GS] +
                   1j * ppc_c["bus"][conductance, BS])
    y_shunt = 1 / (z_shunt.real + 1j * z_shunt.imag * fc / net.f_hz)
    ppc_c["bus"][conductance, GS] = y_shunt.real[0]
    ppc_c["bus"][conductance, BS] = y_shunt.imag[0]
    _calc_ybus(ppc_c)
    _calc_zbus(ppc_c)
    _calc_rx(net, ppc_c)
    rx_equiv_c = ppc_c["bus"][:,
                              R_EQUIV] / ppc_c["bus"][:,
                                                      X_EQUIV] * fc / net.f_hz
    return _kappa(rx_equiv_c)
Esempio n. 2
0
def _calc_sc(net):
    _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)
    _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")

    if net["_options"]["return_all_currents"]:
        _extract_results(net, ppc, ppc_0=None)
    else:
        _extract_results(net, ppc, ppc_0=None)
    _clean_up(net)
Esempio n. 3
0
def _calc_sc_1ph(net):
    """
    calculation method for single phase to ground short-circuit currents
    """
    _add_auxiliary_elements(net)
    # pos. seq bus impedance
    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)
    _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)
    if net._options["branch_results"]:
        _calc_branch_currents(net, ppci)
    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)
Esempio n. 4
0
def _calc_sc(net):
    #    t0 = time.perf_counter()
    _add_auxiliary_elements(net)
    ppc, ppci = _pd2ppc(net)
#    t1 = time.perf_counter()
    _calc_ybus(ppci)
#    t2 = time.perf_counter()
    try:
        _calc_zbus(ppci)
    except Exception as e:
        _clean_up(net, res=False)
        raise(e)
    _calc_rx(net, ppci)
#    t3 = time.perf_counter()
    _add_kappa_to_ppc(net, ppci)
#    t4 = time.perf_counter()
    _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)
Esempio n. 5
0
def _calc_sc(net):
    #    t0 = time.perf_counter()
    _add_auxiliary_elements(net)
    ppc, ppci = _pd2ppc(net)
    #    t1 = time.perf_counter()
    _calc_ybus(ppci)
    #    t2 = time.perf_counter()
    _calc_zbus(ppci)
    _calc_rx(net, ppci)
    #    t3 = time.perf_counter()
    _add_kappa_to_ppc(net, ppci)
    #    t4 = time.perf_counter()
    _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)
    _clean_up(net)


#    t5 = time.perf_counter()
#    net._et = {"sum": t5-t0, "model": t1-t0, "ybus": t2-t1, "zbus": t3-t2, "kappa": t4-t3,
#               "currents": t5-t4}
Esempio n. 6
0
def _calc_sc_1ph(net, bus):
    """
    calculation method for single phase to ground short-circuit currents
    """
    _add_auxiliary_elements(net)
    # pos. seq bus impedance
    ppc, ppci = _pd2ppc(net)
    _calc_ybus(ppci)

    # zero seq bus impedance
    ppc_0, ppci_0 = _pd2ppc_zero(net)
    _calc_ybus(ppci_0)

    if net["_options"]["inverse_y"]:
        _calc_zbus(net, ppci)
        _calc_zbus(net, ppci_0)
    else:
        # Factorization Ybus once
        ppci["internal"]["ybus_fact"] = factorized(ppci["internal"]["Ybus"])
        ppci_0["internal"]["ybus_fact"] = factorized(
            ppci_0["internal"]["Ybus"])

    _calc_rx(net, ppci, bus=bus)
    _add_kappa_to_ppc(net, ppci)

    _calc_rx(net, ppci_0, bus=bus)
    _calc_ikss_1ph(net, ppci, ppci_0, bus=bus)

    if net._options["branch_results"]:
        _calc_branch_currents(net, ppci, bus=bus)
    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, bus=bus)
    _clean_up(net)
Esempio n. 7
0
def _calc_sc(net, bus):
    _add_auxiliary_elements(net)
    ppc, ppci = _pd2ppc(net)
    _calc_ybus(ppci)

    if net["_options"]["inverse_y"]:
        _calc_zbus(net, ppci)
    else:
        # Factorization Ybus once
        ppci["internal"]["ybus_fact"] = factorized(ppci["internal"]["Ybus"])

    _calc_rx(net, ppci, bus)

    # kappa required inverse of Zbus, which is optimized
    if net["_options"]["kappa"]:
        _add_kappa_to_ppc(net, ppci)
    _calc_ikss(net, ppci, bus)

    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, bus)

    ppc = _copy_results_ppci_to_ppc(ppci, ppc, "sc")
    _extract_results(net, ppc, ppc_0=None, bus=bus)
    _clean_up(net)

    if "ybus_fact" in ppci["internal"]:
        # Delete factorization object
        ppci["internal"].pop("ybus_fact")
Esempio n. 8
0
def _kappa_method_c(net, ppc):
    if net.f_hz == 50:
        fc = 20
    elif net.f_hz == 60:
        fc = 24
    else:
        raise ValueError(
            "Frequency has to be 50 Hz or 60 Hz according to the standard")
    ppc_c = copy.deepcopy(ppc)
    ppc_c["branch"][:, BR_X] *= fc / net.f_hz

    zero_conductance = np.where(ppc["bus"][:, GS] == 0)
    ppc["bus"][zero_conductance, BS] *= net.f_hz / fc

    conductance = np.where(ppc["bus"][:, GS] != 0)
    z_shunt = 1 / (ppc_c["bus"][conductance, GS] +
                   1j * ppc_c["bus"][conductance, BS])
    y_shunt = 1 / (z_shunt.real + 1j * z_shunt.imag * fc / net.f_hz)
    ppc_c["bus"][conductance, GS] = y_shunt.real[0]
    ppc_c["bus"][conductance, BS] = y_shunt.imag[0]
    _calc_ybus(ppc_c)

    if net["_options"]["inverse_y"]:
        _calc_zbus(net, ppc_c)
    else:
        # Factorization Ybus once
        ppc_c["internal"]["ybus_fact"] = factorized(ppc_c["internal"]["Ybus"])

    _calc_rx(net, ppc_c, bus=None)
    rx_equiv_c = ppc_c["bus"][:,
                              R_EQUIV] / ppc_c["bus"][:,
                                                      X_EQUIV] * fc / net.f_hz
    return _kappa(rx_equiv_c)
Esempio n. 9
0
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)
Esempio n. 10
0
def _calc_current(net, ppci_orig, bus):
    # Select required ppci bus
    ppci_bus = _get_is_ppci_bus(net, bus)

    # update ppci
    non_ps_gen_ppci_bus, non_ps_gen_ppci, ps_gen_bus_ppci_dict =\
        _create_k_updated_ppci(net, ppci_orig, ppci_bus=ppci_bus)

    # For each ps_gen_bus one unique ppci is required
    ps_gen_ppci_bus = list(ps_gen_bus_ppci_dict.keys())

    for calc_bus in ps_gen_ppci_bus + [non_ps_gen_ppci_bus]:
        if isinstance(calc_bus, np.ndarray):
            # Use ppci for general bus
            this_ppci, this_ppci_bus = non_ps_gen_ppci, calc_bus
        else:
            # Use specific ps_gen_bus ppci
            this_ppci, this_ppci_bus = ps_gen_bus_ppci_dict[
                calc_bus], np.array([calc_bus])

        _calc_ybus(this_ppci)
        if net["_options"]["inverse_y"]:
            _calc_zbus(net, this_ppci)
        else:
            # Factorization Ybus once
            this_ppci["internal"]["ybus_fact"] = factorized(
                this_ppci["internal"]["Ybus"])

        _calc_rx(net, this_ppci, this_ppci_bus)
        _calc_ikss(net, this_ppci, this_ppci_bus)
        _add_kappa_to_ppc(net, this_ppci)
        if net["_options"]["ip"]:
            _calc_ip(net, this_ppci)
        if net["_options"]["ith"]:
            _calc_ith(net, this_ppci)

        if net._options["branch_results"]:
            _calc_branch_currents(net, this_ppci, this_ppci_bus)

        _copy_result_to_ppci_orig(ppci_orig,
                                  this_ppci,
                                  this_ppci_bus,
                                  calc_options=net._options)
Esempio n. 11
0
def _kappa_method_c(net, ppc):
    if net.f_hz == 50:
        fc = 20
    elif net.f_hz == 60:
        fc = 24
    else:
        raise ValueError(
            "Frequency has to be 50 Hz or 60 Hz according to the standard")

    ppc_c = copy.deepcopy(ppc)
    ppc_c["branch"][:, BR_X] *= fc / net.f_hz

    # Generator peak admittance application
    ppc_c["bus"][np.ix_(~np.isnan(ppc_c["bus"][:, GS_P]), [BS, GS])] =\
        ppc_c["bus"][np.ix_(~np.isnan(ppc_c["bus"][:, GS_P]), [BS_P, GS_P])]

    # # TODO: Check this
    # zero_conductance = np.where(ppc["bus"][:,GS] == 0)
    # ppc_c["bus"][zero_conductance, BS] *= net.f_hz / fc

    conductance = np.where(ppc["bus"][:, GS] != 0)
    z_shunt = 1 / (ppc_c["bus"][conductance, GS] +
                   1j * ppc_c["bus"][conductance, BS])
    y_shunt = 1 / (z_shunt.real + 1j * z_shunt.imag * fc / net.f_hz)
    ppc_c["bus"][conductance, GS] = y_shunt.real[0]
    ppc_c["bus"][conductance, BS] = y_shunt.imag[0]
    _calc_ybus(ppc_c)

    if net["_options"]["inverse_y"]:
        _calc_zbus(net, ppc_c)
    else:
        # Factorization Ybus once
        ppc_c["internal"]["ybus_fact"] = factorized(ppc_c["internal"]["Ybus"])

    _calc_rx(net, ppc_c, np.arange(ppc_c["bus"].shape[0]))
    rx_equiv_c = ppc_c["bus"][:,
                              R_EQUIV] / ppc_c["bus"][:,
                                                      X_EQUIV] * fc / net.f_hz
    return _kappa(rx_equiv_c)
Esempio n. 12
0
def _calc_sc_single(net, bus):
    _add_auxiliary_elements(net)
    ppc, ppci = _pd2ppc(net)
    _calc_ybus(ppci)

    if net["_options"]["inverse_y"]:
        _calc_zbus(net, ppci)
        _calc_rx(net, ppci, bus=None)
        _calc_ikss(net, ppci, bus=None)
        _calc_single_bus_sc(net, ppci, bus)
    else:
        # Factorization Ybus once
        ppci["internal"]["ybus_fact"] = factorized(ppci["internal"]["Ybus"])

        _calc_rx(net, ppci, bus)
        _calc_ikss(net, ppci, bus)
        _calc_single_bus_sc_no_y_inv(net, ppci, bus)

        # Delete factorization object
        ppci["internal"].pop("ybus_fact")

    ppc = _copy_results_ppci_to_ppc(ppci, ppc, "sc")
    _extract_single_results(net, ppc)
    _clean_up(net)