get_losses

get_losses(baseMVA, bus, branch)

get_losses() - Returns series losses (and reactive injections) per branch.

LOSS = GET_LOSSES(RESULTS)
LOSS = GET_LOSSES(BASEMVA, BUS, BRANCH)

[LOSS, CHG] = GET_LOSSES(RESULTS)
[LOSS, FCHG, TCHG] = GET_LOSSES(RESULTS)
[LOSS, FCHG, TCHG, DLOSS_DV] = GET_LOSSES(RESULTS)
[LOSS, FCHG, TCHG, DLOSS_DV, DCHG_DVM] = GET_LOSSES(RESULTS)

Computes branch series losses, and optionally reactive injections from
line charging, as functions of bus voltages and branch parameters, using the
following formulae:

    loss = abs( Vf / tau - Vt ) ^ 2 / (Rs - j Xs)
    fchg = abs( Vf / tau ) ^ 2 * Bc / 2
    tchg = abs( Vt ) ^ 2 * Bc / 2

Optionally, computes the partial derivatives of the line losses with
respect to voltage angles and magnitudes.

Input:
    RESULTS - a MATPOWER case struct with bus voltages corresponding to
              a valid power flow solution.
              (Can optionally be specified as individual fields BASEMVA,
               BUS, and BRANCH.)

Output(s):
    LOSS - complex NL x 1 vector of losses (in MW), where NL is the number
           of branches in the system, representing only the losses in the
           series impedance element of the PI model for each branch.
    CHG -  NL x 1 vector of total reactive injection for each line
           (in MVAr), representing the line charging injections of both
           of the shunt elements of PI model for each branch.
    FCHG - Same as CHG, but for the element at the "from" end of the
           branch only.
    TCHG - Same as CHG, but for the element at the "to" end of the branch.
    DLOSS_DV - Struct with partial derivatives of LOSS with respect to bus
           voltages, with fields:
        .a  - Partial with respect to bus voltage angles.
        .m  - Partial with respect to bus voltage magnitudes.
    DCHG_DVM - Struct with partial derivatives of FCHG and TCHG with
           respect to bus voltage magnitudes, with fields:
        .f  - Partial of FCHG with respect to bus voltage magnitudes.
        .t  - Partial of TCHG with respect to bus voltage magnitudes.

Example:
    results = runpf(mycase);
    [loss, chg] = get_losses(results);
    total_system_real_losses = sum(real(loss));
    total_system_reac_losses = sum(imag(loss)) - sum(chg);

    [loss, fchg, tchg, dloss_dV] = get_losses(results);