d2Sbr_dV2

d2Sbr_dV2(Cbr, Ybr, V, mu, vcart)

d2Sbr_dV2() - Computes 2nd derivatives of complex brch power flow w.r.t. voltage.

The derivatives can be take with respect to polar or cartesian coordinates
of voltage, depending on the 5th argument.

[HAA, HAV, HVA, HVV] = D2SBR_DV2(CBR, YBR, V, MU)
[HAA, HAV, HVA, HVV] = D2SBR_DV2(CBR, YBR, V, MU, 0)

Returns 4 matrices containing the partial derivatives w.r.t. voltage angle
and magnitude of the product of a vector MU with the 1st partial
derivatives of the complex branch power flows.

[HRR, HRI, HIR, HII] = d2Sbr_dV2(CBR, YBR, V, MU, 1)

Returns 4 matrices containing the partial derivatives w.r.t. real and
imaginary part of complex voltage of the product of a vector MU with the
1st partial derivatives of the complex branch power flows.

Takes sparse connection matrix CBR, sparse branch admittance matrix YBR,
voltage vector V and nl x 1 vector of multipliers MU. Output matrices are
sparse.

Examples:
    f = branch(:, F_BUS);
    Cf =  sparse(1:nl, f, ones(nl, 1), nl, nb);
    [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
    Cbr = Cf;
    Ybr = Yf;
    [Haa, Hav, Hva, Hvv] = d2Sbr_dV2(Cbr, Ybr, V, mu);

    Here the output matrices correspond to:
        Haa = d/dVa (dSbr_dVa.' * mu)
        Hav = d/dVm (dSbr_dVa.' * mu)
        Hva = d/dVa (dSbr_dVm.' * mu)
        Hvv = d/dVm (dSbr_dVm.' * mu)

    [Hrr, Hri, Hir, Hii] = d2Sbr_dV2(Cbr, Ybr, V, mu, 1);

    Here the output matrices correspond to:
        Hrr = d/dVr (dSbr_dVr.' * mu)
        Hri = d/dVi (dSbr_dVr.' * mu)
        Hir = d/dVr (dSbr_dVi.' * mu)
        Hii = d/dVi (dSbr_dVi.' * mu)

For more details on the derivations behind the derivative code used in MATPOWER information, see:

[TN2]  R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and
       their Derivatives using Complex Matrix Notation", MATPOWER
       Technical Note 2, February 2010. [Online]. Available:
       https://matpower.org/docs/TN2-OPF-Derivatives.pdf
       doi: 10.5281/zenodo.3237866
[TN4]  B. Sereeter and R. D. Zimmerman, "AC Power Flows and their
       Derivatives using Complex Matrix Notation and Cartesian
       Coordinate Voltages," MATPOWER Technical Note 4, April 2018.
       [Online]. Available: https://matpower.org/docs/TN4-OPF-Derivatives-Cartesian.pdf
       doi: 10.5281/zenodo.3237909